JpegMessage.h
Go to the documentation of this file.
00001 
00037 #ifndef LibMultiSense_JpegMessage
00038 #define LibMultiSense_JpegMessage
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_ JpegImageHeader {
00051 public:
00052 
00053 static CRL_CONSTEXPR IdType      ID      = ID_DATA_JPEG_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     int64_t  frameId;
00063     uint16_t width;
00064     uint16_t height;
00065     uint32_t length;
00066     uint32_t quality;
00067 
00068     JpegImageHeader() : 
00069 #ifdef SENSORDPOD_FIRMWARE
00070         id(ID),
00071         version(VERSION),
00072 #endif // SENSORPOD_FIRMWARE
00073         source(0),
00074         frameId(0),
00075         width(0),
00076         height(0),
00077         length(0),
00078         quality(0) {};
00079 };
00080 
00081 #ifndef SENSORPOD_FIRMWARE
00082 
00083 class JpegImage : public JpegImageHeader {
00084 public:
00085 
00086     void *dataP;
00087 
00088     //
00089     // Constructors
00090 
00091     JpegImage(utility::BufferStreamReader&r, VersionType v) {serialize(r,v);};
00092     JpegImage() : dataP(NULL) {};
00093 
00094     //
00095     // Serialization routine
00096 
00097     template<class Archive>
00098         void serialize(Archive&          message,
00099                        const VersionType version)
00100     {
00101         message & source;
00102         message & frameId;
00103         message & width;
00104         message & height;
00105         message & length;
00106         message & quality;
00107 
00108         if (typeid(Archive) == typeid(utility::BufferStreamWriter)) {
00109           
00110             message.write(dataP, length);
00111 
00112         } else {
00113 
00114             dataP = message.peek();
00115             message.seek(message.tell() + length);
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