Changeset 10413
- Timestamp:
- May 2, 2015, 11:20:45 PM (10 years ago)
- Location:
- code/branches/core7/src
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/CMakeLists.txt
r10407 r10413 34 34 NamespaceNode.cc 35 35 Template.cc 36 UpdateListener.cc 36 37 ViewportEventListener.cc 37 38 WindowEventListener.cc -
code/branches/core7/src/libraries/core/Core.cc
r10407 r10413 79 79 #include "object/ObjectList.h" 80 80 #include "module/ModuleInstance.h" 81 #include "UpdateListener.h" 81 82 82 83 namespace orxonox … … 481 482 void Core::preUpdate(const Clock& time) 482 483 { 483 // Update singletons before general ticking 484 ScopedSingletonManager::preUpdate<ScopeID::Root>(time); 484 // Update UpdateListeners before general ticking 485 for (ObjectList<UpdateListener>::iterator it = ObjectList<UpdateListener>::begin(); it != ObjectList<UpdateListener>::end(); ++it) 486 it->preUpdate(time); 485 487 if (this->bGraphicsLoaded_) 486 488 { … … 489 491 // Update GUI 490 492 this->guiManager_->preUpdate(time); 491 // Update singletons before general ticking492 ScopedSingletonManager::preUpdate<ScopeID::Graphics>(time);493 493 } 494 494 // Process console events and status line … … 501 501 void Core::postUpdate(const Clock& time) 502 502 { 503 // Update singletons just before rendering 504 ScopedSingletonManager::postUpdate<ScopeID::Root>(time); 503 // Update UpdateListeners just before rendering 504 for (ObjectList<UpdateListener>::iterator it = ObjectList<UpdateListener>::begin(); it != ObjectList<UpdateListener>::end(); ++it) 505 it->postUpdate(time); 505 506 if (this->bGraphicsLoaded_) 506 507 { 507 // Update singletons just before rendering508 ScopedSingletonManager::postUpdate<ScopeID::Graphics>(time);509 508 // Render (doesn't throw) 510 509 this->graphicsManager_->postUpdate(time); -
code/branches/core7/src/libraries/core/CorePrereqs.h
r10407 r10413 209 209 class Thread; 210 210 class ThreadPool; 211 class UpdateListener; 211 212 class ViewportEventListener; 212 213 template <class T> -
code/branches/core7/src/libraries/core/singleton/ScopedSingletonManager.cc
r10407 r10413 41 41 return managers; 42 42 } 43 /*static*/ ScopedSingletonManager::ManagerMultiMap& ScopedSingletonManager::getManagersByScope()44 {45 static ManagerMultiMap managers;46 return managers;47 }48 43 49 44 /*static*/ void ScopedSingletonManager::addManager(ScopedSingletonManager* manager) 50 45 { 51 46 getManagers()[manager->className_] = manager; 52 getManagersByScope().insert(std::make_pair(manager->scope_, manager));53 47 } 54 48 } -
code/branches/core7/src/libraries/core/singleton/ScopedSingletonManager.h
r10407 r10413 68 68 namespace orxonox 69 69 { 70 class Destroyable;71 72 70 /** 73 @brief Base class of ClassScopedSingletonManager, implements some static functions 74 used to dispatch calls to preUpdate and postUpdate to all instances of this class. 75 It also keeps track of all existing ScopedSingletonManagers and stores them in a 76 map, sorted by the scope they belong to. 71 @brief Base class of ClassScopedSingletonManager. Keeps track of all existing ScopedSingletonManagers 72 and stores them in a map, sorted by the scope they belong to. 77 73 */ 78 74 class _CoreExport ScopedSingletonManager … … 89 85 static void addManager(ScopedSingletonManager* manager); 90 86 91 /// Calls preUpdate in all instances of ScopedSingletonManager that are registered in the map.92 template<ScopeID::Value scope>93 static void preUpdate(const Clock& time)94 {95 assert(Scope<scope>::isActive());96 for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)97 it->second->preUpdate(time);98 }99 virtual void preUpdate(const Clock& time) = 0;100 101 /// Calls postUpdate in all instances of ScopedSingletonManager that are registered in the map.102 template<ScopeID::Value scope>103 static void postUpdate(const Clock& time)104 {105 assert(Scope<scope>::isActive());106 for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)107 it->second->postUpdate(time);108 }109 virtual void postUpdate(const Clock& time) = 0;110 111 87 static std::map<std::string, ScopedSingletonManager*>& getManagers(); 112 88 typedef std::multimap<ScopeID::Value, ScopedSingletonManager*> ManagerMultiMap; 113 static ManagerMultiMap& getManagersByScope();114 89 115 90 protected: … … 177 152 } 178 153 179 //! Called every frame by the ScopedSingletonManager180 void preUpdate(const Clock& time)181 {182 assert(Scope<scope>::isActive());183 // assuming T inherits Singleton<T>184 singletonPtr_->preUpdateSingleton(time);185 }186 187 //! Called every frame by the ScopedSingletonManager188 void postUpdate(const Clock& time)189 {190 assert(Scope<scope>::isActive());191 // assuming T inherits Singleton<T>192 singletonPtr_->postUpdateSingleton(time);193 }194 195 154 private: 196 155 T* singletonPtr_; ///< Unique instance of the singleton class @a T … … 257 216 } 258 217 259 //! Called every frame by the ScopedSingletonManager260 void preUpdate(const Clock& time)261 {262 assert(Scope<scope>::isActive());263 // assuming T inherits Singleton<T>264 if (singletonPtr_ != NULL)265 singletonPtr_->preUpdateSingleton(time);266 }267 268 //! Called every frame by the ScopedSingletonManager269 void postUpdate(const Clock& time)270 {271 assert(Scope<scope>::isActive());272 // assuming T inherits Singleton<T>273 if (singletonPtr_ != NULL)274 singletonPtr_->postUpdateSingleton(time);275 }276 277 218 private: 278 219 T* singletonPtr_; ///< Unique instance of the singleton class @a T -
code/branches/core7/src/libraries/util/Singleton.h
r10398 r10413 146 146 } 147 147 148 //! Update method called by ClassSingletonManager (if used)149 void preUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->preUpdate(time); }150 //! Empty update method for the static polymorphism151 void preUpdate(const Clock& time) { }152 //! Update method called by ClassSingletonManager (if used)153 void postUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->postUpdate(time); }154 //! Empty update method for the static polymorphism155 void postUpdate(const Clock& time) { }156 157 148 protected: 158 149 //! Constructor sets the singleton instance pointer -
code/branches/core7/src/orxonox/PawnManager.cc
r10407 r10413 37 37 ManageScopedSingleton(PawnManager, ScopeID::Root, false); 38 38 39 RegisterAbstractClass(PawnManager).inheritsFrom< Tickable>();39 RegisterAbstractClass(PawnManager).inheritsFrom<UpdateListener>(); 40 40 41 41 PawnManager::PawnManager() -
code/branches/core7/src/orxonox/PawnManager.h
r8351 r10413 33 33 34 34 #include "util/Singleton.h" 35 #include " tools/interfaces/Tickable.h"35 #include "core/UpdateListener.h" 36 36 37 37 namespace orxonox 38 38 { 39 class _OrxonoxExport PawnManager : public Singleton<PawnManager>, public Tickable39 class _OrxonoxExport PawnManager : public Singleton<PawnManager>, public UpdateListener 40 40 { 41 41 friend class Singleton<PawnManager>; … … 45 45 46 46 virtual void preUpdate(const Clock& time); 47 virtual void postUpdate(const Clock& time) { /*no action*/ } 47 48 48 49 private: -
code/branches/core7/src/orxonox/ShipPartManager.cc
r10407 r10413 37 37 ManageScopedSingleton(ShipPartManager, ScopeID::Root, false); 38 38 39 RegisterAbstractClass(ShipPartManager).inheritsFrom< Tickable>();39 RegisterAbstractClass(ShipPartManager).inheritsFrom<UpdateListener>(); 40 40 41 41 ShipPartManager::ShipPartManager() -
code/branches/core7/src/orxonox/ShipPartManager.h
r10262 r10413 33 33 34 34 #include "util/Singleton.h" 35 #include " tools/interfaces/Tickable.h"35 #include "core/UpdateListener.h" 36 36 37 37 namespace orxonox 38 38 { 39 class _OrxonoxExport ShipPartManager : public Singleton<ShipPartManager>, public Tickable39 class _OrxonoxExport ShipPartManager : public Singleton<ShipPartManager>, public UpdateListener 40 40 { 41 41 friend class Singleton<ShipPartManager>; … … 45 45 46 46 virtual void preUpdate(const Clock& time); 47 virtual void postUpdate(const Clock& time) { /*no action*/ } 47 48 48 49 private: -
code/branches/core7/src/orxonox/overlays/InGameConsole.cc
r10407 r10413 67 67 ManageScopedSingleton(InGameConsole, ScopeID::Graphics, false); 68 68 69 RegisterAbstractClass(InGameConsole).inheritsFrom<WindowEventListener>() ;69 RegisterAbstractClass(InGameConsole).inheritsFrom<WindowEventListener>().inheritsFrom<UpdateListener>(); 70 70 71 71 /** -
code/branches/core7/src/orxonox/overlays/InGameConsole.h
r8858 r10413 39 39 #include "core/WindowEventListener.h" 40 40 #include "core/command/Shell.h" 41 #include "core/UpdateListener.h" 41 42 42 43 namespace orxonox 43 44 { 44 class _OrxonoxExport InGameConsole : public Singleton<InGameConsole>, public ShellListener, public WindowEventListener 45 class _OrxonoxExport InGameConsole : public Singleton<InGameConsole>, public ShellListener, public WindowEventListener, public UpdateListener 45 46 { 46 47 friend class Singleton<InGameConsole>; … … 53 54 54 55 void preUpdate(const Clock& time); 56 void postUpdate(const Clock& time) { /*no action*/ } 55 57 56 58 static void openConsole(); -
code/branches/core7/src/orxonox/sound/SoundManager.cc
r10407 r10413 66 66 } 67 67 68 RegisterAbstractClass(SoundManager).inheritsFrom<Configurable>() ;68 RegisterAbstractClass(SoundManager).inheritsFrom<Configurable>().inheritsFrom<UpdateListener>(); 69 69 70 70 SoundManager::SoundManager() -
code/branches/core7/src/orxonox/sound/SoundManager.h
r9667 r10413 41 41 #include "core/config/Configurable.h" 42 42 #include "core/object/SmartPtr.h" 43 #include "core/UpdateListener.h" 43 44 44 45 // tolua_begin … … 59 60 class _OrxonoxExport SoundManager 60 61 // tolua_end 61 : public Singleton<SoundManager>, public Configurable 62 : public Singleton<SoundManager>, public Configurable, public UpdateListener 62 63 { // tolua_export 63 64 friend class Singleton<SoundManager>; … … 68 69 69 70 void preUpdate(const Clock& time); 71 void postUpdate(const Clock& time) { /*no action*/ } 70 72 void setConfigValues(); 71 73
Note: See TracChangeset
for help on using the changeset viewer.