Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 12, 2008, 11:23:32 PM (16 years ago)
Author:
rgrieder
Message:
  • minor Singleton changes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/core/InputManager.cc

    r1034 r1035  
    4343    @brief The reference to the singleton
    4444  */
    45   InputManager* InputManager::singletonRef_s = 0;
     45  //InputManager* InputManager::singletonRef_s = 0;
    4646
    4747  /**
     
    6060  InputManager::~InputManager()
    6161  {
    62     this->destroyDevices();
     62    this->destroy();
    6363  }
    6464
    6565  /**
    6666    @brief The one instance of the InputManager is stored in this function.
    67     @return The pointer to the only instance of the InputManager
    68   */
    69   InputManager *InputManager::getSingleton()
    70   {
    71     if (!singletonRef_s)
    72       singletonRef_s = new InputManager();
    73     return singletonRef_s;
     67    @return A reference to the only instance of the InputManager
     68  */
     69  InputManager& InputManager::getSingleton()
     70  {
     71    static InputManager theOnlyInstance;
     72    return theOnlyInstance;
    7473  }
    7574
     
    142141
    143142  /**
    144     @brief Destroys all the created input devices.
    145   */
    146   void InputManager::destroyDevices()
    147   {
    148     COUT(ORX_DEBUG) << "*** InputManager: Destroying InputManager..." << std::endl;
     143    @brief Destroys all the created input devices and handlers.
     144  */
     145  void InputManager::destroy()
     146  {
     147    COUT(ORX_DEBUG) << "*** InputManager: Destroying ..." << std::endl;
    149148    if (this->mouse_)
    150149      this->inputSystem_->destroyInputObject(mouse_);
     
    157156    this->keyboard_      = 0;
    158157    this->inputSystem_   = 0;
     158
     159    if (this->handlerBuffer_)
     160      delete this->handlerBuffer_;
     161    if (this->handlerGame_)
     162      delete this->handlerGame_;
     163    if (this->handlerGUI_)
     164      delete this->handlerGUI_;
     165
     166    this->handlerBuffer_ = 0;
     167    this->handlerGame_   = 0;
     168    this->handlerGUI_    = 0;
     169
    159170    COUT(ORX_DEBUG) << "*** InputManager: Destroying done." << std::endl;
    160   }
    161 
    162   /**
    163     @brief Destroys the singleton.
    164   */
    165   void InputManager::destroySingleton()
    166   {
    167     if (singletonRef_s)
    168       delete singletonRef_s;
    169     singletonRef_s = 0;
    170171  }
    171172
Note: See TracChangeset for help on using the changeset viewer.