Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 3, 2015, 1:54:43 PM (9 years ago)
Author:
landauf
Message:

improved documentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/libraries/core/singleton/ScopedSingletonManager.h

    r10413 r10418  
    6161    If this macro is called for a singleton, it is registered with ScopedSingletonManager
    6262    and will thus be created if its scope becomes active and destroyed if is deactivated.
     63
     64
     65    Usually a singleton gets created automatically when it is first used, but it will never
     66    be destroyed (unless the singleton explicitly deletes itself). To allow controlled
     67    construction and destruction, the singleton can be put within a virtual scope. This is
     68    done by registering the singleton class with orxonox::ScopedSingletonManager. To
     69    do so, the ManageScopedSingleton() macro has to be called:
     70
     71    @code
     72    ManageScopedSingleton(TestSingleton, ScopeID::Graphics, false); // muste be called in a source (*.cc) file
     73    @endcode
     74
     75    @b Important: If you call ManageScopedSingleton(), you don't have to initialize singletonPtr_s anymore,
     76    because that's already done by the macro.
     77
     78    Now the singleton TestSingleton gets automatically created if the scope Graphics becomes
     79    active and also gets destroyed if the scope is deactivated.
     80
     81    Note that not all singletons must register with a scope, but it's recommended.
     82
    6383*/
    6484#define ManageScopedSingleton(className, scope, allowedToFail) \
Note: See TracChangeset for help on using the changeset viewer.