9 #ifndef DtHlaStateDecoder_H_
10 #define DtHlaStateDecoder_H_
51 typedef void (*DtAttributeDecoder) (
53 const RTI::AttributeHandleValuePairSet& avlist,
54 unsigned long pairSetIndex);
61 DtAttributeDecoder addDecoder(RTI::AttributeHandle h,
62 DtAttributeDecoder func);
63 DtAttributeDecoder removeDecoder(RTI::AttributeHandle h);
71 DtAttributeDecoder addDecoder(
char*
attrName,
72 DtAttributeDecoder func,
bool complain =
true);
73 DtAttributeDecoder removeDecoder(
char*
attrName,
bool complain =
true);
76 virtual DtAttributeDecoder decoder(
const RTI::AttributeHandle &handle)
const;
83 virtual RTI::ObjectClassHandle objectClassHandle()
const;
100 static inline char* decodingBuffer(
int length);
103 static char* attributeData(
const RTI::AttributeHandleValuePairSet& attrs,
104 int index, RTI::ULong& length);
111 static char* attributeData(
112 const RTI::AttributeHandleValuePairSet& attrs,
int index, RTI::ULong& length,
113 unsigned int expectedDataSize,
char*
attrName);
117 static DtNetEventId* eventIdAttributeData(
const RTI::AttributeHandleValuePairSet& attrs,
126 virtual void decodeAttribute(
128 const RTI::AttributeHandleValuePairSet& attrs,
129 unsigned long pairSetIndex)
const;
165 AttributeHandleDecoderMap::const_iterator pos =
myDecoderList.find(handle);
179 const RTI::AttributeHandleValuePairSet& attrs,
int index, RTI::ULong& length)
184 dataPtr = attrs.getValuePointer(index, length);
188 length = attrs.getValueLength(index);
192 attrs.getValue(index, dataPtr, length);
199 const RTI::AttributeHandleValuePairSet& attrs,
int index, RTI::ULong& length,
200 unsigned int expectedDataSize,
char*
attrName)
202 char* outDataPtr = 0;
205 outDataPtr = attrs.getValuePointer(index, length);
209 length = attrs.getValueLength(index);
210 if (length > 0 && length >= expectedDataSize)
213 attrs.getValue(index, outDataPtr, length);
217 if (length != expectedDataSize)
219 if (length < expectedDataSize)
221 DtWarn(
"Cannot decode attribute %s.\n"
222 "Size of data (%d) is smaller than expected (%d).\n",
223 attrName, length, expectedDataSize);
229 DtVerbose(
"When decoding attribute %s,\n"
230 "found size of data (%d) is larger than expected (%d).\n",
231 attrName, length, expectedDataSize);
239 const RTI::AttributeHandleValuePairSet& attrs,
int index)
241 RTI::ULong length = 0;
243 length = attrs.getValueLength(index);
247 attrs.getValue(index, dataPtr, length);
256 #define DtADD_ATTR_DECODER(attrName) \
257 addDecoder((char *)#attrName, (DtAttributeDecoder) decode##attrName);
260 #define DtADD_ATTR_DECODER_QUIET(attrName) \
261 addDecoder((char *)#attrName, (DtAttributeDecoder) decode##attrName, false);
267 #define DtDECLARE_ATTR_DECODER(stateRepClass, attrName) \
268 static void decode##attrName(stateRepClass* stateRep, \
269 const RTI::AttributeHandleValuePairSet& attrs, int pairSetIndex)
279 #define DtDEFINE_SIMPLE_ATTR_DECODER_WITH_CAST( \
280 decClass, stateRepClass, attrName, netType, mutator, castExpr) \
281 void decClass::decode##attrName( \
282 stateRepClass* stateRep, \
283 const RTI::AttributeHandleValuePairSet& attrs, \
286 RTI::ULong length = 0; \
287 netType* netValPtr = (netType*)attributeData(attrs, index, length, sizeof(netType), #attrName); \
290 stateRep->mutator(castExpr *netValPtr); \
301 #define DtDEFINE_SIMPLE_ATTR_DECODER_WITH_CAST_SET( \
302 decClass, stateRepClass, attrName, netType, castExpr) \
303 DtDEFINE_SIMPLE_ATTR_DECODER_WITH_CAST( \
304 decClass, stateRepClass, attrName, netType, set##attrName, castExpr)
312 #define DtDEFINE_SIMPLE_ATTR_DECODER_MUTATOR( \
313 decClass, stateRepClass, attrName, netType, mutator) \
314 void decClass::decode##attrName( \
315 stateRepClass* stateRep, \
316 const RTI::AttributeHandleValuePairSet& attrs, \
319 RTI::ULong length = 0; \
320 netType* netValPtr = (netType*)attributeData(attrs, index, length, sizeof(netType), #attrName); \
323 stateRep->mutator(*netValPtr); \
333 #define DtDEFINE_SIMPLE_ATTR_DECODER_SET( \
334 decClass, stateRepClass, attrName, netType) \
335 DtDEFINE_SIMPLE_ATTR_DECODER_MUTATOR( \
336 decClass, stateRepClass, attrName, netType, set##attrName)
346 #define DtDEFINE_SIMPLE_ATTR_DECODER_WITH_CAST_AND_PARAM( \
347 decClass, stateRepClass, attrName, netType, mutator, param, castExpr) \
348 void decClass::decode##attrName( \
349 stateRepClass* stateRep, \
350 const RTI::AttributeHandleValuePairSet& attrs, \
353 RTI::ULong length = 0; \
354 netType* netValPtr = (netType*)attributeData(attrs, index, length, sizeof(netType), #attrName); \
357 stateRep->mutator(param, castExpr *netValPtr); \
361 #define DtDEFINE_SIMPLE_GLOBAL_OBJECT_DESIGNATOR_ATTR_DECODER( \
362 decClass, stateRepClass, attrName, mutator) \
363 void decClass::decode##attrName( \
364 stateRepClass* stateRep, \
365 const RTI::AttributeHandleValuePairSet& attrs, \
368 RTI::ULong length = 0; \
369 DtGlobalObjectDesignator objName = (char*) attrs.getValuePointer(pairSetIndex, length); \
370 stateRep->mutator(objName); \
377 #define DtDEFINE_SIMPLE_ATTR_DECODER_BUFF(decClass, stateRepClass, \
379 void decClass::decode##attrName( \
380 stateRepClass* stateRep, \
381 const RTI::AttributeHandleValuePairSet& attrs, \
384 RTI::ULong length = 0; \
385 char* buff = attributeData(attrs, index, length); \
388 stateRep->mutator(buff, length); \
393 #define DtDEFINE_SIMPLE_ATTR_DECODER( \
394 decClass, stateRepClass, attrName, netType, mutator) \
395 DtDEFINE_SIMPLE_ATTR_DECODER_MUTATOR(decClass, stateRepClass, \
396 attrName, netType, mutator)
Declares a function for managing decoding buffers.
std::map< RTI::AttributeHandle, DtAttributeDecoder > AttributeHandleDecoderMap
Definition: hlaStateDecoder.h:134
Instances of DtExerciseConn are used to provide an application's interface or connection to the netwo...
Definition: exerciseConnHLA.h:58
#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:51
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:157
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:146
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:238
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:32
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:173
DtOutputStream DtVerbose
These DtOutputStream instances are used for all print messaging in VR-Link.
DtExerciseConn * myExConn
Definition: hlaStateDecoder.h:139
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:135
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:178
AttributeHandleBoolMap myMutableReportedWarning
myReportedWarnings is an array for keeping track of which warnings have been already issued...
Definition: hlaStateDecoder.h:153
RTI::ObjectClassHandle myHandle
Definition: hlaStateDecoder.h:141
static bool theUseGetValuePointer
Definition: hlaStateDecoder.h:120
virtual DtAttributeDecoder decoder(const RTI::AttributeHandle &handle) const
Get the attribute decoder for the specified handle.
Definition: hlaStateDecoder.h:163
DtObjClassDesc * myClassDesc
Definition: hlaStateDecoder.h:140
class DtStateMsg:
Definition: stateMsgHLA.h:32
This file contains typedefs for machine dependant types.