ImageMessage.h
Go to the documentation of this file.
00001 
00037 #ifndef LibMultiSense_ImageMessage
00038 #define LibMultiSense_ImageMessage
00039 
00040 #include <typeinfo>
00041 #include <cmath>
00042 
00043 #include "details/utility/Portability.hh"
00044 
00045 namespace crl {
00046 namespace multisense {
00047 namespace details {
00048 namespace wire {
00049 
00050 class WIRE_HEADER_ATTRIBS_ ImageHeader {
00051 public:
00052 
00053 static CRL_CONSTEXPR IdType      ID      = ID_DATA_IMAGE;
00054 static CRL_CONSTEXPR VersionType VERSION = 1;
00055 
00056 #ifdef SENSORPOD_FIRMWARE
00057     IdType      id;
00058     VersionType version;
00059 #endif // SENSORPOD_FIRMWARE
00060 
00061     uint32_t source;
00062     uint32_t bitsPerPixel;
00063     int64_t  frameId;
00064     uint16_t width;
00065     uint16_t height;
00066 
00067     ImageHeader() 
00068         : 
00069 #ifdef SENSORDPOD_FIRMWARE
00070         id(ID),
00071         version(VERSION),
00072 #endif // SENSORPOD_FIRMWARE
00073         source(0),
00074         bitsPerPixel(0),
00075         frameId(0),
00076         width(0),
00077         height(0) {};
00078 };
00079 
00080 #ifndef SENSORPOD_FIRMWARE
00081 
00082 class Image : public ImageHeader {
00083 public:
00084 
00085     void *dataP;
00086 
00087     //
00088     // Constructors
00089 
00090     Image(utility::BufferStreamReader&r, VersionType v) {serialize(r,v);};
00091     Image() : dataP(NULL) {};
00092 
00093     //
00094     // Serialization routine
00095 
00096     template<class Archive>
00097         void serialize(Archive&          message,
00098                        const VersionType version)
00099     {
00100         message & source;
00101         message & bitsPerPixel;
00102         message & frameId;
00103         message & width;
00104         message & height;
00105 
00106         const uint32_t imageSize = static_cast<uint32_t> (std::ceil(((double) bitsPerPixel / 8.0) * width * height));
00107 
00108         if (typeid(Archive) == typeid(utility::BufferStreamWriter)) {
00109           
00110             message.write(dataP, imageSize);
00111 
00112         } else {
00113 
00114             dataP = message.peek();
00115             message.seek(message.tell() + imageSize);
00116         }
00117     }
00118 };
00119 
00120 #endif // !SENSORPOD_FIRMWARE
00121 
00122 }}}}; // namespaces
00123 
00124 #endif


multisense_lib
Author(s):
autogenerated on Thu Aug 27 2015 14:01:11