Changeset 5850 for code/branches/core5/src/libraries/util
- Timestamp:
- Oct 1, 2009, 11:44:53 AM (15 years ago)
- Location:
- code/branches/core5/src/libraries/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.