FACT++  1.0
DimData.h
Go to the documentation of this file.
1 #ifndef FACT_DimData
2 
3 struct DimData
4 {
5  const int qos;
6  const std::string name;
7  const std::string format;
8  const std::vector<char> data;
9  const Time time;
10 
11  Time extract(DimInfo *inf) const
12  {
13  // Must be called in exactly this order!
14  const int tsec = inf->getTimestamp();
15  const int tms = inf->getTimestampMillisecs();
16 
17  return Time(tsec, tms*1000);
18  }
19 
20  DimData(DimInfo *inf) : qos(inf->getQuality()),
21  name(inf->getName()),
22  format(inf->getFormat()),
23  data(inf->getString(), inf->getString()+inf->getSize()),
24  time(extract(inf))
25  {
26  }
27 
28  template<typename T>
29  T get(uint32_t offset=0) const { return *reinterpret_cast<const T*>(data.data()+offset); }
30 
31  template<typename T>
32  const T *ptr(uint32_t offset=0) const { return reinterpret_cast<const T*>(data.data()+offset); }
33 
34  template<typename T>
35  const T &ref(uint32_t offset=0) const { return *reinterpret_cast<const T*>(data.data()+offset); }
36 
37  const char *c_str() const { return (char*)data.data(); }
38 
39  size_t size() const { return data.size(); }
40 };
41 
42 #endif
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
const std::string name
Definition: DimData.h:6
Definition: dic.hxx:31
int getTimestampMillisecs()
Definition: diccpp.cxx:114
const std::vector< char > data
Definition: DimData.h:8
const Time time
Definition: DimData.h:9
Definition: DimData.h:3
int getTimestamp()
Definition: diccpp.cxx:107
const T & ref(uint32_t offset=0) const
Definition: DimData.h:35
const std::string format
Definition: DimData.h:7
const int qos
Definition: DimData.h:5
size_t size() const
Definition: DimData.h:39
const char * c_str() const
Definition: DimData.h:37
DimData(DimInfo *inf)
Definition: DimData.h:20
Time extract(DimInfo *inf) const
Definition: DimData.h:11
const T * ptr(uint32_t offset=0) const
Definition: DimData.h:32