Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 1, 2009, 11:44:53 AM (15 years ago)
Author:
rgrieder
Message:

Moved the singleton creation/destruction mess to the Core class by using just two possible Scopes:

  • ScopeID::Root for singletons that may always persists
  • ScopeID::Graphics for singletons that only work when graphics was loaded
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/libraries/util/ScopedSingleton.h

    r5802 r5850  
    3737namespace orxonox
    3838{
     39    class Clock;
    3940    /**
    4041    @brief
     
    5960                assert(Scope<scope>::isActive());
    6061
    61                 if (!T::singletonPtr_s && Scope<scope>::isActive())
     62                if (!T::singletonPtr_s)
    6263                    T::singletonPtr_s = new T();
    6364
    6465                return *T::singletonPtr_s;
    6566            }
     67
     68            //! Update method for singletons like the ingame console
     69            virtual void updated(const Clock& time) { static_cast<T*>(this)->update(time); }
     70            //! Empty update method for the static polymorphism
     71            void update(const Clock& time) { }
    6672
    6773        protected:
     
    8591            {
    8692                // The ScopedSingleton shouldn't be active bevor the scope is activated -> always assertion failed
    87                 assert(T::singletonPtr_s == 0 && false);
     93                assert(false);
    8894            }
    8995
Note: See TracChangeset for help on using the changeset viewer.