Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1035


Ignore:
Timestamp:
Apr 12, 2008, 11:23:32 PM (16 years ago)
Author:
rgrieder
Message:
  • minor Singleton changes
Location:
code/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/GraphicsEngine.cc

    r1032 r1035  
    2525 *
    2626 */
     27
    2728 /**
    2829    @file orxonox.cc
  • code/trunk/src/orxonox/GraphicsEngine.h

    r1032 r1035  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *
     4 *
     5 *   License notice:
     6 *
     7 *   This program is free software; you can redistribute it and/or
     8 *   modify it under the terms of the GNU General Public License
     9 *   as published by the Free Software Foundation; either version 2
     10 *   of the License, or (at your option) any later version.
     11 *
     12 *   This program is distributed in the hope that it will be useful,
     13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 *   GNU General Public License for more details.
     16 *
     17 *   You should have received a copy of the GNU General Public License
     18 *   along with this program; if not, write to the Free Software
     19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     20 *
     21 *   Author:
     22 *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
     23 *   Co-authors:
     24 *      Reto Grieder
     25 *
     26 */
     27
    128/**
    2   @file GraphicsEngine.h
    3   @brief Graphics Engine
     29  @file
     30  @brief Declaration of GraphicsEngine Singleton.
    431  @author Benjamin Knecht <beni_at_orxonox.net>
    532 */
     
    4269
    4370      static GraphicsEngine& getSingleton();
     71      static GraphicsEngine* getSingletonPtr() { return &getSingleton(); }
    4472
    4573    private:
    4674      // don't mess with singletons
    4775      GraphicsEngine();
     76      ~GraphicsEngine();
    4877      GraphicsEngine(GraphicsEngine&) { }
    49       ~GraphicsEngine();
    5078
    5179      //! Method called by the LogListener from Ogre
  • code/trunk/src/orxonox/Orxonox.cc

    r1032 r1035  
    113113      delete this->orxonoxHUD_;
    114114    Loader::close();
    115     InputManager::destroySingleton();
     115    InputManager::getSingleton().destroy();
    116116    if (this->auMan_)
    117117      delete this->auMan_;
     
    329329  void Orxonox::setupInputSystem()
    330330  {
    331     inputHandler_ = InputManager::getSingleton();
     331    inputHandler_ = &InputManager::getSingleton();
    332332    if (!inputHandler_->initialise(ogre_->getWindowHandle(),
    333333          ogre_->getWindowWidth(), ogre_->getWindowHeight()))
  • 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
  • code/trunk/src/orxonox/core/InputManager.h

    r1024 r1035  
    6767  public:
    6868    bool initialise(size_t windowHnd, int windowWidth, int windowHeight);
    69     void destroyDevices();
     69    void destroy();
    7070    void tick(float dt);
    7171    void setWindowExtents(int width, int height);
     
    7777    OIS::Keyboard *getKeyboard() { return this->keyboard_; }
    7878
    79     static InputManager* getSingleton();
    80     static void destroySingleton();
     79    static InputManager& getSingleton();
     80    static InputManager* getSingletonPtr() { return &getSingleton(); }
    8181
    8282  private:
     
    8484    InputManager ();
    8585    InputManager (const InputManager&);
    86     InputManager& operator=(const InputManager& instance);
    8786    ~InputManager();
    8887
     
    9998
    10099    //! Pointer to the instance of the singleton
    101     static InputManager *singletonRef_s;
     100    //static InputManager *singletonRef_s;
    102101  };
    103102}
  • code/trunk/src/orxonox/objects/SpaceShip.cc

    r1032 r1035  
    417417    void SpaceShip::tick(float dt)
    418418    {
    419       if (InputManager::getSingleton()->getMouse()->getEventCallback() != this)
    420         {
    421             if (InputManager::getSingleton()->getMouse())
     419      if (InputManager::getSingleton().getMouse()->getEventCallback() != this)
     420        {
     421            if (InputManager::getSingleton().getMouse())
    422422            {
    423                 InputManager::getSingleton()->getMouse()->setEventCallback(this);
     423                InputManager::getSingleton().getMouse()->setEventCallback(this);
    424424                this->setMouseEventCallback_ = true;
    425425            }
     
    446446        }
    447447
    448         OIS::Keyboard* mKeyboard = InputManager::getSingleton()->getKeyboard();
    449         OIS::Mouse* mMouse = InputManager::getSingleton()->getMouse();
     448        OIS::Keyboard* mKeyboard = InputManager::getSingleton().getKeyboard();
     449        OIS::Mouse* mMouse = InputManager::getSingleton().getMouse();
    450450
    451451
  • code/trunk/visual_studio/vc8/orxonox.vcproj

    r1032 r1035  
    245245                                                        />
    246246                                                </FileConfiguration>
     247                                                <FileConfiguration
     248                                                        Name="Release|Win32"
     249                                                        ExcludedFromBuild="true"
     250                                                        >
     251                                                        <Tool
     252                                                                Name="VCCLCompilerTool"
     253                                                        />
     254                                                </FileConfiguration>
    247255                                        </File>
    248256                                        <File
     
    257265                                                        />
    258266                                                </FileConfiguration>
     267                                                <FileConfiguration
     268                                                        Name="Release|Win32"
     269                                                        ExcludedFromBuild="true"
     270                                                        >
     271                                                        <Tool
     272                                                                Name="VCCLCompilerTool"
     273                                                        />
     274                                                </FileConfiguration>
    259275                                        </File>
    260276                                        <File
     
    269285                                                        />
    270286                                                </FileConfiguration>
     287                                                <FileConfiguration
     288                                                        Name="Release|Win32"
     289                                                        ExcludedFromBuild="true"
     290                                                        >
     291                                                        <Tool
     292                                                                Name="VCCLCompilerTool"
     293                                                        />
     294                                                </FileConfiguration>
    271295                                        </File>
    272296                                        <File
     
    281305                                                        />
    282306                                                </FileConfiguration>
     307                                                <FileConfiguration
     308                                                        Name="Release|Win32"
     309                                                        ExcludedFromBuild="true"
     310                                                        >
     311                                                        <Tool
     312                                                                Name="VCCLCompilerTool"
     313                                                        />
     314                                                </FileConfiguration>
    283315                                        </File>
    284316                                        <File
     
    293325                                                        />
    294326                                                </FileConfiguration>
     327                                                <FileConfiguration
     328                                                        Name="Release|Win32"
     329                                                        ExcludedFromBuild="true"
     330                                                        >
     331                                                        <Tool
     332                                                                Name="VCCLCompilerTool"
     333                                                        />
     334                                                </FileConfiguration>
    295335                                        </File>
    296336                                        <File
     
    299339                                                <FileConfiguration
    300340                                                        Name="Debug|Win32"
     341                                                        ExcludedFromBuild="true"
     342                                                        >
     343                                                        <Tool
     344                                                                Name="VCCLCompilerTool"
     345                                                        />
     346                                                </FileConfiguration>
     347                                                <FileConfiguration
     348                                                        Name="Release|Win32"
    301349                                                        ExcludedFromBuild="true"
    302350                                                        >
Note: See TracChangeset for help on using the changeset viewer.