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 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.
Instances of DtExerciseConn are used to provide an application's interface or connection to the netwo...
Definition: exerciseConnDIS.h:62
#define DT_DLL_VL
Definition: vlMachineTypes.h:108
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.