9 #ifndef DtHlaStateDecoder_H_
10 #define DtHlaStateDecoder_H_
41 DtObjClassDesc* classDesc);
44 virtual ~DtHlaStateDecoder();
47 DtHlaStateDecoder(
const DtHlaStateDecoder& orig);
50 DtHlaStateDecoder& operator=(
const DtHlaStateDecoder& orig);
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;
88 virtual DtHlaStateDecoder* clone()
const;
94 virtual DtHlaStateDecoder* clone(DtObjClassDesc* classDesc)
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,
122 static bool theUseGetValuePointer;
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;
143 virtual void copyDecFuncs(
const DtHlaStateDecoder& orig);
146 typedef std::map<RTI::AttributeHandle, DtAttributeDecoder> AttributeHandleDecoderMap;
147 typedef std::map<RTI::AttributeHandle, bool> AttributeHandleBoolMap;
152 DtObjClassDesc* myClassDesc;
153 RTI::ObjectClassHandle myHandle;
158 AttributeHandleDecoderMap myDecoderList;
165 mutable AttributeHandleBoolMap myMutableReportedWarning;
169 inline RTI::ObjectClassHandle DtHlaStateDecoder::objectClassHandle()
const
174 inline DtHlaStateDecoder::DtAttributeDecoder
175 DtHlaStateDecoder::decoder(
const RTI::AttributeHandle &handle)
const
177 AttributeHandleDecoderMap::const_iterator pos = myDecoderList.find(handle);
178 if (pos != myDecoderList.end())
185 inline char* DtHlaStateDecoder::decodingBuffer(
int length)
190 inline char* DtHlaStateDecoder::attributeData(
191 const RTI::AttributeHandleValuePairSet& attrs,
int index, RTI::ULong& length)
194 if (theUseGetValuePointer)
196 dataPtr = attrs.getValuePointer(index, length);
200 length = attrs.getValueLength(index);
203 dataPtr = decodingBuffer(length);
204 attrs.getValue(index, dataPtr, length);
210 inline char* DtHlaStateDecoder::attributeData(
211 const RTI::AttributeHandleValuePairSet& attrs,
int index, RTI::ULong& length,
212 unsigned int expectedDataSize,
char*
attrName)
214 char* outDataPtr = 0;
215 if (theUseGetValuePointer)
217 outDataPtr = attrs.getValuePointer(index, length);
221 length = attrs.getValueLength(index);
222 if (length > 0 && length >= expectedDataSize)
224 outDataPtr = decodingBuffer(length);
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);
250 inline DtNetEventId* DtHlaStateDecoder::eventIdAttributeData(
251 const RTI::AttributeHandleValuePairSet& attrs,
int index)
253 RTI::ULong length = 0;
255 length = attrs.getValueLength(index);
258 dataPtr = decodingBuffer(length+1);
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 char attrNameCstr[] = #attrName; \
300 netType* netValPtr = (netType*)attributeData(attrs, index, length, sizeof(netType), attrNameCstr); \
303 stateRep->mutator(castExpr *netValPtr); \
314 #define DtDEFINE_SIMPLE_ATTR_DECODER_WITH_CAST_SET( \
315 decClass, stateRepClass, attrName, netType, castExpr) \
316 DtDEFINE_SIMPLE_ATTR_DECODER_WITH_CAST( \
317 decClass, stateRepClass, attrName, netType, set##attrName, castExpr)
325 #define DtDEFINE_SIMPLE_ATTR_DECODER_MUTATOR( \
326 decClass, stateRepClass, attrName, netType, mutator) \
327 void decClass::decode##attrName( \
328 stateRepClass* stateRep, \
329 const RTI::AttributeHandleValuePairSet& attrs, \
332 RTI::ULong length = 0; \
333 netType* netValPtr = (netType*)attributeData(attrs, index, length, sizeof(netType), #attrName); \
336 stateRep->mutator(*netValPtr); \
346 #define DtDEFINE_SIMPLE_ATTR_DECODER_SET( \
347 decClass, stateRepClass, attrName, netType) \
348 DtDEFINE_SIMPLE_ATTR_DECODER_MUTATOR( \
349 decClass, stateRepClass, attrName, netType, set##attrName)
359 #define DtDEFINE_SIMPLE_ATTR_DECODER_WITH_CAST_AND_PARAM( \
360 decClass, stateRepClass, attrName, netType, mutator, param, castExpr) \
361 void decClass::decode##attrName( \
362 stateRepClass* stateRep, \
363 const RTI::AttributeHandleValuePairSet& attrs, \
366 RTI::ULong length = 0; \
367 netType* netValPtr = (netType*)attributeData(attrs, index, length, sizeof(netType), #attrName); \
370 stateRep->mutator(param, castExpr *netValPtr); \
374 #define DtDEFINE_SIMPLE_GLOBAL_OBJECT_DESIGNATOR_ATTR_DECODER( \
375 decClass, stateRepClass, attrName, mutator) \
376 void decClass::decode##attrName( \
377 stateRepClass* stateRep, \
378 const RTI::AttributeHandleValuePairSet& attrs, \
381 RTI::ULong length = 0; \
382 DtGlobalObjectDesignator objName = (char*) attrs.getValuePointer(pairSetIndex, length); \
383 stateRep->mutator(objName); \
390 #define DtDEFINE_SIMPLE_ATTR_DECODER_BUFF(decClass, stateRepClass, \
392 void decClass::decode##attrName( \
393 stateRepClass* stateRep, \
394 const RTI::AttributeHandleValuePairSet& attrs, \
397 RTI::ULong length = 0; \
398 char* buff = attributeData(attrs, index, length); \
401 stateRep->mutator(buff, length); \
406 #define DtDEFINE_SIMPLE_ATTR_DECODER( \
407 decClass, stateRepClass, attrName, netType, mutator) \
408 DtDEFINE_SIMPLE_ATTR_DECODER_MUTATOR(decClass, stateRepClass, \
409 attrName, netType, mutator)
Declares a function for managing decoding buffers.
Instances of DtExerciseConn are used to provide an application's interface or connection to the netwo...
Definition: exerciseConnDIS.h:63
#define DT_DLL_VL
Definition: vlMachineTypes.h:120
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.
int DtNotifyLevel
DtNotifyLevel is used to control the level of diagnostics output by VR-Link.
DtOutputStream DtVerbose
These DtOutputStream instances are used for all print messaging in VR-Link.
DtStateRepository is an abstract base class for maintaining state for an object.
Definition: stateRepository.h:50
DtOutputStream DtWarn
These DtOutputStream instances are used for all print messaging in VR-Link.
Definition: eventId.h:131
Instances of DtStateMsg are used to represent state data communicated via the network in a DIS (as op...
Definition: stateMsgDIS.h:21
Contains the DtVrlUuid class declaration/definition.
This file contains typedefs for machine dependant types.