Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 29, 2009, 10:27:10 PM (15 years ago)
Author:
rgrieder
Message:

Derived all singletons implemented in a usual manner from orxonox::Singleton<T>.
This resolves inconsistencies with the singletonPtr_s variable in case of exceptions (asserts were being triggered then).
And while at it replaced singletonRef_s with singletonPtr_s for it to be less misleading (as fabian has already pointed out).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/resource/src/util/Singleton.h

    r3364 r3366  
    4040        Usage:
    4141        Inherit publicly from Singleton<MyClass> and provide access to
    42         MyClass::singletonRef_s.
    43         This can be done with a friend declaration.
     42        MyClass::singletonPtr_s.
     43        This can easily be done with a friend declaration.
    4444    */
    4545    template <class T>
     
    5050        static T& getInstance()
    5151        {
    52             assert(T::singletonRef_s != NULL);
    53             return *T::singletonRef_s;
     52            assert(T::singletonPtr_s != NULL);
     53            return *T::singletonPtr_s;
    5454        }
    5555
    5656    protected:
    57         // Constructor sets the singleton instance pointer
     57        //! Constructor sets the singleton instance pointer
    5858        Singleton()
    5959        {
    60             assert(T::singletonRef_s == NULL);
    61             T::singletonRef_s = static_cast<T*>(this);
     60            assert(T::singletonPtr_s == NULL);
     61            T::singletonPtr_s = static_cast<T*>(this);
    6262        }
    63         // Constructor resets the singleton instance pointer
     63
     64        //! Constructor resets the singleton instance pointer
    6465        ~Singleton()
    6566        {
    66             assert(T::singletonRef_s != NULL);
    67             T::singletonRef_s = NULL;
     67            assert(T::singletonPtr_s != NULL);
     68            T::singletonPtr_s = NULL;
    6869        }
    6970
Note: See TracChangeset for help on using the changeset viewer.