VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
simObjectManager.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 
9 #include "vrfobjcore/simObject.h"
10 #include <tbb/spin_rw_mutex.h>
11 #include <boost/signals2.hpp>
12 #include <vrfutil/vrf4XAPI.h>
13 
14 namespace makVrf
15 {
16  class DtStateData;
17  class DtFrameStateInterface;
18 }
19 
20 class DtSimObject;
22 class DtUUID;
23 class DtEntityIdentifier;
25 
43 {
44 private:
47  DtSimObjectManager& operator=(const DtSimObjectManager&);
48 
49 public:
52 
54  virtual ~DtSimObjectManager();
55 
57  virtual void tick();
58 
60  virtual void init();
61 
63  static DtSimObjectManager* creator(DtSimulationServices*);
64 
68  {
69  return mySimulationServices;
70  }
71 
73  virtual void advanceFrame();
74 
76  virtual DtSimObjectReference lookup(const DtUUID&) const;
78  virtual DtSimObjectReference lookup(const DtEntityIdentifier&) const;
79 
81  virtual DtSimObjectReference lookup(unsigned long long) const;
82 
84  mutable boost::signals2::signal<void ()> signal_advancedFrame;
85 
87  mutable boost::signals2::signal<void (DtSimObjectReference)> signal_simObjectAdded;
88 
90  mutable boost::signals2::signal<void (DtSimObjectReference)> signal_simObjectDeleted;
91 
93  mutable boost::signals2::signal<void (const DtUUID& oldUUID, const DtUUID& newUUID)> signal_uuidChanged;
94 
96  mutable boost::signals2::signal<void (const DtUUID& oldUUID, const DtUUID& newUUID)> signal_uuidUpgradedTo;
97 
99  mutable boost::signals2::signal<void (const DtSimObject*, const DtString& oldText, const DtString& newText)> signal_simObjectRenamed;
100 
101  typedef std::map<unsigned long long, DtSimObjectReference> SimObjects;
104  SimObjects simObjects() const;
105 
108  virtual void objectsEmbarkedOn(const DtUUID&, std::vector<DtSimObjectReference>& list) const;
109 
111  virtual void clear();
112 
114  virtual bool hasValidSimulatedEntity() const;
115 
117  virtual bool has(const DtUUID&) const;
118 
119  typedef std::set<const makVrf::DtFrameStateInterface*> CurrentFrameStates;
120  template <typename T_Component> const CurrentFrameStates& stateComponents() const;
121 
122  typedef boost::signals2::signal<void (makVrf::DtStateComponent*)> StateComponentAddedSignal;
123  typedef boost::signals2::signal<void (makVrf::DtStateComponent*)> StateComponentRemovedSignal;
124  template <typename T_Component> StateComponentAddedSignal& signalWhenStateComponentAdded();
125  template <typename T_Component> StateComponentAddedSignal& signalWhenStateComponentRemoved();
126 
128  virtual DtSimObjectReferenceList entitiesTracking(const DtUUID&) const;
129 
131  virtual DtSimObjectReferenceList entitiesJamming(const DtUUID&) const;
132 
135  virtual std::vector<DtSimObjectReference> objectsOfType(const DtEntityType&) const;
136 
137 protected:
138  virtual void simObjectDeleted(const DtSimObject*);
139 
141  virtual DtSimObjectReference getOrCreateSimObjectReference(makVrf::DtStateData*, bool createOnlyIfNotPresent = false) const;
142  virtual void uuidChanged(unsigned long long, const DtUUID& oldUUID, const DtUUID& newUUID);
143  virtual void objectRenamed(const DtSimObject*, const DtString& oldName, const DtString& newName);
144  virtual void simObjectAdded(makVrf::DtStateData*);
145  virtual void discoveredObjectReference(const DtString& awaiting);
146 
148  bool isDeleted(const DtUUID&) const;
149 
152  virtual void slot_uuidUpgradedTo(const DtUUID& oldUUID, const DtUUID& newUUID);
153 
154 protected:
156  mutable tbb::spin_rw_mutex myMutex;
157 
158  boost::signals2::scoped_connection myStateDataAddedConnection;
159  boost::signals2::scoped_connection myUUIDChangedConnection;
160  boost::signals2::scoped_connection myUUIDUpgradedConnection;
161 
163 
164  typedef std::map<DtString, DtSimObjectReference> AwaitingMap;
166 
168  std::set<DtUUID> myDeleted;
169 
170 public:
173  VRF4API_METHOD DtSimObjectReference lookupVrfObjectByUUID(const DtUUID& u) const { return lookup(u); };
175  VRF4API_METHOD DtSimObjectReference lookupVrfObjectByEntityIdentifier(const DtEntityIdentifier& id) const { return lookup(id); };
176  VRF4API_METHOD const DtDiGuyCharacterDataManager* diGuyCharacterManager() const;
178 };
179 
180 #include "vrfobjcore/simObjectManager.inl"
UUID is a unique ID wrapper class.
Definition: rwUUID.h:229
SimObjects myAdded
Definition: simObjectManager.h:167
boost::signals2::scoped_connection myUUIDChangedConnection
Definition: simObjectManager.h:159
boost::signals2::signal< void(makVrf::DtStateComponent *)> StateComponentRemovedSignal
Definition: simObjectManager.h:123
The DtSimObjectReference is a shared pointer that can be used amongst many object for access to the u...
Definition: simObjectReference.h:26
std::map< unsigned long long, DtSimObjectReference > SimObjects
Definition: simObjectManager.h:101
boost::signals2::signal< void(const DtSimObject *, const DtString &oldText, const DtString &newText)> signal_simObjectRenamed
Signal sent when an objects name has changed.
Definition: simObjectManager.h:99
boost::signals2::signal< void(DtSimObjectReference)> signal_simObjectAdded
Signal sent when a new DtSimObjectReference has been added.
Definition: simObjectManager.h:87
boost::signals2::signal< void(const DtUUID &oldUUID, const DtUUID &newUUID)> signal_uuidUpgradedTo
Signal when a UUID is remapped. Called after awaiting list has been changed.
Definition: simObjectManager.h:96
boost::signals2::signal< void(const DtUUID &oldUUID, const DtUUID &newUUID)> signal_uuidChanged
Signal when UUID is changed. Called before the map is updated with the new uuid.
Definition: simObjectManager.h:93
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:336
#define DT_DLL_vrfobjcore
This file is used to determine how to build.
Definition: vrfobjcoreDefines.h:24
Contains data describing the available attributes and animations for each DI-Guy character type...
Definition: diGuyCharacterDataManager.h:33
AwaitingMap myAwaitingMap
Definition: simObjectManager.h:165
SimObjects mySimObjects
Definition: simObjectManager.h:162
VRF4API_METHOD DtSimObjectReference lookupVrfObjectByEntityIdentifier(const DtEntityIdentifier &id) const
Deprecated API added to allow for older code to compile.
Definition: simObjectManager.h:175
boost::signals2::signal< void(DtSimObjectReference)> signal_simObjectDeleted
Signal sent when a new DtSimObjectReference has been deleted.
Definition: simObjectManager.h:90
std::map< DtString, DtSimObjectReference > AwaitingMap
Definition: simObjectManager.h:164
DtSimulationServices * mySimulationServices
Definition: simObjectManager.h:155
DtSimulationServices * simManager()
Definition: simObjectManager.h:67
This is a convenience list that will add DtSimObjectReference objects and modify the list as objects ...
Definition: simObjectReferenceList.h:22
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:90
This class is the central access point for all current-frame state of all objects in the simulation i...
Definition: simObjectManager.h:42
boost::signals2::signal< void()> signal_advancedFrame
Signal sent when frame is advanced.
Definition: simObjectManager.h:84
Represents a single simulation object in the exercise. Object may be VRF simulation, or non-VRF simulated, and may be simulated by the local sim engine, or by a remote sim engine. Only public (external) state of the object is available. All data is read-only. All access to data of the object is thread safe within the simulation frame.
Definition: simObject.h:79
boost::signals2::scoped_connection myStateDataAddedConnection
Definition: simObjectManager.h:158
boost::signals2::signal< void(makVrf::DtStateComponent *)> StateComponentAddedSignal
Definition: simObjectManager.h:122
std::set< DtUUID > myDeleted
Definition: simObjectManager.h:168
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
std::set< const makVrf::DtFrameStateInterface * > CurrentFrameStates
Definition: simObjectManager.h:119
boost::signals2::scoped_connection myUUIDUpgradedConnection
Definition: simObjectManager.h:160
#define VRF4API_METHOD
Include this header file to allow for the definition/usage of the ability to mark something as deprec...
Definition: vrf4XAPI.h:22
VRF4API_METHOD DtSimObjectReference lookupVrfObjectByUUID(const DtUUID &u) const
Deprecated API added to allow for older code to compile.
Definition: simObjectManager.h:173
tbb::spin_rw_mutex myMutex
Definition: simObjectManager.h:156
VRF4API_METHOD DtSimObjectReference lookupVrfObjectByGlobalId(const DtUUID &u) const
Deprecated API added to allow for older code to compile.
Definition: simObjectManager.h:174

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)