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/objects/quest
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/resource/src/orxonox/objects/quest/QuestDescription.h

    r3196 r3366  
    5454        Damian 'Mozork' Frick
    5555    */
    56     class _OrxonoxExport QuestDescription
     56    class _OrxonoxExport QuestDescription : public BaseObject
     57    {
    5758// tolua_end
    58         : public BaseObject
    59     { // tolua_export
    6059        public:
    6160            QuestDescription(BaseObject* creator);
  • code/branches/resource/src/orxonox/objects/quest/QuestManager.cc

    r3349 r3366  
    4747{
    4848    //! Pointer to the current (and single) instance of this class.
    49     /*static*/ QuestManager* QuestManager::singletonRef_s = NULL;
     49    /*static*/ QuestManager* QuestManager::singletonPtr_s = NULL;
    5050
    5151    /**
     
    5858    {
    5959        RegisterRootObject(QuestManager);
    60 
    61         assert(singletonRef_s == 0);
    62         singletonRef_s = this;
    6360    }
    6461
     
    7067    {
    7168
    72     }
    73 
    74     /**
    75     @brief
    76         Returns a reference to the current (and single) instance of the QuestManager, and creates one if there isn't one to begin with.
    77     @return
    78         Returns a reference to the single instance of the Quest Manager.
    79     */
    80     /*static*/ QuestManager & QuestManager::getInstance()
    81     {
    82         assert(singletonRef_s);
    83         return *singletonRef_s;
    8469    }
    8570
  • code/branches/resource/src/orxonox/objects/quest/QuestManager.h

    r3196 r3366  
    4040#include <map>
    4141#include <string>
     42
     43#include "util/Singleton.h"
    4244#include "core/OrxonoxClass.h"
    4345
     
    7173        Damian 'Mozork' Frick
    7274    */
    73     class _OrxonoxExport QuestManager
    74 // tolua_end
    75         : public OrxonoxClass
    76 // tolua_begin
     75    class _OrxonoxExport QuestManager : public Singleton<QuestManager>, public orxonox::OrxonoxClass
    7776    {
    7877// tolua_end
     78            friend class Singleton<QuestManager>;
    7979        public:
    8080            QuestManager();
    8181            virtual ~QuestManager();
    8282
    83             static QuestManager& getInstance(); // tolua_export //!< Returns a reference to the single instance of the Quest Manager.
     83            //! Returns a reference to the single instance of the Quest Manager.
     84            static QuestManager& getInstance() { return Singleton<QuestManager>::getInstance(); } // tolua_export
    8485
    8586            bool registerQuest(Quest* quest); //!< Registers a Quest in the QuestManager.
     
    9293
    9394        private:
    94             static QuestManager* singletonRef_s;
     95            static QuestManager* singletonPtr_s;
    9596
    9697            std::map<std::string, Quest*> questMap_; //!< All Quests registered by their id's.
Note: See TracChangeset for help on using the changeset viewer.