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-2010 VT MAK
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 
152 protected:
153 
154  DtExerciseConn* myExConn;
155  DtObjClassDesc* myClassDesc;
156  RTI::ObjectClassHandle myHandle;
157 
160  std::map<RTI::AttributeHandle,DtAttributeEncoder> myEncoderList;
161  std::map<RTI::AttributeHandle,DtAttributeChecker> myCheckerList;
162 
165  std::vector<DtAttributeChecker> myCheckerCache;
166  const RTI::AttributeHandleSet* myCachedSet;
167 
168 
171  std::map<RTI::AttributeHandle,bool> myReportedWarning;
172 };
173 
174 inline RTI::ObjectClassHandle DtHlaStateEncoder::objectClassHandle()
175 {
176  return myHandle;
177 }
178 
179 inline DtHlaStateEncoder::DtAttributeEncoder
180  DtHlaStateEncoder::encoder(const RTI::AttributeHandle &hand)
181 {
182  return myEncoderList[hand];
183 };
184 
185 inline DtHlaStateEncoder::DtAttributeChecker
186  DtHlaStateEncoder::checker(const RTI::AttributeHandle &hand)
187 {
188  return myCheckerList[hand];
189 };
190 
193 #define DtADD_ATTR_ENCODER(attrName) \
194  addEncoder((char *)#attrName, (DtAttributeEncoder) encode##attrName)
195 
197 #define DtADD_ATTR_ENCODER_QUIET(attrName) \
198  addEncoder((char *)#attrName, (DtAttributeEncoder) encode##attrName, false)
199 
203 #define DtADD_ATTR_CHECKER(attrName) \
204  addChecker((char *)#attrName, (DtAttributeChecker) need##attrName)
205 
207 #define DtADD_ATTR_CHECKER_QUIET(attrName) \
208  addChecker((char *)#attrName, (DtAttributeChecker) need##attrName, false)
209 
213 #define DtDECLARE_ATTR_ENCODER(stateRepClass, attrName) \
214  static void encode##attrName(const stateRepClass& rep, \
215  RTI::AttributeHandleValuePairSet* attrs, \
216  RTI::AttributeHandle attrHandle)
217 
220 #define DtDECLARE_ATTR_CHECKER(stateRepClass, attrName) \
221  static bool need##attrName(const stateRepClass& stateRep, \
222  const stateRepClass& asSeenByRemote)
223 
229 #define DtDEFINE_SIMPLE_ATTR_ENCODER( \
230  encClass, stateRepClass, attrName, netType, inspector) \
231 void encClass::encode##attrName(const stateRepClass& rep, \
232  RTI::AttributeHandleValuePairSet* attrs, \
233  RTI::AttributeHandle attrHandle) \
234 { \
235  netType netVal; \
236  netVal = rep.inspector(); \
237  attrs->add(attrHandle, (char*) &netVal, sizeof(netType)); \
238 }
239 
240 #define DtDEFINE_SIMPLE_GLOBAL_OBJECT_DESIGNATOR_ATTR_ENCODER( \
241  encClass, stateRepClass, attrName, inspector) \
242 void encClass::encode##attrName(const stateRepClass& rep, \
243  RTI::AttributeHandleValuePairSet* attrs, \
244  RTI::AttributeHandle attrHandle) \
245 { \
246  DtGlobalObjectDesignator netVal = rep.inspector(); \
247  attrs->add(attrHandle, (char*) netVal.string(), netVal.length()+1); \
248 }
249 
255 #define DtDEFINE_SIMPLE_ATTR_CHECKER( \
256  encClass, stateRepClass, attrName, inspector) \
257 bool encClass::need##attrName(const stateRepClass& stateRep, \
258  const stateRepClass& asSeenByRemote) \
259 { \
260  return (bool) !(stateRep.inspector() == asSeenByRemote.inspector()); \
261 }
262 
263 #endif
264 #endif
265 
Instances of DtExerciseConn are used to provide an application&#39;s interface or connection to the netwo...
Definition: exerciseConnDIS.h:61
#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 Tue Feb 2 21:02:17 EST 2021 from SVN revision 223668
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)