Changeset 5850 for code/branches/core5/src/libraries
- Timestamp:
- Oct 1, 2009, 11:44:53 AM (15 years ago)
- Location:
- code/branches/core5/src/libraries
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/libraries/core/Core.cc
r5838 r5850 264 264 // create a shell 265 265 this->shell_.reset(new Shell()); 266 267 // Create singletons that always exist (in other libraries) 268 this->rootScope_.reset(new Scope<ScopeID::Root>()); 266 269 } 267 270 … … 289 292 inputManager_->getMousePosition(), graphicsManager_->isFullScreen())); 290 293 294 // Create singletons associated with graphics (in other libraries) 295 graphicsScope_.reset(new Scope<ScopeID::Graphics>()); 296 291 297 unloader.Dismiss(); 292 298 … … 296 302 void Core::unloadGraphics() 297 303 { 298 this->guiManager_.reset();; 299 this->inputManager_.reset();; 304 this->graphicsScope_.reset(); 305 this->guiManager_.reset(); 306 this->inputManager_.reset(); 300 307 this->graphicsManager_.reset(); 301 308 … … 420 427 void Core::preUpdate(const Clock& time) 421 428 { 429 // singletons from other libraries 430 Scope<ScopeID::Root>::update(time); 422 431 if (this->bGraphicsLoaded_) 423 432 { … … 426 435 // process gui events 427 436 this->guiManager_->update(time); 437 // graphics singletons from other libraries 438 Scope<ScopeID::Graphics>::update(time); 428 439 } 429 440 // process thread commands -
code/branches/core5/src/libraries/core/Core.h
r5836 r5850 36 36 #include <boost/scoped_ptr.hpp> 37 37 #include "util/OutputHandler.h" 38 #include "util/Scope.h" 38 39 #include "util/ScopeGuard.h" 39 40 #include "util/Singleton.h" … … 100 101 scoped_ptr<InputManager> inputManager_; //!< Interface to OIS 101 102 scoped_ptr<GUIManager> guiManager_; //!< Interface to GUI 103 scoped_ptr<Scope<ScopeID::Root> > rootScope_; 104 scoped_ptr<Scope<ScopeID::Graphics> > graphicsScope_; 102 105 103 106 bool bGraphicsLoaded_; -
code/branches/core5/src/libraries/util/Scope.h
r5738 r5850 31 31 32 32 #include "UtilPrereqs.h" 33 33 34 #include <cassert> 35 #include <map> 34 36 #include <set> 35 #include <map>36 37 #include "Debug.h" 37 38 … … 45 46 enum Value 46 47 { 47 GSRoot, 48 GSGraphics, 49 GSLevel 48 Root, 49 Graphics 50 50 }; 51 51 } 52 52 53 class ScopeListener; // Forward declaration 53 // Forward declarations 54 class ScopeListener; 55 class Clock; 54 56 55 57 /** … … 87 89 //! Gets called if the scope is deactivated 88 90 virtual void deactivated() = 0; 91 //! Gets called if the scope is updated 92 virtual void updated(const Clock& time) = 0; 89 93 90 94 private: … … 136 140 return (ScopeManager::instanceCounts_s[scope] > 0); 137 141 } 142 143 //! Update method for the ScopeListeners (to implement singleton updates) 144 static void update(const Clock& time) 145 { 146 if (isActive()) 147 { 148 for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); ) 149 (*(it++))->updated(time); 150 } 151 } 138 152 }; 139 153 } -
code/branches/core5/src/libraries/util/ScopedSingleton.h
r5802 r5850 37 37 namespace orxonox 38 38 { 39 class Clock; 39 40 /** 40 41 @brief … … 59 60 assert(Scope<scope>::isActive()); 60 61 61 if (!T::singletonPtr_s && Scope<scope>::isActive())62 if (!T::singletonPtr_s) 62 63 T::singletonPtr_s = new T(); 63 64 64 65 return *T::singletonPtr_s; 65 66 } 67 68 //! Update method for singletons like the ingame console 69 virtual void updated(const Clock& time) { static_cast<T*>(this)->update(time); } 70 //! Empty update method for the static polymorphism 71 void update(const Clock& time) { } 66 72 67 73 protected: … … 85 91 { 86 92 // The ScopedSingleton shouldn't be active bevor the scope is activated -> always assertion failed 87 assert( T::singletonPtr_s == 0 &&false);93 assert(false); 88 94 } 89 95
Note: See TracChangeset
for help on using the changeset viewer.