Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jul 29, 2009, 10:27:10 PM (15 years ago)
Author:
rgrieder
Message:

Derived all singletons implemented in a usual manner from orxonox::Singleton<T>.
This resolves inconsistencies with the singletonPtr_s variable in case of exceptions (asserts were being triggered then).
And while at it replaced singletonRef_s with singletonPtr_s for it to be less misleading (as fabian has already pointed out).

Location:
code/branches/resource/src/orxonox/overlays/notifications
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/resource/src/orxonox/overlays/notifications/NotificationManager.cc

    r3196 r3366  
    4646    const std::string NotificationManager::NONE = "none";
    4747
    48     NotificationManager* NotificationManager::singletonRef_s = NULL;
     48    NotificationManager* NotificationManager::singletonPtr_s = NULL;
    4949
    5050    /**
     
    5555    {
    5656        RegisterRootObject(NotificationManager);
    57 
    58         assert(singletonRef_s == 0);
    59         singletonRef_s = this;
    6057
    6158        this->highestIndex_ = 0;
     
    7067    }
    7168
    72     /**
    73     @brief
    74         Returns the current (and single) instance of the NotificationManager. Creates one, if there isn't one to begin with.
    75     @return
    76         Returns a reference to the single instance of the NotificationManager.
    77     */
    78     /*static*/ NotificationManager & NotificationManager::getInstance()
    79     {
    80         assert(singletonRef_s);
    81         return *singletonRef_s;
    82     }
    83    
    8469    /**
    8570    @brief
  • code/branches/resource/src/orxonox/overlays/notifications/NotificationManager.h

    r3196 r3366  
    4040#include <map>
    4141#include <string>
     42
     43#include "util/Singleton.h"
    4244#include "core/OrxonoxClass.h"
    4345
     
    5254        Damian 'Mozork' Frick
    5355    */
    54     class _OrxonoxExport NotificationManager : public OrxonoxClass
     56    class _OrxonoxExport NotificationManager : public Singleton<NotificationManager>, public OrxonoxClass
    5557    {
     58            friend class Singleton<NotificationManager>;
    5659        public:
    5760            NotificationManager();
     
    6063            static const std::string ALL;
    6164            static const std::string NONE;
    62 
    63             static NotificationManager & getInstance(); //! Returns a reference to the single instance of the NotificationManager.
    6465
    6566            bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager.
     
    8889
    8990        private:
    90             static NotificationManager* singletonRef_s;
     91            static NotificationManager* singletonPtr_s;
    9192
    9293            int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that  no key appears twice.
Note: See TracChangeset for help on using the changeset viewer.