9 #ifndef DtHlaStateDecoder_H_
10 #define DtHlaStateDecoder_H_
53 typedef void (*DtAttributeDecoder) (
55 const RTI::AttributeHandleValuePairSet& avlist,
56 unsigned long pairSetIndex);
63 DtAttributeDecoder addDecoder(RTI::AttributeHandle h,
64 DtAttributeDecoder func);
65 DtAttributeDecoder removeDecoder(RTI::AttributeHandle h);
73 DtAttributeDecoder addDecoder(
char*
attrName,
74 DtAttributeDecoder func,
bool complain =
true);
75 DtAttributeDecoder removeDecoder(
char*
attrName,
bool complain =
true);
78 virtual DtAttributeDecoder decoder(
const RTI::AttributeHandle &handle)
const;
85 virtual RTI::ObjectClassHandle objectClassHandle()
const;
102 static inline char* decodingBuffer(
int length);
105 static char* attributeData(
const RTI::AttributeHandleValuePairSet& attrs,
106 int index, RTI::ULong& length);
113 static char* attributeData(
114 const RTI::AttributeHandleValuePairSet& attrs,
int index, RTI::ULong& length,
115 unsigned int expectedDataSize,
char*
attrName);
119 static DtNetEventId* eventIdAttributeData(
const RTI::AttributeHandleValuePairSet& attrs,
127 static std::wstring wideStringFromHlaUnicodeString(
char* buffer,
int size,
bool* error =
nullptr);
132 static bool getVectorFromArrayOfUuid(
char* buffer,
int size, std::vector< DtVrlUuid >& uuids);
138 virtual void decodeAttribute(
140 const RTI::AttributeHandleValuePairSet& attrs,
141 unsigned long pairSetIndex)
const;
177 AttributeHandleDecoderMap::const_iterator pos =
myDecoderList.find(handle);
191 const RTI::AttributeHandleValuePairSet& attrs,
int index, RTI::ULong& length)
196 dataPtr = attrs.getValuePointer(index, length);
200 length = attrs.getValueLength(index);
204 attrs.getValue(index, dataPtr, length);
211 const RTI::AttributeHandleValuePairSet& attrs,
int index, RTI::ULong& length,
212 unsigned int expectedDataSize,
char*
attrName)
214 char* outDataPtr = 0;
217 outDataPtr = attrs.getValuePointer(index, length);
221 length = attrs.getValueLength(index);
222 if (length > 0 && length >= expectedDataSize)
225 attrs.getValue(index, outDataPtr, length);
229 if (length != expectedDataSize)
231 if (length < expectedDataSize)
233 DtWarn(
"Cannot decode attribute %s.\n"
234 "Size of data (%d) is smaller than expected (%d).\n",
235 attrName, length, expectedDataSize);
241 DtVerbose(
"When decoding attribute %s,\n"
242 "found size of data (%d) is larger than expected (%d).\n",
243 attrName, length, expectedDataSize);
251 const RTI::AttributeHandleValuePairSet& attrs,
int index)
253 RTI::ULong length = 0;
255 length = attrs.getValueLength(index);
259 attrs.getValue(index, dataPtr, length);
268 #define DtADD_ATTR_DECODER(attrName) \
269 addDecoder((char *)#attrName, (DtAttributeDecoder) decode##attrName);
272 #define DtADD_ATTR_DECODER_QUIET(attrName) \
273 addDecoder((char *)#attrName, (DtAttributeDecoder) decode##attrName, false);
279 #define DtDECLARE_ATTR_DECODER(stateRepClass, attrName) \
280 static void decode##attrName(stateRepClass* stateRep, \
281 const RTI::AttributeHandleValuePairSet& attrs, int pairSetIndex)
291 #define DtDEFINE_SIMPLE_ATTR_DECODER_WITH_CAST( \
292 decClass, stateRepClass, attrName, netType, mutator, castExpr) \
293 void decClass::decode##attrName( \
294 stateRepClass* stateRep, \
295 const RTI::AttributeHandleValuePairSet& attrs, \
298 RTI::ULong length = 0; \
299 netType* netValPtr = (netType*)attributeData(attrs, index, length, sizeof(netType), #attrName); \
302 stateRep->mutator(castExpr *netValPtr); \
313 #define DtDEFINE_SIMPLE_ATTR_DECODER_WITH_CAST_SET( \
314 decClass, stateRepClass, attrName, netType, castExpr) \
315 DtDEFINE_SIMPLE_ATTR_DECODER_WITH_CAST( \
316 decClass, stateRepClass, attrName, netType, set##attrName, castExpr)
324 #define DtDEFINE_SIMPLE_ATTR_DECODER_MUTATOR( \
325 decClass, stateRepClass, attrName, netType, mutator) \
326 void decClass::decode##attrName( \
327 stateRepClass* stateRep, \
328 const RTI::AttributeHandleValuePairSet& attrs, \
331 RTI::ULong length = 0; \
332 netType* netValPtr = (netType*)attributeData(attrs, index, length, sizeof(netType), #attrName); \
335 stateRep->mutator(*netValPtr); \
345 #define DtDEFINE_SIMPLE_ATTR_DECODER_SET( \
346 decClass, stateRepClass, attrName, netType) \
347 DtDEFINE_SIMPLE_ATTR_DECODER_MUTATOR( \
348 decClass, stateRepClass, attrName, netType, set##attrName)
358 #define DtDEFINE_SIMPLE_ATTR_DECODER_WITH_CAST_AND_PARAM( \
359 decClass, stateRepClass, attrName, netType, mutator, param, castExpr) \
360 void decClass::decode##attrName( \
361 stateRepClass* stateRep, \
362 const RTI::AttributeHandleValuePairSet& attrs, \
365 RTI::ULong length = 0; \
366 netType* netValPtr = (netType*)attributeData(attrs, index, length, sizeof(netType), #attrName); \
369 stateRep->mutator(param, castExpr *netValPtr); \
373 #define DtDEFINE_SIMPLE_GLOBAL_OBJECT_DESIGNATOR_ATTR_DECODER( \
374 decClass, stateRepClass, attrName, mutator) \
375 void decClass::decode##attrName( \
376 stateRepClass* stateRep, \
377 const RTI::AttributeHandleValuePairSet& attrs, \
380 RTI::ULong length = 0; \
381 DtGlobalObjectDesignator objName = (char*) attrs.getValuePointer(pairSetIndex, length); \
382 stateRep->mutator(objName); \
389 #define DtDEFINE_SIMPLE_ATTR_DECODER_BUFF(decClass, stateRepClass, \
391 void decClass::decode##attrName( \
392 stateRepClass* stateRep, \
393 const RTI::AttributeHandleValuePairSet& attrs, \
396 RTI::ULong length = 0; \
397 char* buff = attributeData(attrs, index, length); \
400 stateRep->mutator(buff, length); \
405 #define DtDEFINE_SIMPLE_ATTR_DECODER( \
406 decClass, stateRepClass, attrName, netType, mutator) \
407 DtDEFINE_SIMPLE_ATTR_DECODER_MUTATOR(decClass, stateRepClass, \
408 attrName, netType, mutator)
Declares a function for managing decoding buffers.
std::map< RTI::AttributeHandle, DtAttributeDecoder > AttributeHandleDecoderMap
Definition: hlaStateDecoder.h:146
Instances of DtExerciseConn are used to provide an application's interface or connection to the netwo...
Definition: exerciseConnHLA.h:61
#define DT_DLL_VL
Definition: vlMachineTypes.h:108
void(* DtAttributeDecoder)(DtStateRepository *stateRep, const RTI::AttributeHandleValuePairSet &avlist, unsigned long pairSetIndex)
Attribute decoding function declaration.
Definition: hlaStateDecoder.h:53
DT_DLL_VLPROTIND char * DtDecodingBuffer(unsigned int requestedLength)
DtDecodingBuffer returns a pointer to a chunk of memory requestedLength long which can be used for de...
Functions in vlPrint.h provide an error and print facility for vrlink.
virtual RTI::ObjectClassHandle objectClassHandle() const
Get the object's class handle.
Definition: hlaStateDecoder.h:169
An instance of DtObjClassDesc is a "class descriptor" for an HLA Object class.
Definition: objClassDesc13.h:41
AttributeHandleDecoderMap myDecoderList
myDecoderList is a map of decoders for each attribute registered to this state.
Definition: hlaStateDecoder.h:158
static DtNetEventId * eventIdAttributeData(const RTI::AttributeHandleValuePairSet &attrs, int index)
Get the attribute data as a DtNetEventId (adds defensive null terminator) Returns a pointer to the at...
Definition: hlaStateDecoder.h:250
int DtNotifyLevel
DtNotifyLevel is used to control the level of diagnostics output by VR-Link.
DtHlaStateDecoder is used to provide decoding of a state message into a state repository in an HLA (a...
Definition: hlaStateDecoder.h:34
static char * decodingBuffer(int length)
Returns a pointer to a buffer that can be used to copy data obtained from a phvps.
Definition: hlaStateDecoder.h:185
DtOutputStream DtVerbose
These DtOutputStream instances are used for all print messaging in VR-Link.
DtExerciseConn * myExConn
Definition: hlaStateDecoder.h:151
DtStateRepository is an abstract base class for maintaining state for an object.
Definition: stateRepository.h:50
std::map< RTI::AttributeHandle, bool > AttributeHandleBoolMap
Definition: hlaStateDecoder.h:147
DtOutputStream DtWarn
These DtOutputStream instances are used for all print messaging in VR-Link.
static char * attributeData(const RTI::AttributeHandleValuePairSet &attrs, int index, RTI::ULong &length)
Returns a pointer to the attribute data.
Definition: hlaStateDecoder.h:190
AttributeHandleBoolMap myMutableReportedWarning
myReportedWarnings is an array for keeping track of which warnings have been already issued...
Definition: hlaStateDecoder.h:165
RTI::ObjectClassHandle myHandle
Definition: hlaStateDecoder.h:153
static bool theUseGetValuePointer
Definition: hlaStateDecoder.h:122
virtual DtAttributeDecoder decoder(const RTI::AttributeHandle &handle) const
Get the attribute decoder for the specified handle.
Definition: hlaStateDecoder.h:175
DtObjClassDesc * myClassDesc
Definition: hlaStateDecoder.h:152
class DtStateMsg:
Definition: stateMsgHLA.h:32
Contains the DtVrlUuid class declaration/definition.
This file contains typedefs for machine dependant types.