[Orxonox-commit 1108] r5829 - in code/branches/core5/src: libraries/core libraries/core/input libraries/network modules/gamestates orxonox/gametypes

landauf at orxonox.net landauf at orxonox.net
Mon Sep 28 21:31:24 CEST 2009


Author: landauf
Date: 2009-09-28 21:31:24 +0200 (Mon, 28 Sep 2009)
New Revision: 5829

Modified:
   code/branches/core5/src/libraries/core/BaseObject.h
   code/branches/core5/src/libraries/core/EventIncludes.h
   code/branches/core5/src/libraries/core/GraphicsManager.cc
   code/branches/core5/src/libraries/core/input/InputManager.cc
   code/branches/core5/src/libraries/core/input/Mouse.cc
   code/branches/core5/src/libraries/network/GamestateManager.cc
   code/branches/core5/src/modules/gamestates/GSGraphics.cc
   code/branches/core5/src/modules/gamestates/GSIOConsole.cc
   code/branches/core5/src/modules/gamestates/GSLevel.cc
   code/branches/core5/src/modules/gamestates/GSMainMenu.cc
   code/branches/core5/src/modules/gamestates/GSRoot.cc
   code/branches/core5/src/orxonox/gametypes/UnderAttack.cc
Log:
replaced most occurrences of setObject(o) in combination with createFunctor(f) with the more convenient createFunctor(f, o)

Modified: code/branches/core5/src/libraries/core/BaseObject.h
===================================================================
--- code/branches/core5/src/libraries/core/BaseObject.h	2009-09-28 19:14:00 UTC (rev 5828)
+++ code/branches/core5/src/libraries/core/BaseObject.h	2009-09-28 19:31:24 UTC (rev 5829)
@@ -39,8 +39,8 @@
 #define SetMainState(classname, statename, setfunction, getfunction) \
     if (this->getMainStateName() == statename) \
     { \
-        this->functorSetMainState_ = createFunctor(&classname::setfunction)->setObject(this); \
-        this->functorGetMainState_ = createFunctor(&classname::getfunction)->setObject(this); \
+        this->functorSetMainState_ = createFunctor(&classname::setfunction, this); \
+        this->functorGetMainState_ = createFunctor(&classname::getfunction, this); \
     }
 
 

