VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
managedObjectList.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2005 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
10 
11 #pragma once
12 
15 #include <vrfutil/rwUUID.h>
16 
17 #include <vlutil/vlConfig.h>
18 #include <list>
19 #include <vlutil/vlSmartPointers.h>
20 #include <vlutil/vlTime.h>
21 
22 #include <tbb/spin_mutex.h>
23 
27 
29 
32 typedef DtBoost::shared_ptr<DtManagedObjectList> DtManagedObjectListPtr;
35 typedef DtBoost::shared_ptr<const DtManagedObjectList> DtManagedObjectListConstPtr;
36 
46 {
47 private:
51  DtManagedObjectList& operator=(DtManagedObjectList& orig);
53 
54 protected:
57  DtManagedObjectList(const DtString& listName = "" /* For tracy profiling */);
58 
60  virtual void init();
61 
62  virtual void init(const std::vector<DtSimObjectReference>&);
63 
64 public:
65  DtManagedObjectList(const DtSimulationServices* simServices,
66  const DtVrfObjectPredicate& predicate =
68  bool reevaluateFlag = false, DtTime evaluationPeriod = 0,
69  const DtString& listName = "" /* For tracy profiling*/);
70 
72  DtManagedObjectList(const std::vector<DtSimObjectReference>& subordinates,
73  const DtVrfObjectPredicate& predicate,
74  const DtString& listName = "" /* For tracy profiling*/);
75 
78  static DtManagedObjectListPtr create(
79  const DtSimulationServices* objectManager,
80  const DtVrfObjectPredicate& predicate =
82  bool reevaluatePeriodically = false, DtTime evaluationPeriod = 0.0,
83  const DtString& listName = "" /*For tracy profiling*/ );
84 
86  virtual ~DtManagedObjectList();
87 
89  virtual const DtVrfObjectPredicate& predicate() const;
90 
92  virtual void tick(DtVrfCallbackQueue* queue = nullptr);
93 
95  virtual bool reevaluateFlag() const ;
96 
98  virtual DtTime evaluationPeriod() const;
99 
100  typedef std::set<DtSimObjectReference>::iterator iterator;
101  typedef std::set<DtSimObjectReference>::const_iterator const_iterator;
102 
103  static DtManagedObjectListPtr nullList();
104 
108  virtual iterator begin();
109  virtual const_iterator begin() const;
110  virtual iterator end();
111  virtual const_iterator end() const;
112  virtual size_t size() const;
114 
117  virtual const DtSimObject* find(const DtUUID& entityId) const;
120  virtual bool contains(const DtSimObjectReference& simObj) const;
121 
127  virtual void invalidate();
128 
130  double lastTimeModified() const
131  {
132  return myLastTimeModified;
133  }
134 
136  virtual bool isTimeToEvaluate() const;
137 
138 protected:
139 
140  //add & remove using correct hash key type
141  virtual void add(DtSimObjectReference obj);
142  virtual void remove(const DtSimObject* obj);
143 
145  virtual void populateList();
146 
147  virtual void simObjectAdded(DtSimObjectReference ref);
148 
150  static void predicateCallback(DtSimObjectReference vrfObject,
151  DtVrfObjectPredicateEvaluator* predicateEval, void* userData);
152  virtual void processPredicateCallback(DtSimObjectReference vrfObject,
153  DtVrfObjectPredicateEvaluator* predicateEval);
154 
156  virtual bool shouldAdd(DtSimObjectReference ref) const;
157 
158 protected:
165  std::set<DtSimObjectReference> myFilteredObjectList;
167 
168  tbb::spin_mutex myMutex;
169 
171  {
172  boost::signals2::connection removalConnection;
174  };
175 
176  typedef std::map<unsigned long long, ConnectionInformation > ConnectionMap;
178 
179  boost::signals2::scoped_connection mySimObjectAddedConnection;
180 
182  mutable double myNextEvaluationTime = 0.;
183 };
184 
UUID is a unique ID wrapper class.
Definition: uuid.h:59
DtTime myEvaluationPeriod
Definition: managedObjectList.h:163
double myLastTimeModified
Definition: managedObjectList.h:181
boost::signals2::connection removalConnection
Definition: managedObjectList.h:172
std::map< unsigned long long, ConnectionInformation > ConnectionMap
Definition: managedObjectList.h:176
tbb::spin_mutex myMutex
Definition: managedObjectList.h:168
bool myReevaluateFlag
Definition: managedObjectList.h:162
voidpf void uLong size
Definition: ioapi.h:39
The DtSimObjectReference is a shared pointer that can be used amongst many object for access to the u...
Definition: simObjectReference.h:26
Simple asynchronous callback queue.
Definition: vrfCallbackQueue.h:32
Contains the DtUUID class declaration.
std::set< DtSimObjectReference > myFilteredObjectList
Definition: managedObjectList.h:165
const DtSimulationServices * mySimulationServices
Definition: managedObjectList.h:159
Definition: managedObjectList.h:170
std::set< DtSimObjectReference >::iterator iterator
Definition: managedObjectList.h:100
DtVrfObjectPredicate * myNegatedPredicate
Definition: managedObjectList.h:161
Contains the DtVrfObjectPredicate class declaration.
Definition: vrfObjectPredicate.h:20
DtString myListName
Definition: managedObjectList.h:166
#define DT_DLL_vrfobjcore
This file is used to determine how to build.
Definition: vrfobjcoreDefines.h:24
DtBoost::shared_ptr< DtManagedObjectList > DtManagedObjectListPtr
Evaluation period of -1 means to keep around but never evaluate beyond what the list already has...
Definition: managedObjectList.h:26
The predicate callback manager allows for registration of callbacks by sim object for predicates...
Definition: predicateCallbackManager.h:20
DtVrfObjectPredicate * myPredicate
Definition: managedObjectList.h:160
ConnectionMap myConnectionMap
Definition: managedObjectList.h:177
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:95
Definition: vrfObjectPredicateEvaluator.h:17
std::set< DtSimObjectReference >::const_iterator const_iterator
Definition: managedObjectList.h:101
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:88
static const DtVrfObjectPredicate & nullPredicate()
Returns an instance of a DtNullVrfObjectPredicate.
double lastTimeModified() const
The last wall clock time this list was modified (object added or removed)
Definition: managedObjectList.h:130
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
DtBoost::shared_ptr< const DtManagedObjectList > DtManagedObjectListConstPtr
Typedef for a shared pointer to a const DtOrgViewManagedObjectList. These lists are used within VR-Fo...
Definition: managedObjectList.h:35
Instances of DtManagedObjectList are created and maintained by a DtManagedObjectListManager. The lists contains a subset of the objects in DtSimObjectManager that meet the specified predicate. If specified at creation time, the list automatically updates itself periodically. The lists should be handled though shared pointers.
Definition: managedObjectList.h:45
DtPredicateCallbackManager myPredicateCallbackManager
Definition: managedObjectList.h:164
DtSimObjectReference simObjectReference
Definition: managedObjectList.h:173
boost::signals2::scoped_connection mySimObjectAddedConnection
Definition: managedObjectList.h:179

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)