9 #ifndef DtHlaStateDecoder_H_
10 #define DtHlaStateDecoder_H_
37 DtObjClassDesc* classDesc);
40 virtual ~DtHlaStateDecoder();
43 DtHlaStateDecoder(
const DtHlaStateDecoder& orig);
46 DtHlaStateDecoder& operator=(
const DtHlaStateDecoder& orig);
49 typedef void (*DtAttributeDecoder) (
51 const RTI::AttributeHandleValuePairSet& avlist,
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;
84 virtual DtHlaStateDecoder* clone()
const;
90 virtual DtHlaStateDecoder* clone(DtObjClassDesc* classDesc)
const;
98 static inline char* decodingBuffer(
int length);
104 virtual void decodeAttribute(
106 const RTI::AttributeHandleValuePairSet& attrs,
107 unsigned long pairSetIndex)
const;
109 virtual void copyDecFuncs(
const DtHlaStateDecoder& orig);
112 typedef std::map<RTI::AttributeHandle, DtAttributeDecoder> AttributeHandleDecoderMap;
113 typedef std::map<RTI::AttributeHandle, bool> AttributeHandleBoolMap;
118 DtObjClassDesc* myClassDesc;
119 RTI::ObjectClassHandle myHandle;
124 AttributeHandleDecoderMap myDecoderList;
131 mutable AttributeHandleBoolMap myMutableReportedWarning;
135 inline RTI::ObjectClassHandle DtHlaStateDecoder::objectClassHandle()
const
140 inline DtHlaStateDecoder::DtAttributeDecoder
141 DtHlaStateDecoder::decoder(
const RTI::AttributeHandle &handle)
const
143 AttributeHandleDecoderMap::const_iterator pos = myDecoderList.find(handle);
144 if (pos != myDecoderList.end())
151 inline char* DtHlaStateDecoder::decodingBuffer(
int length)
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))