OpenDaVINCI  4.15.3
Container.h
Go to the documentation of this file.
1 
20 #ifndef OPENDAVINCI_CORE_DATA_CONTAINER_H_
21 #define OPENDAVINCI_CORE_DATA_CONTAINER_H_
22 
23 #include <sstream>
24 #include <string>
25 
29 
30 namespace odcore {
31  namespace data {
32 
33 class SerializableData;
34 
35  using namespace std;
36 
41  public:
42  enum DATATYPE {
43  UNDEFINEDDATA = 1,
44  DMCP_CONFIGURATION_REQUEST = 5,
45  };
46 
47  public:
48  Container();
49 
55  Container(const SerializableData &serializableData);
56 
63  Container(const SerializableData &serializableData, const int32_t &dataType);
64 
70  Container(const Container &obj);
71 
72  virtual ~Container();
73 
80  Container& operator=(const Container &obj);
81 
87  int32_t getDataType() const;
88 
89  virtual ostream& operator<<(ostream &out) const;
90  virtual istream& operator>>(istream &in);
91 
103  template<class T>
104  inline T getData() {
105  T containerData;
106  // Reset failbit as some Deserializer fully consume the entire stream.
107  m_serializedData.clear();
108  // Read from beginning.
109  m_serializedData.seekg(ios::beg);
110  m_serializedData >> containerData;
111  return containerData;
112  }
113 
120  const TimeStamp getSentTimeStamp() const;
121 
128  void setSentTimeStamp(const TimeStamp &sentTimeStamp);
129 
136  const TimeStamp getReceivedTimeStamp() const;
137 
144  void setReceivedTimeStamp(const TimeStamp &receivedTimeStamp);
145 
152  const TimeStamp getSampleTimeStamp() const;
153 
159  void setSampleTimeStamp(const TimeStamp &sampleTimeStamp);
160 
166  const string toString() const;
167 
173  void setSenderStamp(const uint32_t &senderStamp);
174 
180  uint32_t getSenderStamp() const;
181 
182  private:
183  int32_t m_dataType;
184  stringstream m_serializedData;
185 
186  TimeStamp m_sent;
187  TimeStamp m_received;
188  TimeStamp m_sampleTimeStamp;
189 
190  uint32_t m_senderStamp;
191  };
192 
193  }
194 } // odcore::data
195 
196 #endif /*OPENDAVINCI_CORE_DATA_CONTAINER_H_*/
Definition: Container.h:40
#define OPENDAVINCI_API
Definition: opendavinci.h:67
Definition: SerializableData.h:36
DATATYPE
Definition: Container.h:42
Definition: TimeStamp.h:38
Definition: Serializable.h:59
T getData()
Definition: Container.h:104