Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 30, 2009, 11:07:06 AM (15 years ago)
Author:
rgrieder
Message:

Added preUpdate and postUpdate methods for all classes inheriting Singleton. Replaced update() with preUpdate except for the GraphicsManager (postUpdate).
However this does not apply to the Client and Server singletons in the network library. We should think about putting them in a scope as well.

Location:
code/branches/presentation2/src/libraries/core
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/libraries/core/Core.cc

    r6169 r6183  
    316316    void Core::preUpdate(const Clock& time)
    317317    {
    318         // singletons from other libraries
    319         ScopedSingletonManager::update<ScopeID::Root>(time);
     318        // Update singletons before general ticking
     319        ScopedSingletonManager::preUpdate<ScopeID::Root>(time);
    320320        if (this->bGraphicsLoaded_)
    321321        {
    322             // process input events
    323             this->inputManager_->update(time);
    324             // process gui events
    325             this->guiManager_->update(time);
    326             // graphics singletons from other libraries
    327             ScopedSingletonManager::update<ScopeID::Graphics>(time);
    328         }
    329         // process console text
    330         this->ioConsole_->update(time);
    331         // process thread commands
    332         this->tclThreadManager_->update(time);
     322            // Process input events
     323            this->inputManager_->preUpdate(time);
     324            // Update GUI
     325            this->guiManager_->preUpdate(time);
     326            // Update singletons before general ticking
     327            ScopedSingletonManager::preUpdate<ScopeID::Graphics>(time);
     328        }
     329        // Process console events and status line
     330        this->ioConsole_->preUpdate(time);
     331        // Process thread commands
     332        this->tclThreadManager_->preUpdate(time);
    333333    }
    334334
    335335    void Core::postUpdate(const Clock& time)
    336336    {
     337        // Update singletons just before rendering
     338        ScopedSingletonManager::postUpdate<ScopeID::Root>(time);
    337339        if (this->bGraphicsLoaded_)
    338340        {
     341            // Update singletons just before rendering
     342            ScopedSingletonManager::postUpdate<ScopeID::Graphics>(time);
    339343            // Render (doesn't throw)
    340             this->graphicsManager_->update(time);
     344            this->graphicsManager_->postUpdate(time);
    341345        }
    342346    }
  • code/branches/presentation2/src/libraries/core/GUIManager.cc

    r6156 r6183  
    166166        This time value is then used to provide a fluent animation of the GUI.
    167167    */
    168     void GUIManager::update(const Clock& time)
     168    void GUIManager::preUpdate(const Clock& time)
    169169    {
    170170        assert(guiSystem_);
  • code/branches/presentation2/src/libraries/core/GUIManager.h

    r6156 r6183  
    6666        ~GUIManager();
    6767
    68         void update(const Clock& time);
     68        void preUpdate(const Clock& time);
    6969
    7070        static void showGUI(const std::string& name, bool hidePrevious=false, bool showCursor=true);
  • code/branches/presentation2/src/libraries/core/GraphicsManager.cc

    r6105 r6183  
    341341        need the time. So we shouldn't run into problems.
    342342    */
    343     void GraphicsManager::update(const Clock& time)
     343    void GraphicsManager::postUpdate(const Clock& time)
    344344    {
    345345        Ogre::FrameEvent evt;
  • code/branches/presentation2/src/libraries/core/GraphicsManager.h

    r6105 r6183  
    6363        void setConfigValues();
    6464
    65         void update(const Clock& time);
     65        void postUpdate(const Clock& time);
    6666
    6767        Ogre::Viewport* getViewport()         { return this->viewport_; }
  • code/branches/presentation2/src/libraries/core/IOConsole.cc

    r6181 r6183  
    116116
    117117        // Make sure we make way for the status lines
    118         this->update(Game::getInstance().getGameClock());
     118        this->preUpdate(Game::getInstance().getGameClock());
    119119    }
    120120
     
    122122    {
    123123        // Empty all buffers
    124         this->update(Game::getInstance().getGameClock());
     124        this->preUpdate(Game::getInstance().getGameClock());
    125125        // Erase input and status lines
    126126        this->cout_ << "\033[1G\033[J";
     
    139139    }
    140140
    141     void IOConsole::update(const Clock& time)
     141    void IOConsole::preUpdate(const Clock& time)
    142142    {
    143143        unsigned char c;
     
    495495        this->cursorChanged();
    496496        this->lastRefreshTime_ = Game::getInstance().getGameClock().getRealMicroseconds();
    497         this->update(Game::getInstance().getGameClock());
     497        this->preUpdate(Game::getInstance().getGameClock());
    498498
    499499        this->shell_->registerListener(this);
     
    505505        this->shell_->unregisterListener(this);
    506506        // Empty all buffers
    507         this->update(Game::getInstance().getGameClock());
     507        this->preUpdate(Game::getInstance().getGameClock());
    508508
    509509        // Erase input and status lines
     
    523523
    524524    //! Processes the pending input key strokes, refreshes the status lines and handles std::cout (redirected)
    525     void IOConsole::update(const Clock& time)
     525    void IOConsole::preUpdate(const Clock& time)
    526526    {
    527527        // Process input
  • code/branches/presentation2/src/libraries/core/IOConsole.h

    r6180 r6183  
    5757        ~IOConsole();
    5858
    59         void update(const Clock& time);
     59        void preUpdate(const Clock& time);
    6060
    6161    private:
  • code/branches/presentation2/src/libraries/core/ScopedSingletonManager.h

    r6182 r6183  
    5555
    5656            template<ScopeID::Value scope>
    57             static void update(const Clock& time)
     57            static void preUpdate(const Clock& time)
    5858            {
    5959                assert(Scope<scope>::isActive());
    6060                for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)
    61                     it->second->update(time);
     61                    it->second->preUpdate(time);
    6262            }
    63             virtual void update(const Clock& time) = 0;
     63            virtual void preUpdate(const Clock& time) = 0;
     64            template<ScopeID::Value scope>
     65            static void postUpdate(const Clock& time)
     66            {
     67                assert(Scope<scope>::isActive());
     68                for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)
     69                    it->second->postUpdate(time);
     70            }
     71            virtual void postUpdate(const Clock& time) = 0;
    6472
    6573            static std::map<std::string, ScopedSingletonManager*>& getManagers();
     
    113121
    114122        //! Called every frame by the ScopedSingletonManager
    115         void update(const Clock& time)
    116         {
    117             assert(Scope<scope>::isActive());
    118             // assuming T inherits Singleton<T>
    119             singletonPtr_->updateSingleton(time);
     123        void preUpdate(const Clock& time)
     124        {
     125            assert(Scope<scope>::isActive());
     126            // assuming T inherits Singleton<T>
     127            singletonPtr_->preUpdateSingleton(time);
     128        }
     129
     130        //! Called every frame by the ScopedSingletonManager
     131        void postUpdate(const Clock& time)
     132        {
     133            assert(Scope<scope>::isActive());
     134            // assuming T inherits Singleton<T>
     135            singletonPtr_->postUpdateSingleton(time);
    120136        }
    121137
     
    170186
    171187        //! Called every frame by the ScopedSingletonManager
    172         void update(const Clock& time)
     188        void preUpdate(const Clock& time)
    173189        {
    174190            assert(Scope<scope>::isActive());
    175191            // assuming T inherits Singleton<T>
    176192            if (singletonPtr_ != NULL)
    177                 singletonPtr_->updateSingleton(time);
     193                singletonPtr_->preUpdateSingleton(time);
     194        }
     195
     196        //! Called every frame by the ScopedSingletonManager
     197        void postUpdate(const Clock& time)
     198        {
     199            assert(Scope<scope>::isActive());
     200            // assuming T inherits Singleton<T>
     201            if (singletonPtr_ != NULL)
     202                singletonPtr_->postUpdateSingleton(time);
    178203        }
    179204
  • code/branches/presentation2/src/libraries/core/TclThreadManager.cc

    r5929 r6183  
    122122        @brief The "main loop" of the TclThreadManager. Creates new threads if needed and handles queries and queued commands for the main interpreter.
    123123    */
    124     void TclThreadManager::update(const Clock& time)
     124    void TclThreadManager::preUpdate(const Clock& time)
    125125    {
    126126        // Get the bundle of the main interpreter (0)
  • code/branches/presentation2/src/libraries/core/TclThreadManager.h

    r5781 r6183  
    6666            static void debug(const std::string& error);
    6767
    68             void update(const Clock& time);
     68            void preUpdate(const Clock& time);
    6969
    7070            std::list<unsigned int> getThreadList() const;
  • code/branches/presentation2/src/libraries/core/input/InputManager.cc

    r6108 r6183  
    366366    // ############################################################
    367367
    368     void InputManager::update(const Clock& time)
     368    void InputManager::preUpdate(const Clock& time)
    369369    {
    370370        if (internalState_ & Bad)
     
    466466    @brief
    467467        Updates the currently active states (according to activeStates_) for each device.
    468         Also, a list of all active states (no duplicates!) is compiled for the general update().
     468        Also, a list of all active states (no duplicates!) is compiled for the general preUpdate().
    469469    */
    470470    void InputManager::updateActiveStates()
  • code/branches/presentation2/src/libraries/core/input/InputManager.h

    r6150 r6183  
    9999            was submitted while updating, the request will be postponed until the next update call.
    100100        */
    101         void update(const Clock& time);
     101        void preUpdate(const Clock& time);
    102102        //! Clears all input device buffers. This usually only includes the pressed button list.
    103103        void clearBuffers();
     
    108108            Reloads all the input devices. Use this method to initialise new joy sticks.
    109109        @note
    110             Only reloads immediately if the call stack doesn't include the update() method.
     110            Only reloads immediately if the call stack doesn't include the preUpdate() method.
    111111        */
    112112        void reload();
     
    157157        @remarks
    158158            - You can't remove the internal states "empty", "calibrator" and "detector".
    159             - The removal process is being postponed if InputManager::update() is currently running.
     159            - The removal process is being postponed if InputManager::preUpdate() is currently running.
    160160        */
    161161        bool destroyState(const std::string& name);
Note: See TracChangeset for help on using the changeset viewer.