Modified: code/branches/core5/src/libraries/core/EventIncludes.h
===================================================================
--- code/branches/core5/src/libraries/core/EventIncludes.h	2009-09-28 19:14:00 UTC (rev 5828)
+++ code/branches/core5/src/libraries/core/EventIncludes.h	2009-09-28 19:31:24 UTC (rev 5829)
@@ -48,8 +48,7 @@
     orxonox::EventContainer* containername = this->getEventContainer(eventname); \
     if (!containername) \
     { \
-        ExecutorMember<classname>* executor = orxonox::createExecutor(orxonox::createFunctor(&classname::functionname), std::string( #classname ) + "::" + #functionname); \
-        executor->setObject(this); \
+        ExecutorMember<classname>* executor = orxonox::createExecutor(orxonox::createFunctor(&classname::functionname, this), std::string( #classname ) + "::" + #functionname); \
         containername = new orxonox::EventContainer(std::string(eventname), executor, orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
         this->addEventContainer(eventname, containername); \
     } \
@@ -60,8 +59,7 @@
     orxonox::EventContainer* containername = this->getEventContainer(eventname); \
     if (!containername) \
     { \
-        ExecutorMember<classname>* executor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::functionname), std::string( #classname ) + "::" + #functionname); \
-        executor->setObject(this); \
+        ExecutorMember<classname>* executor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::functionname, this), std::string( #classname ) + "::" + #functionname); \
         containername = new orxonox::EventContainer(std::string(eventname), executor, orxonox::ClassIdentifier<subclassname>::getIdentifier()); \
         this->addEventContainer(eventname, containername); \
     } \

Modified: code/branches/core5/src/libraries/core/GraphicsManager.cc
===================================================================
--- code/branches/core5/src/libraries/core/GraphicsManager.cc	2009-09-28 19:14:00 UTC (rev 5828)
+++ code/branches/core5/src/libraries/core/GraphicsManager.cc	2009-09-28 19:31:24 UTC (rev 5829)
@@ -317,8 +317,7 @@
         Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(0);
 
         // add console commands
-        FunctorMember<GraphicsManager>* functor1 = createFunctor(&GraphicsManager::printScreen);
-        ccPrintScreen_ = createConsoleCommand(functor1->setObject(this), "printScreen");
+        ccPrintScreen_ = createConsoleCommand(createFunctor(&GraphicsManager::printScreen, this), "printScreen");
         CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_);
     }
 

Modified: code/branches/core5/src/libraries/core/input/InputManager.cc
===================================================================
--- code/branches/core5/src/libraries/core/input/InputManager.cc	2009-09-28 19:14:00 UTC (rev 5828)
+++ code/branches/core5/src/libraries/core/input/InputManager.cc	2009-09-28 19:31:24 UTC (rev 5829)
@@ -108,9 +108,7 @@
         // KeyDetector to evaluate a pressed key's name
         InputState* detector = createInputState("detector", false, false, InputStatePriority::Detector);
         // Create a callback to avoid buttonHeld events after the key has been detected
-        FunctorMember<InputManager>* bufferFunctor = createFunctor(&InputManager::clearBuffers);
-        bufferFunctor->setObject(this);
-        detector->setLeaveFunctor(bufferFunctor);
+        detector->setLeaveFunctor(createFunctor(&InputManager::clearBuffers, this));
         keyDetector_ = new KeyDetector();
         detector->setHandler(keyDetector_);
 
@@ -123,18 +121,10 @@
 
         this->updateActiveStates();
 
-        {
-            // calibrate console command
-            FunctorMember<InputManager>* functor = createFunctor(&InputManager::calibrate);
-            functor->setObject(this);
-            this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "calibrate"), true);
-        }
-        {
-            // reload console command
-            FunctorMember<InputManager>* functor = createFunctor(&InputManager::reload);
-            functor->setObject(this);
-            this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "reload"), false);
-        }
+        // calibrate console command
+        this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&InputManager::calibrate, this), "calibrate"), true);
+        // reload console command
+        this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&InputManager::reload, this), "reload"), false);
 
         CCOUT(4) << "Construction complete." << std::endl;
         internalState_ = Nothing;

Modified: code/branches/core5/src/libraries/core/input/Mouse.cc
===================================================================
--- code/branches/core5/src/libraries/core/input/Mouse.cc	2009-09-28 19:14:00 UTC (rev 5828)
+++ code/branches/core5/src/libraries/core/input/Mouse.cc	2009-09-28 19:31:24 UTC (rev 5829)
@@ -47,18 +47,10 @@
         this->windowResized(this->getWindowWidth(), this->getWindowHeight());
 
 #ifdef ORXONOX_PLATFORM_LINUX
-        {
-            // Mouse grab console command
-            FunctorMember<Mouse>* functor = createFunctor(&Mouse::grab);
-            functor->setObject(this);
-            this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "grab"), false);
-        }
-        {
-            // Mouse ungrab console command
-            FunctorMember<Mouse>* functor = createFunctor(&Mouse::ungrab);
-            functor->setObject(this);
-            this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "ungrab"), false);
-        }
+        // Mouse grab console command
+        this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&Mouse::grab, this), "grab"), false);
+        // Mouse ungrab console command
+        this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&Mouse::ungrab, this), "ungrab"), false);
 #endif
     }
 

Modified: code/branches/core5/src/libraries/network/GamestateManager.cc
===================================================================
--- code/branches/core5/src/libraries/network/GamestateManager.cc	2009-09-28 19:14:00 UTC (rev 5828)
+++ code/branches/core5/src/libraries/network/GamestateManager.cc	2009-09-28 19:31:24 UTC (rev 5829)
@@ -159,8 +159,7 @@
       clientGamestates.push(0);
       finishGamestate( cid, &clientGamestates.back(), client, reference );
       //FunctorMember<GamestateManager>* functor = 
-//       ExecutorMember<GamestateManager>* executor = createExecutor( createFunctor(&GamestateManager::finishGamestate) );
-//       executor->setObject(this);
+//       ExecutorMember<GamestateManager>* executor = createExecutor( createFunctor(&GamestateManager::finishGamestate, this) );
 //       executor->setDefaultValues( cid, &clientGamestates.back(), client, reference );
 //       (*static_cast<Executor*>(executor))();
 //       this->threadPool_->passFunction( executor, true );

