VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
stateCacheManager.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2013 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
11 
12 #pragma once
13 
20 
22 #include <vrvCore/DtUniqueID.h>
23 #include <vrvCore/DtEntityState.h>
24 
26 
27 #include <map>
28 
29 #include <boost/function.hpp>
30 #include <boost/bind.hpp>
31 
32 #include <vlpi/appearance.h>
33 
34 namespace makVrf
35 {
36  namespace VRF_PROTOCOL_NAMESPACE
37  {
38  template <typename _StateType>
40  {
41  public:
43  : myProcessor(iface)
44  {
48  }
49 
51  {
52  }
53 
54  void enable()
55  {
57  }
58 
59  void disable()
60  {
62  }
63 
64  void addIsModifiedCallbackCheck(const boost::function<bool (const _StateType& newState,
65  const _StateType& originalState)>& function)
66  {
67  myIsModifiedFunctions.push_back(function);
68  }
69 
71  {
72  typename std::map<makVrv::DtUniqueID, _StateType>::iterator iter;
73  iter = myMap.find(id);
74 
75  if (iter != myMap.end())
76  {
77  myMap.erase(iter);
78  }
79  }
80 
82  const makVrv::DtSimState& incoming)
83  {
84  const _StateType& state = static_cast<const _StateType&>(incoming);
85  myMap[id] = state;
86  }
87 
89  const makVrv::DtSimState& incoming)
90  {
91  const _StateType& state = static_cast<const _StateType&>(incoming);
92 
93  typename DtIsModifiedCallList::iterator iter =
94  myIsModifiedFunctions.begin();
95  typename std::map<makVrv::DtUniqueID, _StateType>::const_iterator
96  cacheIter = myMap.find(id);
97 
98  while (iter != myIsModifiedFunctions.end())
99  {
100  if ((*iter)(state, cacheIter->second))
101  {
102  myMap[id] = state;
104  return;
105  }
106 
107  ++iter;
108  }
109  }
110 
111  protected:
112  std::map<makVrv::DtUniqueID, _StateType> myMap;
113 
114  typedef std::vector<boost::function<bool (const _StateType& newState,
115  const _StateType& originalState)> > DtIsModifiedCallList;
116 
120  };
121 
122  class VRF_PROTOCOL_EXPORT DtEntityStateCacheManager : public DtStateCacheManager<makVrv::DtVrlinkSimulatedEntityState>
123  {
124  public:
126  : DtStateCacheManager<makVrv::DtVrlinkSimulatedEntityState>(i)
127  {
128  addIsModifiedCallbackCheck(boost::bind(&DtEntityStateCacheManager::checkParentId, this, _1, _2));
129  addIsModifiedCallbackCheck(boost::bind(&DtEntityStateCacheManager::checkGlobalId, this, _1, _2));
130  addIsModifiedCallbackCheck(boost::bind(&DtEntityStateCacheManager::checkMarkingText, this, _1, _2));
131  addIsModifiedCallbackCheck(boost::bind(&DtEntityStateCacheManager::checkAppearance, this, _1, _2));
132  addIsModifiedCallbackCheck(boost::bind(&DtEntityStateCacheManager::checkForceId, this, _1, _2));
133  }
134 
135  protected:
137  const makVrv::DtVrlinkSimulatedEntityState& cached) const
138  {
139  return (newState.myAttachedToId != cached.myAttachedToId);
140  }
141 
143  const makVrv::DtVrlinkSimulatedEntityState& cached) const
144  {
145  return (newState.myForce != cached.myForce);
146  }
147 
149  const makVrv::DtVrlinkSimulatedEntityState& cached) const
150  {
151  return (newState.myMarkingText != cached.myMarkingText);
152  }
153 
155  const makVrv::DtVrlinkSimulatedEntityState& cached) const
156  {
157  return (newState.myGlobalId != cached.myGlobalId);
158  }
159 
162  {
163  return (newState.myAppearance != state.myAppearance);
164  }
165  };
166 
167  class VRF_PROTOCOL_EXPORT DtEnvironmentProcessStateCacheManager : public DtStateCacheManager<DtVrlinkNetworkUpdateSimulatedEnvironmentProcess>
168  {
169  public:
172  {
173  addIsModifiedCallbackCheck(boost::bind(&DtEnvironmentProcessStateCacheManager::checkAll, this, _1, _2));
174  }
175 
176  protected:
179  {
180  return (newState != cached);
181  }
182  };
183 
184  class VRF_PROTOCOL_EXPORT DtWeatherStateCacheManager : public DtStateCacheManager<DtVrlinkSimulatedWeatherState>
185  {
186  public:
189  {
190  addIsModifiedCallbackCheck(boost::bind(&DtWeatherStateCacheManager::checkAll, this, _1, _2));
191  }
192 
193  protected:
195  const DtVrlinkSimulatedWeatherState& cached) const
196  {
197  return (newState != cached);
198  }
199  };
200 
201  class VRF_PROTOCOL_EXPORT DtCloudLayerStateCacheManager : public DtStateCacheManager<DtVrlinkSimulatedCloudLayerState>
202  {
203  public:
206  {
207  addIsModifiedCallbackCheck(boost::bind(&DtCloudLayerStateCacheManager::checkAll, this, _1, _2));
208  }
209 
210  protected:
212  const DtVrlinkSimulatedCloudLayerState& cached) const
213  {
214  return (newState != cached);
215  }
216  };
217 
219  {
220  public:
223  {
224  addIsModifiedCallbackCheck(boost::bind(&DtExtendedStateDataCacheManager::checkAll, this, _1, _2));
225  }
226 
227  protected:
228  bool checkAll(const DtExtendedStateData& newState,
229  const DtExtendedStateData& cached) const
230  {
231  return (newState != cached);
232  }
233  };
234 
235  class VRF_PROTOCOL_EXPORT DtObjectStateStateCacheManager : public DtStateCacheManager<DtVrfNetworkUpdateObjectDataState>
236  {
237  public:
240  {
241  addIsModifiedCallbackCheck(boost::bind(&DtObjectStateStateCacheManager::checkEchelonId, this, _1, _2));
242  addIsModifiedCallbackCheck(boost::bind(&DtObjectStateStateCacheManager::checkBoundingVolume, this, _1, _2));
243  }
244 
245  protected:
248  {
249  return (newState.myEchelonIdString != state.myEchelonIdString);
250  }
251 
254  {
255  return (newState.myBoundingVolume.magnitudeSquared() != state.myBoundingVolume.magnitudeSquared());
256  }
257  };
258 
259  class VRF_PROTOCOL_EXPORT DtAggregateStateCacheManager : public DtStateCacheManager<DtVrlinkNetworkUpdateSimulatedAggregateState>
260  {
261  public:
264  {
265  addIsModifiedCallbackCheck(boost::bind(&DtAggregateStateCacheManager::checkParentId, this, _1, _2));
266  addIsModifiedCallbackCheck(boost::bind(&DtAggregateStateCacheManager::checkGlobalId, this, _1, _2));
267  addIsModifiedCallbackCheck(boost::bind(&DtAggregateStateCacheManager::checkAggregateState, this, _1, _2));
268  addIsModifiedCallbackCheck(boost::bind(&DtAggregateStateCacheManager::checkMarkingText, this, _1, _2));
269  addIsModifiedCallbackCheck(boost::bind(&DtAggregateStateCacheManager::checkSubAggregates, this, _1, _2));
270  addIsModifiedCallbackCheck(boost::bind(&DtAggregateStateCacheManager::checkSubEntities, this, _1, _2));
271  addIsModifiedCallbackCheck(boost::bind(&DtAggregateStateCacheManager::checkAppearance, this, _1, _2));
272  addIsModifiedCallbackCheck(boost::bind(&DtAggregateStateCacheManager::checkForceId, this, _1, _2));
273  }
274 
275  protected:
278  {
279  return (newState.myAppearance != state.myAppearance);
280  }
281 
284  {
285  int numberOfAggs = newState.mySubAggregates.size();
286  int curAggLimit = state.mySubAggregates.size();
287 
288  if (numberOfAggs != curAggLimit)
289  {
290  return true;
291  }
292 
293  for (int i = 0; i < numberOfAggs; i++)
294  {
295  if (state.mySubAggregates[i] != newState.mySubAggregates[i])
296  {
297  return true;
298  }
299  }
300 
301  return false;
302  }
303 
306  {
307  int numberOfAggs = newState.mySubEntities.size();
308  int curAggLimit = state.mySubEntities.size();
309 
310  if (numberOfAggs != curAggLimit)
311  {
312  return true;
313  }
314 
315  for (int i = 0; i < numberOfAggs; i++)
316  {
317  if (state.mySubEntities[i] != newState.mySubEntities[i])
318  {
319  return true;
320  }
321  }
322 
323  return false;
324  }
325 
328  {
329  return (newState.myAttachedToId != cached.myAttachedToId);
330  }
331 
334  {
335  return (newState.myForce != cached.myForce);
336  }
337 
340  {
341  return (newState.myGlobalId != cached.myGlobalId);
342  }
343 
346  {
347  return (newState.myMarkingText != cached.myMarkingText);
348  }
349 
352  {
353  return (newState.myAggregateState != cached.myAggregateState);
354  }
355  };
356  }
357 }
DtIsModifiedCallList myIsModifiedFunctions
Definition: stateCacheManager.h:117
bool checkEchelonId(const DtVrfNetworkUpdateObjectDataState &newState, const DtVrfNetworkUpdateObjectDataState &state)
Definition: stateCacheManager.h:246
bool blockConnections(bool blocked)
Blocks/unblocks connections.
Contains makVrv::DtSimDataProcessorInterface class.
bool checkAggregateState(const DtVrlinkNetworkUpdateSimulatedAggregateState &newState, const DtVrlinkNetworkUpdateSimulatedAggregateState &cached) const
Definition: stateCacheManager.h:350
makVrv::DtSimDataProcessorInterface * myProcessor
Definition: stateCacheManager.h:118
DtCloudLayerStateCacheManager(makVrv::DtSimDataProcessorInterface *i)
Definition: stateCacheManager.h:204
#define VRF_PROTOCOL_EXPORT
Definition: vrfProtocol.h:24
boost::signal< void(DtUniqueID, const DtSimState &) > signal_stateAdded
Definition: DtSimDataProcessorInterface.h:33
Definition: stateCacheManager.h:39
void slot_stateRemoved(makVrv::DtUniqueID id)
Definition: stateCacheManager.h:70
DtStateCacheManager(makVrv::DtSimDataProcessorInterface *iface)
Definition: stateCacheManager.h:42
DtAggregateStateCacheManager(makVrv::DtSimDataProcessorInterface *i)
Definition: stateCacheManager.h:262
bool checkSubAggregates(const DtVrlinkNetworkUpdateSimulatedAggregateState &newState, const DtVrlinkNetworkUpdateSimulatedAggregateState &state)
Definition: stateCacheManager.h:282
The class that is the interface between the GUI and the back-end.
Definition: vrfObjectDataState.h:64
boost::signal< void(DtUniqueID, const DtSimState &) > signal_stateUpdated
Definition: DtSimDataProcessorInterface.h:34
DtEnvironmentProcessStateCacheManager(makVrv::DtSimDataProcessorInterface *i)
Definition: stateCacheManager.h:170
boost::signal< void(DtUniqueID) > signal_stateRemoved
Definition: DtSimDataProcessorInterface.h:35
bool checkParentId(const DtVrlinkNetworkUpdateSimulatedAggregateState &newState, const DtVrlinkNetworkUpdateSimulatedAggregateState &cached) const
Definition: stateCacheManager.h:326
bool checkForceId(const makVrv::DtVrlinkSimulatedEntityState &newState, const makVrv::DtVrlinkSimulatedEntityState &cached) const
Definition: stateCacheManager.h:142
bool checkMarkingText(const makVrv::DtVrlinkSimulatedEntityState &newState, const makVrv::DtVrlinkSimulatedEntityState &cached) const
Definition: stateCacheManager.h:148
bool checkAll(const DtVrlinkSimulatedWeatherState &newState, const DtVrlinkSimulatedWeatherState &cached) const
Definition: stateCacheManager.h:194
bool checkAppearance(const makVrv::DtVrlinkSimulatedEntityState &newState, const makVrv::DtVrlinkSimulatedEntityState &state)
Definition: stateCacheManager.h:160
virtual ~DtStateCacheManager()
Definition: stateCacheManager.h:50
bool checkMarkingText(const DtVrlinkNetworkUpdateSimulatedAggregateState &newState, const DtVrlinkNetworkUpdateSimulatedAggregateState &cached) const
Definition: stateCacheManager.h:344
bool checkForceId(const DtVrlinkNetworkUpdateSimulatedAggregateState &newState, const DtVrlinkNetworkUpdateSimulatedAggregateState &cached) const
Definition: stateCacheManager.h:332
#define VRF_PROTOCOL_NAMESPACE
Definition: vrfDis.h:18
binderNoArgs< _Fn > bind(const _Fn &_Func, const _Ty &_Left)
Definition: DtSTLUtilities.h:76
void addIsModifiedCallbackCheck(const boost::function< bool(const _StateType &newState, const _StateType &originalState)> &function)
Definition: stateCacheManager.h:64
DtWeatherStateCacheManager(makVrv::DtSimDataProcessorInterface *i)
Definition: stateCacheManager.h:187
DtEntityStateCacheManager(makVrv::DtSimDataProcessorInterface *i)
Definition: stateCacheManager.h:125
bool checkSubEntities(const DtVrlinkNetworkUpdateSimulatedAggregateState &newState, const DtVrlinkNetworkUpdateSimulatedAggregateState &state)
Definition: stateCacheManager.h:304
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:24
void enable()
Definition: stateCacheManager.h:54
Contains makVrv::DtEntityState class.
std::vector< boost::function< bool(const _StateType &newState, const _StateType &originalState)> > DtIsModifiedCallList
Definition: stateCacheManager.h:115
std::string myEchelonIdString
Definition: vrfObjectDataState.h:84
void disable()
Definition: stateCacheManager.h:59
unsigned long long DtUniqueID
Definition: DtUniqueID.h:22
bool checkAll(const DtExtendedStateData &newState, const DtExtendedStateData &cached) const
Definition: stateCacheManager.h:228
Methods a data processor needs to implement to be considered a data processor.
Definition: DtSimDataProcessorInterface.h:24
bool checkBoundingVolume(const DtVrfNetworkUpdateObjectDataState &newState, const DtVrfNetworkUpdateObjectDataState &state)
Definition: stateCacheManager.h:252
bool checkGlobalId(const DtVrlinkNetworkUpdateSimulatedAggregateState &newState, const DtVrlinkNetworkUpdateSimulatedAggregateState &cached) const
Definition: stateCacheManager.h:338
bool checkAll(const DtVrlinkNetworkUpdateSimulatedEnvironmentProcess &newState, const DtVrlinkNetworkUpdateSimulatedEnvironmentProcess &cached) const
Definition: stateCacheManager.h:177
Base class to provide boost signal/slot management.
bool checkAppearance(const DtVrlinkNetworkUpdateSimulatedAggregateState &newState, const DtVrlinkNetworkUpdateSimulatedAggregateState &state)
Definition: stateCacheManager.h:276
DtVector myBoundingVolume
Definition: vrfObjectDataState.h:99
void slot_forceUpdateIfModified(makVrv::DtUniqueID id, const makVrv::DtSimState &incoming)
Definition: stateCacheManager.h:88
DtExtendedStateDataCacheManager(makVrv::DtSimDataProcessorInterface *i)
Definition: stateCacheManager.h:221
bool checkParentId(const makVrv::DtVrlinkSimulatedEntityState &newState, const makVrv::DtVrlinkSimulatedEntityState &cached) const
Definition: stateCacheManager.h:136
std::map< makVrv::DtUniqueID, _StateType > myMap
Definition: stateCacheManager.h:112
A DtSimState is the base class for all state objects.
Definition: DtSimState.h:22
Contains makVrv::DtUniqueID type.
bool checkAll(const DtVrlinkSimulatedCloudLayerState &newState, const DtVrlinkSimulatedCloudLayerState &cached) const
Definition: stateCacheManager.h:211
makVrv::DtSignalConnectionManager myConnectionManager
Definition: stateCacheManager.h:119
void slot_stateAdded(makVrv::DtUniqueID id, const makVrv::DtSimState &incoming)
Definition: stateCacheManager.h:81
bool checkGlobalId(const makVrv::DtVrlinkSimulatedEntityState &newState, const makVrv::DtVrlinkSimulatedEntityState &cached) const
Definition: stateCacheManager.h:154
DtObjectStateStateCacheManager(makVrv::DtSimDataProcessorInterface *i)
Definition: stateCacheManager.h:238
Definition: extendedStateData.h:26
virtual void forceObjectUpdate(DtUniqueID)=0

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)