VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
hlaStateEncoder.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1992-2025 MAK Technologies, Inc
3 ** All rights reserved.
4 *********************************************************************/
5 
8 
9 #ifndef DtHlaStateEncoder_H_
10 #define DtHlaStateEncoder_H_
11 
12 #if DtHLA
13 
14 
15 #include <vlutil/vlMachineTypes.h>
16 
17 #include "rtiNamespace.h"
18 #include "rtiCompatibility.h"
19 #include <map>
20 #include <vector>
21 
23 class DT_DLL_VL DtObjClassDesc;
25 class DT_DLL_VL DtStateMsg;
26 
30 class DT_DLL_VL DtHlaStateEncoder
31 {
32 public:
33 
35  DtHlaStateEncoder( DtExerciseConn* exConn,
36  DtObjClassDesc* classDesc);
37 
39  virtual ~DtHlaStateEncoder();
40 
42  DtHlaStateEncoder(const DtHlaStateEncoder& orig);
43 
45  DtHlaStateEncoder& operator=(const DtHlaStateEncoder& orig);
46 
50  typedef void (*DtAttributeEncoder)(
51  const DtStateRepository& stateRep,
52  RTI::AttributeHandleValuePairSet* avList,
53  RTI::AttributeHandle handle);
54 
56  typedef bool (*DtAttributeChecker)(
57  const DtStateRepository& stateRep,
58  const DtStateRepository& asSeenByRemote);
59 
62  typedef bool (*DtAttributeCheckerWithHandle)(
63  const DtStateRepository& stateRep,
64  const DtStateRepository& asSeenByRemote,
65  RTI::AttributeHandle handle);
66 
67 
73  DtAttributeEncoder addEncoder(RTI::AttributeHandle hand,
74  DtAttributeEncoder func);
75  DtAttributeEncoder removeEncoder(RTI::AttributeHandle hand);
76 
83  DtAttributeEncoder addEncoder(char* name,
84  DtAttributeEncoder func, bool complain = true);
85  DtAttributeEncoder removeEncoder(char* name, bool complain = true);
86 
92  DtAttributeChecker addChecker(RTI::AttributeHandle hand,
93  DtAttributeChecker func);
94  DtAttributeChecker removeChecker(RTI::AttributeHandle hand);
95 
102  DtAttributeChecker addChecker(char* name,
103  DtAttributeChecker func, bool complain = true);
104  DtAttributeChecker removeChecker(char* name, bool complain = true);
105 
107  inline DtAttributeEncoder encoder(const RTI::AttributeHandle &handle) ;
108 
110  inline DtAttributeChecker checker(const RTI::AttributeHandle &handle) ;
111 
119  virtual void encode(const DtStateRepository& stateRep,
120  const DtStateRepository& asSeenByRemote,
121  const RTI::AttributeHandleSet& neededAttrs,
122  const RTI::AttributeHandleSet& includeThese,
123  DtStateMsg* msg);
124 
126  virtual RTI::ObjectClassHandle objectClassHandle();
127 
132  virtual DtHlaStateEncoder* clone(DtObjClassDesc* classDesc) const;
133 
135  virtual DtHlaStateEncoder* clone() const;
136 
137  virtual void preCalculateEligible(const RTI::AttributeHandleSet& neededAttrs);
138 public:
139 
143  static bool trueChecker(const DtStateRepository& stateRep,
144  const DtStateRepository& asSeenByRemote);
145 
149  static bool falseChecker(const DtStateRepository& stateRep,
150  const DtStateRepository& asSeenByRemote);
151 
154  static void wideStringToHlaUnicodeString(const std::wstring& wideString,
155  RTI::AttributeHandleValuePairSet* avList,
156  RTI::AttributeHandle attrHandle);
157 
158 protected:
159 
160  DtExerciseConn* myExConn;
161  DtObjClassDesc* myClassDesc;
162  RTI::ObjectClassHandle myHandle;
163 
166  std::map<RTI::AttributeHandle,DtAttributeEncoder> myEncoderList;
167  std::map<RTI::AttributeHandle,DtAttributeChecker> myCheckerList;
168 
171  std::vector<DtAttributeChecker> myCheckerCache;
172  const RTI::AttributeHandleSet* myCachedSet;
173 
174 
177  std::map<RTI::AttributeHandle,bool> myReportedWarning;
178 };
179 
180 inline RTI::ObjectClassHandle DtHlaStateEncoder::objectClassHandle()
181 {
182  return myHandle;
183 }
184 
185 inline DtHlaStateEncoder::DtAttributeEncoder
186  DtHlaStateEncoder::encoder(const RTI::AttributeHandle &hand)
187 {
188  return myEncoderList[hand];
189 };
190 
191 inline DtHlaStateEncoder::DtAttributeChecker
192  DtHlaStateEncoder::checker(const RTI::AttributeHandle &hand)
193 {
194  return myCheckerList[hand];
195 };
196 
199 #define DtADD_ATTR_ENCODER(attrName) \
200  addEncoder((char *)#attrName, (DtAttributeEncoder) encode##attrName)
201 
203 #define DtADD_ATTR_ENCODER_QUIET(attrName) \
204  addEncoder((char *)#attrName, (DtAttributeEncoder) encode##attrName, false)
205 
209 #define DtADD_ATTR_CHECKER(attrName) \
210  addChecker((char *)#attrName, (DtAttributeChecker) need##attrName)
211 
213 #define DtADD_ATTR_CHECKER_QUIET(attrName) \
214  addChecker((char *)#attrName, (DtAttributeChecker) need##attrName, false)
215 
219 #define DtDECLARE_ATTR_ENCODER(stateRepClass, attrName) \
220  static void encode##attrName(const stateRepClass& rep, \
221  RTI::AttributeHandleValuePairSet* attrs, \
222  RTI::AttributeHandle attrHandle)
223 
226 #define DtDECLARE_ATTR_CHECKER(stateRepClass, attrName) \
227  static bool need##attrName(const stateRepClass& stateRep, \
228  const stateRepClass& asSeenByRemote)
229 
235 #define DtDEFINE_SIMPLE_ATTR_ENCODER( \
236  encClass, stateRepClass, attrName, netType, inspector) \
237 void encClass::encode##attrName(const stateRepClass& rep, \
238  RTI::AttributeHandleValuePairSet* attrs, \
239  RTI::AttributeHandle attrHandle) \
240 { \
241  netType netVal; \
242  netVal = rep.inspector(); \
243  attrs->add(attrHandle, (char*) &netVal, sizeof(netType)); \
244 }
245 
246 #define DtDEFINE_SIMPLE_GLOBAL_OBJECT_DESIGNATOR_ATTR_ENCODER( \
247  encClass, stateRepClass, attrName, inspector) \
248 void encClass::encode##attrName(const stateRepClass& rep, \
249  RTI::AttributeHandleValuePairSet* attrs, \
250  RTI::AttributeHandle attrHandle) \
251 { \
252  DtGlobalObjectDesignator netVal = rep.inspector(); \
253  attrs->add(attrHandle, (char*) netVal.string(), netVal.length()+1); \
254 }
255 
261 #define DtDEFINE_SIMPLE_ATTR_CHECKER( \
262  encClass, stateRepClass, attrName, inspector) \
263 bool encClass::need##attrName(const stateRepClass& stateRep, \
264  const stateRepClass& asSeenByRemote) \
265 { \
266  return (bool) !(stateRep.inspector() == asSeenByRemote.inspector()); \
267 }
268 
269 
275 #define DtDEFINE_SIMPLE_ATTR_ENCODER_WITH_PARAM( \
276  encClass, stateRepClass, attrName, netType, inspector, param) \
277 void encClass::encode##attrName(const stateRepClass& rep, \
278  RTI::AttributeHandleValuePairSet* attrs, \
279  RTI::AttributeHandle attrHandle) \
280 { \
281  if (rep.hasMode(param)) { \
282  netType netVal; \
283  netVal = rep.inspector(param); \
284  attrs->add(attrHandle, (char*) &netVal, sizeof(netType)); \
285  } \
286 }
287 
293 #define DtDEFINE_SIMPLE_ATTR_CHECKER_WITH_PARAM( \
294  encClass, stateRepClass, attrName, inspector, param) \
295 bool encClass::need##attrName(const stateRepClass& stateRep, \
296  const stateRepClass& asSeenByRemote) \
297 { \
298  return (bool) (stateRep.hasMode(param) && asSeenByRemote.hasMode(param) \
299  && !(stateRep.inspector(param) == \
300  asSeenByRemote.inspector(param))); \
301 }
302 
303 
304 
305 #endif
306 #endif
307 
Instances of DtExerciseConn are used to provide an application&#39;s interface or connection to the netwo...
Definition: exerciseConnDIS.h:62
#define DT_DLL_VL
Definition: vlMachineTypes.h:108
DtStateRepository is an abstract base class for maintaining state for an object.
Definition: stateRepository.h:50
Instances of DtStateMsg are used to represent state data communicated via the network in a DIS (as op...
Definition: stateMsgDIS.h:21
This file contains typedefs for machine dependant types.

Document ID: Generated on Thu Oct 16 00:12:25 EDT 2025 from SVN revision 280738
Copyright © 1992-2025 MAK Technologies. All Rights Reserved (www.mak.com)