MAK RTIspy API Documentation for HLA 1.3
rtiTemplateMsg.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2011 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 
8 
9 #ifndef DtRtiTemplateMsg_H_
10 #define DtRtiTemplateMsg_H_
11 
12 
13 #include "rtiMsg.h"
14 #include "connectMgr.h"
16 #include <vector>
17 
18 class DtRtiBaseMsgParam;
20 
44 {
45 public:
46 
48  virtual ~DtRtiTemplateMsg();
49 
53  unsigned addParameter(DtRtiBaseMsgParam* param);
54 
56  virtual void printData(DtLogicalTimeFactory* logicalTimeFactory) const;
57 
58 protected:
59 
62 
65 
68  virtual int minSize() const;
69 
70  friend class DtNetMsgHeaderParam;
71 
72 protected:
73 
76 
78  std::vector<DtRtiBaseMsgParam*> myMsgParams;
79 
82 
84  int myMinSize;
85 
86 };
87 
88 
91 {
92 public:
93 
94  static const char* headerName()
95  {
96  static const char theName[] = "Header";
97  return theName;
98  }
99 
102  , myMsg(msg) {}
104 
106  void* endPtr() { return myMsg->netHeader() + 1; }
107  const void* endPtr() const { return myMsg->netHeader() + 1; };
108 
110  unsigned minSize() { return sizeof(DtNetMsgHeader); }
111 
113  unsigned elementSize() { return sizeof(DtNetMsgHeader); }
114 
116  void print() const {}
117 
121  void setOctetBoundary(unsigned prevBoundary)
122  {
123  myOctetBoundary = minSize() % 8;
124  }
125 
126 protected:
128 
130 };
131 
132 
133 // This macro will automatically declare all of the methods necessary to
134 // create a standard RTI message with the exception of the set and get
135 // functions for the individual parameters.
136 #define DtDECLARE_STANDARD_MSG_METHODS(ClassName) \
137  public: \
138  typedef void (*ClassName##Cb)(const ClassName& msg, void* usr); \
139  ClassName(DtBufferPtr buffer = DtUSE_INTERNAL_BUFFER); \
140  ClassName(const DtNetMsgHeader* netHeader, \
141  DtBufferPtr buffer = DtUSE_INTERNAL_BUFFER); \
142  virtual ~ClassName(); \
143  void addAllParameters(); \
144  virtual DtRtiMsg* clone(bool copy = true) const; \
145  static DtRtiMsg* create(const DtNetMsgHeader* initial, \
146  DtBufferPtr buffer = DtUSE_INTERNAL_BUFFER); \
147  static DtRtiMsg* create( \
148  DtBufferPtr buffer = DtUSE_INTERNAL_BUFFER); \
149  static void addCallback(DtConnectionMgr* conn, \
150  ClassName##Cb cb, void* usr); \
151  static void removeCallback(DtConnectionMgr* conn, \
152  ClassName##Cb cb, void* usr); \
153  protected: \
154  ClassName* self() const /* Casts away const-ness */ \
155  { return const_cast<ClassName*>( this ); }
156 
157 // This macro will automatically define most of the methods declared by
158 // DtDECLARE_STANDARD_MSG_METHODS, with the exception of addAllParameters().
159 #define DtDEFINE_STANDARD_MSG_METHODS(ClassName) \
160  ClassName::ClassName(DtBufferPtr buffer) \
161  : DtRtiTemplateMsg(ClassName##Kind) \
162  { \
163  addAllParameters(); \
164  initDtRtiMsg(minSize(), internalDtRtiMsgKind(), buffer); \
165  } \
166  ClassName::ClassName(const DtNetMsgHeader* netHdr, \
167  DtBufferPtr buffer) \
168  : DtRtiTemplateMsg(ClassName##Kind) \
169  { \
170  addAllParameters(); \
171  initDtRtiMsg(netHdr, buffer); \
172  } \
173  ClassName::~ClassName() {} \
174  DtRtiMsg* ClassName::clone(bool copy) const \
175  { \
176  if (copy) \
177  { \
178  return new ClassName(this->netHeader()); \
179  } \
180  else \
181  { \
182  return new ClassName(); \
183  } \
184  } \
185  DtRtiMsg* ClassName::create(DtBufferPtr buffer) \
186  { \
187  return new ClassName(buffer); \
188  } \
189  DtRtiMsg* ClassName::create(const DtNetMsgHeader* initial, \
190  DtBufferPtr buffer) \
191  { \
192  return new ClassName(initial, buffer); \
193  } \
194  void ClassName::addCallback(DtConnectionMgr* conn, \
195  ClassName##Cb cb, void* usr) \
196  { \
197  conn->addMsgCallback(ClassName##Kind, \
198  (DtRtiMsgCbMgr::DtCallbackFcn) cb, usr); \
199  } \
200  void ClassName::removeCallback(DtConnectionMgr* conn, \
201  ClassName##Cb cb, void* usr) \
202  { \
203  conn->removeMsgCallback(ClassName##Kind, \
204  (DtRtiMsgCbMgr::DtCallbackFcn) cb, usr); \
205  }
206 
207 
208 
209 
210 #endif
211 

Document ID: Generated on Fri Mar 14 19:08:55 EDT 2014 from SVN revision 137085
Copyright © 2005-2014 VT MÄK Inc. All Rights Reserved (www.mak.com)