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/core/input
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/resource/src/core/input/InputManager.cc

    r3327 r3366  
    6464    InputHandler InputHandler::EMPTY;
    6565
    66     InputManager* InputManager::singletonRef_s = 0;
     66    InputManager* InputManager::singletonPtr_s = 0;
    6767
    6868    //! Defines the |= operator for easier use.
     
    9393        RegisterRootObject(InputManager);
    9494
    95         assert(singletonRef_s == 0);
    96         singletonRef_s = this;
    97 
    9895        CCOUT(4) << "Constructing..." << std::endl;
    9996
     
    138135        }
    139136
     137        CCOUT(4) << "Construction complete." << std::endl;
    140138        internalState_ = Nothing;
    141         CCOUT(4) << "Construction complete." << std::endl;
    142139    }
    143140
     
    297294
    298295        CCOUT(4) << "Destruction complete." << std::endl;
    299         singletonRef_s = 0;
    300296    }
    301297
  • code/branches/resource/src/core/input/InputManager.h

    r3327 r3366  
    3737#include <vector>
    3838
     39#include "util/Singleton.h"
    3940#include "core/WindowEventListener.h"
    4041#include "InputState.h"
     
    6263          If the OIS::InputManager or the Keyboard fail, an exception is thrown.
    6364    */
    64     class _CoreExport InputManager : public WindowEventListener
     65    class _CoreExport InputManager : public Singleton<InputManager>, public WindowEventListener
    6566    {
     67        friend class Singleton<InputManager>;
    6668    public:
    6769        //! Represents internal states of the InputManager.
     
    168170            { return this->oisInputManager_; }
    169171
    170         //! Returns a reference to the singleton instance
    171         static InputManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
    172 
    173172    private: // functions
    174173        // don't mess with a Singleton
     
    211210        std::set<InputState*>               stateDestroyRequests_; //!< Requests to destroy a state
    212211
    213         static InputManager*                singletonRef_s;        //!< Pointer reference to the singleton
     212        static InputManager*                singletonPtr_s;        //!< Pointer reference to the singleton
    214213    };
    215214}
Note: See TracChangeset for help on using the changeset viewer.