VR-Vantage API Documentation
DtAgentManager.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2010 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 /******************************************************************************
6 ** $RCSfile: DtAgentManager.h,v $ $Revision: 1.47 $ $State: Exp $
7 ******************************************************************************/
8 
12 
13 #ifndef DtSceneManager_H_
14 #define DtSceneManager_H_
15 
16 #include <vrvCore/vrvCore.h>
20 
21 #include <boost/smart_ptr/detail/atomic_count.hpp>
22 #include <boost/thread/condition.hpp>
23 #include <boost/thread/mutex.hpp>
24 #include <boost/signals.hpp>
25 #include <boost/unordered_map.hpp>
26 
27 #include <list>
28 #include <map>
29 #include <vector>
30 
31 namespace makVrv
32 {
33  class DtAsynchronousAgentManager;
34  class DtCoordinateSystem;
35  class DtDe;
36  class DtMessage;
37  class DtSceneProctor;
38  class DtAgentUpdateResolverInterface;
39  class DtAgent;
40 
46  {
47  public:
48 
50 
53 
55  virtual ~DtAgentManager();
56 
60  virtual void tick();
61 
63  virtual void updateScene(DtMessage& message);
64 
67  virtual DtAgentUpdateResolverInterface* findUpdater(DtUniqueID id);
68 
70  DtElementID findElementId(DtUniqueID id);
71 
75  virtual bool sceneObjectIsVisible(DtElementID id) const;
76 
77  //@name DtAsynchronousAgentManagerInterfaces related functions.
79 
86  virtual DtAsynchronousAgentManager* createAsynchronousManager(const std::string& ownerName);
87 
90  void checkForIgLock(bool forceLock = false);
91 
97  virtual DtDe& acquireLockedIg();
98 
104  virtual void releaseLockedIg();
105 
107 
109  inline DtDe& de()
110  {
111  return myDe;
112  }
113 
117  void clear();
118 
121  boost::signal<void (DtUniqueID id)> signal_objectCreated;
122 
123  protected:
124 
132  virtual unsigned char acquireNamespaceId(
133  DtAsynchronousAgentManager* sceneManagerInterface,
134  const std::string& ownerName);
135 
138  virtual void releaseNamespaceId(unsigned char nsId);
139 
143  {
144 
145  public:
146 
148  : message(0)
149  , distribute(false)
150  {
151  }
152 
155 
156  };
157 
158  typedef std::vector<MessageParcel> MessageParcelVector;
159 
165  virtual void addAsynchronousUpdateMessages(MessageParcelVector& messages);
166 
167  typedef std::vector<DtMessage*> MessageList;
168 
171  void distributeAndUpdate( MessageList& masterMessages, MessageList& distributedMessages );
172 
176  virtual void localEncodeAndUpdateScene();
177 
179  virtual void createObject(const std::string& className, DtUniqueID id);
180 
182  virtual void updateObject(DtUniqueID id,DtMessage& msg, unsigned int updatesize);
183 
185  virtual void destroyObject(DtUniqueID id);
186 
187  protected:
188 
189  typedef boost::function< void (DtAgentManagerInterface*) >
191 
195  {
196  //Local copy.
197  std::string name;
198  //Used to pass functions to be executed on the asynchronous interface.
200  };
201 
202  typedef boost::unordered_map<DtUniqueID,AsynchronousInterfaceEntry> NamespaceMap;
203  typedef boost::unordered_map<DtUniqueID,DtAgentUpdateResolverInterface*> UpdaterMap;
204  typedef std::vector<DtAgent*> DriverVector;
205 
206 
208 
210  std::pair<DtUniqueID,DtAgentUpdateResolverInterface*> myLastObjectCache;
215 
216  boost::detail::atomic_count myAtomicWaitingCount;
217  boost::condition myRequestIgCondition;
218  boost::condition myReleaseIgCondition;
219  boost::mutex myMonitor;
220 
221  //Force checking the asynchronous messages.
223 
224  };
225 
229  {
230 
231  public:
233  static DtSceneManagerCreator& instance(DtDe& theIG);
234 
236  static void registerInstance(DtDe& theIG,DtSceneManagerCreator* anInstance);
237 
239  virtual DtAgentManager* create(DtDe&);
240  };
241 
242 }
243 
244 #endif


Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)