Modified: code/branches/core5/src/modules/gamestates/GSGraphics.cc
===================================================================
--- code/branches/core5/src/modules/gamestates/GSGraphics.cc	2009-09-28 19:14:00 UTC (rev 5828)
+++ code/branches/core5/src/modules/gamestates/GSGraphics.cc	2009-09-28 19:31:24 UTC (rev 5829)
@@ -108,9 +108,7 @@
         console_->initialise();
 
         // add console command to toggle GUI
-        FunctorMember<GSGraphics>* functor = createFunctor(&GSGraphics::toggleGUI);
-        functor->setObject(this);
-        this->ccToggleGUI_ = createConsoleCommand(functor, "toggleGUI");
+        this->ccToggleGUI_ = createConsoleCommand(createFunctor(&GSGraphics::toggleGUI, this), "toggleGUI");
         CommandExecutor::addConsoleCommandShortcut(this->ccToggleGUI_);
 
         // enable master input

Modified: code/branches/core5/src/modules/gamestates/GSIOConsole.cc
===================================================================
--- code/branches/core5/src/modules/gamestates/GSIOConsole.cc	2009-09-28 19:14:00 UTC (rev 5828)
+++ code/branches/core5/src/modules/gamestates/GSIOConsole.cc	2009-09-28 19:31:24 UTC (rev 5829)
@@ -49,9 +49,7 @@
     void GSIOConsole::activate()
     {
         {
-            FunctorMember<GSIOConsole>* functor = createFunctor(&GSIOConsole::loadMenu);
-            functor->setObject(this);
-            this->ccLoadMenu_ = createConsoleCommand(functor, "loadMenu");
+            this->ccLoadMenu_ = createConsoleCommand(createFunctor(&GSIOConsole::loadMenu, this), "loadMenu");
             CommandExecutor::addConsoleCommandShortcut(this->ccLoadMenu_);
         }
     }

Modified: code/branches/core5/src/modules/gamestates/GSLevel.cc
===================================================================
--- code/branches/core5/src/modules/gamestates/GSLevel.cc	2009-09-28 19:14:00 UTC (rev 5828)
+++ code/branches/core5/src/modules/gamestates/GSLevel.cc	2009-09-28 19:31:24 UTC (rev 5829)
@@ -115,13 +115,9 @@
         if (GameMode::showsGraphics())
         {
             // keybind console command
-            FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind);
-            functor1->setObject(this);
-            ccKeybind_ = createConsoleCommand(functor1, "keybind");
+            ccKeybind_ = createConsoleCommand(createFunctor(&GSLevel::keybind, this), "keybind");
             CommandExecutor::addConsoleCommandShortcut(ccKeybind_);
-            FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind);
-            functor2->setObject(this);
-            ccTkeybind_ = createConsoleCommand(functor2, "tkeybind");
+            ccTkeybind_ = createConsoleCommand(createFunctor(&GSLevel::tkeybind, this), "tkeybind");
             CommandExecutor::addConsoleCommandShortcut(ccTkeybind_);
             // set our console command as callback for the key detector
             InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_);

Modified: code/branches/core5/src/modules/gamestates/GSMainMenu.cc
===================================================================
--- code/branches/core5/src/modules/gamestates/GSMainMenu.cc	2009-09-28 19:14:00 UTC (rev 5828)
+++ code/branches/core5/src/modules/gamestates/GSMainMenu.cc	2009-09-28 19:31:24 UTC (rev 5829)
@@ -74,36 +74,16 @@
         GUIManager::getInstance().setCamera(this->camera_);
         GraphicsManager::getInstance().setCamera(this->camera_);
 
