VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtAgentManager.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2015 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
15 
16 #include <boost/smart_ptr/detail/atomic_count.hpp>
17 #include <boost/thread/condition.hpp>
18 #include <boost/thread/mutex.hpp>
19 #include <boost/signals.hpp>
20 #include <boost/unordered_map.hpp>
21 
22 #include <vector>
23 
24 namespace makVrv
25 {
26  class DtAsynchronousAgentManager;
27  class DtCoordinateSystem;
28  class DtDe;
29  class DtMessage;
30  class DtSceneProctor;
31  class DtAgentUpdateResolverInterface;
32  class DtAgent;
33 
39  {
40  public:
41 
43 
46 
48  virtual ~DtAgentManager();
49 
53  virtual void cleanup();
54 
58  virtual void tick();
59 
61  virtual void updateScene(DtMessage& message);
62 
65  virtual DtAgentUpdateResolverInterface* findUpdater(DtUniqueID id);
66 
68  DtElementID findElementId(DtUniqueID id);
69 
73  virtual bool sceneObjectIsVisible(DtElementID id) const;
74 
75  //@name DtAsynchronousAgentManagerInterfaces related functions.
77 
84  virtual DtAsynchronousAgentManager* createAsynchronousManager(const std::string& ownerName);
85 
88  void checkForIgLock(bool forceLock = false);
89 
95  virtual DtDe& acquireLockedIg();
96 
102  virtual void releaseLockedIg();
103 
105 
107  inline DtDe& de()
108  {
109  return myDe;
110  }
111 
115  void clear();
116 
119  boost::signal<void (DtUniqueID id)> signal_objectCreated;
120 
121  protected:
122 
130  virtual unsigned char acquireNamespaceId(
131  DtAsynchronousAgentManager* sceneManagerInterface,
132  const std::string& ownerName);
133 
136  virtual void releaseNamespaceId(unsigned char nsId);
137 
141  {
142 
143  public:
144 
146  : message(0)
147  , distribute(false)
148  {
149  }
150 
153 
154  };
155 
156  typedef std::vector<MessageParcel> MessageParcelVector;
157 
163  virtual void addAsynchronousUpdateMessages(MessageParcelVector& messages);
164 
165  typedef std::vector<DtMessage*> MessageList;
166 
169  void distributeAndUpdate( MessageList& masterMessages, MessageList& distributedMessages );
170 
174  virtual void localEncodeAndUpdateScene();
175 
177  virtual void createObject(const std::string& className, DtUniqueID id);
178 
180  virtual void updateObject(DtUniqueID id,DtMessage& msg, unsigned int updatesize);
181 
183  virtual void destroyObject(DtUniqueID id);
184 
185  protected:
186 
187  typedef boost::function< void (DtAgentManagerInterface*) >
189 
193  {
194  //Local copy.
195  std::string name;
196  //Used to pass functions to be executed on the asynchronous interface.
198  };
199 
200  typedef boost::unordered_map<DtUniqueID,AsynchronousInterfaceEntry> NamespaceMap;
201  typedef boost::unordered_map<DtUniqueID,DtAgentUpdateResolverInterface*> UpdaterMap;
202  typedef std::vector<DtAgent*> DriverVector;
203 
204 
206 
208  std::pair<DtUniqueID,DtAgentUpdateResolverInterface*> myLastObjectCache;
213 
214  boost::detail::atomic_count myAtomicWaitingCount;
215  boost::condition myRequestIgCondition;
216  boost::condition myReleaseIgCondition;
217  boost::mutex myMonitor;
218 
219  //Force checking the asynchronous messages.
221 
222  };
223 
227  {
228 
229  public:
231  static DtSceneManagerCreator& instance(DtDe& theIG);
232 
234  static void registerInstance(DtDe& theIG,DtSceneManagerCreator* anInstance);
235 
237  virtual DtAgentManager* create(DtDe&);
238  };
239 
240 }

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)