Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  
igtlBindMessage.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   The OpenIGTLink Library
00004   Module:    $HeadURL: http://svn.na-mic.org/NAMICSandBox/trunk/OpenIGTLink2_beta/Source/igtlBindMessage.h $
00005   Language:  C++
00006   Date:      $Date: 2009-12-16 23:58:02 -0500 (Wed, 16 Dec 2009) $
00007   Version:   $Revision: 5466 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010 
00011   This software is distributed WITHOUT ANY WARRANTY; without even
00012   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00013   PURPOSE.  See the above copyright notices for more information.
00014 
00015 =========================================================================*/
00016 
00017 #ifndef __igtlBindMessage_h
00018 #define __igtlBindMessage_h
00019 
00020 #include <string>
00021 
00022 #include "igtlObject.h"
00023 #include "igtlMath.h"
00024 #include "igtlMessageBase.h"
00025 #include "igtlTypes.h"
00026 
00027 namespace igtl
00028 {
00029 //
00030 // Base class for BindMessage, GetBindMessage and StartBindMessage
00031 //
00032 class IGTLCommon_EXPORT BindMessageBase: public MessageBase
00033 {
00034 public:
00035   typedef BindMessageBase                Self;
00036   typedef MessageBase                    Superclass;
00037   typedef SmartPointer<Self>             Pointer;
00038   typedef SmartPointer<const Self>       ConstPointer;
00039 
00040   igtlTypeMacro(igtl::BindMessageBase, igtl::MessageBase);
00041   igtlNewMacro(igtl::BindMessageBase);
00042 
00043 public:
00044   
00045   void        Init();
00046 
00047   int         SetNumberOfChildMessages(unsigned int n);
00048   int         GetNumberOfChildMessages();
00049 
00050   int         AppendChildMessage(igtl::MessageBase * child);
00051   int         SetChildMessage(unsigned int i, igtl::MessageBase * child);
00052 
00053   const char* GetChildMessageType(unsigned int i);
00054 
00055 protected:
00056 
00057   BindMessageBase();
00058   ~BindMessageBase();
00059   
00060 protected:
00061 
00062   typedef struct {
00063     std::string  type;
00064     std::string  name;
00065     igtlUint64   size;
00066     void *       ptr;
00067   } ChildMessageInfo;
00068 
00069   std::vector<ChildMessageInfo> m_ChildMessages;
00070   
00071 };
00072 
00073 
00074 class IGTLCommon_EXPORT BindMessage: public BindMessageBase
00075 {
00076 public:
00077   typedef BindMessage                    Self;
00078   typedef BindMessageBase                Superclass;
00079   typedef SmartPointer<Self>             Pointer;
00080   typedef SmartPointer<const Self>       ConstPointer;
00081 
00082   igtlTypeMacro(igtl::BindMessage, igtl::BindMessageBase);
00083   igtlNewMacro(igtl::BindMessage);
00084 
00085 public:
00086   
00087   int         GetChildMessage(unsigned int i, igtl::MessageBase * child);
00088 
00089 protected:
00090   BindMessage();
00091   ~BindMessage();
00092   
00093 protected:
00094 
00095   virtual int  GetBodyPackSize();
00096   virtual int  PackBody();
00097   virtual int  UnpackBody();
00098 
00099 };
00100 
00101 
00102 class IGTLCommon_EXPORT GetBindMessage: public BindMessageBase
00103 {
00104 public:
00105   typedef GetBindMessage               Self;
00106   typedef BindMessageBase              Superclass;
00107   typedef SmartPointer<Self>           Pointer;
00108   typedef SmartPointer<const Self>     ConstPointer;
00109 
00110   igtlTypeMacro(igtl::GetBindMessage, igtl::BindMessageBase);
00111   igtlNewMacro(igtl::GetBindMessage);
00112 
00113 public:
00114   
00115   int          AppendChildMessage(const char * type, const char * name);
00116 
00117 protected:
00118   GetBindMessage();
00119   ~GetBindMessage();
00120   
00121 protected:
00122   
00123   virtual int  GetBodyPackSize();
00124   virtual int  PackBody();
00125   virtual int  UnpackBody();
00126 
00127 };
00128 
00129 
00130 class IGTLCommon_EXPORT StartBindMessage: public GetBindMessage
00131 {
00132 public:
00133   typedef StartBindMessage             Self;
00134   typedef GetBindMessage               Superclass;
00135   typedef SmartPointer<Self>           Pointer;
00136   typedef SmartPointer<const Self>     ConstPointer;
00137 
00138   igtlTypeMacro(igtl::StartBindMessage, igtl::GetBindMessage);
00139   igtlNewMacro(igtl::StartBindMessage);
00140 
00141 public:
00142 
00143   // Set/get time resolution. The time resolution is specified
00144   // as a 64-bit fixed-point used in OpenIGTLink time stamp.
00145   void        SetResolution(igtlUint64 res);
00146   igtlUint64  GetResolution();
00147 
00148 protected:
00149   StartBindMessage();
00150   ~StartBindMessage();
00151   
00152 protected:
00153 
00154   virtual int  GetBodyPackSize();
00155   virtual int  PackBody();
00156   virtual int  UnpackBody();
00157 
00158   igtlUint64   m_Resolution;
00159 
00160 };
00161 
00162 
00163 class IGTLCommon_EXPORT StopBindMessage: public MessageBase
00164 {
00165 public:
00166   typedef StopBindMessage                Self;
00167   typedef MessageBase                    Superclass;
00168   typedef SmartPointer<Self>             Pointer;
00169   typedef SmartPointer<const Self>       ConstPointer;
00170 
00171   igtlTypeMacro(igtl::StopBindMessage, igtl::MessageBase);
00172   igtlNewMacro(igtl::StopBindMessage);
00173 
00174 protected:
00175   StopBindMessage() : MessageBase() { this->m_DefaultBodyType  = "STP_BIND"; };
00176   ~StopBindMessage() {};
00177 
00178 protected:
00179   virtual int  GetBodyPackSize() { return 0; };
00180   virtual int  PackBody()        { AllocatePack(); return 1; };
00181   virtual int  UnpackBody()      { return 1; };
00182 
00183 };
00184 
00185 
00186 class IGTLCommon_EXPORT RTSBindMessage: public MessageBase
00187 {
00188 public:
00189   typedef RTSBindMessage         Self;
00190   typedef MessageBase                    Superclass;
00191   typedef SmartPointer<Self>             Pointer;
00192   typedef SmartPointer<const Self>       ConstPointer;
00193 
00194   // Status type
00195   enum {
00196     STATUS_SUCCESS = 0,
00197     STATUS_ERROR = 1
00198   };
00199 
00200 
00201   igtlTypeMacro(igtl::RTSBindMessage, igtl::MessageBase);
00202   igtlNewMacro(igtl::RTSBindMessage);
00203 
00204   void          SetStatus(igtlUint8 status){ this->m_Status = status; }
00205   igtlUint8     GetStatus()                { return this->m_Status; };
00206 
00207 protected:
00208   RTSBindMessage() : MessageBase(), m_Status(0) { this->m_DefaultBodyType  = "RTS_BIND"; };
00209   ~RTSBindMessage() {};
00210 
00211   igtlUint8 m_Status;
00212 
00213 protected:
00214   virtual int  GetBodyPackSize();
00215   virtual int  PackBody();
00216   virtual int  UnpackBody();
00217 
00218 };
00219 
00220 
00221 
00222 } // namespace igtl
00223 
00224 #endif // _igtlBindMessage_h
00225 
00226 
00227 
00228 

Generated at Wed Apr 27 2011 00:08:07 for OpenIGTLink by doxygen 1.7.4 written by Dimitri van Heesch, © 1997-2000