Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 4, 2015, 9:12:21 PM (9 years ago)
Author:
landauf
Message:

merged branch core7 back to trunk

Location:
code/trunk
Files:
4 deleted
6 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/util/CMakeLists.txt

    r9765 r10624  
    2626  CRC32.cc
    2727  ExprParser.cc
    28   Scope.cc
    29   ScopedSingletonManager.cc
    3028  SharedPtr.cc
    3129  Sleep.cc
  • code/trunk/src/libraries/util/SharedPtr.h

    r8351 r10624  
    138138        OtherClass* other3 = new OtherClass(object);        // "
    139139
    140     }                                                       // The SmartPtr "object" is destroyed at the end of the scope,
     140    }                                                       // The SharedPtr "object" is destroyed at the end of the scope,
    141141                                                            // but the three instances of OtherClass keep the object alive
    142142                                                            // until they are all destroyed.
  • code/trunk/src/libraries/util/Singleton.h

    r8858 r10624  
    5252        public:
    5353            TestSingleton();                                // public constructor because we may want to manage this singleton
    54                                                             //     with an orxonox::ScopedSingletonManager (see below)
     54                                                            //     with an orxonox::ScopedSingletonWrapper
    5555            virtual ~TestSingleton();                       // public destructor
    5656
     
    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
     
    11294#include "UtilPrereqs.h"
    11395
    114 #include <cassert>
    11596#include <cstring>
     97#include <typeinfo>
     98
     99#include "OrxAssert.h"
    116100
    117101namespace orxonox
     
    134118        static T& getInstance()
    135119        {
    136             assert(T::singletonPtr_s != NULL);
     120            OrxVerify(T::singletonPtr_s != NULL, "T=" << typeid(T).name());
    137121            return *T::singletonPtr_s;
    138122        }
     
    144128        }
    145129
    146         //! Update method called by ClassSingletonManager (if used)
    147         void preUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->preUpdate(time); }
    148         //! Empty update method for the static polymorphism
    149         void preUpdate(const Clock& time) { }
    150         //! Update method called by ClassSingletonManager (if used)
    151         void postUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->postUpdate(time); }
    152         //! Empty update method for the static polymorphism
    153         void postUpdate(const Clock& time) { }
    154 
    155130    protected:
    156131        //! Constructor sets the singleton instance pointer
    157132        Singleton()
    158133        {
    159             assert(T::singletonPtr_s == NULL);
     134            OrxVerify(T::singletonPtr_s == NULL, "T=" << typeid(T).name());
    160135            T::singletonPtr_s = static_cast<T*>(this);
    161136        }
     
    164139        virtual ~Singleton()
    165140        {
    166             assert(T::singletonPtr_s != NULL);
     141            OrxVerify(T::singletonPtr_s != NULL, "T=" << typeid(T).name());
    167142            T::singletonPtr_s = NULL;
    168143        }
  • code/trunk/src/libraries/util/UtilPrereqs.h

    r9550 r10624  
    6262
    6363//-----------------------------------------------------------------------
    64 // Enums
    65 //-----------------------------------------------------------------------
    66 
    67 namespace orxonox
    68 {
    69     namespace ScopeID
    70     {
    71         //!A list of available scopes for the Scope template.
    72         enum Value
    73         {
    74             Root,
    75             Graphics
    76         };
    77     }
    78 }
    79 
    80 //-----------------------------------------------------------------------
    8164// Forward declarations
    8265//-----------------------------------------------------------------------
     
    9679    class OutputManager;
    9780    class OutputStream;
    98     template <ScopeID::Value>
    99     class Scope;
    100     template <class, ScopeID::Value>
    101     class ScopedSingleton;
    10281    class ScopeListener;
    10382    template <class T>
  • code/trunk/src/libraries/util/output/OutputDefinitions.h

    r10317 r10624  
    170170            {
    171171                REGISTER_OUTPUT_SUBCONTEXT(misc, executor);
    172                 REGISTER_OUTPUT_SUBCONTEXT(misc, factory);
    173172                REGISTER_OUTPUT_SUBCONTEXT(misc, gui);
    174173                REGISTER_OUTPUT_SUBCONTEXT(misc, overlays);
Note: See TracChangeset for help on using the changeset viewer.