9 #ifndef DtInteractionDecoder_H_
10 #define DtInteractionDecoder_H_
42 typedef void (*DtParameterDecoder)(DtInteractionRep* inter,
43 const RTI::ParameterHandleValuePairSet& pvlist,
50 DtInterClassDesc* classDesc);
53 virtual ~DtInteractionDecoder();
60 DtParameterDecoder addDecoder(RTI::ParameterHandle handle,
61 DtParameterDecoder proc);
68 DtParameterDecoder addDecoder(
char* name,
69 DtParameterDecoder proc);
72 virtual DtParameterDecoder decoder(RTI::ParameterHandle handle)
const;
76 DtInteractionRep* interaction,
78 const RTI::ParameterHandleValueMap& pvMap
80 const RTI::ParameterHandleValuePairSet& pvList
85 virtual RTI::InteractionClassHandle interactionClassHandle();
88 virtual DtInteractionDecoder* clone()
const;
94 virtual DtInteractionDecoder* clone(DtInterClassDesc* interDesc)
const;
102 static char* decodingBuffer(
int length);
105 static char* parameterData(
const RTI::ParameterHandleValuePairSet& pvList,
106 int index, RTI::ULong& length);
113 static char* parameterData(
114 const RTI::ParameterHandleValuePairSet& pvList,
int index, RTI::ULong& length,
115 unsigned int expectedDataSize,
char* paramName);
120 const RTI::ParameterHandleValuePairSet& params,
int index);
122 static bool theUseGetValuePointer;
126 static void decodeGenericParameter(DtInteractionWithEncDec* inter,
127 const RTI::ParameterHandleValuePairSet& pvlist,
int i);
133 DtInteractionDecoder(
const DtInteractionDecoder& orig);
136 DtInteractionDecoder& operator=(
const DtInteractionDecoder& orig);
139 virtual void decodeParameter(DtInteractionRep* inter,
140 const RTI::ParameterHandleValuePairSet& pvList,
int index);
145 DtInterClassDesc* myClassDesc;
147 RTI::InteractionClassHandle myClassHandle;
150 std::map<RTI::ParameterHandle, DtParameterDecoder> myList;
154 inline RTI::InteractionClassHandle
155 DtInteractionDecoder::interactionClassHandle()
157 return myClassHandle;
160 inline char* DtInteractionDecoder::decodingBuffer(
int length)
165 inline char* DtInteractionDecoder::parameterData(
166 const RTI::ParameterHandleValuePairSet& pvList,
int index, RTI::ULong& length)
169 if (theUseGetValuePointer)
171 dataPtr = pvList.getValuePointer(index, length);
175 length = pvList.getValueLength(index);
178 dataPtr = decodingBuffer(length);
179 pvList.getValue(index, dataPtr, length);
185 inline char* DtInteractionDecoder::parameterData(
186 const RTI::ParameterHandleValuePairSet& pvList,
int index, RTI::ULong& length,
187 unsigned int expectedDataSize,
char* paramName)
189 char* outDataPtr = 0;
190 if (theUseGetValuePointer)
192 outDataPtr = pvList.getValuePointer(index, length);
196 length = pvList.getValueLength(index);
197 if (length > 0 && length >= expectedDataSize)
199 outDataPtr = decodingBuffer(length);
200 pvList.getValue(index, outDataPtr, length);
204 if (length != expectedDataSize)
206 if (length < expectedDataSize)
208 DtWarn(
"Cannot decode parameter %s.\n"
209 "Size of data (%d) is smaller than expected (%d).\n",
210 paramName, length, expectedDataSize);
216 DtVerbose(
"When decoding parameter %s,\n"
217 "found size of data (%d) is larger than expected (%d).\n",
218 paramName, length, expectedDataSize);
225 inline DtNetEventId* DtInteractionDecoder::eventIdParameterData(
226 const RTI::ParameterHandleValuePairSet& params,
int index)
228 RTI::ULong length = 0;
230 length = params.getValueLength(index);
233 dataPtr = decodingBuffer(length+1);
234 params.getValue(index, dataPtr, length);
243 #define DtADD_PARAM_DECODER(paramName) \
244 addDecoder((char *)#paramName, (DtParameterDecoder) decode##paramName)
248 #define DtDECLARE_PARAM_DECODER(RepT, paramName) \
249 static void decode##paramName(RepT* inter, \
250 const RTI::ParameterHandleValuePairSet& params, int pairSetIndex)
259 #define DtDEFINE_SIMPLE_PARAM_DECODER_WITH_CAST(decClass, interClass, \
260 paramName, netType, mutator, castExpr) \
261 void decClass::decode##paramName(interClass* inter, \
262 const RTI::ParameterHandleValuePairSet& params, \
265 RTI::ULong length = 0; \
266 netType* netValPtr = (netType*)parameterData(params, index, length, sizeof(netType), #paramName); \
269 inter->mutator(castExpr *netValPtr); \
280 #define DtDEFINE_SIMPLE_PARAM_DECODER_WITH_CAST_SET(decClass, interClass, \
281 paramName, netType, castExpr) \
282 DtDEFINE_SIMPLE_PARAM_DECODER_WITH_CAST(decClass, interClass, \
283 paramName, netType, set##paramName, castExpr)
291 #define DtDEFINE_SIMPLE_PARAM_DECODER_MUTATOR(decClass, interClass, \
292 paramName, netType, mutator) \
293 void decClass::decode##paramName(interClass* inter, \
294 const RTI::ParameterHandleValuePairSet& params, \
297 RTI::ULong length = 0; \
298 netType* netValPtr = (netType*)parameterData(params, index, length, sizeof(netType), #paramName); \
301 inter->mutator(*netValPtr); \
311 #define DtDEFINE_SIMPLE_PARAM_DECODER_MUTATOR_SET(decClass, interClass, \
312 paramName, netType) \
313 DtDEFINE_SIMPLE_PARAM_DECODER_MUTATOR(decClass, interClass, \
314 paramName, netType, set##paramName)
316 #define DtDEFINE_SIMPLE_GLOBAL_OBJECT_DESIGNATOR_PARAM_DECODER( \
317 decClass, interClass, paramName, mutator) \
318 void decClass::decode##paramName(interClass* inter, \
319 const RTI::ParameterHandleValuePairSet& params, \
322 RTI::ULong length = 0; \
323 DtGlobalObjectDesignator objName = (char*) params.getValuePointer(index, length); \
324 inter->mutator(objName); \
331 #define DtDEFINE_SIMPLE_PARAM_DECODER_BUFF(decClass, interClass, \
332 paramName, mutator) \
333 void decClass::decode##paramName(interClass* inter, \
334 const RTI::ParameterHandleValuePairSet& params, \
337 RTI::ULong length = 0; \
338 char* buff = parameterData(params, index, length); \
341 inter->mutator(buff, length); \
345 #define DtDEFINE_SIMPLE_PARAM_DECODER(decClass, interClass, \
346 paramName, netType, mutator) \
347 DtDEFINE_SIMPLE_PARAM_DECODER_MUTATOR(decClass, interClass, \
348 paramName, 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.
DtOutputStream DtWarn
These DtOutputStream instances are used for all print messaging in VR-Link.
Definition: eventId.h:131
This file contains typedefs for machine dependant types.