OpenDaVINCI  4.16.0
LCMSerializerVisitor.h
Go to the documentation of this file.
1 
20 #ifndef OPENDAVINCI_CORE_SERIALIZATION_LCMSERIALIZERVISITOR_H_
21 #define OPENDAVINCI_CORE_SERIALIZATION_LCMSERIALIZERVISITOR_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  LCMSerializerVisitor& operator=(const LCMSerializerVisitor &);
56 
57  public:
59 
60  virtual ~LCMSerializerVisitor();
61 
62  virtual void getSerializedData(ostream &o);
63 
69  void setChannelName(const string &channelName);
70 
76  int64_t getHash() const;
77 
78  private:
79  virtual uint32_t writeValue(ostream &o, const Serializable &v) {(void)o; (void)v; return 0;}
80  virtual uint32_t writeValue(ostream &o, const bool &v) {(void)o; (void)v; return 0;}
81  virtual uint32_t writeValue(ostream &o, const char &v) {(void)o; (void)v; return 0;}
82  virtual uint32_t writeValue(ostream &o, const unsigned char &v) {(void)o; (void)v; return 0;}
83  virtual uint32_t writeValue(ostream &o, const int8_t &v) {(void)o; (void)v; return 0;}
84  virtual uint32_t writeValue(ostream &o, const int16_t &v) {(void)o; (void)v; return 0;}
85  virtual uint32_t writeValue(ostream &o, const uint16_t &v) {(void)o; (void)v; return 0;}
86  virtual uint32_t writeValue(ostream &o, const int32_t &v) {(void)o; (void)v; return 0;}
87  virtual uint32_t writeValue(ostream &o, const uint32_t &v) {(void)o; (void)v; return 0;}
88  virtual uint32_t writeValue(ostream &o, const int64_t &v) {(void)o; (void)v; return 0;}
89  virtual uint32_t writeValue(ostream &o, const uint64_t &v) {(void)o; (void)v; return 0;}
90  virtual uint32_t writeValue(ostream &o, const float &v) {(void)o; (void)v; return 0;}
91  virtual uint32_t writeValue(ostream &o, const double &v) {(void)o; (void)v; return 0;}
92  virtual uint32_t writeValue(ostream &o, const string &v) {(void)o; (void)v; return 0;}
93  virtual uint32_t writeValue(ostream &o, const void *data, const uint32_t &size) {(void)o; (void)data; (void)size; return 0;}
94 
95  private:
96  virtual void write(const uint32_t &id, const Serializable &s);
97  virtual void write(const uint32_t &id, const bool &b);
98  virtual void write(const uint32_t &id, const char &c);
99  virtual void write(const uint32_t &id, const unsigned char &uc);
100  virtual void write(const uint32_t &id, const int8_t &i);
101  virtual void write(const uint32_t &id, const int16_t &i);
102  virtual void write(const uint32_t &id, const uint16_t &ui);
103  virtual void write(const uint32_t &id, const int32_t &i);
104  virtual void write(const uint32_t &id, const uint32_t &ui);
105  virtual void write(const uint32_t &id, const int64_t &i);
106  virtual void write(const uint32_t &id, const uint64_t &ui);
107  virtual void write(const uint32_t &id, const float &f);
108  virtual void write(const uint32_t &id, const double &d);
109  virtual void write(const uint32_t &id, const string &s);
110  virtual void write(const uint32_t &id, const void *data, const uint32_t &size);
111 
112  private:
113  virtual void beginVisit(const int32_t &id, const string &shortName, const string &longName);
114  virtual void endVisit();
115 
116  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const Serializable &s);
117  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const bool &b);
118  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const char &c);
119  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const unsigned char &uc);
120  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const int8_t &i);
121  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const int16_t &i);
122  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const uint16_t &ui);
123  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const int32_t &i);
124  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const uint32_t &ui);
125  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const int64_t &i);
126  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const uint64_t &ui);
127  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const float &f);
128  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const double &d);
129  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const string &s);
130  virtual void write(const uint32_t &id, const string &longName, const string &shortName, const void *data, const uint32_t &size);
131 
132  public:
133  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, Serializable &v);
134  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, bool &v);
135  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, char &v);
136  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, unsigned char &v);
137  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, int8_t &v);
138  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, int16_t &v);
139  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, uint16_t &v);
140  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, int32_t &v);
141  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, uint32_t &v);
142  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, int64_t &v);
143  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, uint64_t &v);
144  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, float &v);
145  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, double &v);
146  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, string &v);
147  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, void *data, const uint32_t &size);
148  virtual void visit(const uint32_t &id, const string &longName, const string &shortName, void *data, const uint32_t &count, const odcore::TYPE_ &t);
149 
150  public:
154  static int64_t calculateHash(int64_t v, const char &c);
155 
159  static int64_t calculateHash(int64_t v, const string &s);
160 
161  private:
162  string m_channelName;
163  int64_t m_hash;
164  stringstream m_buffer;
165  };
166 
167  }
168 } // odcore::serialization
169 
170 #endif /*OPENDAVINCI_CORE_SERIALIZATION_LCMSERIALIZERVISITOR_H_*/
Definition: Serializer.h:38
Definition: LCMSerializerVisitor.h:41
TYPE_
Definition: opendavinci.h:96
Definition: Visitor.h:37
Definition: Serializable.h:59