Changeset 5929 for code/trunk/src/libraries/util
- Timestamp:
- Oct 12, 2009, 8:20:07 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 1 deleted
- 5 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
/code/branches/core5 (added) merged: 5768-5769,5772,5775-5780,5783-5785,5791-5792,5795-5807,5809-5814,5816-5832,5836-5839,5842-5853,5855-5899,5904-5922,5924-5928
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/util/CMakeLists.txt
r5781 r5929 19 19 20 20 SET_SOURCE_FILES(UTIL_SRC_FILES 21 Clipboard.cc22 CRC32.cc23 21 Exception.cc 24 ExprParser.cc25 22 Math.cc 26 23 MultiType.cc 24 Scope.cc 25 StringUtils.cc 26 COMPILATION_BEGIN StableCompilation.cc 27 Clipboard.cc 28 Clock.cc 29 CRC32.cc 30 ExprParser.cc 27 31 OutputBuffer.cc 28 32 OutputHandler.cc 29 Scope.cc30 33 SignalHandler.cc 31 34 Sleep.cc 32 StringUtils.cc33 35 SubString.cc 36 COMPILATION_END 34 37 ) 35 38 -
code/trunk/src/libraries/util/Scope.h
r5738 r5929 31 31 32 32 #include "UtilPrereqs.h" 33 33 34 #include <cassert> 35 #include <map> 34 36 #include <set> 35 #include <map> 37 36 38 #include "Debug.h" 39 #include "ScopeGuard.h" 37 40 38 41 namespace orxonox 39 42 { 40 namespace ScopeID41 {42 /**43 @brief A list of available scopes for the Scope template.44 */45 enum Value46 {47 GSRoot,48 GSGraphics,49 GSLevel50 };51 }52 53 class ScopeListener; // Forward declaration54 55 43 /** 56 44 @brief The ScopeManager stores the variables of the scope templates in a statically linked context. … … 77 65 protected: 78 66 //! Constructor: Registers the instance. 79 ScopeListener(ScopeID::Value scope) : scope_(scope) 67 ScopeListener(ScopeID::Value scope) : scope_(scope), bActivated_(false) 80 68 { ScopeManager::listeners_s[this->scope_].insert(this); } 81 69 //! Destructor: Unregisters the instance. … … 90 78 private: 91 79 ScopeID::Value scope_; //!< Store the scope to unregister on destruction 80 bool bActivated_; 92 81 }; 93 82 … … 105 94 Scope() 106 95 { 107 ScopeManager::instanceCounts_s[scope]++; 108 assert(ScopeManager::instanceCounts_s[scope] > 0); 109 if (ScopeManager::instanceCounts_s[scope] == 1) 96 try 110 97 { 111 for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); ) 112 (*(it++))->activated(); 98 ScopeManager::instanceCounts_s[scope]++; 99 assert(ScopeManager::instanceCounts_s[scope] > 0); 100 if (ScopeManager::instanceCounts_s[scope] == 1) 101 { 102 Loki::ScopeGuard deactivator = Loki::MakeObjGuard(*this, &Scope::deactivateListeners); 103 for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); ) 104 { 105 (*it)->activated(); 106 (*(it++))->bActivated_ = true; 107 } 108 deactivator.Dismiss(); 109 } 110 } 111 catch (...) 112 { 113 ScopeManager::instanceCounts_s[scope]--; 114 throw; 113 115 } 114 116 } … … 125 127 126 128 if (ScopeManager::instanceCounts_s[scope] == 0) 129 this->deactivateListeners(); 130 } 131 132 void deactivateListeners() 133 { 134 for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); ) 127 135 { 128 for (typename std::set<ScopeListener*>::iterator it = ScopeManager::listeners_s[scope].begin(); it != ScopeManager::listeners_s[scope].end(); ) 129 (*(it++))->deactivated(); 136 if ((*it)->bActivated_) 137 { 138 try 139 { (*it)->deactivated(); } 140 catch (...) 141 { COUT(0) << "ScopeListener::deactivated() failed! This MUST NOT happen, fix it!" << std::endl; } 142 (*(it++))->bActivated_ = false; 143 } 144 else 145 ++it; 130 146 } 131 147 } -
code/trunk/src/libraries/util/Singleton.h
r5738 r5929 55 55 } 56 56 57 //! Update method called by ClassSingletonManager (if used) 58 void updateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->update(time); } 59 //! Empty update method for the static polymorphism 60 void update(const Clock& time) { } 61 57 62 protected: 58 63 //! Constructor sets the singleton instance pointer -
code/trunk/src/libraries/util/UtilPrereqs.h
r5738 r5929 28 28 29 29 /** 30 @file 31 @brief Contains all the necessary forward declarations for all classes and structs. 30 @file 31 @brief 32 Shared library macros, enums, constants and forward declarations for the util library 32 33 */ 33 34 … … 40 41 // Shared library settings 41 42 //----------------------------------------------------------------------- 43 42 44 #if defined(ORXONOX_PLATFORM_WINDOWS) && !defined( UTIL_STATIC_BUILD ) 43 45 # ifdef UTIL_SHARED_BUILD … … 56 58 #endif 57 59 60 //----------------------------------------------------------------------- 61 // Enums 62 //----------------------------------------------------------------------- 63 64 namespace orxonox 65 { 66 namespace ScopeID 67 { 68 //!A list of available scopes for the Scope template. 69 enum Value 70 { 71 Root, 72 Graphics 73 }; 74 } 75 } 58 76 59 77 //----------------------------------------------------------------------- … … 63 81 namespace orxonox 64 82 { 83 class Clock; 65 84 class Exception; 66 85 class ExprParser; … … 71 90 class OutputBufferListener; 72 91 class OutputHandler; 92 template <ScopeID::Value> 93 class Scope; 94 template <class, ScopeID::Value> 95 class ScopedSingleton; 96 class ScopeListener; 73 97 class SignalHandler; 98 template <class T> 99 class Singleton; 74 100 class SubString; 75 101 }
Note: See TracChangeset
for help on using the changeset viewer.