23 #ifndef DtRtiTemplateMsgParams_H_
24 #define DtRtiTemplateMsgParams_H_
27 #include <vlutil/vlNetTypes.h>
28 #include <vlutil/vlPrint.h>
43 virtual void*
endPtr() = 0;
44 virtual const void*
endPtr()
const = 0;
60 virtual void print()
const = 0;
94 template<
typename ParamType,
typename NetParamType>
118 return static_cast<ParamType
>(*
paramPtr());
124 val =
static_cast<ParamType
>(*
paramPtr());
130 return (reinterpret_cast<char*>(
paramPtr()) +
sizeof(NetParamType));
135 return (reinterpret_cast<const char*>(
paramPtr()) +
sizeof(NetParamType));
139 unsigned minSize() {
return sizeof(NetParamType); }
148 MAKRti::DtVerbose <<
name() <<
": " <<
param() << std::endl;
159 assert(prevBoundary == 0 || (prevBoundary %
minSize()) == 0);
167 const NetParamType*
paramPtr()
const {
return reinterpret_cast<const NetParamType*
>(
beginPtr()); }
184 #define DtDECLARE_PARAMETER_METHODS(ParamName, ParamType) \
186 static const char* ParamName##Name; \
187 void set##ParamName(ParamType val); \
188 ParamType get##ParamName() const;
195 #define DtDECLARE_BY_REF_PARAMETER_METHODS(ParamName, ParamType) \
197 static const char* ParamName##Name; \
198 void set##ParamName(const ParamType& val); \
199 ParamType get##ParamName() const; \
200 void get##ParamName(ParamType& val) const;
206 #define DtDECLARE_UNSIGNED_PARAMETER_METHODS(ParamName, BitSize) \
207 DtDECLARE_PARAMETER_METHODS(ParamName, MAKRti::DtU##BitSize) \
209 typedef DtRtiMsgParam<MAKRti::DtU##BitSize, MAKRti::DtNetU##BitSize> ParamName##Type; \
210 ParamName##Type* my##ParamName;
216 #define DtDECLARE_BOOL_PARAMETER_METHODS(ParamName) \
217 DtDECLARE_PARAMETER_METHODS(ParamName, bool) \
219 typedef DtRtiMsgParam<MAKRti::DtU8, MAKRti::DtNetU8> ParamName##Type; \
220 ParamName##Type* my##ParamName;
226 #define DtDECLARE_INT_PARAMETER_METHODS(ParamName, BitSize) \
227 DtDECLARE_PARAMETER_METHODS(ParamName, MAKRti::DtInt##BitSize) \
229 typedef DtRtiMsgParam<MAKRti::DtInt##BitSize, MAKRti::DtNetInt##BitSize> ParamName##Type; \
230 ParamName##Type* my##ParamName;
237 #define DtDECLARE_ENUMERATION_PARAMETER_METHODS(ParamName, EnumType, BitSize) \
238 DtDECLARE_PARAMETER_METHODS(ParamName, EnumType) \
240 typedef DtRtiMsgParam<MAKRti::DtU##BitSize, MAKRti::DtNetU##BitSize> ParamName##Type; \
241 ParamName##Type* my##ParamName;
247 #define DtDECLARE_FLOAT_PARAMETER_METHODS(ParamName, BitSize) \
248 DtDECLARE_PARAMETER_METHODS(ParamName, MAKRti::DtFloat##BitSize) \
250 typedef DtRtiMsgParam<MAKRti::DtFloat##BitSize, MAKRti::DtNetFloat##BitSize> ParamName##Type; \
251 ParamName##Type* my##ParamName;
268 #define DtDEFINE_PARAMETER_METHODS(ClassName, ParamName, ParamType) \
269 const char* ClassName::ParamName##Name = #ParamName; \
270 void ClassName::set##ParamName(ParamType val) \
272 my##ParamName->setParam(val); \
274 ParamType ClassName::get##ParamName() const \
276 return static_cast<ParamType>(my##ParamName->param()); \
285 #define DtDEFINE_BY_REF_PARAMETER_METHODS(ClassName, ParamName, ParamType) \
286 const char* ClassName::ParamName##Name = #ParamName; \
287 void ClassName::set##ParamName(const ParamType& val) \
289 my##ParamName->setParamRef(val); \
291 ParamType ClassName::get##ParamName() const \
293 return my##ParamName->param(); \
295 void ClassName::get##ParamName(ParamType& val) const \
297 my##ParamName->getParam(val); \
305 #define DtDEFINE_UNSIGNED_PARAMETER_METHODS(ClassName, ParamName, BitSize) \
306 DtDEFINE_PARAMETER_METHODS(ClassName, ParamName, DtU##BitSize)
312 #define DtDEFINE_BOOL_PARAMETER_METHODS(ClassName, ParamName) \
313 DtDEFINE_PARAMETER_METHODS(ClassName, ParamName, bool)
320 #define DtDEFINE_INT_PARAMETER_METHODS(ClassName, ParamName, BitSize) \
321 DtDEFINE_PARAMETER_METHODS(ClassName, ParamName, DtInt##BitSize)
328 #define DtDEFINE_ENUMERATION_PARAMETER_METHODS(ClassName, ParamName, EnumType)\
329 DtDEFINE_PARAMETER_METHODS(ClassName, ParamName, EnumType)
336 #define DtDEFINE_FLOAT_PARAMETER_METHODS(ClassName, ParamName, BitSize) \
337 DtDEFINE_PARAMETER_METHODS(ClassName, ParamName, DtFloat##BitSize)
348 #define DtADD_PARAMETER(ParamName) \
349 addParameter(my##ParamName = new ParamName##Type(ParamName##Name));
const char * myName
The parameter name.
Definition: rtiTemplateMsgParams.h:90
virtual unsigned elementSize()=0
Returns the size of single element in this parameter.
unsigned octetBoundary() const
Returns the octet boundary of the parameter in the message.
Definition: rtiTemplateMsgParams.h:66
DtRtiBaseMsgParam(const char *paramName)
Definition: rtiTemplateMsgParams.h:78
void setParam(ParamType val)
Sets the value of the parameter.
Definition: rtiTemplateMsgParams.h:102
virtual void * endPtr()=0
Returns a pointer to location just after this parameter in the message.
void * beginPtr()
Returns a pointer to the start of this parameter in the message.
Definition: rtiTemplateMsgParams.h:47
void * endPtr()
Returns a pointer to location just after this parameter in the message.
Definition: rtiTemplateMsgParams.h:128
unsigned myOctetBoundary
Octet boundary of this parameter.
Definition: rtiTemplateMsgParams.h:87
const NetParamType * paramPtr() const
Definition: rtiTemplateMsgParams.h:167
unsigned minSize()
Returns the minimum size of this parameter.
Definition: rtiTemplateMsgParams.h:139
~DtRtiBaseMsgParam()
Definition: rtiTemplateMsgParams.h:35
ParamType param() const
Gets the value of the parameter.
Definition: rtiTemplateMsgParams.h:116
unsigned elementSize()
Returns the size of single element in this parameter.
Definition: rtiTemplateMsgParams.h:143
void print() const
Prints the parameter.
Definition: rtiTemplateMsgParams.h:146
The template for an RTI message parameter.
Definition: rtiTemplateMsgParams.h:95
NetParamType * paramPtr()
Returns a pointer to location of this parameter in the message.
Definition: rtiTemplateMsgParams.h:166
The base class for all templated RTI message parameters.
Definition: rtiTemplateMsgParams.h:32
void setParamRef(const ParamType &val)
Sets the value of the parameter by reference.
Definition: rtiTemplateMsgParams.h:109
const void * beginPtr() const
Definition: rtiTemplateMsgParams.h:51
const void * endPtr() const
Definition: rtiTemplateMsgParams.h:133
virtual void print() const =0
Prints the parameter.
virtual void setOctetBoundary(unsigned prevBoundary)=0
Sets the octet boundary of the parameter in the message based on the boundary of this parameter and t...
void getParam(ParamType &val) const
Gets the value of the parameter by reference.
Definition: rtiTemplateMsgParams.h:122
void setPrevParam(DtRtiBaseMsgParam *prevParam)
Sets the pointer to the previous parameter in the message.
Definition: rtiTemplateMsgParams.h:38
~DtRtiMsgParam()
Definition: rtiTemplateMsgParams.h:99
DtRtiMsgParam(const char *paramName)
Definition: rtiTemplateMsgParams.h:98
void setOctetBoundary(unsigned prevBoundary)
Sets the octet boundary of the parameter in the message based on the boundary of this parameter and t...
Definition: rtiTemplateMsgParams.h:154
virtual const char * name() const
Returns the parameter name.
Definition: rtiTemplateMsgParams.h:63
DtRtiBaseMsgParam * myPrevParam
Pointer to the previous parameter in this message.
Definition: rtiTemplateMsgParams.h:84
virtual unsigned minSize()=0
Returns the minimum size of this parameter.