-        {
-            FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startStandalone);
-            functor->setObject(this);
-            this->ccStartStandalone_ = createConsoleCommand(functor, "startGame");
-            CommandExecutor::addConsoleCommandShortcut(this->ccStartStandalone_);
-        }
-        {
-            FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startServer);
-            functor->setObject(this);
-            this->ccStartServer_ = createConsoleCommand(functor, "startServer");
-            CommandExecutor::addConsoleCommandShortcut(this->ccStartServer_);
-        }
-        {
-            FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startClient);
-            functor->setObject(this);
-            this->ccStartClient_ = createConsoleCommand(functor, "startClient");
-            CommandExecutor::addConsoleCommandShortcut(this->ccStartClient_);
-        }
-        {
-            FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startDedicated);
-            functor->setObject(this);
-            this->ccStartDedicated_ = createConsoleCommand(functor, "startDedicated");
-            CommandExecutor::addConsoleCommandShortcut(this->ccStartDedicated_);
-        }
-        {
-            FunctorMember<GSMainMenu>* functor = createFunctor(&GSMainMenu::startMainMenu);
-            functor->setObject(this);
-            this->ccStartMainMenu_ = createConsoleCommand(functor, "startMainMenu");
-            CommandExecutor::addConsoleCommandShortcut(this->ccStartMainMenu_);
-        }
+        this->ccStartStandalone_ = createConsoleCommand(createFunctor(&GSMainMenu::startStandalone, this), "startGame");
+        CommandExecutor::addConsoleCommandShortcut(this->ccStartStandalone_);
+        this->ccStartServer_ = createConsoleCommand(createFunctor(&GSMainMenu::startServer, this), "startServer");
+        CommandExecutor::addConsoleCommandShortcut(this->ccStartServer_);
+        this->ccStartClient_ = createConsoleCommand(createFunctor(&GSMainMenu::startClient, this), "startClient");
+        CommandExecutor::addConsoleCommandShortcut(this->ccStartClient_);
+        this->ccStartDedicated_ = createConsoleCommand(createFunctor(&GSMainMenu::startDedicated, this), "startDedicated");
+        CommandExecutor::addConsoleCommandShortcut(this->ccStartDedicated_);
+        this->ccStartMainMenu_ = createConsoleCommand(createFunctor(&GSMainMenu::startMainMenu, this), "startMainMenu");
+        CommandExecutor::addConsoleCommandShortcut(this->ccStartMainMenu_);
 
         InputManager::getInstance().enterState("mainMenu");
 

Modified: code/branches/core5/src/modules/gamestates/GSRoot.cc
===================================================================
--- code/branches/core5/src/modules/gamestates/GSRoot.cc	2009-09-28 19:14:00 UTC (rev 5828)
+++ code/branches/core5/src/modules/gamestates/GSRoot.cc	2009-09-28 19:31:24 UTC (rev 5829)
@@ -62,21 +62,13 @@
         // reset game speed to normal
         this->timeFactor_ = 1.0f;
 
-        {
-            // time factor console command
-            FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::setTimeFactor);
-            functor->setObject(this);
-            this->ccSetTimeFactor_ = createConsoleCommand(functor, "setTimeFactor");
-            CommandExecutor::addConsoleCommandShortcut(this->ccSetTimeFactor_).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);
-        }
+        // time factor console command
+        this->ccSetTimeFactor_ = createConsoleCommand(createFunctor(&GSRoot::setTimeFactor, this), "setTimeFactor");
+        CommandExecutor::addConsoleCommandShortcut(this->ccSetTimeFactor_).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);
 
-        {
-            // time factor console command
-            FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::pause);
-            functor->setObject(this);
-            this->ccPause_ = createConsoleCommand(functor, "pause");
-            CommandExecutor::addConsoleCommandShortcut(this->ccPause_).accessLevel(AccessLevel::Offline);
-        }
+        // time factor console command
+        this->ccPause_ = createConsoleCommand(createFunctor(&GSRoot::pause, this), "pause");
+        CommandExecutor::addConsoleCommandShortcut(this->ccPause_).accessLevel(AccessLevel::Offline);
 
         // create the LevelManager
         this->levelManager_ = new LevelManager();

Modified: code/branches/core5/src/orxonox/gametypes/UnderAttack.cc
===================================================================
--- code/branches/core5/src/orxonox/gametypes/UnderAttack.cc	2009-09-28 19:14:00 UTC (rev 5828)
+++ code/branches/core5/src/orxonox/gametypes/UnderAttack.cc	2009-09-28 19:31:24 UTC (rev 5829)
@@ -45,7 +45,7 @@
         this->gameTime_ = 180;
         this->teams_ = 2;
         this->destroyer_ = 0;
-        this->destroyer_.addCallback(createFunctor(&UnderAttack::killedDestroyer)->setObject(this));
+        this->destroyer_.addCallback(createFunctor(&UnderAttack::killedDestroyer, this));
         this->gameEnded_ = false;
 
         this->setHUDTemplate("UnderAttackHUD");




More information about the Orxonox-commit mailing list