#include <igtlMessageBase.h>
Public Types | |
enum | { UNPACK_UNDEF = 0x0000, UNPACK_HEADER = 0x0001, UNPACK_BODY = 0x0002 } |
typedef SmartPointer< const Self > | ConstPointer |
typedef SmartPointer< Self > | Pointer |
typedef MessageBase | Self |
typedef Object | Superclass |
Public Member Functions | |
void | AllocatePack () |
int | Copy (const MessageBase *mb) |
virtual LightObject::Pointer | CreateAnother () const |
virtual void | DebugOff () const |
virtual void | DebugOn () const |
virtual void | Delete () |
int | GetBodySizeToRead () |
const char * | GetBodyType () |
bool | GetDebug () const |
const char * | GetDeviceName () |
const char * | GetDeviceType () |
virtual const char * | GetNameOfClass () const |
void * | GetPackBodyPointer () |
int | GetPackBodySize () |
void * | GetPackPointer () |
int | GetPackSize () |
virtual int | GetReferenceCount () const |
int | GetTimeStamp (unsigned int *sec, unsigned int *frac) |
void | GetTimeStamp (igtl::TimeStamp::Pointer &ts) |
igtlNewMacro (igtl::MessageBase) | |
igtlTypeMacro (Object, LightObject) | |
void | InitPack () |
virtual int | Pack () |
void | Print (std::ostream &os) const |
virtual void | Register () const |
void | SetDebug (bool debugFlag) const |
void | SetDeviceName (const char *name) |
virtual int | SetMessageHeader (const MessageHeader *mb) |
virtual void | SetReferenceCount (int) |
int | SetTimeStamp (unsigned int sec, unsigned int frac) |
void | SetTimeStamp (igtl::TimeStamp::Pointer &ts) |
int | Unpack (int crccheck=0) |
virtual void | UnRegister () const |
Static Public Member Functions | |
static void | BreakOnError () |
static Pointer | New () |
static void | SetGlobalWarningDisplay (bool flag) |
static bool | GetGlobalWarningDisplay () |
static void | GlobalWarningDisplayOn () |
static void | GlobalWarningDisplayOff () |
Protected Member Functions | |
virtual void | AllocatePack (int bodySize) |
int | CopyBody (const MessageBase *mb) |
int | CopyHeader (const MessageBase *mb) |
virtual int | GetBodyPackSize () |
MessageBase () | |
virtual int | PackBody () |
virtual void | PrintSelf (std::ostream &os) const |
virtual int | UnpackBody () |
~MessageBase () | |
virtual void | PrintHeader (std::ostream &os) const |
virtual void | PrintTrailer (std::ostream &os) const |
Protected Attributes | |
unsigned char * | m_Body |
int | m_BodySizeToRead |
std::string | m_BodyType |
std::string | m_DefaultBodyType |
std::string | m_DeviceName |
unsigned char * | m_Header |
int | m_IsBodyUnpacked |
int | m_IsHeaderUnpacked |
int | m_PackSize |
volatile int | m_ReferenceCount |
SimpleFastMutexLock | m_ReferenceCountLock |
unsigned int | m_TimeStampSec |
unsigned int | m_TimeStampSecFraction |
The MessageBase class is the base class of all message type classes used in the Open IGT Link Library. The message classes can be used both for serializing (packing) Open IGT Link message byte streams. The class can also deserializing (unpacking) Open IGT Link. For the deserialization example, please refer igtlMessageHeader.h.
The typical packing procedures using sub-classes of MessageBase look like the followings
// Create instance and set Device Name igtl::TransformMessage::Pointer transMsg; transMsg = igtl::TransformMessage::New(); transMsg->SetDeviceName("Tracker"); // Create matrix and substitute values igtl::Matrix4x4 matrix; GetRandomTestMatrix(matrix); // Set matrix data, serialize, and send it. transMsg->SetMatrix(matrix); transMsg->Pack(); socket->Send(transMsg->GetPackPointer(), transMsg->GetPackSize());
Definition at line 55 of file igtlMessageBase.h.
typedef SmartPointer<const Self> igtl::MessageBase::ConstPointer |
Definition at line 62 of file igtlMessageBase.h.
typedef SmartPointer<Self> igtl::MessageBase::Pointer |
Definition at line 61 of file igtlMessageBase.h.
typedef MessageBase igtl::MessageBase::Self |
Definition at line 59 of file igtlMessageBase.h.
typedef Object igtl::MessageBase::Superclass |
Definition at line 60 of file igtlMessageBase.h.
anonymous enum |
Unpack status. They are returned by the Unpack() function.
Enumerator | |
---|---|
UNPACK_UNDEF | |
UNPACK_HEADER | |
UNPACK_BODY |
Definition at line 68 of file igtlMessageBase.h.
|
protected |
|
protected |
void igtl::MessageBase::AllocatePack | ( | ) |
AllocatePack() allocates memory for packing / receiving buffer.
|
protectedvirtual |
Allocates memory specifying the body size. This function is used when creating a brank package to receive data)
Reimplemented in igtl::ImageMessage2.
|
staticinherited |
This method is called when igtlExceptionMacro executes. It allows the debugger to break on error.
int igtl::MessageBase::Copy | ( | const MessageBase * | mb | ) |
Copy() copies contents from the specified Massage class. If the type of the specified class is the same as this class, both general header and body are copied. Otherwise, only general header is copied.
|
protected |
Copies the serialized body data.
|
protected |
Copies a header from.
|
virtualinherited |
Create an object from an instance, potentially deferring to a factory. This method allows you to create an instance of an object that is exactly the same type as the referring object. This is useful in cases where an object has been cast back to a base class.
Reimplemented from igtl::LightObject.
|
virtualinherited |
Turn debugging output off.
|
virtualinherited |
Turn debugging output on.
|
virtualinherited |
Delete an igtl object. This method should always be used to delete an object when the new operator was used to create it. Using the C delete method will not work with reference counting.
|
inlineprotectedvirtual |
Gets the size of the serialized body.
Reimplemented in igtl::PolyDataMessage, igtl::ImageMessage2, igtl::ImageMessage, igtl::QuaternionTrackingDataMessage, igtl::RTSBindMessage, igtl::TrackingDataMessage, igtl::HeaderOnlyMessageBase, igtl::RTSQuaternionTrackingDataMessage, igtl::StopBindMessage, igtl::TrajectoryMessage, igtl::RTSTrackingDataMessage, igtl::ImageMetaMessage, igtl::StartBindMessage, igtl::LabelMetaMessage, igtl::PointMessage, igtl::StopQuaternionTrackingDataMessage, igtl::StopTrackingDataMessage, igtl::GetTrajectoryMessage, igtl::NDArrayMessage, igtl::GetImageMetaMessage, igtl::GetBindMessage, igtl::StartQuaternionTrackingDataMessage, igtl::GetLabelMetaMessage, igtl::GetPointMessage, igtl::StartTrackingDataMessage, igtl::StatusMessage, igtl::BindMessage, igtl::ColorTableMessage, igtl::PositionMessage, igtl::TransformMessage, igtl::CapabilityMessage, igtl::SensorMessage, igtl::StringMessage, igtl::GetImageMessage2, igtl::GetPolyDataMessage, igtl::GetCapabilityMessage, and igtl::GetColorTableMessage.
Definition at line 160 of file igtlMessageBase.h.
|
inline |
GetBodySizeToRead() returns the size of the body to be read. This function must be called after the message header is set.
Definition at line 151 of file igtlMessageBase.h.
|
inline |
GetBodyType() gets the type of the body.
Definition at line 130 of file igtlMessageBase.h.
|
inherited |
Get the value of the debug flag.
const char* igtl::MessageBase::GetDeviceName | ( | ) |
Gets the device (message) name.
const char* igtl::MessageBase::GetDeviceType | ( | ) |
Gets the device (message) type.
|
staticinherited |
This is a global flag that controls whether any debug, warning or error messages are displayed.
|
inlinevirtualinherited |
Return the name of this class as a string. Used by the object factory (implemented in New()) to instantiate objects of a named type. Also used for debugging and other output information.
Definition at line 84 of file igtlLightObject.h.
void* igtl::MessageBase::GetPackBodyPointer | ( | ) |
Gets a pointer to the raw byte array for the serialized body data.
int igtl::MessageBase::GetPackBodySize | ( | ) |
Gets the size of the serialized body data.
void* igtl::MessageBase::GetPackPointer | ( | ) |
Gets a pointer to the raw byte array for the serialized data including the header and the body.
int igtl::MessageBase::GetPackSize | ( | ) |
Gets the size of the serialized data.
|
inlinevirtualinherited |
Gets the reference count on this object.
Definition at line 110 of file igtlLightObject.h.
int igtl::MessageBase::GetTimeStamp | ( | unsigned int * | sec, |
unsigned int * | frac | ||
) |
Gets time of message creation. 'sec' and 'frac' are seconds and fractions of a second respectively.
void igtl::MessageBase::GetTimeStamp | ( | igtl::TimeStamp::Pointer & | ts | ) |
Gets time of message creation.
|
inlinestaticinherited |
This is a global flag that controls whether any debug, warning or error messages are displayed.
Definition at line 116 of file igtlObject.h.
References igtl::Object::SetGlobalWarningDisplay().
|
inlinestaticinherited |
This is a global flag that controls whether any debug, warning or error messages are displayed.
Definition at line 114 of file igtlObject.h.
References igtl::Object::SetGlobalWarningDisplay().
igtl::MessageBase::igtlNewMacro | ( | igtl::MessageBase | ) |
|
inherited |
Standard part of all igtl objects.
void igtl::MessageBase::InitPack | ( | ) |
Call InitPack() before receive header. This function simply resets the Unpacked flag for both the header and body pack.
|
staticinherited |
Method for creation through the object factory.
|
virtual |
Pack() serializes the header and body based on the member variables. PackBody() must be implemented in the child class.
Reimplemented in igtl::ImageMessage2.
|
inlineprotectedvirtual |
Packs (serialize) the body. Must be implemented in a child class.
Reimplemented in igtl::PolyDataMessage, igtl::ImageMessage2, igtl::ImageMessage, igtl::QuaternionTrackingDataMessage, igtl::RTSBindMessage, igtl::TrackingDataMessage, igtl::HeaderOnlyMessageBase, igtl::RTSQuaternionTrackingDataMessage, igtl::StopBindMessage, igtl::TrajectoryMessage, igtl::RTSTrackingDataMessage, igtl::ImageMetaMessage, igtl::StartBindMessage, igtl::LabelMetaMessage, igtl::PointMessage, igtl::StopQuaternionTrackingDataMessage, igtl::StopTrackingDataMessage, igtl::GetTrajectoryMessage, igtl::NDArrayMessage, igtl::GetImageMetaMessage, igtl::GetBindMessage, igtl::StartQuaternionTrackingDataMessage, igtl::GetLabelMetaMessage, igtl::GetPointMessage, igtl::StartTrackingDataMessage, igtl::StatusMessage, igtl::BindMessage, igtl::ColorTableMessage, igtl::PositionMessage, igtl::TransformMessage, igtl::CapabilityMessage, igtl::SensorMessage, igtl::StringMessage, igtl::GetImageMessage2, igtl::GetPolyDataMessage, igtl::GetCapabilityMessage, and igtl::GetColorTableMessage.
Definition at line 163 of file igtlMessageBase.h.
|
inherited |
Cause the object to print itself out.
|
protectedvirtualinherited |
|
protectedvirtualinherited |
Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes.
Reimplemented from igtl::LightObject.
Reimplemented in igtl::MultiThreader, igtl::MutexLock, igtl::ObjectFactoryBase, igtl::Socket, igtl::FastMutexLock, igtl::TimeStamp, igtl::ServerSocket, and igtl::ClientSocket.
|
protectedvirtualinherited |
|
virtualinherited |
Return this objects modified time. Update the modification time for this object. Many filters rely on the modification time to determine if they need to recompute their data. Increase the reference count (mark as used by another object).
Reimplemented from igtl::LightObject.
|
inherited |
Set the value of the debug flag. A non-zero value turns debugging on.
void igtl::MessageBase::SetDeviceName | ( | const char * | name | ) |
Sets the device (message) name.
|
staticinherited |
This is a global flag that controls whether any debug, warning or error messages are displayed.
Referenced by igtl::Object::GlobalWarningDisplayOff(), and igtl::Object::GlobalWarningDisplayOn().
|
inlinevirtual |
Sets the message header.
Reimplemented in igtl::PositionMessage.
Definition at line 147 of file igtlMessageBase.h.
|
virtualinherited |
Sets the reference count (use with care)
Reimplemented from igtl::LightObject.
int igtl::MessageBase::SetTimeStamp | ( | unsigned int | sec, |
unsigned int | frac | ||
) |
Sets time of message creation. 'sec' and 'frac' are seconds and fractions of a second respectively.
void igtl::MessageBase::SetTimeStamp | ( | igtl::TimeStamp::Pointer & | ts | ) |
Sets time of message creation.
int igtl::MessageBase::Unpack | ( | int | crccheck = 0 | ) |
Unpack() deserializes the header and/or body, extracting data from the byte stream. If the header has already been deserilized, Unpack() deserializes only the body part. UnpackBody() must be implemented to deserialize the body part. Unpack() performs 64-bit CRC check, when crccheck = 1. It returns:
UNPACK_UNDEF : Nothing deserialized UNPACK_HEADER : The header has been deserialized. UNPACK_BODY : The body has been deserialized. If CRC check fails, Unpack() doesn't deserialize the body, thus it doesn't return UNPACK_BODY flag. UNPACK_HEADER|UNPACK_BODY: Both the header and body have been deserialized
|
inlineprotectedvirtual |
Unpacks (deserialize) the body. Must be implemented in a child class.
Reimplemented in igtl::PolyDataMessage, igtl::ImageMessage2, igtl::ImageMessage, igtl::QuaternionTrackingDataMessage, igtl::RTSBindMessage, igtl::TrackingDataMessage, igtl::HeaderOnlyMessageBase, igtl::RTSQuaternionTrackingDataMessage, igtl::StopBindMessage, igtl::TrajectoryMessage, igtl::RTSTrackingDataMessage, igtl::ImageMetaMessage, igtl::StartBindMessage, igtl::LabelMetaMessage, igtl::PointMessage, igtl::StopQuaternionTrackingDataMessage, igtl::StopTrackingDataMessage, igtl::GetTrajectoryMessage, igtl::NDArrayMessage, igtl::GetImageMetaMessage, igtl::GetBindMessage, igtl::StartQuaternionTrackingDataMessage, igtl::GetLabelMetaMessage, igtl::GetPointMessage, igtl::StartTrackingDataMessage, igtl::StatusMessage, igtl::BindMessage, igtl::ColorTableMessage, igtl::PositionMessage, igtl::TransformMessage, igtl::CapabilityMessage, igtl::SensorMessage, igtl::StringMessage, igtl::GetImageMessage2, igtl::GetPolyDataMessage, igtl::GetCapabilityMessage, and igtl::GetColorTableMessage.
Definition at line 165 of file igtlMessageBase.h.
|
virtualinherited |
Decrease the reference count (release by another object).
Reimplemented from igtl::LightObject.
|
protected |
A pointer to the byte array for the serialized body. To prevent large copy of the byte array in the Pack() function, header byte array is concatinated to the byte array for the header.
Definition at line 187 of file igtlMessageBase.h.
|
protected |
The size of the body to be read. This function must be called after the message header is set.
Definition at line 191 of file igtlMessageBase.h.
|
protected |
A character string for the device type (message type). This will be used when the header is desrialized from a byte stream received from the network.
Definition at line 198 of file igtlMessageBase.h.
|
protected |
A character string for the default device type (message type).
Definition at line 194 of file igtlMessageBase.h.
|
protected |
A character string for the device name (message name).
Definition at line 201 of file igtlMessageBase.h.
|
protected |
A pointer to the byte array for the serialized header. To prevent large copy of the byte array in the Pack() function, header byte array is concatinated to the byte array for the body.
Definition at line 182 of file igtlMessageBase.h.
|
protected |
Unpacking (desrialization) status for the body (0: – 1: unpacked).
Definition at line 215 of file igtlMessageBase.h.
|
protected |
Unpacking (desrialization) status for the header (0: – 1: unpacked).
Definition at line 212 of file igtlMessageBase.h.
|
protected |
Definition at line 177 of file igtlMessageBase.h.
|
mutableprotectedinherited |
Number of uses of this object by other objects.
Definition at line 131 of file igtlLightObject.h.
|
mutableprotectedinherited |
Mutex lock to protect modification to the reference count
Definition at line 134 of file igtlLightObject.h.
|
protected |
A time stamp (second) for message creation. It consists of fields for seconds (m_TimeStampSec)and franctions of a second (m_TimeStampSecFraction).
Definition at line 205 of file igtlMessageBase.h.
|
protected |
A time stamp (second) for message creation. It consists of fields for seconds (m_TimeStampSec)and franctions of a second (m_TimeStampSecFraction).
Definition at line 209 of file igtlMessageBase.h.