OpenDaVINCI  4.16.0
ROSSerializerVisitor.h
Go to the documentation of this file.
1 
20 #ifndef OPENDAVINCI_CORE_SERIALIZATION_ROSSERIALIZERVISITOR_H_
21 #define OPENDAVINCI_CORE_SERIALIZATION_ROSSERIALIZERVISITOR_H_
22 
23 #include <sstream>
24 #include <string>
25 
29 
30 namespace odcore {
31  namespace serialization {
32 
33 class Serializable;
34 
35  using namespace std;
36 
42  private:
49 
55  ROSSerializerVisitor& operator=(const ROSSerializerVisitor &);
56 
57  public:
59 
60  virtual ~ROSSerializerVisitor();
61 
62  virtual void getSerializedData(ostream &o);
63 
69  void setMessageID(const uint8_t &messageId);
70 
71  private:
72  virtual uint32_t writeValue(ostream &o, const Serializable &v) {(void)o; (void)v; return 0;}
73  virtual uint32_t writeValue(ostream &o, const bool &v) {(void)o; (void)v; return 0;}
74  virtual uint32_t writeValue(ostream &o, const char &v) {(void)o; (void)v; return 0;}
75  virtual uint32_t writeValue(ostream &o, const unsigned char &v) {(void)o; (void)v; return 0;}
76  virtual uint32_t writeValue(ostream &o, const int8_t &v) {(void)o; (void)v; return 0;}
77  virtual uint32_t writeValue(ostream &o, const int16_t &v) {(void)o; (void)v; return 0;}
78  virtual uint32_t writeValue(ostream &o, const uint16_t &v) {(void)o; (void)v; return 0;}
79  virtual uint32_t writeValue(ostream &o, const int32_t &v) {(void)o; (void)v; return 0;}
80  virtual uint32_t writeValue(ostream &o, const uint32_t &v) {(void)o; (void)v; return 0;}
81  virtual uint32_t writeValue(ostream &o, const int64_t &v) {(void)o; (void)v; return 0;}
82  virtual uint32_t writeValue(ostream &o, const uint64_t &v) {(void)o; (void)v; return 0;}
83  virtual uint32_t writeValue(ostream &o, const float &v) {(void)o; (void)v; return 0;}
84  virtual uint32_t writeValue(ostream &o, const double &v) {(void)o; (void)v; return 0;}
85  virtual uint32_t writeValue(ostream &o, const string &v) {(void)o; (void)v; return 0;}
86  virtual uint32_t writeValue(ostream &o, const void *data, const uint32_t &size) {(void)o; (void)data; (void)size; return 0;}
87 
88  private:
89  virtual void write(const uint32_t &id, const Serializable &s);
90  virtual void write(const uint32_t &id, const bool &b);
91  virtual void write(const uint32_t &id, const char &c);
92  virtual void write(const uint32_t &id, const unsigned char &uc);
93  virtual void write(const uint32_t &id, const int8_t &i);
94  virtual void write(const uint32_t &id, const int16_t &i);
95  virtual void write(const uint32_t &id, const uint16_t &ui);
96  virtual void write(const uint32_t &id, const int32_t &i);
97  virtual void write(const uint32_t &id, const uint32_t &ui);
98  virtual void write(const uint32_t &id, const int64_t &i);
99  virtual void write(const uint32_t &id, const uint64_t &ui);
100  virtual void write(const uint32_t &id, const float &f);
101  virtual void write(const uint32_t &id, const double &d);
102  virtual void write(const uint32_t &id, const string &s);
103  virtual void write(const uint32_t &id, const void *data, const uint32_t &size);
104 
105  private:
106  virtual void beginVisit(const int32_t &id, const string &shortName, const string &longName);
107  virtual void endVisit();
108 
109  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const Serializable &s);
110  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const bool &b);
111  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const char &c);
112  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const unsigned char &uc);
113  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const int8_t &i);
114  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const int16_t &i);
115  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const uint16_t &ui);
116  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const int32_t &i);
117  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const uint32_t &ui);
118  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const int64_t &i);
119  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const uint64_t &ui);
120  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const float &f);
121  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const double &d);
122  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const string &s);
123  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const void *data, const uint32_t &size);
124 
125  public:
126  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, Serializable &v);
127  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, bool &v);
128  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, char &v);
129  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, unsigned char &v);
130  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, int8_t &v);
131  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, int16_t &v);
132  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, uint16_t &v);
133  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, int32_t &v);
134  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, uint32_t &v);
135  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, int64_t &v);
136  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, uint64_t &v);
137  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, float &v);
138  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, double &v);
139  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, string &v);
140  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, void *data, const uint32_t &size);
141  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, void *data, const uint32_t &count, const odcore::TYPE_ &t);
142 
143  private:
144  uint8_t m_messageId;
145  uint32_t m_size;
146  stringstream m_buffer;
147  };
148 
149  }
150 } // odcore::serialization
151 
152 #endif /*OPENDAVINCI_CORE_SERIALIZATION_ROSSERIALIZERVISITOR_H_*/
Definition: Serializer.h:38
TYPE_
Definition: opendavinci.h:96
Definition: Visitor.h:37
Definition: Serializable.h:59
Definition: ROSSerializerVisitor.h:41