9 #ifndef DtInteractionDecoder_H_
10 #define DtInteractionDecoder_H_
42 typedef void (*DtParameterDecoder)(DtInteractionRep* inter,
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
85 virtual RTI::InteractionClassHandle interactionClassHandle();
102 static char* decodingBuffer(
int length);
113 static char* parameterData(
115 unsigned int expectedDataSize,
char* paramName);
139 virtual void decodeParameter(DtInteractionRep* inter,
150 std::map<RTI::ParameterHandle, DtParameterDecoder>
myList;
154 inline RTI::InteractionClassHandle
179 pvList.
getValue(index, dataPtr, length);
187 unsigned int expectedDataSize,
char* paramName)
189 char* outDataPtr = 0;
197 if (length > 0 && length >= expectedDataSize)
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);
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)