Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 29, 2009, 7:16:36 PM (15 years ago)
Author:
rgrieder
Message:

Extended Singleton<T> with a exists() method.

File:
1 edited

Legend:

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

    r6417 r6431  
    5151        static T& getInstance()
    5252        {
    53             assert(T::singletonPtr_s != 0);
     53            assert(T::singletonPtr_s != NULL);
    5454            return *T::singletonPtr_s;
     55        }
     56
     57        //! Tells whether the singleton has been created
     58        static bool exists()
     59        {
     60            return (T::singletonPtr_s != NULL);
    5561        }
    5662
     
    6874        Singleton()
    6975        {
    70             assert(T::singletonPtr_s == 0);
     76            assert(T::singletonPtr_s == NULL);
    7177            T::singletonPtr_s = static_cast<T*>(this);
    7278        }
     
    7581        ~Singleton()
    7682        {
    77             assert(T::singletonPtr_s != 0);
    78             T::singletonPtr_s = 0;
     83            assert(T::singletonPtr_s != NULL);
     84            T::singletonPtr_s = NULL;
    7985        }
    8086
Note: See TracChangeset for help on using the changeset viewer.