VR-Link API Documentation for DIS
interDecoder.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 DtInteractionDecoder_H_
10 #define DtInteractionDecoder_H_
11 
12 #if DtHLA
13 
14 
15 #include <vlutil/vlMachineTypes.h>
16 #include <vlutil/vlPrint.h>
17 #include <vlpi/bufferMgr.h>
18 
19 #include "rtiNamespace.h"
20 #include "rtiCompatibility.h"
21 #include <map>
22 
24 class DT_DLL_VL DtInterClassDesc;
25 
30 class DT_DLL_VL DtInteractionRep;
31 
32 
36 class DT_DLL_VL DtInteractionDecoder
37 {
38 public:
39 
41  typedef void (*DtParameterDecoder)(DtInteractionRep* inter,
42  const RTI::ParameterHandleValuePairSet& pvlist,
43  int i);
44 
45 public:
46 
48  DtInteractionDecoder(DtExerciseConn* exConn,
49  DtInterClassDesc* classDesc);
50 
52  virtual ~DtInteractionDecoder();
53 
59  DtParameterDecoder addDecoder(RTI::ParameterHandle handle,
60  DtParameterDecoder proc);
61 
67  DtParameterDecoder addDecoder(char* name,
68  DtParameterDecoder proc);
69 
71  virtual DtParameterDecoder decoder(RTI::ParameterHandle handle) const;
72 
74  virtual void decode(
75  DtInteractionRep* interaction,
76 #if DtHLA_1516
77  const RTI::ParameterHandleValueMap& pvMap
78 #else
79  const RTI::ParameterHandleValuePairSet& pvList
80 #endif
81  );
82 
84  virtual RTI::InteractionClassHandle interactionClassHandle();
85 
87  virtual DtInteractionDecoder* clone() const;
88 
93  virtual DtInteractionDecoder* clone(DtInterClassDesc* interDesc) const;
94 
95 public:
96 
101  static char* decodingBuffer(int length);
102 
103 protected:
104 
106  DtInteractionDecoder(const DtInteractionDecoder& orig);
107 
109  DtInteractionDecoder& operator=(const DtInteractionDecoder& orig);
110 
112  virtual void decodeParameter(DtInteractionRep* inter,
113  const RTI::ParameterHandleValuePairSet& pvList, int index);
114 
115 protected:
116 
117  DtExerciseConn* myExConn;
118  DtInterClassDesc* myClassDesc;
119 
120  RTI::InteractionClassHandle myClassHandle;
121 
123  std::map<RTI::ParameterHandle, DtParameterDecoder> myList;
124 
125 };
126 
127 inline RTI::InteractionClassHandle
128  DtInteractionDecoder::interactionClassHandle()
129 {
130  return myClassHandle;
131 }
132 
133 inline char* DtInteractionDecoder::decodingBuffer(int length)
134 {
135  return DtDecodingBuffer(length);
136 }
137 
138 
141 #define DtADD_PARAM_DECODER(attrName) \
142  addDecoder((char *)#attrName, (DtParameterDecoder) decode##attrName)
143 
146 #define DtDECLARE_PARAM_DECODER(RepT, paramName) \
147  static void decode##paramName(RepT* inter, \
148  const RTI::ParameterHandleValuePairSet& params, int pairSetIndex)
149 
150 #define DtDEFINE_SIMPLE_PARAM_DECODER_WITH_CAST(decClass, interClass, \
151  paramName, netType, mutator, castExpr) \
152 void decClass::decode##paramName(interClass* inter, \
153  const RTI::ParameterHandleValuePairSet& params, \
154  int index) \
155 { \
156  RTI::ULong length = params.getValueLength(index); \
157  if (length > sizeof(netType)) \
158  { \
159  DtWarn("Size of value decoded for parameter %s (%d)\n", \
160  #paramName, length); \
161  DtWarn(" is larger than size of %s (%d)\n", #netType, sizeof(netType)); \
162  return; \
163  } \
164  netType netVal; \
165  params.getValue(index, (char*) &netVal, length); \
166  inter->mutator(castExpr netVal); \
167 }
168 
169 #define DtDEFINE_SIMPLE_GLOBAL_OBJECT_DESIGNATOR_PARAM_DECODER( \
170  decClass, interClass, paramName, mutator) \
171 void decClass::decode##paramName(interClass* inter, \
172  const RTI::ParameterHandleValuePairSet& params, \
173  int index) \
174 { \
175  RTI::ULong length = 0; \
176  DtGlobalObjectDesignator objName = \
177  (char*) params.getValuePointer(index, length); \
178  inter->mutator(objName); \
179 }
180 
181 
182 #define DtDEFINE_SIMPLE_PARAM_DECODER(decClass, interClass, \
183  paramName, netType, mutator) \
184  DtDEFINE_SIMPLE_PARAM_DECODER_WITH_CAST(decClass, interClass, \
185  paramName, netType, mutator, (netType))
186 
187 #endif
188 #endif
189 

Document ID: Generated on Wed Aug 14 15:35:11 EDT 2013 from SVN revision 130445
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)