Changeset 6038 for sandbox/src/libraries/util
- Timestamp:
- Nov 5, 2009, 9:22:22 PM (15 years ago)
- Location:
- sandbox
- Files:
-
- 1 deleted
- 4 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
sandbox
- Property svn:mergeinfo changed
-
sandbox/src/libraries/util/CMakeLists.txt
r5782 r6038 19 19 20 20 SET_SOURCE_FILES(UTIL_SRC_FILES 21 CRC32.cc22 21 Exception.cc 23 ExprParser.cc24 22 Math.cc 25 23 MultiType.cc 24 Scope.cc 25 StringUtils.cc 26 COMPILATION_BEGIN StableCompilation.cc 27 Clock.cc 28 CRC32.cc 29 ExprParser.cc 26 30 OutputBuffer.cc 27 31 OutputHandler.cc 28 Scope.cc29 32 SignalHandler.cc 30 33 Sleep.cc 31 StringUtils.cc32 34 SubString.cc 35 COMPILATION_END 33 36 ) 34 37 -
sandbox/src/libraries/util/Clock.h
r6035 r6038 31 31 32 32 #include "UtilPrereqs.h" 33 #include "OgreForwardRefs.h" 33 34 namespace Ogre { class Timer; } 34 35 35 36 namespace orxonox -
sandbox/src/libraries/util/Scope.h
r5738 r6038 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 } -
sandbox/src/libraries/util/UtilPrereqs.h
r5738 r6038 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.