15#ifndef __igtlMessageBase_h
16#define __igtlMessageBase_h
86#if OpenIGTLink_HEADER_VERSION >= 2
88 typedef std::map<std::string, std::pair<IANA_ENCODING_TYPE, std::string> > MetaDataMap;
97 UNPACK_UNDEF = 0x0000,
98 UNPACK_HEADER = 0x0001,
130#if OpenIGTLink_HEADER_VERSION >= 2
134 igtlUint32 GetMetaDataSize();
137 igtlUint16 GetMetaDataHeaderSize();
140 igtlUint32 GetMessageID();
143 void SetMessageID(igtlUint32 idValue);
146 bool SetMetaDataElement(
const std::string& key,
IANA_ENCODING_TYPE encodingScheme, std::string value);
147 bool SetMetaDataElement(
const std::string& key, igtl_uint8);
148 bool SetMetaDataElement(
const std::string& key, igtl_int8);
149 bool SetMetaDataElement(
const std::string& key, igtl_uint16);
150 bool SetMetaDataElement(
const std::string& key, igtl_int16);
151 bool SetMetaDataElement(
const std::string& key, igtl_uint32);
152 bool SetMetaDataElement(
const std::string& key, igtl_int32);
153 bool SetMetaDataElement(
const std::string& key, igtl_uint64);
154 bool SetMetaDataElement(
const std::string& key, igtl_int64);
155 bool SetMetaDataElement(
const std::string& key,
float);
156 bool SetMetaDataElement(
const std::string& key,
double);
159 bool GetMetaDataElement(
const std::string& key, std::string& value)
const;
160 bool GetMetaDataElement(
const std::string& key,
IANA_ENCODING_TYPE& encoding, std::string& value)
const;
163 const MetaDataMap& GetMetaData()
const;
166 bool PackExtendedHeader();
174 bool UnpackExtendedHeader();
177 bool UnpackMetaData();
347#if OpenIGTLink_HEADER_VERSION >= 2
350 unsigned char* m_ExtendedHeader;
353 bool m_IsExtendedHeaderUnpacked;
356 unsigned char* m_MetaData;
359 unsigned char* m_MetaDataHeader;
362 igtlUint32 m_MessageId;
365 MetaDataMap m_MetaDataMap;
386 this->m_SendMessageType =
"";
409#define igtlCreateDefaultQueryMessageClass(name, msgtype) \
410class IGTLCommon_EXPORT name : public HeaderOnlyMessageBase\
414typedef HeaderOnlyMessageBase Superclass; \
415typedef SmartPointer<Self> Pointer; \
416typedef SmartPointer<const Self> ConstPointer; \
418igtlTypeMacro(igtl::name, igtl::HeaderOnlyMessageBase); \
419igtlNewMacro(igtl::name); \
422name() : HeaderOnlyMessageBase() { this->m_SendMessageType = msgtype; }; \
int CopyBody(const MessageBase *mb)
Copies the serialized body data.
unsigned int m_TimeStampSecFraction
virtual igtl::MessageBase::Pointer Clone()
Create a clone of this message, new memory but all internals are preserved.
unsigned short GetHeaderVersion() const
Gets the message version number.
int SetTimeStamp(unsigned int sec, unsigned int frac)
Sets time of message creation. 'sec' and 'frac' are seconds and fractions of a second respectively.
int CopyHeader(const MessageBase *mb)
Copies a header from given message.
virtual int PackContent()
Packs (serialize) the content. Must be implemented in all child classes.
int Unpack(int crccheck=0)
void * GetBufferPointer()
Gets a pointer to the raw byte array for the serialized data including the header and the body.
virtual void AllocateBuffer(int contentSize)
virtual int UnpackContent()
Unpacks (deserialize) the content. Must be implemented in all child classes.
void SetDeviceName(const char *name)
Sets the device name.
unsigned int m_TimeStampSec
void UnpackHeader(int &r)
Unpack the first 58 bytes.
void SetTimeStamp(igtl::TimeStamp::Pointer &ts)
Sets time of message creation.
const char * GetBodyType()
Gets the type of the body.
std::string m_DeviceName
A character string for the device name (message name).
void * GetPackBodyPointer()
std::string m_ReceiveMessageType
int CalculateReceiveContentSize()
int Copy(const MessageBase *mb)
const char * GetDeviceType()
Gets the device (message) type.
void SetDeviceName(const std::string &name)
Sets the device name.
bool m_IsBodyUnpacked
Unpacking (deserialization) status for the body.
virtual int CalculateContentBufferSize()
Gets the size of the serialized content.
unsigned char * m_Content
A pointer to the underlying content of a message.
const char * GetDeviceName()
Gets the device name.
void GetTimeStamp(igtl::TimeStamp::Pointer &ts)
Gets time of message creation.
int GetBufferSize()
Gets the size of the serialized message data.
void UnpackBody(int crccheck, int &r)
int GetTimeStamp(unsigned int *sec, unsigned int *frac)
Gets time of message creation. 'sec' and 'frac' are seconds and fractions of a second respectively.
void SetHeaderVersion(unsigned short headerVersion)
Sets the message version number.
std::string m_SendMessageType
A character string for the send device type (message type).
bool m_IsBodyPacked
Packing (serialization) status for the body.
virtual int SetMessageHeader(const MessageHeader *mb)
Sets the message header.
bool m_IsHeaderUnpacked
Unpacking (deserialization) status for the header.
unsigned short m_HeaderVersion
An unsigned short for the message format version.
std::string GetMessageType() const
Gets the message type.
std::string GetDeviceName() const
Gets the device name.
int GetBufferBodySize()
Gets the size of the serialized body data.
void * GetBufferBodyPointer()
Gets a pointer to the raw byte array for the serialized body data.
virtual void AllocateUnpack(int bodySizeToRead)
SmartPointer< Self > Pointer
void SetDeviceType(const std::string &type)
Sets the device (message) type.
SmartPointer< const Self > ConstPointer
Base class for most igtl classes.
Implements transparent reference counting.
#define igtlTypeMacro(thisClass, superclass)
The "igtl" namespace contains all OpenIGTLink classes. There are several nested namespaces within the...
class MessageBase MessageHeader