[Orxonox-commit 1465] r6183 - in code/branches/presentation2/src: libraries/core libraries/core/input libraries/util orxonox/overlays orxonox/sound
rgrieder at orxonox.net
rgrieder at orxonox.net
Mon Nov 30 11:07:06 CET 2009
Author: rgrieder
Date: 2009-11-30 11:07:06 +0100 (Mon, 30 Nov 2009)
New Revision: 6183
Modified:
code/branches/presentation2/src/libraries/core/Core.cc
code/branches/presentation2/src/libraries/core/GUIManager.cc
code/branches/presentation2/src/libraries/core/GUIManager.h
code/branches/presentation2/src/libraries/core/GraphicsManager.cc
code/branches/presentation2/src/libraries/core/GraphicsManager.h
code/branches/presentation2/src/libraries/core/IOConsole.cc
code/branches/presentation2/src/libraries/core/IOConsole.h
code/branches/presentation2/src/libraries/core/ScopedSingletonManager.h
code/branches/presentation2/src/libraries/core/TclThreadManager.cc
code/branches/presentation2/src/libraries/core/TclThreadManager.h
code/branches/presentation2/src/libraries/core/input/InputManager.cc
code/branches/presentation2/src/libraries/core/input/InputManager.h
code/branches/presentation2/src/libraries/util/Singleton.h
code/branches/presentation2/src/orxonox/overlays/InGameConsole.cc
code/branches/presentation2/src/orxonox/overlays/InGameConsole.h
code/branches/presentation2/src/orxonox/sound/SoundManager.cc
code/branches/presentation2/src/orxonox/sound/SoundManager.h
Log:
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.
Modified: code/branches/presentation2/src/libraries/core/Core.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/Core.cc 2009-11-30 09:44:06 UTC (rev 6182)
+++ code/branches/presentation2/src/libraries/core/Core.cc 2009-11-30 10:07:06 UTC (rev 6183)
@@ -315,29 +315,33 @@
void Core::preUpdate(const Clock& time)
{
- // singletons from other libraries
- ScopedSingletonManager::update<ScopeID::Root>(time);
+ // Update singletons before general ticking
+ ScopedSingletonManager::preUpdate<ScopeID::Root>(time);
if (this->bGraphicsLoaded_)
{
- // process input events
- this->inputManager_->update(time);
- // process gui events
- this->guiManager_->update(time);
- // graphics singletons from other libraries
- ScopedSingletonManager::update<ScopeID::Graphics>(time);
+ // Process input events
+ this->inputManager_->preUpdate(time);
+ // Update GUI
+ this->guiManager_->preUpdate(time);
+ // Update singletons before general ticking
+ ScopedSingletonManager::preUpdate<ScopeID::Graphics>(time);
}
- // process console text
- this->ioConsole_->update(time);
- // process thread commands
- this->tclThreadManager_->update(time);
+ // Process console events and status line
+ this->ioConsole_->preUpdate(time);
+ // Process thread commands
+ this->tclThreadManager_->preUpdate(time);
}
void Core::postUpdate(const Clock& time)
{
+ // Update singletons just before rendering
+ ScopedSingletonManager::postUpdate<ScopeID::Root>(time);
if (this->bGraphicsLoaded_)
{
+ // Update singletons just before rendering
+ ScopedSingletonManager::postUpdate<ScopeID::Graphics>(time);
// Render (doesn't throw)
- this->graphicsManager_->update(time);
+ this->graphicsManager_->postUpdate(time);
}
}
}
Modified: code/branches/presentation2/src/libraries/core/GUIManager.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/GUIManager.cc 2009-11-30 09:44:06 UTC (rev 6182)
+++ code/branches/presentation2/src/libraries/core/GUIManager.cc 2009-11-30 10:07:06 UTC (rev 6183)
@@ -165,7 +165,7 @@
The elapsed time since the last call is given in the time value provided by the clock.
This time value is then used to provide a fluent animation of the GUI.
*/
- void GUIManager::update(const Clock& time)
+ void GUIManager::preUpdate(const Clock& time)
{
assert(guiSystem_);
guiSystem_->injectTimePulse(time.getDeltaTime());
Modified: code/branches/presentation2/src/libraries/core/GUIManager.h
===================================================================
--- code/branches/presentation2/src/libraries/core/GUIManager.h 2009-11-30 09:44:06 UTC (rev 6182)
+++ code/branches/presentation2/src/libraries/core/GUIManager.h 2009-11-30 10:07:06 UTC (rev 6183)
@@ -65,7 +65,7 @@
GUIManager(Ogre::RenderWindow* renderWindow, const std::pair<int, int>& mousePosition, bool bFullScreen);
~GUIManager();
- void update(const Clock& time);
+ void preUpdate(const Clock& time);
static void showGUI(const std::string& name, bool hidePrevious=false, bool showCursor=true);
void showGUIExtra(const std::string& name, const std::string& ptr, bool hidePrevious=false, bool showCursor=true);
Modified: code/branches/presentation2/src/libraries/core/GraphicsManager.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/GraphicsManager.cc 2009-11-30 09:44:06 UTC (rev 6182)
+++ code/branches/presentation2/src/libraries/core/GraphicsManager.cc 2009-11-30 10:07:06 UTC (rev 6183)
@@ -340,7 +340,7 @@
as shown that there is probably only one FrameListener that doesn't even
need the time. So we shouldn't run into problems.
*/
- void GraphicsManager::update(const Clock& time)
+ void GraphicsManager::postUpdate(const Clock& time)
{
Ogre::FrameEvent evt;
evt.timeSinceLastFrame = time.getDeltaTime();
Modified: code/branches/presentation2/src/libraries/core/GraphicsManager.h
===================================================================
--- code/branches/presentation2/src/libraries/core/GraphicsManager.h 2009-11-30 09:44:06 UTC (rev 6182)
+++ code/branches/presentation2/src/libraries/core/GraphicsManager.h 2009-11-30 10:07:06 UTC (rev 6183)
@@ -62,7 +62,7 @@
void setConfigValues();
- void update(const Clock& time);
+ void postUpdate(const Clock& time);
Ogre::Viewport* getViewport() { return this->viewport_; }
Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; }
Modified: code/branches/presentation2/src/libraries/core/IOConsole.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/IOConsole.cc 2009-11-30 09:44:06 UTC (rev 6182)
+++ code/branches/presentation2/src/libraries/core/IOConsole.cc 2009-11-30 10:07:06 UTC (rev 6183)
@@ -115,13 +115,13 @@
std::cout.rdbuf(this->origCout_.rdbuf());
// Make sure we make way for the status lines
- this->update(Game::getInstance().getGameClock());
+ this->preUpdate(Game::getInstance().getGameClock());
}
IOConsole::~IOConsole()
{
// Empty all buffers
- this->update(Game::getInstance().getGameClock());
+ this->preUpdate(Game::getInstance().getGameClock());
// Erase input and status lines
this->cout_ << "\033[1G\033[J";
// Move cursor to the bottom
@@ -138,7 +138,7 @@
OutputHandler::getInstance().enableCout();
}
- void IOConsole::update(const Clock& time)
+ void IOConsole::preUpdate(const Clock& time)
{
unsigned char c;
std::string escapeSequence;
@@ -494,7 +494,7 @@
this->inputChanged();
this->cursorChanged();
this->lastRefreshTime_ = Game::getInstance().getGameClock().getRealMicroseconds();
- this->update(Game::getInstance().getGameClock());
+ this->preUpdate(Game::getInstance().getGameClock());
this->shell_->registerListener(this);
}
@@ -504,7 +504,7 @@
{
this->shell_->unregisterListener(this);
// Empty all buffers
- this->update(Game::getInstance().getGameClock());
+ this->preUpdate(Game::getInstance().getGameClock());
// Erase input and status lines
COORD pos = {0, this->inputLineRow_};
@@ -522,7 +522,7 @@
}
//! Processes the pending input key strokes, refreshes the status lines and handles std::cout (redirected)
- void IOConsole::update(const Clock& time)
+ void IOConsole::preUpdate(const Clock& time)
{
// Process input
while (true)
Modified: code/branches/presentation2/src/libraries/core/IOConsole.h
===================================================================
--- code/branches/presentation2/src/libraries/core/IOConsole.h 2009-11-30 09:44:06 UTC (rev 6182)
+++ code/branches/presentation2/src/libraries/core/IOConsole.h 2009-11-30 10:07:06 UTC (rev 6183)
@@ -56,7 +56,7 @@
IOConsole();
~IOConsole();
- void update(const Clock& time);
+ void preUpdate(const Clock& time);
private:
void setTerminalMode();
Modified: code/branches/presentation2/src/libraries/core/ScopedSingletonManager.h
===================================================================
--- code/branches/presentation2/src/libraries/core/ScopedSingletonManager.h 2009-11-30 09:44:06 UTC (rev 6182)
+++ code/branches/presentation2/src/libraries/core/ScopedSingletonManager.h 2009-11-30 10:07:06 UTC (rev 6183)
@@ -54,13 +54,21 @@
static void addManager(ScopedSingletonManager* manager);
template<ScopeID::Value scope>
- static void update(const Clock& time)
+ static void preUpdate(const Clock& time)
{
assert(Scope<scope>::isActive());
for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)
- it->second->update(time);
+ it->second->preUpdate(time);
}
- virtual void update(const Clock& time) = 0;
+ virtual void preUpdate(const Clock& time) = 0;
+ template<ScopeID::Value scope>
+ static void postUpdate(const Clock& time)
+ {
+ assert(Scope<scope>::isActive());
+ for (ManagerMultiMap::iterator it = getManagersByScope().lower_bound(scope); it != getManagersByScope().upper_bound(scope); ++it)
+ it->second->postUpdate(time);
+ }
+ virtual void postUpdate(const Clock& time) = 0;
static std::map<std::string, ScopedSingletonManager*>& getManagers();
typedef std::multimap<ScopeID::Value, ScopedSingletonManager*> ManagerMultiMap;
@@ -112,13 +120,21 @@
}
//! Called every frame by the ScopedSingletonManager
- void update(const Clock& time)
+ void preUpdate(const Clock& time)
{
assert(Scope<scope>::isActive());
// assuming T inherits Singleton<T>
- singletonPtr_->updateSingleton(time);
+ singletonPtr_->preUpdateSingleton(time);
}
+ //! Called every frame by the ScopedSingletonManager
+ void postUpdate(const Clock& time)
+ {
+ assert(Scope<scope>::isActive());
+ // assuming T inherits Singleton<T>
+ singletonPtr_->postUpdateSingleton(time);
+ }
+
private:
T* singletonPtr_;
};
@@ -169,14 +185,23 @@
}
//! Called every frame by the ScopedSingletonManager
- void update(const Clock& time)
+ void preUpdate(const Clock& time)
{
assert(Scope<scope>::isActive());
// assuming T inherits Singleton<T>
if (singletonPtr_ != NULL)
- singletonPtr_->updateSingleton(time);
+ singletonPtr_->preUpdateSingleton(time);
}
+ //! Called every frame by the ScopedSingletonManager
+ void postUpdate(const Clock& time)
+ {
+ assert(Scope<scope>::isActive());
+ // assuming T inherits Singleton<T>
+ if (singletonPtr_ != NULL)
+ singletonPtr_->postUpdateSingleton(time);
+ }
+
private:
T* singletonPtr_;
};
Modified: code/branches/presentation2/src/libraries/core/TclThreadManager.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/TclThreadManager.cc 2009-11-30 09:44:06 UTC (rev 6182)
+++ code/branches/presentation2/src/libraries/core/TclThreadManager.cc 2009-11-30 10:07:06 UTC (rev 6183)
@@ -121,7 +121,7 @@
/**
@brief The "main loop" of the TclThreadManager. Creates new threads if needed and handles queries and queued commands for the main interpreter.
*/
- void TclThreadManager::update(const Clock& time)
+ void TclThreadManager::preUpdate(const Clock& time)
{
// Get the bundle of the main interpreter (0)
TclInterpreterBundle* bundle = this->getInterpreterBundle(0);
Modified: code/branches/presentation2/src/libraries/core/TclThreadManager.h
===================================================================
--- code/branches/presentation2/src/libraries/core/TclThreadManager.h 2009-11-30 09:44:06 UTC (rev 6182)
+++ code/branches/presentation2/src/libraries/core/TclThreadManager.h 2009-11-30 10:07:06 UTC (rev 6183)
@@ -65,7 +65,7 @@
static void error(const std::string& error);
static void debug(const std::string& error);
- void update(const Clock& time);
+ void preUpdate(const Clock& time);
std::list<unsigned int> getThreadList() const;
Modified: code/branches/presentation2/src/libraries/core/input/InputManager.cc
===================================================================
--- code/branches/presentation2/src/libraries/core/input/InputManager.cc 2009-11-30 09:44:06 UTC (rev 6182)
+++ code/branches/presentation2/src/libraries/core/input/InputManager.cc 2009-11-30 10:07:06 UTC (rev 6183)
@@ -365,7 +365,7 @@
// ########## ##########
// ############################################################
- void InputManager::update(const Clock& time)
+ void InputManager::preUpdate(const Clock& time)
{
if (internalState_ & Bad)
ThrowException(General, "InputManager was not correctly reloaded.");
@@ -465,7 +465,7 @@
/**
@brief
Updates the currently active states (according to activeStates_) for each device.
- Also, a list of all active states (no duplicates!) is compiled for the general update().
+ Also, a list of all active states (no duplicates!) is compiled for the general preUpdate().
*/
void InputManager::updateActiveStates()
{
Modified: code/branches/presentation2/src/libraries/core/input/InputManager.h
===================================================================
--- code/branches/presentation2/src/libraries/core/input/InputManager.h 2009-11-30 09:44:06 UTC (rev 6182)
+++ code/branches/presentation2/src/libraries/core/input/InputManager.h 2009-11-30 10:07:06 UTC (rev 6183)
@@ -98,7 +98,7 @@
Any InpuStates changes (destroy, enter, leave) and happens here. If a reload request
was submitted while updating, the request will be postponed until the next update call.
*/
- void update(const Clock& time);
+ void preUpdate(const Clock& time);
//! Clears all input device buffers. This usually only includes the pressed button list.
void clearBuffers();
//! Starts joy stick calibration.
@@ -107,7 +107,7 @@
@brief
Reloads all the input devices. Use this method to initialise new joy sticks.
@note
- Only reloads immediately if the call stack doesn't include the update() method.
+ Only reloads immediately if the call stack doesn't include the preUpdate() method.
*/
void reload();
@@ -156,7 +156,7 @@
True if removal was successful, false if name was not found.
@remarks
- You can't remove the internal states "empty", "calibrator" and "detector".
- - The removal process is being postponed if InputManager::update() is currently running.
+ - The removal process is being postponed if InputManager::preUpdate() is currently running.
*/
bool destroyState(const std::string& name);
Modified: code/branches/presentation2/src/libraries/util/Singleton.h
===================================================================
--- code/branches/presentation2/src/libraries/util/Singleton.h 2009-11-30 09:44:06 UTC (rev 6182)
+++ code/branches/presentation2/src/libraries/util/Singleton.h 2009-11-30 10:07:06 UTC (rev 6183)
@@ -55,9 +55,13 @@
}
//! Update method called by ClassSingletonManager (if used)
- void updateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->update(time); }
+ void preUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->preUpdate(time); }
//! Empty update method for the static polymorphism
- void update(const Clock& time) { }
+ void preUpdate(const Clock& time) { }
+ //! Update method called by ClassSingletonManager (if used)
+ void postUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->postUpdate(time); }
+ //! Empty update method for the static polymorphism
+ void postUpdate(const Clock& time) { }
protected:
//! Constructor sets the singleton instance pointer
Modified: code/branches/presentation2/src/orxonox/overlays/InGameConsole.cc
===================================================================
--- code/branches/presentation2/src/orxonox/overlays/InGameConsole.cc 2009-11-30 09:44:06 UTC (rev 6182)
+++ code/branches/presentation2/src/orxonox/overlays/InGameConsole.cc 2009-11-30 10:07:06 UTC (rev 6183)
@@ -356,7 +356,7 @@
/**
@brief Used to control the actual scrolling and the cursor.
*/
- void InGameConsole::update(const Clock& time)
+ void InGameConsole::preUpdate(const Clock& time)
{
if (this->scroll_ != 0)
{
Modified: code/branches/presentation2/src/orxonox/overlays/InGameConsole.h
===================================================================
--- code/branches/presentation2/src/orxonox/overlays/InGameConsole.h 2009-11-30 09:44:06 UTC (rev 6182)
+++ code/branches/presentation2/src/orxonox/overlays/InGameConsole.h 2009-11-30 10:07:06 UTC (rev 6183)
@@ -51,7 +51,7 @@
void initialise();
void setConfigValues();
- void update(const Clock& time);
+ void preUpdate(const Clock& time);
static void openConsole();
static void closeConsole();
Modified: code/branches/presentation2/src/orxonox/sound/SoundManager.cc
===================================================================
--- code/branches/presentation2/src/orxonox/sound/SoundManager.cc 2009-11-30 09:44:06 UTC (rev 6182)
+++ code/branches/presentation2/src/orxonox/sound/SoundManager.cc 2009-11-30 10:07:06 UTC (rev 6183)
@@ -101,7 +101,7 @@
alutExit();
}
- void SoundManager::update(const Clock& time)
+ void SoundManager::preUpdate(const Clock& time)
{
this->processCrossFading(time.getDeltaTime());
}
Modified: code/branches/presentation2/src/orxonox/sound/SoundManager.h
===================================================================
--- code/branches/presentation2/src/orxonox/sound/SoundManager.h 2009-11-30 09:44:06 UTC (rev 6182)
+++ code/branches/presentation2/src/orxonox/sound/SoundManager.h 2009-11-30 10:07:06 UTC (rev 6183)
@@ -50,7 +50,7 @@
SoundManager();
~SoundManager();
- void update(const Clock& time);
+ void preUpdate(const Clock& time);
void setConfigValues();
void setListenerPosition(const Vector3& position);
More information about the Orxonox-commit
mailing list