Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 24, 2015, 11:19:15 PM (9 years ago)
Author:
landauf
Message:

StaticallyInitializedScopedSingletonWrapper registers ScopedSingletonWrapper in ScopeManager

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  
    11ADD_SOURCE_FILES(CORE_SRC_FILES
    22  Scope.cc
     3  ScopedSingletonIncludes.cc
    34)
  • code/branches/core7/src/libraries/core/singleton/Scope.h

    r10458 r10460  
    7676        template <ScopeID::Value scope>
    7777        friend class Scope;
    78         friend class ScopeListener;
     78        friend class StaticallyInitializedScopedSingletonWrapper;
    7979
    8080        private:
     
    9595
    9696        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() { }
    10399
    104100            //! Gets called if the scope is activated
     
    106102            //! Gets called if the scope is deactivated
    107103            virtual void deactivated() = 0;
     104
     105        public:
     106            inline ScopeID::Value getScope() const
     107                { return this->scope_; }
    108108
    109109        private:
  • code/branches/core7/src/libraries/core/singleton/ScopedSingletonIncludes.h

    r10459 r10460  
    8383            StaticallyInitializedScopedSingletonWrapper(ScopedSingletonWrapper* wrapper) : wrapper_(wrapper) {}
    8484
    85             virtual void load() {}
    86             virtual void unload() {}
     85            virtual void load();
     86            virtual void unload();
    8787
    8888            inline ScopedSingletonWrapper& getWrapper()
  • code/branches/core7/src/libraries/core/singleton/ScopedSingletonWrapper.h

    r10459 r10460  
    5757        @brief Base class of ClassScopedSingletonWrapper.
    5858    */
    59     class _CoreExport ScopedSingletonWrapper
     59    class _CoreExport ScopedSingletonWrapper : public ScopeListener
    6060    {
    6161        public:
    6262            /// Constructor: Initializes all the values
    6363            ScopedSingletonWrapper(const std::string& className, ScopeID::Value scope)
    64                 : className_(className)
    65                 , scope_(scope)
     64                : ScopeListener(scope)
     65                , className_(className)
    6666            { }
    6767            virtual ~ScopedSingletonWrapper() { }
     
    6969        protected:
    7070            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 object
    7271    };
    7372
     
    8988    */
    9089    template <class T, ScopeID::Value scope, bool allowedToFail>
    91     class ClassScopedSingletonWrapper : public ScopedSingletonWrapper, public ScopeListener
     90    class ClassScopedSingletonWrapper : public ScopedSingletonWrapper
    9291    {
    9392    public:
     
    9594        ClassScopedSingletonWrapper(const std::string& className)
    9695            : ScopedSingletonWrapper(className, scope)
    97             , ScopeListener(scope)
    9896            , singletonPtr_(NULL)
    9997        {
     
    145143    */
    146144    template <class T, ScopeID::Value scope>
    147     class ClassScopedSingletonWrapper<T, scope, true> : public ScopedSingletonWrapper, public ScopeListener
     145    class ClassScopedSingletonWrapper<T, scope, true> : public ScopedSingletonWrapper
    148146    {
    149147    public:
     
    151149        ClassScopedSingletonWrapper(const std::string& className)
    152150            : ScopedSingletonWrapper(className, scope)
    153             , ScopeListener(scope)
    154151            , singletonPtr_(NULL)
    155152        {
Note: See TracChangeset for help on using the changeset viewer.