15 #ifndef DtRtiTemplateMsgInetAddrParams_H_
16 #define DtRtiTemplateMsgInetAddrParams_H_
20 #include <vlutil/vlInetAddr.h>
32 , myFamilyParam(familyParam) {}
40 myFamilyParam->setParam(addr.family());
44 MAKRti::DtInetAddr
param()
const
46 const MAKRti::DtNetU128* ptr =
paramPtr();
47 return MAKRti::DtInetAddr(*ptr,
48 MAKRti::DtInetUtils::DtInetAddrFamily(
49 static_cast<MAKRti::DtU32>(myFamilyParam->param())));
55 const MAKRti::DtNetU128* ptr =
paramPtr();
56 addr = MAKRti::DtInetAddr(*ptr,
57 MAKRti::DtInetUtils::DtInetAddrFamily(
58 static_cast<MAKRti::DtU32>(myFamilyParam->param())));
64 return (reinterpret_cast<char*>(
paramPtr()) +
sizeof(MAKRti::DtNetU128));
69 return (reinterpret_cast<const char*>(
paramPtr()) +
sizeof(MAKRti::DtNetU128));
73 unsigned minSize() {
return sizeof(MAKRti::DtNetU128); }
81 MAKRti::DtVerbose <<
name() <<
": " <<
param().toDtString() << std::endl;
91 assert(prevBoundary == 0 || (prevBoundary % 8) == 0);
98 MAKRti::DtNetU128*
paramPtr() {
return reinterpret_cast<MAKRti::DtNetU128*
>(
beginPtr()); }
99 const MAKRti::DtNetU128*
paramPtr()
const {
return reinterpret_cast<const MAKRti::DtNetU128*
>(
beginPtr()); }
111 template<
typename AllocatedMsgParamType>
116 AllocatedMsgParamType* allocatedNumParam,
DtRtiMsgParam<MAKRti::DtU32,
117 MAKRti::DtNetU32>* familyParam)
120 , myFamilyParam(familyParam)
135 *ptr = addr.toU128();
144 bool setParams(
const MAKRti::DtInetAddr* addrs,
unsigned num)
151 MAKRti::DtNetU128* ptr =
paramPtr();
154 for(
unsigned i = 0; i < num; ++i)
158 myFamilyParam->setParam(static_cast<MAKRti::DtU32>(addrs[i].family()));
160 ptr[i] = addrs[i].toU128();
169 template <
typename ParamContainerType>
177 MAKRti::DtNetU128* ptr =
paramPtr();
180 typename ParamContainerType::const_iterator iter = container.begin();
181 typename ParamContainerType::const_iterator iterEnd = container.end();
182 for(
unsigned i = 0; iter != iterEnd; ++iter, ++i)
186 myFamilyParam->setParam(static_cast<MAKRti::DtU32>(iter->family()));
188 ptr[i] = iter->toU128();
197 template <
typename ParamContainerType>
201 const MAKRti::DtNetU128* ptr =
paramPtr();
202 DtInetUtils::DtInetAddrFamily family =
203 DtInetUtils::DtInetAddrFamily(static_cast<DtU32>(myFamilyParam->param()));
204 for(
unsigned i = 0; i < count; ++i)
206 container.insert(container.end(), MAKRti::DtInetAddr(ptr[i], family));
215 const MAKRti::DtNetU128* ptr =
paramPtr();
216 DtInetUtils::DtInetAddrFamily family =
217 DtInetUtils::DtInetAddrFamily(static_cast<MAKRti::DtU32>(myFamilyParam->param()));
218 for(
unsigned i = 0; i < count; ++i)
220 buff[i] = MAKRti::DtInetAddr(ptr[i], family);
233 const MAKRti::DtNetU128* ptr =
paramPtr();
234 addr = MAKRti::DtInetAddr(ptr[0],
235 DtInetUtils::DtInetAddrFamily(static_cast<MAKRti::DtU32>(myFamilyParam->param())));
248 const MAKRti::DtNetU128* ptr =
paramPtr();
250 DtInetUtils::DtInetAddrFamily(static_cast<MAKRti::DtU32>(myFamilyParam->param())));
282 MAKRti::DtVerbose <<
name() <<
": " << std::endl;
283 MAKRti::DtInetAddr addr;
286 MAKRti::DtVerbose <<
" " << addr.toDtString() << std::endl;
289 MAKRti::DtVerbose <<
" " << addr.toDtString() << std::endl;
294 MAKRti::DtVerbose <<
" Empty" << std::endl;
307 assert(prevBoundary == 0 || (prevBoundary % 8) == 0);
314 const MAKRti::DtNetU128*
paramPtr()
const {
return reinterpret_cast<const MAKRti::DtNetU128*
>(
beginPtr()); }
348 #define DtDECLARE_INET_ADDR_PARAMETER_METHODS(ParamName) \
349 DtDECLARE_BY_REF_PARAMETER_METHODS(ParamName, MAKRti::DtInetAddr) \
351 typedef DtRtiMsgParam<MAKRti::DtInetAddr, MAKRti::DtNetU128> ParamName##Type; \
352 ParamName##Type* my##ParamName;
358 #define DtDECLARE_INET_ADDR_ARRAY_PARAMETER_METHODS(ParamName, CountBitSize) \
359 DtDECLARE_ARRAY_PARAMETER_METHODS(ParamName, MAKRti::DtInetAddr) \
361 typedef DtRtiArrayMsgParam<MAKRti::DtInetAddr, MAKRti::DtU128, MAKRti::DtNetU128, \
362 DtRtiMsgParam<MAKRti::DtU##CountBitSize, MAKRti::DtNetU##CountBitSize> > ParamName##Type; \
363 ParamName##Type* my##ParamName;
375 #define DtDEFINE_INET_ADDR_PARAMETER_METHODS(ClassName, ParamName) \
376 DtDEFINE_BY_REF_PARAMETER_METHODS(ClassName, ParamName, MAKRti::DtInetAddr)
385 #define DtDEFINE_INET_ADDR_ARRAY_PARAMETER_CONTAINER_METHODS(ClassName, ParamName, CtrType)\
386 void ClassName::set##ParamName(const CtrType& container, \
387 DtResizeArrayFlag resizeFlag) \
389 unsigned currNum = my##ParamName->numItems(); \
390 if(resizeFlag == DtResizeIfNeeded && container.size() != currNum) \
392 unsigned currSize = currNum * sizeof(MAKRti::DtNetU128); \
393 unsigned newSize = container.size() * sizeof(MAKRti::DtNetU128); \
394 char* begPtr = static_cast<char*>(my##ParamName->beginPtr()); \
395 if(newSize > currSize) \
397 insertBytes(begPtr + currSize, newSize - currSize); \
399 else if(currSize > newSize) \
401 deleteBytes(begPtr + newSize, currSize - newSize); \
403 my##ParamName->setNumItems(container.size()); \
405 my##ParamName->setParams(container); \
407 void ClassName::get##ParamName(CtrType& container) const \
409 my##ParamName->getParams(container); \
416 #define DtDEFINE_INET_ADDR_ARRAY_PARAMETER_METHODS(ClassName, ParamName) \
417 const char* ClassName::ParamName##Name = #ParamName; \
418 DtDEFINE_INET_ADDR_ARRAY_PARAMETER_CONTAINER_METHODS(ClassName, ParamName, std::set<MAKRti::DtInetAddr>) \
419 DtDEFINE_INET_ADDR_ARRAY_PARAMETER_CONTAINER_METHODS(ClassName, ParamName, std::vector<MAKRti::DtInetAddr>) \
420 DtDEFINE_INET_ADDR_ARRAY_PARAMETER_CONTAINER_METHODS(ClassName, ParamName, std::list<MAKRti::DtInetAddr>) \
421 DtDEFINE_INET_ADDR_ARRAY_PARAMETER_CONTAINER_METHODS(ClassName, ParamName, std::deque<MAKRti::DtInetAddr>) \
422 void ClassName::set##ParamName(const MAKRti::DtInetAddr* buff, \
423 unsigned num, DtResizeArrayFlag resizeFlag) \
425 unsigned currNum = my##ParamName->numItems(); \
426 if(resizeFlag == DtResizeIfNeeded && num != currNum) \
428 unsigned currSize = currNum * sizeof(MAKRti::DtNetU128); \
429 unsigned newSize = num * sizeof(MAKRti::DtNetU128); \
430 char* begPtr = static_cast<char*>(my##ParamName->beginPtr()); \
431 if(newSize > currSize) \
433 insertBytes(begPtr + currSize, newSize - currSize); \
435 else if(currSize > newSize) \
437 deleteBytes(begPtr + newSize, currSize - newSize); \
439 my##ParamName->setNumItems(num); \
441 my##ParamName->setParams(buff, num); \
443 unsigned ClassName::get##ParamName(MAKRti::DtInetAddr* buff) const \
445 return my##ParamName->getParams(buff); \
460 #define DtADD_INET_ADDR_PARAMETER(ParamName, FamilyParamName) \
461 addParameter(my##ParamName = new ParamName##Type(ParamName##Name, my##FamilyParamName));
467 #define DtADD_INET_ADDR_ARRAY_PARAMETER(ParamName, SizeParamName, FamilyParamName) \
468 addParameter(my##ParamName = new ParamName##Type(ParamName##Name, my##SizeParamName, my##FamilyParamName));
unsigned numItems() const
Returns the number of items in this array.
Definition: rtiTemplateMsgArrayParams.h:241
DtRtiMsgParam< MAKRti::DtU32, MAKRti::DtNetU32 > * myFamilyParam
The parameter which points to the IP address family.
Definition: rtiTemplateMsgInetAddrParams.h:104
unsigned elementSize()
Returns the size of single element in this parameter.
Definition: rtiTemplateMsgInetAddrParams.h:271
unsigned minSize()
Returns the minimum size of this parameter, which is 0 since it could be an empty array...
Definition: rtiTemplateMsgInetAddrParams.h:268
void * beginPtr()
Returns a pointer to the start of this parameter in the message.
Definition: rtiTemplateMsgParams.h:47
AllocatedMsgParamType * myAllocatedNumParam
The parameter which specifies how many elements can fit in the space allotted for this array...
Definition: rtiTemplateMsgArrayParams.h:287
const void * endPtr() const
Definition: rtiTemplateMsgInetAddrParams.h:261
AllocatedMsgParamType * myAllocatedNumParam
The parameter which specifies how many elements can fit in the space allotted for this array...
Definition: rtiTemplateMsgInetAddrParams.h:322
unsigned myMutableNextParamIndex
The index to the next item to be retrieved by nextParam.
Definition: rtiTemplateMsgInetAddrParams.h:331
unsigned myOctetBoundary
Octet boundary of this parameter.
Definition: rtiTemplateMsgParams.h:87
void setOctetBoundary(unsigned prevBoundary)
Sets the octet boundary of the parameter in the message.
Definition: rtiTemplateMsgInetAddrParams.h:302
NetParamType * paramPtr()
Returns a pointer to location of this parameter in the message.
Definition: rtiTemplateMsgArrayParams.h:280
void print() const
Prints the parameter.
Definition: rtiTemplateMsgInetAddrParams.h:79
unsigned myNumUsed
The number of items currently used in the array.
Definition: rtiTemplateMsgArrayParams.h:290
ParamType param() const
Gets the value of the parameter.
Definition: rtiTemplateMsgParams.h:116
const MAKRti::DtNetU128 * paramPtr() const
Definition: rtiTemplateMsgInetAddrParams.h:314
void setNumItems(unsigned num)
Sets the number of items in this array.
Definition: rtiTemplateMsgInetAddrParams.h:277
~DtRtiMsgParam()
Definition: rtiTemplateMsgInetAddrParams.h:33
void setOctetBoundary(unsigned prevBoundary)
Sets the octet boundary of the parameter in the message.
Definition: rtiTemplateMsgInetAddrParams.h:86
This file defines the DtRtiArrayMsgParam template which can be used to create a message parameter whi...
unsigned minSize()
Returns the minimum size of this parameter.
Definition: rtiTemplateMsgInetAddrParams.h:73
This file defines the DtRtiMsgParam template which can be used to produce template based message clas...
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
MAKRti::DtInetAddr param() const
Gets the value of the parameter.
Definition: rtiTemplateMsgInetAddrParams.h:44
MAKRti::DtNetU128 * paramPtr()
Returns a pointer to location of this parameter in the message.
Definition: rtiTemplateMsgInetAddrParams.h:313
The base class for all templated RTI message parameters.
Definition: rtiTemplateMsgParams.h:32
unsigned getParams(MAKRti::DtInetAddr *buff) const
Populates the buffer with all of the parameter data in this parameter array.
Definition: rtiTemplateMsgInetAddrParams.h:212
bool getNextParam(ParamType &val) const
Gets the value of the next parameter item in the array.
Definition: rtiTemplateMsgArrayParams.h:211
unsigned myMutableNextParamIndex
The index to the next item to be retrieved by nextParam.
Definition: rtiTemplateMsgArrayParams.h:293
bool getFirstParam(MAKRti::DtInetAddr &addr) const
Gets the value of the first parameter item in the array and resets the index for getNextParam().
Definition: rtiTemplateMsgInetAddrParams.h:228
void print() const
Prints the parameter.
Definition: rtiTemplateMsgInetAddrParams.h:280
bool setParams(const ParamContainerType &container)
Sets the entire contents of the array.
Definition: rtiTemplateMsgInetAddrParams.h:170
DtRtiMsgParam< MAKRti::DtU32, MAKRti::DtNetU32 > * myFamilyParam
The parameter which points to the IP address family.
Definition: rtiTemplateMsgInetAddrParams.h:325
const void * endPtr() const
Definition: rtiTemplateMsgInetAddrParams.h:67
bool getNextParam(MAKRti::DtInetAddr &addr) const
Gets the value of the next parameter item in the array.
Definition: rtiTemplateMsgInetAddrParams.h:243
bool setParams(const MAKRti::DtInetAddr *addrs, unsigned num)
Sets the entire contents of the array.
Definition: rtiTemplateMsgInetAddrParams.h:144
DtRtiArrayMsgParam(const char *paramName, AllocatedMsgParamType *allocatedNumParam, DtRtiMsgParam< MAKRti::DtU32, MAKRti::DtNetU32 > *familyParam)
Definition: rtiTemplateMsgInetAddrParams.h:115
unsigned myNumUsed
The number of items currently used in the array.
Definition: rtiTemplateMsgInetAddrParams.h:328
void getParams(ParamContainerType &container) const
Populates the container with all of the parameter data in this parameter array.
Definition: rtiTemplateMsgInetAddrParams.h:198
unsigned numItems() const
Returns the number of items in this array.
Definition: rtiTemplateMsgInetAddrParams.h:274
The template for an RTI message parameter which is actually an array of items of the same type...
Definition: rtiTemplateMsgArrayParams.h:92
unsigned elementSize()
Same as minSize.
Definition: rtiTemplateMsgInetAddrParams.h:76
void getParam(MAKRti::DtInetAddr &addr) const
Gets the value of the parameter.
Definition: rtiTemplateMsgInetAddrParams.h:53
DtRtiMsgParam(const char *paramName)
Definition: rtiTemplateMsgParams.h:98
DtRtiMsgParam(const char *paramName, DtRtiMsgParam< MAKRti::DtU32, MAKRti::DtNetU32 > *familyParam)
Definition: rtiTemplateMsgInetAddrParams.h:29
~DtRtiArrayMsgParam()
Definition: rtiTemplateMsgInetAddrParams.h:123
virtual const char * name() const
Returns the parameter name.
Definition: rtiTemplateMsgParams.h:63
bool getFirstParam(ParamType &val) const
Gets the value of the first parameter item in the array and resets the index for getNextParam().
Definition: rtiTemplateMsgArrayParams.h:197
bool addParam(const MAKRti::DtInetAddr &addr)
Adds a new parameter data item to the array.
Definition: rtiTemplateMsgInetAddrParams.h:127
MAKRti::DtNetU128 * paramPtr()
Returns a pointer to location of this parameter in the message.
Definition: rtiTemplateMsgInetAddrParams.h:98
DtRtiArrayMsgParam(const char *paramName, AllocatedMsgParamType *allocatedNum)
Definition: rtiTemplateMsgArrayParams.h:95
void setParamRef(const MAKRti::DtInetAddr &addr)
Sets the value of the parameter.
Definition: rtiTemplateMsgInetAddrParams.h:36
const MAKRti::DtNetU128 * paramPtr() const
Definition: rtiTemplateMsgInetAddrParams.h:99
void * endPtr()
Returns a pointer to location just after this parameter in the message.
Definition: rtiTemplateMsgInetAddrParams.h:256
void * endPtr()
Returns a pointer to location just after this parameter in the message.
Definition: rtiTemplateMsgInetAddrParams.h:62