9 #ifndef DtHlaStateDecoder_H_
10 #define DtHlaStateDecoder_H_
49 typedef void (*DtAttributeDecoder) (
52 unsigned long pairSetIndex);
59 DtAttributeDecoder addDecoder(RTI::AttributeHandle h,
60 DtAttributeDecoder func);
61 DtAttributeDecoder removeDecoder(RTI::AttributeHandle h);
69 DtAttributeDecoder addDecoder(
char*
attrName,
70 DtAttributeDecoder func,
bool complain =
true);
71 DtAttributeDecoder removeDecoder(
char*
attrName,
bool complain =
true);
74 virtual DtAttributeDecoder decoder(
const RTI::AttributeHandle &handle)
const;
81 virtual RTI::ObjectClassHandle objectClassHandle()
const;
98 static inline char* decodingBuffer(
int length);
104 virtual void decodeAttribute(
107 unsigned long pairSetIndex)
const;
143 AttributeHandleDecoderMap::const_iterator pos =
myDecoderList.find(handle);
158 #define DtADD_ATTR_DECODER(attrName) \
159 addDecoder((char *)#attrName, (DtAttributeDecoder) decode##attrName);
162 #define DtADD_ATTR_DECODER_QUIET(attrName) \
163 addDecoder((char *)#attrName, (DtAttributeDecoder) decode##attrName, false);
169 #define DtDECLARE_ATTR_DECODER(stateRepClass, attrName) \
170 static void decode##attrName(stateRepClass* stateRep, \
171 const RTI::AttributeHandleValuePairSet& attrs, int pairSetIndex)
180 #define DtDEFINE_SIMPLE_ATTR_DECODER_WITH_CAST( \
181 decClass, stateRepClass, attrName, netType, mutator, castExpr) \
182 void decClass::decode##attrName( \
183 stateRepClass* stateRep, \
184 const RTI::AttributeHandleValuePairSet& attrs, \
187 RTI::ULong length = attrs.getValueLength(pairSetIndex); \
189 if (length > sizeof(netType)) \
191 DtWarn("Size of value decoded from RTI update for attribute %s (%d)\n", \
192 #attrName, length); \
193 DtWarn(" is larger than size of %s (%d)\n", #netType, sizeof(netType)); \
196 attrs.getValue(pairSetIndex, (char*) &netVal, length); \
197 stateRep->mutator(castExpr netVal); \
200 #define DtDEFINE_SIMPLE_GLOBAL_OBJECT_DESIGNATOR_ATTR_DECODER( \
201 decClass, stateRepClass, attrName, mutator) \
202 void decClass::decode##attrName( \
203 stateRepClass* stateRep, \
204 const RTI::AttributeHandleValuePairSet& attrs, \
207 RTI::ULong length = 0; \
208 DtGlobalObjectDesignator objName = (char*) attrs.getValuePointer(pairSetIndex, length); \
209 stateRep->mutator(objName); \
212 #define DtDEFINE_SIMPLE_ATTR_DECODER( \
213 decClass, stateRepClass, attrName, netType, mutator) \
214 DtDEFINE_SIMPLE_ATTR_DECODER_WITH_CAST(decClass, stateRepClass, \
215 attrName, netType, mutator, (netType))