MAK RTIspy API Documentation for HLA 1516
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
int myMinSize
The minimum size needed for this message.
Definition: rtiTemplateMsg.h:84
DtRtiMsgKind
Definition: rtiMsgKind.h:9
DtNetMsgHeaderParam(DtRtiTemplateMsg *msg)
Definition: rtiTemplateMsg.h:100
Definition: netRtiMsgHdr.h:23
A message parameter class specifically to handle DtNetMsgHeader.
Definition: rtiTemplateMsg.h:90
unsigned minSize()
Returns the minimum size of this parameter.
Definition: rtiTemplateMsg.h:110
!DtIFSPEC1516
Definition: fedTimeFactory.h:190
std::vector< DtRtiBaseMsgParam * > myMsgParams
The list of other message parameters.
Definition: rtiTemplateMsg.h:78
virtual void printData(DtLogicalTimeFactory *logicalTimeFactory) const
unsigned myOctetBoundary
Octet boundary of this parameter.
Definition: rtiTemplateMsgParams.h:87
This file contains the declaration of the Connection Manager.
void setOctetBoundary(unsigned prevBoundary)
Sets the octet boundary of the parameter in the message based on the boundary of this parameter and t...
Definition: rtiTemplateMsg.h:121
const void * endPtr() const
Definition: rtiTemplateMsg.h:107
This file defines the DtRtiMsgParam template which can be used to produce template based message clas...
The base class for all templated RTI message parameters.
Definition: rtiTemplateMsgParams.h:32
unsigned elementSize()
Same as minSize.
Definition: rtiTemplateMsg.h:113
DtRtiMsg is the base class for messages between RTI components.
Definition: rtiMsg.h:45
void * endPtr()
Returns a pointer to location just after this parameter in the message.
Definition: rtiTemplateMsg.h:106
~DtNetMsgHeaderParam()
Definition: rtiTemplateMsg.h:103
virtual DtNetMsgHeader * netHeader() const
Get header of network representation.
Definition: rtiMsg.h:336
void print() const
Prints the parameter.
Definition: rtiTemplateMsg.h:116
virtual DtRtiMsgKind internalDtRtiMsgKind()=0
static const char * headerName()
Definition: rtiTemplateMsg.h:94
DtRtiMsgKind myMsgKind
The message kind.
Definition: rtiTemplateMsg.h:81
#define DT_DLL_LRC
Definition: rtiMsConfig.h:126
DtRtiTemplateMsg defines a base class which can be subclassed to quickly produce a new RTI messages b...
Definition: rtiTemplateMsg.h:43
DtNetMsgHeaderParam * myHeaderParam
The parameter which points to the message header.
Definition: rtiTemplateMsg.h:75
DtRtiTemplateMsg * myMsg
Definition: rtiTemplateMsg.h:129

Document ID: Generated on Thu May 11 15:55:32 EDT 2023 from SVN revision 254743
Copyright © 2005-2020 MAK Technologies Inc. All Rights Reserved (www.mak.com)