Changeset 10460 for code/branches/core7/src/libraries/core/singleton
- Timestamp:
- May 24, 2015, 11:19:15 PM (10 years ago)
- Location:
- code/branches/core7/src/libraries/core/singleton
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/singleton/CMakeLists.txt
r10458 r10460 1 1 ADD_SOURCE_FILES(CORE_SRC_FILES 2 2 Scope.cc 3 ScopedSingletonIncludes.cc 3 4 ) -
code/branches/core7/src/libraries/core/singleton/Scope.h
r10458 r10460 76 76 template <ScopeID::Value scope> 77 77 friend class Scope; 78 friend class S copeListener;78 friend class StaticallyInitializedScopedSingletonWrapper; 79 79 80 80 private: … … 95 95 96 96 protected: 97 //! Constructor: Registers the instance. 98 ScopeListener(ScopeID::Value scope) : scope_(scope), bActivated_(false) 99 { ScopeManager::getListeners()[this->scope_].insert(this); } 100 //! Destructor: Unregisters the instance. 101 virtual ~ScopeListener() 102 { ScopeManager::getListeners()[this->scope_].erase(this); } 97 ScopeListener(ScopeID::Value scope) : scope_(scope), bActivated_(false) { } 98 virtual ~ScopeListener() { } 103 99 104 100 //! Gets called if the scope is activated … … 106 102 //! Gets called if the scope is deactivated 107 103 virtual void deactivated() = 0; 104 105 public: 106 inline ScopeID::Value getScope() const 107 { return this->scope_; } 108 108 109 109 private: -
code/branches/core7/src/libraries/core/singleton/ScopedSingletonIncludes.h
r10459 r10460 83 83 StaticallyInitializedScopedSingletonWrapper(ScopedSingletonWrapper* wrapper) : wrapper_(wrapper) {} 84 84 85 virtual void load() {}86 virtual void unload() {}85 virtual void load(); 86 virtual void unload(); 87 87 88 88 inline ScopedSingletonWrapper& getWrapper() -
code/branches/core7/src/libraries/core/singleton/ScopedSingletonWrapper.h
r10459 r10460 57 57 @brief Base class of ClassScopedSingletonWrapper. 58 58 */ 59 class _CoreExport ScopedSingletonWrapper 59 class _CoreExport ScopedSingletonWrapper : public ScopeListener 60 60 { 61 61 public: 62 62 /// Constructor: Initializes all the values 63 63 ScopedSingletonWrapper(const std::string& className, ScopeID::Value scope) 64 : className_(className)65 , scope_(scope)64 : ScopeListener(scope) 65 , className_(className) 66 66 { } 67 67 virtual ~ScopedSingletonWrapper() { } … … 69 69 protected: 70 70 const std::string className_; ///< The name of the scoped singleton class that is managed by this object 71 const ScopeID::Value scope_; ///< The scope of the singleton that is managed by this object72 71 }; 73 72 … … 89 88 */ 90 89 template <class T, ScopeID::Value scope, bool allowedToFail> 91 class ClassScopedSingletonWrapper : public ScopedSingletonWrapper , public ScopeListener90 class ClassScopedSingletonWrapper : public ScopedSingletonWrapper 92 91 { 93 92 public: … … 95 94 ClassScopedSingletonWrapper(const std::string& className) 96 95 : ScopedSingletonWrapper(className, scope) 97 , ScopeListener(scope)98 96 , singletonPtr_(NULL) 99 97 { … … 145 143 */ 146 144 template <class T, ScopeID::Value scope> 147 class ClassScopedSingletonWrapper<T, scope, true> : public ScopedSingletonWrapper , public ScopeListener145 class ClassScopedSingletonWrapper<T, scope, true> : public ScopedSingletonWrapper 148 146 { 149 147 public: … … 151 149 ClassScopedSingletonWrapper(const std::string& className) 152 150 : ScopedSingletonWrapper(className, scope) 153 , ScopeListener(scope)154 151 , singletonPtr_(NULL) 155 152 {
Note: See TracChangeset
for help on using the changeset viewer.