VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
remoteObjectManager.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #pragma once
7 
11 #include <legionDataStore/dataTypes.h>
12 #include "legionStandardOM/views/entityView.h"
13 #include <legionStandardOM/sets/readEnvironmentProcessRepository.hpp>
14 
15 class DtStateDataManager;
16 class DtVrfCallbackQueue;
17 
18 namespace Legion
19 {
20  class ViewManager;
21 }
22 
23 namespace makVrf
24 {
29  {
30  public:
33 
34  virtual ~DtRemoteObjectManager();
35 
36  virtual void beginFrame();
37  virtual void advanceFrame();
38 
39  virtual void init(DtStateDataManager*);
40 
42  {
43  return myStateDataManager;
44  }
45 
46  Legion::ViewManager* viewManager()
47  {
48  return myViewManager;
49  }
50 
51  virtual void printReflectedObjectCounts() const;
52 
53  virtual void createRemoteObject(Legion::UInt64 id);
54 
55  protected:
56  virtual void objectsAdded(const std::vector<LOM::ReadEntityRepository>&);
57  virtual void objectsRemoved(const std::vector<LOM::ReadEntityRepository>&);
58 
59  virtual void environmentalObjectsAdded(const std::vector<LOM::ReadEnvironmentProcessRepository>&);
60  virtual void environmentalObjectsRemoved(const std::vector<LOM::ReadEnvironmentProcessRepository>&);
61 
62  protected:
63  virtual bool setupComponents(DtStateData*);
64 
65  protected:
67  {
68  StateComponentAssociation(DtRemoteObjectManager* m) : myRemoteObjectManager(m) {};
70  virtual bool hasStateComponent(DtStateData* sd) const = 0;
71  virtual void addStateComponent(DtStateData* sd) const = 0;
72  virtual void addExistingStateComponents(DtStateData* sd) const = 0;
73 
74  protected:
76  };
77 
78  template <typename T_VRFStateComponent, typename T_LegionComponent>
80  {
81  StateComponentAdder(DtRemoteObjectManager* m, bool onlyOne) : StateComponentAssociation(m), myOnlyOne(onlyOne)
82  {
83  myView = (typename Legion::SetView<T_LegionComponent>*)(m->viewManager()->createSetView<T_LegionComponent>());
84  myView->addInstanceAddedCallback(typename Legion::SetView<T_LegionComponent>::InstanceCallback(this, &StateComponentAdder::handleLegionSetAdded));
85  myView->addInstanceRemovedCallback(typename Legion::SetView<T_LegionComponent>::InstanceCallback(this, &StateComponentAdder::handleLegionSetRemoved));
86  }
87 
89  {
90  myView->removeInstanceAddedCallback(typename Legion::SetView<T_LegionComponent>::InstanceCallback(this, &StateComponentAdder::handleLegionSetAdded));
91  myView->removeInstanceRemovedCallback(typename Legion::SetView<T_LegionComponent>::InstanceCallback(this, &StateComponentAdder::handleLegionSetRemoved));
92  myRemoteObjectManager->viewManager()->destroyView(myView);
93  }
94 
95  virtual void addExistingStateComponents(DtStateData* sd) const
96  {
97  addStateComponent(sd);
98  }
99 
100  virtual void addStateComponent(DtStateData* sd) const
101  {
102  if (myOnlyOne && sd->hasStateComponent<T_VRFStateComponent>())
103  {
104  return;
105  }
106 
107  if (sd->readStateInstance() && (T_LegionComponent::isType(sd->readStateInstance()->instanceHandle())))
108  {
109  sd->addStateComponent<T_VRFStateComponent>();
110  }
111  else
112  {
114  int componentCount = sd->componentCount<T_LegionComponent>();
115  int i;
116 
117  for (i = 0; i < componentCount; i++)
118  {
119  sd->addStateComponent<T_VRFStateComponent>();
120  }
121  }
122  }
123 
124  virtual bool hasStateComponent(DtStateData* sd) const
125  {
126  return sd->findNextFrameLegionComponent<T_LegionComponent>().isValid();
127  }
128 
129  virtual void handleLegionSetRemoved(const std::vector<T_LegionComponent>& objs)
130  {
131  }
132 
133  virtual void handleLegionSetAdded(const std::vector<T_LegionComponent>& objs)
134  {
135  if (myRemoteObjectManager->stateDataManager())
136  {
137  DtStateDataManager* sdm = myRemoteObjectManager->stateDataManager();
138 
139  int iLimit = objs.size();
140  int i;
141 
142  for (i = 0; i < iLimit; ++i)
143  {
144  DtStateData* sd = sdm->stateDataForLegionId(objs[i].globalId());
145 
146  if (sd)
147  {
148  addStateComponent(sd);
149  }
150  }
151  }
152  }
153 
154  protected:
155  Legion::SetView<T_LegionComponent>* myView;
156  bool myOnlyOne;
157  };
158 
159  public:
160  template <typename T_VRFComponent, typename T_LegionComponent> void
161  registerLegionSetToStateComponent(bool onlyOne = false)
162  {
163  LegionSetToStateComponent::iterator iter = myLegionSetToStateComponent.find(T_LegionComponent::type());
164 
165  if (iter != myLegionSetToStateComponent.end())
166  {
167  delete iter->second;
168  }
169 
170  myLegionSetToStateComponent[T_LegionComponent::type()] = new StateComponentAdder<T_VRFComponent, T_LegionComponent>(this, onlyOne);
171  }
172 
173  virtual void setProcessRemoteObjectsInParallel(bool);
175  {
176  return myProcessRemoteObjectsInParallel;
177  }
178 
182  virtual void setNumCallbackThreads(unsigned);
183 
185  virtual bool rediscoverObjects();
186 
187  protected:
189  Legion::ViewManager* myViewManager;
190  Legion::View* myEntityView;
191  Legion::View* myEnvironmentalView;
192 
193  typedef std::map<Legion::UInt32, StateComponentAssociation*> LegionSetToStateComponent;
195 
196  std::vector<Legion::UInt64> myProcessNewObjects;
199  };
200 }
Definition: remoteObjectManager.h:79
virtual void addStateComponent(DtStateData *sd) const
Definition: remoteObjectManager.h:100
Legion::ViewManager * viewManager()
Definition: remoteObjectManager.h:46
StateComponentAdder(DtRemoteObjectManager *m, bool onlyOne)
Definition: remoteObjectManager.h:81
#define DT_DLL_legionNetworkInterface
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: legionNetworkInterfaceDefines.h:26
virtual ~StateComponentAssociation()
Definition: remoteObjectManager.h:69
DtStateDataManager * myStateDataManager
Definition: remoteObjectManager.h:188
virtual ~StateComponentAdder()
Definition: remoteObjectManager.h:88
virtual void handleLegionSetAdded(const std::vector< T_LegionComponent > &objs)
Definition: remoteObjectManager.h:133
bool hasStateComponent(bool checkWritable=false)
Definition: stateData.h:559
Simple asynchronous callback queue.
Definition: vrfCallbackQueue.h:32
std::vector< Legion::UInt64 > myProcessNewObjects
Definition: remoteObjectManager.h:196
unsigned int componentCount() const
Definition: stateData.h:388
T_Component findNextFrameLegionComponent(int index=0)
Definition: stateData.h:403
class DtRemoteObjectManager:
Definition: remoteObjectManager.h:28
DtStateDataManager * stateDataManager()
Definition: remoteObjectManager.h:41
DtVrfCallbackQueue * myNetworkCallbackQueue
Definition: remoteObjectManager.h:198
LegionSetToStateComponent myLegionSetToStateComponent
Definition: remoteObjectManager.h:194
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:336
Legion::SetView< T_LegionComponent > * myView
Definition: remoteObjectManager.h:155
virtual void addExistingStateComponents(DtStateData *sd) const
Definition: remoteObjectManager.h:95
bool processRemoteObjectsInParallel() const
Definition: remoteObjectManager.h:174
unsigned long long UInt64
Definition: stateDataTypes.h:17
Legion::ReadStateInstance * readStateInstance() const
Definition: stateData.h:719
void registerLegionSetToStateComponent(bool onlyOne=false)
Definition: remoteObjectManager.h:161
bool myProcessRemoteObjectsInParallel
Definition: remoteObjectManager.h:197
virtual bool hasStateComponent(DtStateData *sd) const
Definition: remoteObjectManager.h:124
bool myOnlyOne
Definition: remoteObjectManager.h:156
StateComponentAssociation(DtRemoteObjectManager *m)
Definition: remoteObjectManager.h:68
Legion::View * myEnvironmentalView
Definition: remoteObjectManager.h:191
std::map< Legion::UInt32, StateComponentAssociation * > LegionSetToStateComponent
Definition: remoteObjectManager.h:193
virtual const DtStateData * stateDataForLegionId(UInt64) const
DtRemoteObjectManager * myRemoteObjectManager
Definition: remoteObjectManager.h:75
Legion::ViewManager * myViewManager
Definition: remoteObjectManager.h:189
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
Legion::View * myEntityView
Definition: remoteObjectManager.h:190
T_Component * addStateComponent(bool checkWritable=false, bool isRemote=false)
Using the global state component factory, creates and adds a new state of the given type...
Definition: stateData.h:452
virtual void handleLegionSetRemoved(const std::vector< T_LegionComponent > &objs)
Definition: remoteObjectManager.h:129
This class holds the state data that represents each simulation object in the system.
Definition: stateDataManager.h:71

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)