ImageMessage.h
Go to the documentation of this file.
1 
37 #ifndef LibMultiSense_ImageMessage
38 #define LibMultiSense_ImageMessage
39 
40 #include <typeinfo>
41 #include <cmath>
42 
44 
45 namespace crl {
46 namespace multisense {
47 namespace details {
48 namespace wire {
49 
51 public:
52 
54 static CRL_CONSTEXPR VersionType VERSION = 1;
55 
56 #ifdef SENSORPOD_FIRMWARE
57  IdType id;
58  VersionType version;
59 #endif // SENSORPOD_FIRMWARE
60 
61  uint32_t source;
62  uint32_t bitsPerPixel;
63  int64_t frameId;
64  uint16_t width;
65  uint16_t height;
66 
68  :
69 #ifdef SENSORDPOD_FIRMWARE
70  id(ID),
71  version(VERSION),
72 #endif // SENSORPOD_FIRMWARE
73  source(0),
74  bitsPerPixel(0),
75  frameId(0),
76  width(0),
77  height(0) {};
78 };
79 
80 #ifndef SENSORPOD_FIRMWARE
81 
82 class Image : public ImageHeader {
83 public:
84 
85  void *dataP;
86 
87  //
88  // Constructors
89 
91  Image() : dataP(NULL) {};
92 
93  //
94  // Serialization routine
95 
96  template<class Archive>
97  void serialize(Archive& message,
98  const VersionType version)
99  {
100  message & source;
101  message & bitsPerPixel;
102  message & frameId;
103  message & width;
104  message & height;
105 
106  const uint32_t imageSize = static_cast<uint32_t> (std::ceil(((double) bitsPerPixel / 8.0) * width * height));
107 
108  if (typeid(Archive) == typeid(utility::BufferStreamWriter)) {
109 
110  message.write(dataP, imageSize);
111 
112  } else {
113 
114  dataP = message.peek();
115  message.seek(message.tell() + imageSize);
116  }
117  }
118 };
119 
120 #endif // !SENSORPOD_FIRMWARE
121 
122 }}}}; // namespaces
123 
124 #endif
static CRL_CONSTEXPR IdType ID_DATA_IMAGE
Definition: Protocol.h:194
std::string * frameId(M &m)
void serialize(Stream &stream, const T &t)
Definition: channel.cc:56
#define WIRE_HEADER_ATTRIBS_
Definition: Protocol.h:55
void serialize(Archive &message, const VersionType version)
Definition: ImageMessage.h:97
#define CRL_CONSTEXPR
Definition: Portability.hh:38
Image(utility::BufferStreamReader &r, VersionType v)
Definition: ImageMessage.h:90


multisense_lib
Author(s):
autogenerated on Sat Apr 6 2019 02:16:46