VR-Forces 5.0.1 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 DtSimObject*, const DtString& oldText, const DtString& newText)> signal_simObjectRenamed;
97 
98  typedef std::map<unsigned long long, DtSimObjectReference> SimObjects;
101  SimObjects simObjects() const;
102 
105  virtual void objectsEmbarkedOn(const DtUUID&, std::vector<DtSimObjectReference>& list) const;
106 
108  virtual void clear();
109 
111  virtual bool hasValidSimulatedEntity() const;
112 
114  virtual bool has(const DtUUID&) const;
115 
116  typedef std::set<const makVrf::DtFrameStateInterface*> CurrentFrameStates;
117  template <typename T_Component> const CurrentFrameStates& stateComponents() const;
118 
119  typedef boost::signals2::signal<void (makVrf::DtStateComponent*)> StateComponentAddedSignal;
120  typedef boost::signals2::signal<void (makVrf::DtStateComponent*)> StateComponentRemovedSignal;
121  template <typename T_Component> StateComponentAddedSignal& signalWhenStateComponentAdded();
122  template <typename T_Component> StateComponentAddedSignal& signalWhenStateComponentRemoved();
123 
125  virtual DtSimObjectReferenceList entitiesTracking(const DtUUID&) const;
126 
128  virtual DtSimObjectReferenceList entitiesJamming(const DtUUID&) const;
129 
132  virtual std::vector<DtSimObjectReference> objectsOfType(const DtEntityType&) const;
133 
134 protected:
135  virtual void simObjectDeleted(const DtSimObject*);
136 
138  virtual DtSimObjectReference getOrCreateSimObjectReference(makVrf::DtStateData*, bool createOnlyIfNotPresent = false) const;
139  virtual void uuidChanged(unsigned long long, const DtUUID& oldUUID, const DtUUID& newUUID);
140  virtual void objectRenamed(const DtSimObject*, const DtString& oldName, const DtString& newName);
141  virtual void simObjectAdded(makVrf::DtStateData*);
142  virtual void discoveredObjectReference(const DtString& awaiting);
143 
145  bool isDeleted(const DtUUID&) const;
146 
147 protected:
149  mutable tbb::spin_rw_mutex myMutex;
150 
151  boost::signals2::scoped_connection myStateDataAddedConnection;
152  boost::signals2::scoped_connection myUUIDChangedConnection;
153 
155 
156  typedef std::map<DtString, DtSimObjectReference> AwaitingMap;
158 
160  std::set<DtUUID> myDeleted;
161 
162 public:
165  VRF4API_METHOD DtSimObjectReference lookupVrfObjectByUUID(const DtUUID& u) const { return lookup(u); };
167  VRF4API_METHOD DtSimObjectReference lookupVrfObjectByEntityIdentifier(const DtEntityIdentifier& id) const { return lookup(id); };
168  VRF4API_METHOD const DtDiGuyCharacterDataManager* diGuyCharacterManager() const;
170 };
171 
172 #include "vrfobjcore/simObjectManager.inl"
UUID is a unique ID wrapper class.
Definition: rwUUID.h:226
SimObjects myAdded
Definition: simObjectManager.h:159
boost::signals2::scoped_connection myUUIDChangedConnection
Definition: simObjectManager.h:152
boost::signals2::signal< void(makVrf::DtStateComponent *)> StateComponentRemovedSignal
Definition: simObjectManager.h:120
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:98
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:96
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_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:157
SimObjects mySimObjects
Definition: simObjectManager.h:154
VRF4API_METHOD DtSimObjectReference lookupVrfObjectByEntityIdentifier(const DtEntityIdentifier &id) const
Deprecated API added to allow for older code to compile.
Definition: simObjectManager.h:167
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:156
DtSimulationServices * mySimulationServices
Definition: simObjectManager.h:148
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:89
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:151
boost::signals2::signal< void(makVrf::DtStateComponent *)> StateComponentAddedSignal
Definition: simObjectManager.h:119
std::set< DtUUID > myDeleted
Definition: simObjectManager.h:160
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
std::set< const makVrf::DtFrameStateInterface * > CurrentFrameStates
Definition: simObjectManager.h:116
#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:165
tbb::spin_rw_mutex myMutex
Definition: simObjectManager.h:149
VRF4API_METHOD DtSimObjectReference lookupVrfObjectByGlobalId(const DtUUID &u) const
Deprecated API added to allow for older code to compile.
Definition: simObjectManager.h:166

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)