Last change
on this file since 20006 was 13463, checked in by tbretz, 13 years ago |
A very simple and light weight wrapper around DimInfo
|
File size:
1.2 KB
|
Line | |
---|
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
|
---|
Note:
See
TracBrowser
for help on using the repository browser.