Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10418 for code/branches/core7


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

improved documentation

Location:
code/branches/core7/src/libraries
Files:
3 edited

Legend:

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

    r10413 r10418  
    3636namespace orxonox
    3737{
     38    /**
     39     * Inherit from UpdateListener if you need to receive calls before or after the game is ticked. All classes inheriting from UpdateListener
     40     * need to be strictly independent of each other and may not rely on a specific order in which all UpdateListeners are called.
     41     *
     42     * If you do have such a dependency between two UpdateListeners, e.g. A::preUpdate() always needs to be called before B::preUpdate(), then
     43     * you need to create a third class C (which inherits from UpdateListener) with the following implementation:
     44     * void C::preUpdate()
     45     * {
     46     *     A::preUpdate();
     47     *     B::preUpdate();
     48     * }
     49     * This is the only way to ensure that A gets called before B. In this example, only C inherits from UpdateListener, while A and B do not.
     50     * Instead they receive the update from C.
     51     */
    3852    class _CoreExport UpdateListener : virtual public Listable
    3953    {
  • 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) \
  • code/branches/core7/src/libraries/util/Singleton.h

    r10413 r10418  
    6868    TestSingleton* TestSingleton::singletonPtr_s = NULL;
    6969    @endcode
    70 
    71     Usually a singleton gets created automatically when it is first used, but it will never
    72     be destroyed (unless the singleton explicitly deletes itself). To allow controlled
    73     construction and destruction, the singleton can be put within a virtual scope. This is
    74     done by registering the singleton class with orxonox::ScopedSingletonManager. To
    75     do so, the ManageScopedSingleton() macro has to be called:
    76 
    77     @code
    78     ManageScopedSingleton(TestSingleton, ScopeID::Graphics, false); // muste be called in a source (*.cc) file
    79     @endcode
    80 
    81     @b Important: If you call ManageScopedSingleton(), you don't have to initialize singletonPtr_s anymore,
    82     because that's already done by the macro.
    83 
    84     Now the singleton TestSingleton gets automatically created if the scope Graphics becomes
    85     active and also gets destroyed if the scope is deactivated.
    86 
    87     Note that not all singletons must register with a scope, but it's recommended.
    8870
    8971    If a class inherits from orxonox::Singleton, it also inherits its functions. The most important
Note: See TracChangeset for help on using the changeset viewer.