VR-Link API Documentation for HLA 1.3
hlaStateDecoder.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 *********************************************************************/
5 
8 
9 #ifndef DtHlaStateDecoder_H_
10 #define DtHlaStateDecoder_H_
11 
12 #if DtHLA
13 
14 
15 #include <vlutil/vlMachineTypes.h>
16 #include <vlpi/bufferMgr.h>
17 #include "rtiNamespace.h"
18 #include "rtiCompatibility.h"
19 #include <map>
20 
24 class DT_DLL_VL DtStateMsg;
25 
26 
31 {
32 public:
33 
36  DtExerciseConn* exConn,
37  DtObjClassDesc* classDesc);
38 
40  virtual ~DtHlaStateDecoder();
41 
44 
46  DtHlaStateDecoder& operator=(const DtHlaStateDecoder& orig);
47 
49  typedef void (*DtAttributeDecoder) (
50  DtStateRepository* stateRep,
51  const RTI::AttributeHandleValuePairSet& avlist,
52  unsigned long pairSetIndex);
53 
59  DtAttributeDecoder addDecoder(RTI::AttributeHandle h,
60  DtAttributeDecoder func);
61  DtAttributeDecoder removeDecoder(RTI::AttributeHandle h);
62 
69  DtAttributeDecoder addDecoder(char* attrName,
70  DtAttributeDecoder func, bool complain = true);
71  DtAttributeDecoder removeDecoder(char* attrName, bool complain = true);
72 
74  virtual DtAttributeDecoder decoder(const RTI::AttributeHandle &handle) const;
75 
77  virtual void decode(const DtStateMsg& msg,
78  DtStateRepository* stateRep) const ;
79 
81  virtual RTI::ObjectClassHandle objectClassHandle() const;
82 
84  virtual DtHlaStateDecoder* clone() const;
85 
90  virtual DtHlaStateDecoder* clone(DtObjClassDesc* classDesc) const;
91 
92 public:
93 
98  static inline char* decodingBuffer(int length);
99 
100 protected:
101 
104  virtual void decodeAttribute(
105  DtStateRepository* stateRep,
106  const RTI::AttributeHandleValuePairSet& attrs,
107  unsigned long pairSetIndex) const;
108 
109  virtual void copyDecFuncs( const DtHlaStateDecoder& orig);
110 protected:
111 
112  typedef std::map<RTI::AttributeHandle, DtAttributeDecoder> AttributeHandleDecoderMap;
113  typedef std::map<RTI::AttributeHandle, bool> AttributeHandleBoolMap;
114 
115 protected:
116 
119  RTI::ObjectClassHandle myHandle;
120 
121 
125 
126 private:
127 
132 
133 };
134 
135 inline RTI::ObjectClassHandle DtHlaStateDecoder::objectClassHandle() const
136 {
137  return myHandle;
138 }
139 
141 DtHlaStateDecoder::decoder(const RTI::AttributeHandle &handle) const
142 {
143  AttributeHandleDecoderMap::const_iterator pos = myDecoderList.find(handle);
144  if (pos != myDecoderList.end())
145  {
146  return pos->second;
147  }
148  return 0;
149 };
150 
151 inline char* DtHlaStateDecoder::decodingBuffer(int length)
152 {
153  return DtDecodingBuffer(length);
154 }
155 
158 #define DtADD_ATTR_DECODER(attrName) \
159  addDecoder((char *)#attrName, (DtAttributeDecoder) decode##attrName);
160 
162 #define DtADD_ATTR_DECODER_QUIET(attrName) \
163  addDecoder((char *)#attrName, (DtAttributeDecoder) decode##attrName, false);
164 
168 
169 #define DtDECLARE_ATTR_DECODER(stateRepClass, attrName) \
170  static void decode##attrName(stateRepClass* stateRep, \
171  const RTI::AttributeHandleValuePairSet& attrs, int pairSetIndex)
172 
173 
174 
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, \
185  int pairSetIndex) \
186 { \
187  RTI::ULong length = attrs.getValueLength(pairSetIndex); \
188  netType netVal; \
189  if (length > sizeof(netType)) \
190  { \
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)); \
194  return; \
195  } \
196  attrs.getValue(pairSetIndex, (char*) &netVal, length); \
197  stateRep->mutator(castExpr netVal); \
198 }
199 
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, \
205  int pairSetIndex) \
206 { \
207  RTI::ULong length = 0; \
208  DtGlobalObjectDesignator objName = (char*) attrs.getValuePointer(pairSetIndex, length); \
209  stateRep->mutator(objName); \
210 }
211 
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))
216 
217 #endif
218 #endif
219 

Document ID: Generated on Wed Oct 23 22:25:48 EDT 2013 from SVN revision 132765
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)