Changeset 7284 for code/trunk/src/libraries/core
- Timestamp:
- Aug 31, 2010, 3:37:40 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 28 deleted
- 42 edited
- 30 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/BaseObject.cc
r7163 r7284 39 39 #include "Event.h" 40 40 #include "EventIncludes.h" 41 #include "Functor.h"42 41 #include "Iterator.h" 43 42 #include "Template.h" … … 45 44 #include "XMLNameListener.h" 46 45 #include "XMLPort.h" 46 #include "command/Functor.h" 47 47 48 48 namespace orxonox … … 477 477 if (!container) 478 478 { 479 ExecutorMember<BaseObject>*setfunctor = createExecutor(createFunctor(&BaseObject::addEventSource), std::string( "BaseObject" ) + "::" + "addEventSource" + '(' + statename + ')');480 ExecutorMember<BaseObject>*getfunctor = createExecutor(createFunctor(&BaseObject::getEventSource), std::string( "BaseObject" ) + "::" + "getEventSource" + '(' + statename + ')');479 const ExecutorMemberPtr<BaseObject>& setfunctor = createExecutor(createFunctor(&BaseObject::addEventSource), std::string( "BaseObject" ) + "::" + "addEventSource" + '(' + statename + ')'); 480 const ExecutorMemberPtr<BaseObject>& getfunctor = createExecutor(createFunctor(&BaseObject::getEventSource), std::string( "BaseObject" ) + "::" + "getEventSource" + '(' + statename + ')'); 481 481 setfunctor->setDefaultValue(1, statename); 482 482 getfunctor->setDefaultValue(1, statename); -
code/trunk/src/libraries/core/BaseObject.h
r7163 r7284 196 196 mbool bVisible_; //!< True = the object is visible 197 197 std::string mainStateName_; 198 Functor *mainStateFunctor_;198 FunctorPtr mainStateFunctor_; 199 199 std::set<std::string> networkTemplateNames_; 200 200 -
code/trunk/src/libraries/core/CMakeLists.txt
r7163 r7284 19 19 20 20 SET_SOURCE_FILES(CORE_SRC_FILES 21 CommandLineParser.cc 21 22 ConfigValueContainer.cc 22 23 Core.cc … … 29 30 GraphicsManager.cc 30 31 GUIManager.cc 31 IOConsole.cc32 32 Language.cc 33 33 LuaState.cc … … 35 35 OrxonoxClass.cc 36 36 Resource.cc 37 ScopedSingletonManager.cc38 37 WindowEventListener.cc 39 40 # command41 CommandEvaluation.cc42 CommandExecutor.cc43 CommandLineParser.cc44 ConsoleCommand.cc45 ConsoleCommandCompilation.cc46 Executor.cc47 38 48 39 # hierarchy … … 60 51 XMLNameListener.cc 61 52 62 # shell63 IRC.cc64 Shell.cc65 TclBind.cc66 67 53 COMPILATION_BEGIN FilesystemCompilation.cc 68 ArgumentCompletionFunctions.cc54 command/ArgumentCompletionFunctions.cc 69 55 ConfigFileManager.cc 70 56 MemoryArchive.cc … … 75 61 ThreadPool.cc 76 62 COMPILATION_BEGIN ThreadCompilation.cc 77 TclThreadManager.cc63 command/TclThreadManager.cc 78 64 Thread.cc 79 65 COMPILATION_END 80 66 ) 81 67 68 ADD_SUBDIRECTORY(command) 82 69 ADD_SUBDIRECTORY(input) 83 70 … … 85 72 FIND_HEADER_FILES 86 73 TOLUA_FILES 87 CommandExecutor.h74 command/CommandExecutor.h 88 75 ConfigFileManager.h 89 76 Game.h -
code/trunk/src/libraries/core/CommandLineParser.cc
r6417 r7284 335 335 { 336 336 std::vector<std::string> args; 337 SubString tokens(cmdLine, " ", " ", false, '\\', true, '"', true, ' (', ')', false);337 SubString tokens(cmdLine, " ", " ", false, '\\', true, '"', true, '\0', '\0', false); 338 338 for (unsigned i = 0; i < tokens.size(); ++i) 339 339 args.push_back(tokens[i]); … … 363 363 //if (!(line[0] == '#' || line[0] == '%')) 364 364 //{ 365 SubString tokens(line, " ", " ", false, '\\', true, '"', true, ' (', ')', false, '#');365 SubString tokens(line, " ", " ", false, '\\', true, '"', true, '\0', '\0', false, '#'); 366 366 for (unsigned i = 0; i < tokens.size(); ++i) 367 367 if (tokens[i][0] != '#') -
code/trunk/src/libraries/core/CommandLineParser.h
r6021 r7284 64 64 Note the difference between "-" and "--"! 65 65 Also, there is no restriction to the number of strings you add after --name. 66 So "--startVector (2, 4, 5)" is perfectly legal.66 So "--startVector {2, 4, 5}" is perfectly legal. 67 67 68 68 Retrieving an argument is possible with the getCommandLineArgument function of the -
code/trunk/src/libraries/core/ConfigFileManager.cc
r7163 r7284 34 34 #include "util/Math.h" 35 35 #include "util/StringUtils.h" 36 #include "ConsoleCommand.h"37 36 #include "ConfigValueContainer.h" 38 37 #include "PathConfig.h" 38 #include "command/ConsoleCommand.h" 39 39 40 40 namespace orxonox … … 277 277 if (commentposition == std::string::npos) 278 278 { 279 value = removeTrailingWhitespaces(line.substr(pos1 + 1));279 value = line.substr(pos1 + 1); 280 280 } 281 281 else 282 282 { 283 value = removeTrailingWhitespaces(line.substr(pos1 + 1, commentposition - pos1 - 1));283 value = line.substr(pos1 + 1, commentposition - pos1 - 1); 284 284 comment = removeTrailingWhitespaces(line.substr(commentposition)); 285 285 } 286 287 value = removeTrailingWhitespaces(value); 288 value = removeSlashes(value); 286 289 287 290 if (pos2 != std::string::npos && pos3 != std::string::npos && pos3 > pos2 + 1) … … 425 428 //////////////////////// 426 429 430 static const std::string __CC_load_name = "reloadSettings"; 431 static const std::string __CC_setFilename_name = "setSettingsFile"; 432 static const std::string __CC_config_name = "config"; 433 static const std::string __CC_tconfig_name = "tconfig"; 434 static const std::string __CC_getConfig_name = "getConfig"; 435 436 SetConsoleCommand(__CC_load_name, &ConfigFile::load); 437 SetConsoleCommand(__CC_setFilename_name, &SettingsConfigFile::setFilename); 438 SetConsoleCommand(__CC_config_name, &SettingsConfigFile::config).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue()); 439 SetConsoleCommand(__CC_tconfig_name, &SettingsConfigFile::tconfig).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue()); 440 SetConsoleCommand(__CC_getConfig_name, &SettingsConfigFile::getConfig).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()); 441 427 442 SettingsConfigFile* SettingsConfigFile::singletonPtr_s = 0; 428 443 … … 430 445 : ConfigFile(filename) 431 446 { 432 ConsoleCommand* command = createConsoleCommand(createFunctor(&ConfigFile::load, this), "reloadSettings"); 433 CommandExecutor::addConsoleCommandShortcut(command); 434 command = createConsoleCommand(createFunctor(&SettingsConfigFile::setFilename, this), "setSettingsFile"); 435 CommandExecutor::addConsoleCommandShortcut(command); 436 command = createConsoleCommand(createFunctor(&SettingsConfigFile::config, this), "config"); 437 CommandExecutor::addConsoleCommandShortcut(command).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue()); 438 command = createConsoleCommand(createFunctor(&SettingsConfigFile::tconfig, this), "tconfig"); 439 CommandExecutor::addConsoleCommandShortcut(command).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue()); 440 command = createConsoleCommand(createFunctor(&SettingsConfigFile::getConfig, this), "getConfig"); 441 CommandExecutor::addConsoleCommandShortcut(command).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()); 447 ModifyConsoleCommand(__CC_load_name).setObject(this); 448 ModifyConsoleCommand(__CC_setFilename_name).setObject(this); 449 ModifyConsoleCommand(__CC_config_name).setObject(this); 450 ModifyConsoleCommand(__CC_tconfig_name).setObject(this); 451 ModifyConsoleCommand(__CC_getConfig_name).setObject(this); 442 452 } 443 453 444 454 SettingsConfigFile::~SettingsConfigFile() 445 455 { 456 ModifyConsoleCommand(__CC_load_name).setObject(0); 457 ModifyConsoleCommand(__CC_setFilename_name).setObject(0); 458 ModifyConsoleCommand(__CC_config_name).setObject(0); 459 ModifyConsoleCommand(__CC_tconfig_name).setObject(0); 460 ModifyConsoleCommand(__CC_getConfig_name).setObject(0); 446 461 } 447 462 … … 543 558 } 544 559 545 bool SettingsConfigFile::config(const std::string& section, const std::string& entry, const std::string& value) 546 { 547 return this->configImpl(section, entry, value, &ConfigValueContainer::set); 548 } 549 550 bool SettingsConfigFile::tconfig(const std::string& section, const std::string& entry, const std::string& value) 551 { 552 return this->configImpl(section, entry, value, &ConfigValueContainer::tset); 560 void SettingsConfigFile::config(const std::string& section, const std::string& entry, const std::string& value) 561 { 562 if (!this->configImpl(section, entry, value, &ConfigValueContainer::set)) 563 COUT(1) << "Error: Config value \"" << entry << "\" in section \"" << section << "\" doesn't exist." << std::endl; 564 } 565 566 void SettingsConfigFile::tconfig(const std::string& section, const std::string& entry, const std::string& value) 567 { 568 if (!this->configImpl(section, entry, value, &ConfigValueContainer::tset)) 569 COUT(1) << "Error: Config value \"" << entry << "\" in section \"" << section << "\" doesn't exist." << std::endl; 553 570 } 554 571 -
code/trunk/src/libraries/core/ConfigFileManager.h
r7163 r7284 331 331 void clean(bool bCleanComments = false); // tolua_export 332 332 333 boolconfig(const std::string& section, const std::string& entry, const std::string& value); // tolua_export334 booltconfig(const std::string& section, const std::string& entry, const std::string& value); // tolua_export333 void config(const std::string& section, const std::string& entry, const std::string& value); // tolua_export 334 void tconfig(const std::string& section, const std::string& entry, const std::string& value); // tolua_export 335 335 std::string getConfig(const std::string& section, const std::string& entry); // tolua_export 336 336 -
code/trunk/src/libraries/core/ConfigValueContainer.cc
r6536 r7284 302 302 bool ConfigValueContainer::callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiType&), const std::string& input) 303 303 { 304 SubString token(input, " ", SubString::WhiteSpaces, true, '\\', false, '"', false, ' (', ')', false, '\0');304 SubString token(input, " ", SubString::WhiteSpaces, true, '\\', false, '"', false, '\0', '\0', false, '\0'); 305 305 int index = -1; 306 306 bool success = false; -
code/trunk/src/libraries/core/Core.cc
r7175 r7284 52 52 #include "util/Exception.h" 53 53 #include "util/Scope.h" 54 #include "util/ScopedSingletonManager.h" 54 55 #include "util/SignalHandler.h" 55 56 #include "PathConfig.h" 56 #include "CommandExecutor.h"57 57 #include "CommandLineParser.h" 58 58 #include "ConfigFileManager.h" … … 65 65 #include "Identifier.h" 66 66 #include "Language.h" 67 #include "IOConsole.h"68 67 #include "LuaState.h" 69 #include "ScopedSingletonManager.h" 70 #include "TclBind.h" 71 #include "TclThreadManager.h" 68 #include "command/ConsoleCommand.h" 69 #include "command/IOConsole.h" 70 #include "command/TclBind.h" 71 #include "command/TclThreadManager.h" 72 72 #include "input/InputManager.h" 73 73 … … 88 88 : identifierDestroyer_(Identifier::destroyAllIdentifiers) 89 89 // Cleanup guard for external console commands that don't belong to an Identifier 90 , consoleCommandDestroyer_(Co mmandExecutor::destroyExternalCommands)90 , consoleCommandDestroyer_(ConsoleCommand::destroyAll) 91 91 , bGraphicsLoaded_(false) 92 92 , bStartIOConsole_(true) -
code/trunk/src/libraries/core/CorePrereqs.h
r7271 r7284 119 119 T orxonox_cast(U*); 120 120 121 class ArgumentCompleter;122 class ArgumentCompletionListElement;123 121 class BaseObject; 124 122 template <class T> … … 130 128 class ClassTreeMaskNode; 131 129 class ClassTreeMaskObjectIterator; 132 class CommandEvaluation;133 130 class CommandLineParser; 134 131 class CommandLineArgument; … … 140 137 class ConfigFileSection; 141 138 class ConfigValueContainer; 142 class ConsoleCommand;143 139 class Core; 144 140 class DynLib; … … 146 142 struct Event; 147 143 class EventState; 148 class Executor;149 template <class T>150 class ExecutorMember;151 class ExecutorStatic;152 144 class Factory; 153 class Functor;154 template <class T>155 class FunctorMember;156 class FunctorStatic;157 145 class Game; 158 146 class GameState; … … 162 150 class GUIManager; 163 151 class Identifier; 164 class IOConsole;165 class IRC;166 152 template <class T> 167 153 class Iterator; 168 154 class Language; 155 class LuaFunctor; 169 156 class LuaState; 170 157 class MemoryArchive; … … 187 174 struct ResourceInfo; 188 175 class SettingsConfigFile; 189 class Shell;190 class ShellListener;191 176 template <class T> 192 177 class SmartPtr; 193 178 template <class T> 194 179 class SubclassIdentifier; 195 class TclBind;196 struct TclInterpreterBundle;197 template <class T>198 class TclThreadList;199 class TclThreadManager;200 180 class Template; 201 181 class Thread; … … 212 192 class XMLPortObjectContainer; 213 193 class XMLPortParamContainer; 194 195 // Command 196 class ArgumentCompleter; 197 class ArgumentCompletionListElement; 198 class CommandEvaluation; 199 class ConsoleCommand; 200 class Executor; 201 template <class T> 202 class ExecutorMember; 203 class ExecutorStatic; 204 class Functor; 205 template <class O> 206 class FunctorMember; 207 typedef FunctorMember<void> FunctorStatic; 208 template <class F, class O> 209 class FunctorPointer; 210 class IOConsole; 211 class IRC; 212 class Shell; 213 class ShellListener; 214 class TclBind; 215 struct TclInterpreterBundle; 216 template <class T> 217 class TclThreadList; 218 class TclThreadManager; 214 219 215 220 // Input … … 238 243 } 239 244 245 #include "command/FunctorPtr.h" 246 #include "command/ExecutorPtr.h" 247 240 248 // CppTcl 241 249 namespace Tcl -
code/trunk/src/libraries/core/Event.cc
r7271 r7284 34 34 namespace orxonox 35 35 { 36 /**37 @brief Destructor: Deletes the functor of the event state.38 */39 EventState::~EventState()40 {41 if (this->statefunction_)42 delete this->statefunction_;43 }44 45 36 /** 46 37 @brief Processes an event (calls the set-function if the necessary conditions are met). -
code/trunk/src/libraries/core/Event.h
r6800 r7284 67 67 { 68 68 public: 69 EventState(Functor* statefunction, Identifier* subclass, bool bSink = false) : bProcessingEvent_(false), activeEvents_(0), statefunction_(statefunction), subclass_(subclass), bSink_(bSink) {} 70 virtual ~EventState(); 69 EventState(const FunctorPtr& statefunction, Identifier* subclass, bool bSink = false) : bProcessingEvent_(false), activeEvents_(0), statefunction_(statefunction), subclass_(subclass), bSink_(bSink) {} 71 70 72 71 void process(const Event& event, BaseObject* object); 73 72 74 Functor*getFunctor() const73 const FunctorPtr& getFunctor() const 75 74 { return this->statefunction_; } 76 75 … … 78 77 bool bProcessingEvent_; //!< This becomes true while the container processes an event (used to prevent loops) 79 78 int activeEvents_; //!< The number of events which affect this state and are currently active 80 Functor *statefunction_; //!< A functor to set the state79 FunctorPtr statefunction_; //!< A functor to set the state 81 80 Identifier* subclass_; //!< Originators must be an instance of this class (usually BaseObject, but some statefunctions allow a second argument with an originator of a specific class) 82 81 bool bSink_; //!< Determines whether the EventState acts as an EventSink forwarding any Event (even if the state didn't change) or in the normal manner, only processing Events that change the state. -
code/trunk/src/libraries/core/EventIncludes.h
r7163 r7284 31 31 32 32 #include "CorePrereqs.h" 33 #include "Executor.h"34 33 #include "XMLPort.h" 34 #include "command/Executor.h" 35 35 36 36 /** … … 76 76 77 77 #define XMLPortEventStateIntern(name, classname, statename, xmlelement, mode) \ 78 static orxonox::ExecutorMember<classname>* xmlsetfunctor##name = (orxonox::ExecutorMember<classname>*)&orxonox::createExecutor(orxonox::createFunctor(&classname::addEventSource), std::string( #classname ) + "::" + "addEventSource" + '(' + statename + ')')->setDefaultValue(1, statename); \ 79 static orxonox::ExecutorMember<classname>* xmlgetfunctor##name = (orxonox::ExecutorMember<classname>*)&orxonox::createExecutor(orxonox::createFunctor(&classname::getEventSource), std::string( #classname ) + "::" + "getEventSource" + '(' + statename + ')')->setDefaultValue(1, statename); \ 78 static orxonox::ExecutorMemberPtr<classname> xmlsetfunctor##name = orxonox::createExecutor(orxonox::createFunctor(&classname::addEventSource), std::string( #classname ) + "::" + "addEventSource" + '(' + statename + ')').cast<orxonox::ExecutorMember<classname> >(); \ 79 static orxonox::ExecutorMemberPtr<classname> xmlgetfunctor##name = orxonox::createExecutor(orxonox::createFunctor(&classname::getEventSource), std::string( #classname ) + "::" + "getEventSource" + '(' + statename + ')').cast<orxonox::ExecutorMember<classname> >(); \ 80 xmlsetfunctor##name->setDefaultValue(1, statename); \ 81 xmlgetfunctor##name->setDefaultValue(1, statename); \ 80 82 XMLPortObjectGeneric(xmlport##name, classname, orxonox::BaseObject, statename, xmlsetfunctor##name, xmlgetfunctor##name, xmlelement, mode, false, true) 81 83 -
code/trunk/src/libraries/core/GUIManager.cc
r7163 r7284 57 57 #include "util/Exception.h" 58 58 #include "util/OrxAssert.h" 59 #include "ConsoleCommand.h"60 59 #include "Core.h" 61 60 #include "GraphicsManager.h" … … 63 62 #include "PathConfig.h" 64 63 #include "Resource.h" 64 #include "command/ConsoleCommand.h" 65 65 #include "input/InputManager.h" 66 66 #include "input/InputState.h" … … 71 71 static void key_esc() 72 72 { GUIManager::getInstance().keyESC(); } 73 SetConsoleCommand ShortcutExternAlias(key_esc, "keyESC");73 SetConsoleCommand("keyESC", &key_esc); 74 74 75 75 class CEGUILogger : public CEGUI::DefaultLogger … … 99 99 GUIManager* GUIManager::singletonPtr_s = 0; 100 100 101 SetConsoleCommand Shortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, false).defaultValue(2, true);102 SetConsoleCommand Shortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User);101 SetConsoleCommand("showGUI", &GUIManager::showGUI).defaultValue(1, false).defaultValue(2, true); 102 SetConsoleCommand("hideGUI", &GUIManager::hideGUI); 103 103 104 104 /** -
code/trunk/src/libraries/core/Game.cc
r7266 r7284 45 45 #include "util/SubString.h" 46 46 #include "CommandLineParser.h" 47 #include "ConsoleCommand.h"48 47 #include "Core.h" 49 48 #include "CoreIncludes.h" … … 52 51 #include "GameState.h" 53 52 #include "GUIManager.h" 53 #include "command/ConsoleCommand.h" 54 54 55 55 namespace orxonox … … 57 57 static void stop_game() 58 58 { Game::getInstance().stop(); } 59 SetConsoleCommand ShortcutExternAlias(stop_game, "exit");59 SetConsoleCommand("exit", &stop_game); 60 60 static void printFPS() 61 61 { COUT(0) << Game::getInstance().getAvgFPS() << std::endl; } 62 SetConsoleCommand ShortcutExternAlias(printFPS, "printFPS");62 SetConsoleCommand("printFPS", &printFPS); 63 63 static void printTickTime() 64 64 { COUT(0) << Game::getInstance().getAvgTickTime() << std::endl; } 65 SetConsoleCommand ShortcutExternAlias(printTickTime, "printTickTime");65 SetConsoleCommand("printTickTime", &printTickTime); 66 66 67 67 std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s; -
code/trunk/src/libraries/core/GraphicsManager.cc
r6524 r7284 52 52 #include "util/StringUtils.h" 53 53 #include "util/SubString.h" 54 #include "ConsoleCommand.h"55 54 #include "ConfigValueIncludes.h" 56 55 #include "CoreIncludes.h" … … 62 61 #include "WindowEventListener.h" 63 62 #include "XMLFile.h" 63 #include "command/ConsoleCommand.h" 64 64 65 65 namespace orxonox 66 66 { 67 static const std::string __CC_printScreen_name = "printScreen"; 68 DeclareConsoleCommand(__CC_printScreen_name, &prototype::void__void); 69 67 70 class OgreWindowEventListener : public Ogre::WindowEventListener 68 71 { … … 131 134 132 135 Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_.get()); 133 // TODO: Destroy the console command136 ModifyConsoleCommand(__CC_printScreen_name).resetFunction(); 134 137 135 138 // Undeclare the resources … … 290 293 boost::filesystem::path folder(ogrePluginsDirectory_); 291 294 // Do some SubString magic to get the comma separated list of plugins 292 SubString plugins(ogrePlugins_, ",", " ", false, '\\', false, '"', false, ' (', ')', false, '\0');295 SubString plugins(ogrePlugins_, ",", " ", false, '\\', false, '"', false, '{', '}', false, '\0'); 293 296 // Use backslash paths on Windows! file_string() already does that though. 294 297 for (unsigned int i = 0; i < plugins.size(); ++i) … … 321 324 322 325 // add console commands 323 ccPrintScreen_ = createConsoleCommand(createFunctor(&GraphicsManager::printScreen, this), "printScreen"); 324 CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_); 326 ModifyConsoleCommand(__CC_printScreen_name).setFunction(&GraphicsManager::printScreen, this); 325 327 } 326 328 -
code/trunk/src/libraries/core/GraphicsManager.h
r6417 r7284 114 114 int ogreLogLevelCritical_; //!< Corresponding Orxonox debug level for LL_CRITICAL 115 115 116 // console commands117 ConsoleCommand* ccPrintScreen_;118 119 116 static GraphicsManager* singletonPtr_s; //!< Pointer to the Singleton 120 117 }; -
code/trunk/src/libraries/core/Identifier.cc
r6536 r7284 38 38 #include "util/StringUtils.h" 39 39 #include "ConfigValueContainer.h" 40 #include "ConsoleCommand.h"41 40 #include "ClassFactory.h" 42 41 #include "XMLPort.h" … … 64 63 65 64 this->bHasConfigValues_ = false; 66 this->bHasConsoleCommands_ = false;67 65 68 66 // Default network ID is the class ID … … 80 78 delete this->factory_; 81 79 82 for (std::map<std::string, ConsoleCommand*>::iterator it = this->consoleCommands_.begin(); it != this->consoleCommands_.end(); ++it)83 delete (it->second);84 80 for (std::map<std::string, ConfigValueContainer*>::iterator it = this->configValues_.begin(); it != this->configValues_.end(); ++it) 85 81 delete (it->second); … … 433 429 434 430 /** 435 @brief Adds a new console command of this class.436 @param executor The executor of the command437 @param bCreateShortcut If this is true a shortcut gets created so you don't have to add the classname to access this command438 @return The executor of the command439 */440 ConsoleCommand& Identifier::addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut)441 {442 std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(command->getName());443 if (it != this->consoleCommands_.end())444 {445 COUT(2) << "Warning: Overwriting console-command with name " << command->getName() << " in class " << this->getName() << '.' << std::endl;446 delete (it->second);447 }448 449 this->bHasConsoleCommands_ = true;450 this->consoleCommands_[command->getName()] = command;451 this->consoleCommands_LC_[getLowercase(command->getName())] = command;452 453 if (bCreateShortcut)454 CommandExecutor::addConsoleCommandShortcut(command);455 456 return (*command);457 }458 459 /**460 @brief Returns the executor of a console command with given name.461 @brief name The name of the requested console command462 @return The executor of the requested console command463 */464 ConsoleCommand* Identifier::getConsoleCommand(const std::string& name) const465 {466 std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(name);467 if (it != this->consoleCommands_.end())468 return it->second;469 else470 return 0;471 }472 473 /**474 @brief Returns the executor of a console command with given name in lowercase.475 @brief name The name of the requested console command in lowercae476 @return The executor of the requested console command477 */478 ConsoleCommand* Identifier::getLowercaseConsoleCommand(const std::string& name) const479 {480 std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_LC_.find(name);481 if (it != this->consoleCommands_LC_.end())482 return it->second;483 else484 return 0;485 }486 487 /**488 431 @brief Returns a XMLPortParamContainer that loads a parameter of this class. 489 432 @param paramname The name of the parameter -
code/trunk/src/libraries/core/Identifier.h
r7271 r7284 202 202 void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container); 203 203 ConfigValueContainer* getConfigValueContainer(const std::string& varname); 204 205 206 ////////////////////////////207 ///// Console Commands /////208 ////////////////////////////209 /** @brief Returns true if this class has at least one console command. @return True if this class has at least one console command */210 inline bool hasConsoleCommands() const { return this->bHasConsoleCommands_; }211 212 /** @brief Returns the map that stores all console commands. @return The const_iterator */213 inline const std::map<std::string, ConsoleCommand*>& getConsoleCommandMap() const { return this->consoleCommands_; }214 /** @brief Returns a const_iterator to the beginning of the map that stores all console commands. @return The const_iterator */215 inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandMapBegin() const { return this->consoleCommands_.begin(); }216 /** @brief Returns a const_iterator to the end of the map that stores all console commands. @return The const_iterator */217 inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandMapEnd() const { return this->consoleCommands_.end(); }218 219 /** @brief Returns the map that stores all console commands with their names in lowercase. @return The const_iterator */220 inline const std::map<std::string, ConsoleCommand*>& getLowercaseConsoleCommandMap() const { return this->consoleCommands_LC_; }221 /** @brief Returns a const_iterator to the beginning of the map that stores all console commands with their names in lowercase. @return The const_iterator */222 inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandMapBegin() const { return this->consoleCommands_LC_.begin(); }223 /** @brief Returns a const_iterator to the end of the map that stores all console commands with their names in lowercase. @return The const_iterator */224 inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandMapEnd() const { return this->consoleCommands_LC_.end(); }225 226 ConsoleCommand& addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut);227 ConsoleCommand* getConsoleCommand(const std::string& name) const;228 ConsoleCommand* getLowercaseConsoleCommand(const std::string& name) const;229 204 230 205 … … 305 280 bool bHasConfigValues_; //!< True if this class has at least one assigned config value 306 281 std::map<std::string, ConfigValueContainer*> configValues_; //!< A map to link the string of configurable variables with their ConfigValueContainer 307 308 bool bHasConsoleCommands_; //!< True if this class has at least one assigned console command309 std::map<std::string, ConsoleCommand*> consoleCommands_; //!< All console commands of this class310 std::map<std::string, ConsoleCommand*> consoleCommands_LC_; //!< All console commands of this class with their names in lowercase311 282 312 283 std::map<std::string, XMLPortParamContainer*> xmlportParamContainers_; //!< All loadable parameters -
code/trunk/src/libraries/core/Language.cc
r6417 r7284 36 36 #include <fstream> 37 37 #include "util/Debug.h" 38 #include "util/StringUtils.h" 38 39 #include "Core.h" 39 40 #include "PathConfig.h" … … 169 170 @return The localisation 170 171 */ 171 const std::string& Language::getLocalisation(const LanguageEntryLabel& label ) const172 const std::string& Language::getLocalisation(const LanguageEntryLabel& label, bool bError) const 172 173 { 173 174 std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(label); 174 175 if (it != this->languageEntries_.end()) 175 176 return it->second->getLocalisation(); 176 else 177 else if (bError) 177 178 { 178 179 // Uh, oh, an undefined entry was requested: return the default string … … 180 181 return this->defaultLocalisation_; 181 182 } 183 else 184 return BLANKSTRING; 182 185 } 183 186 -
code/trunk/src/libraries/core/Language.h
r6536 r7284 116 116 117 117 void addEntry(const LanguageEntryLabel& label, const std::string& entry); 118 const std::string& getLocalisation(const LanguageEntryLabel& label ) const;118 const std::string& getLocalisation(const LanguageEntryLabel& label, bool bError = true) const; 119 119 120 120 private: … … 145 145 return Language::getInstance().getLocalisation(label); 146 146 } 147 148 //! Shortcut function for Language::getLocalisation without printing an error in case the label doesn't exist 149 inline const std::string& GetLocalisation_noerror(const LanguageEntryLabel& label) 150 { 151 return Language::getInstance().getLocalisation(label, false); 152 } 147 153 } 148 154 -
code/trunk/src/libraries/core/LuaState.cc
r7266 r7284 39 39 #include "util/Debug.h" 40 40 #include "util/Exception.h" 41 #include "IOConsole.h"42 41 #include "Resource.h" 43 42 #include "ToluaBindCore.h" 43 #include "command/IOConsole.h" 44 44 45 45 namespace orxonox … … 370 370 } 371 371 372 void LuaFunctor::operator()( const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)372 void LuaFunctor::operator()() 373 373 { 374 374 lua_->doString(this->code_); -
code/trunk/src/libraries/core/LuaState.h
r7266 r7284 40 40 #include <loki/ScopeGuard.h> 41 41 42 #include "Functor.h"43 42 #include "ToluaInterface.h" 44 43 45 44 namespace orxonox // tolua_export 46 45 { // tolua_export 47 class Functor; // tolua_export46 class LuaFunctor; // tolua_export 48 47 49 //! Functor subclass that simply executes code with 0 arguments.50 class _CoreExport LuaFunctor : public Functor48 //! callback class that executes lua code 49 class _CoreExport LuaFunctor 51 50 { 52 51 public: 53 52 LuaFunctor(const std::string& code, LuaState* luaState); 54 void operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null); 55 void evaluateParam(unsigned int index, MultiType& param) const {} 53 void operator()(); 56 54 57 55 private: … … 91 89 const shared_ptr<ResourceInfo>& getDefaultResourceInfo() { return this->sourceFileInfo_; } 92 90 93 Functor* createLuaFunctor(const std::string& code) { return new LuaFunctor(code, this); } // tolua_export91 LuaFunctor* createLuaFunctor(const std::string& code) { return new LuaFunctor(code, this); } // tolua_export 94 92 //! Tells about whether IOConsole was activated. The Lua debugger only works with a normal console. 95 93 bool usingIOConsole() const; // tolua_export -
code/trunk/src/libraries/core/Thread.cc
r6417 r7284 36 36 37 37 #include "util/Sleep.h" 38 #include " Executor.h"38 #include "command/Executor.h" 39 39 40 40 namespace orxonox … … 75 75 } 76 76 77 bool Thread::evaluateExecutor( Executor*executor )77 bool Thread::evaluateExecutor( const ExecutorPtr& executor ) 78 78 { 79 79 this->isWorkingMutex_->lock(); … … 92 92 { 93 93 //this->executorMutex_->lock(); 94 Executor *executor = this->executor_;94 ExecutorPtr executor = this->executor_; 95 95 //this->executorMutex_->unlock(); 96 96 if( executor ) … … 98 98 (*executor)(); 99 99 this->executorMutex_->lock(); 100 delete this->executor_;101 100 this->executor_ = 0; 102 101 this->executorMutex_->unlock(); -
code/trunk/src/libraries/core/Thread.h
r6417 r7284 46 46 bool isWorking(); 47 47 void waitUntilFinished(); 48 bool evaluateExecutor( Executor*executor );48 bool evaluateExecutor( const ExecutorPtr& executor ); 49 49 50 50 private: 51 51 void threadLoop(); 52 52 53 Executor *executor_;53 ExecutorPtr executor_; 54 54 bool isWorking_; 55 55 bool stopThread_; 56 56 boost::thread* workerThread_; 57 57 boost::mutex* executorMutex_; 58 boost::mutex* 58 boost::mutex* isWorkingMutex_; 59 59 boost::mutex* stopThreadMutex_; 60 60 }; -
code/trunk/src/libraries/core/ThreadPool.cc
r6417 r7284 81 81 } 82 82 83 bool ThreadPool::passFunction( Executor*executor, bool addThread )83 bool ThreadPool::passFunction( const ExecutorPtr& executor, bool addThread ) 84 84 { 85 85 std::vector<Thread*>::iterator it; -
code/trunk/src/libraries/core/ThreadPool.h
r6417 r7284 46 46 unsigned int setNrOfThreads( unsigned int nr ); 47 47 48 bool passFunction( Executor*executor, bool addThread=false );48 bool passFunction( const ExecutorPtr& executor, bool addThread=false ); 49 49 void synchronise(); 50 50 -
code/trunk/src/libraries/core/WeakPtr.h
r7268 r7284 37 37 #include "Identifier.h" 38 38 #include "OrxonoxClass.h" 39 #include " Functor.h"39 #include "command/Functor.h" 40 40 41 41 namespace orxonox … … 78 78 if (this->base_) 79 79 this->base_->unregisterWeakPtr(this); 80 if (this->callback_)81 delete this->callback_;82 80 83 81 } … … 169 167 } 170 168 171 inline void setCallback( Functor*callback)169 inline void setCallback(const FunctorPtr& callback) 172 170 { 173 171 this->callback_ = callback; 174 172 } 175 173 176 inline Functor* getFunctor() const174 inline const FunctorPtr& getCallback() const 177 175 { 178 176 return this->callback_; … … 190 188 T* pointer_; 191 189 OrxonoxClass* base_; 192 Functor *callback_;190 FunctorPtr callback_; 193 191 }; 194 192 -
code/trunk/src/libraries/core/XMLPort.h
r7271 r7284 53 53 #include "util/StringUtils.h" 54 54 #include "Identifier.h" 55 #include "Executor.h"56 55 #include "BaseObject.h" 56 #include "command/Executor.h" 57 57 58 58 // ------------ … … 75 75 */ 76 76 #define XMLPortParam(classname, paramname, loadfunction, savefunction, xmlelement, mode) \ 77 static ExecutorMember <classname>*xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \78 static ExecutorMember <classname>*xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \77 static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \ 78 static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \ 79 79 XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode) 80 80 … … 94 94 #define XMLPortParamVariable(classname, paramname, variable, xmlelement, mode) \ 95 95 XMLPortVariableHelperClass xmlcontainer##variable##dummy(static_cast<void*>(&variable)); \ 96 static ExecutorMember <orxonox::XMLPortVariableHelperClass>* xmlcontainer##variable##loadexecutor = static_cast<ExecutorMember<orxonox::XMLPortVariableHelperClass>*>(orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getLoader(variable)), std::string( #classname ) + "::" + #variable + "loader")); \97 static ExecutorMember <orxonox::XMLPortVariableHelperClass>* xmlcontainer##variable##saveexecutor = static_cast<ExecutorMember<orxonox::XMLPortVariableHelperClass>*>(orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getSaver (variable)), std::string( #classname ) + "::" + #variable + "saver" )); \96 static ExecutorMemberPtr<orxonox::XMLPortVariableHelperClass> xmlcontainer##variable##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getLoader(variable)), std::string( #classname ) + "::" + #variable + "loader"); \ 97 static ExecutorMemberPtr<orxonox::XMLPortVariableHelperClass> xmlcontainer##variable##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getSaver (variable)), std::string( #classname ) + "::" + #variable + "saver" ); \ 98 98 XMLPortParamGeneric(xmlcontainer##variable, classname, orxonox::XMLPortVariableHelperClass, &xmlcontainer##variable##dummy, paramname, xmlcontainer##variable##loadexecutor, xmlcontainer##variable##saveexecutor, xmlelement, mode) 99 99 … … 110 110 */ 111 111 #define XMLPortParamTemplate(classname, paramname, loadfunction, savefunction, xmlelement, mode, ...) \ 112 static ExecutorMember <classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \113 static ExecutorMember <classname>*xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \112 static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<void, classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \ 113 static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \ 114 114 XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode) 115 115 … … 129 129 */ 130 130 #define XMLPortParamLoadOnly(classname, paramname, loadfunction, xmlelement, mode) \ 131 static ExecutorMember <classname>*xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \131 static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \ 132 132 XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, xmlcontainer##loadfunction##0##loadexecutor, 0, xmlelement, mode) 133 133 /** … … 135 135 */ 136 136 #define XMLPortParamLoadOnlyTemplate(classname, paramname, loadfunction, xmlelement, mode, ...) \ 137 static ExecutorMember <classname>* xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \137 static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##0##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<void, classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \ 138 138 XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, xmlcontainer##loadfunction##0##loadexecutor, 0, xmlelement, mode) 139 139 … … 161 161 */ 162 162 #define XMLPortParamExtern(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode) \ 163 static ExecutorMember <externclass>*xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \164 static ExecutorMember <externclass>*xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \163 static ExecutorMemberPtr<externclass> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \ 164 static ExecutorMemberPtr<externclass> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \ 165 165 XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode); 166 166 /** … … 168 168 */ 169 169 #define XMLPortParamExternTemplate(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode, ...) \ 170 static ExecutorMember <externclass>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<externclass, __VA_ARGS__ >(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \171 static ExecutorMember <externclass>*xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \170 static ExecutorMemberPtr<externclass> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<void, externclass, __VA_ARGS__ >(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction); \ 171 static ExecutorMemberPtr<externclass> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction); \ 172 172 XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode); 173 173 … … 249 249 */ 250 250 #define XMLPortObjectExtended(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \ 251 static ExecutorMember <classname>*xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \252 static ExecutorMember <classname>*xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \251 static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \ 252 static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \ 253 253 XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore) 254 254 /** … … 256 256 */ 257 257 #define XMLPortObjectExtendedTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore, ...) \ 258 static ExecutorMember <classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \259 static ExecutorMember <classname>*xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \258 static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<void, classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \ 259 static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \ 260 260 XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore) 261 261 … … 267 267 */ 268 268 #define XMLPortObject(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode) \ 269 static ExecutorMember <classname>*xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \270 static ExecutorMember <classname>*xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \269 static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \ 270 static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \ 271 271 XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, false, true) 272 272 /** … … 274 274 */ 275 275 #define XMLPortObjectTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, ...) \ 276 static ExecutorMember <classname>* xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \277 static ExecutorMember <classname>*xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \276 static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##loadexecutor = orxonox::createExecutor(orxonox::createFunctor<void, classname, __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction); \ 277 static ExecutorMemberPtr<classname> xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \ 278 278 XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, false, true) 279 279 … … 317 317 { return this->paramname_; } 318 318 319 virtual XMLPortParamContainer& description(const std::string& description) = 0; 320 virtual const std::string& getDescription() = 0; 319 inline XMLPortParamContainer& description(const std::string& description) 320 { this->description_ = description; return *this; } 321 inline const std::string& getDescription() const 322 { return this->description_; } 321 323 322 324 virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param) = 0; … … 332 334 Identifier* identifier_; 333 335 BaseObject* owner_; 336 std::string description_; 334 337 }; 335 338 … … 345 348 346 349 public: 347 XMLPortClassParamContainer(const std::string& paramname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>*saveexecutor)350 XMLPortClassParamContainer(const std::string& paramname, Identifier* identifier, const ExecutorMemberPtr<T>& loadexecutor, const ExecutorMemberPtr<T>& saveexecutor) 348 351 { 349 352 this->paramname_ = paramname; … … 355 358 ~XMLPortClassParamContainer() 356 359 { 357 assert(this->loadexecutor_);358 delete this->loadexecutor_;359 if (this->saveexecutor_)360 delete this->saveexecutor_;361 360 } 362 361 … … 395 394 { 396 395 COUT(5) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << std::endl << this->owner_->getLoaderIndentation(); 397 if (this->loadexecutor_->parse(object, attributeValue, ",") || (mode == XMLPort::ExpandObject)) 396 int error; 397 this->loadexecutor_->parse(object, attributeValue, &error, ","); 398 if (!error || (mode == XMLPort::ExpandObject)) 398 399 this->parseResult_ = PR_finished; 399 400 else … … 436 437 } 437 438 438 virtual XMLPortParamContainer& description(const std::string& description)439 { this->loadexecutor_->setDescription(description); return (*this); }440 virtual const std::string& getDescription()441 { return this->loadexecutor_->getDescription(); }442 443 439 virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param) 444 440 { … … 479 475 480 476 private: 481 ExecutorMember <T>*loadexecutor_;482 ExecutorMember <T>*saveexecutor_;477 ExecutorMemberPtr<T> loadexecutor_; 478 ExecutorMemberPtr<T> saveexecutor_; 483 479 ParseParams parseParams_; 484 480 }; … … 502 498 { return this->sectionname_; } 503 499 504 virtual XMLPortObjectContainer& description(const std::string& description) = 0; 505 virtual const std::string& getDescription() = 0; 500 inline XMLPortObjectContainer& description(const std::string& description) 501 { this->description_ = description; return *this; } 502 const std::string& getDescription() const 503 { return this->description_; } 506 504 507 505 bool identifierIsIncludedInLoaderMask(const Identifier* identifier); … … 513 511 Identifier* identifier_; 514 512 Identifier* objectIdentifier_; 513 std::string description_; 515 514 }; 516 515 … … 519 518 { 520 519 public: 521 XMLPortClassObjectContainer(const std::string& sectionname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>*saveexecutor, bool bApplyLoaderMask, bool bLoadBefore)520 XMLPortClassObjectContainer(const std::string& sectionname, Identifier* identifier, const ExecutorMemberPtr<T>& loadexecutor, const ExecutorMemberPtr<T>& saveexecutor, bool bApplyLoaderMask, bool bLoadBefore) 522 521 { 523 522 this->sectionname_ = sectionname; … … 533 532 ~XMLPortClassObjectContainer() 534 533 { 535 assert(this->loadexecutor_);536 delete this->loadexecutor_;537 if (this->saveexecutor_)538 delete this->saveexecutor_;539 534 } 540 535 … … 549 544 } 550 545 551 virtual XMLPortObjectContainer& description(const std::string& description)552 { this->loadexecutor_->setDescription(description); return (*this); }553 virtual const std::string& getDescription()554 { return this->loadexecutor_->getDescription(); }555 556 546 private: 557 ExecutorMember <T>*loadexecutor_;558 ExecutorMember <T>*saveexecutor_;547 ExecutorMemberPtr<T> loadexecutor_; 548 ExecutorMemberPtr<T> saveexecutor_; 559 549 }; 560 550 -
code/trunk/src/libraries/core/input/Button.cc
r6536 r7284 39 39 #include "util/StringUtils.h" 40 40 #include "util/Debug.h" 41 #include "core/ ConsoleCommand.h"42 #include "core/ CommandEvaluation.h"43 #include "core/ CommandExecutor.h"41 #include "core/command/ConsoleCommand.h" 42 #include "core/command/CommandEvaluation.h" 43 #include "core/command/CommandExecutor.h" 44 44 #include "core/ConfigFileManager.h" 45 45 … … 117 117 // separate the commands 118 118 SubString commandStrings(bindingString_, "|", SubString::WhiteSpaces, false, 119 '\\', false, '"', false, ' (', ')', false, '\0');119 '\\', false, '"', false, '{', '}', false, '\0'); 120 120 121 121 for (unsigned int iCommand = 0; iCommand < commandStrings.size(); iCommand++) … … 124 124 { 125 125 SubString tokens(commandStrings[iCommand], " ", SubString::WhiteSpaces, false, 126 '\\', false, '"', false, ' (', ')', false, '\0');126 '\\', false, '"', false, '{', '}', false, '\0'); 127 127 128 128 KeybindMode::Value mode = KeybindMode::None; … … 175 175 176 176 // evaluate the command 177 const CommandEvaluation&eval = CommandExecutor::evaluate(commandStr);178 if (!eval.isValid() )177 CommandEvaluation eval = CommandExecutor::evaluate(commandStr); 178 if (!eval.isValid() || eval.evaluateParams(true)) 179 179 { 180 180 parseError("Command evaluation of \"" + commandStr + "\"failed.", true); -
code/trunk/src/libraries/core/input/HalfAxis.cc
r5781 r7284 34 34 35 35 #include "HalfAxis.h" 36 #include "core/ CommandEvaluation.h"36 #include "core/command/CommandEvaluation.h" 37 37 38 38 namespace orxonox -
code/trunk/src/libraries/core/input/InputCommands.h
r6417 r7284 37 37 38 38 #include "InputPrereqs.h" 39 #include "core/ CommandEvaluation.h"39 #include "core/command/CommandEvaluation.h" 40 40 41 41 namespace orxonox -
code/trunk/src/libraries/core/input/InputManager.cc
r7266 r7284 47 47 #include "core/CoreIncludes.h" 48 48 #include "core/ConfigValueIncludes.h" 49 #include "core/ConsoleCommand.h"50 49 #include "core/CommandLineParser.h" 51 #include "core/Functor.h"52 50 #include "core/GraphicsManager.h" 51 #include "core/command/ConsoleCommand.h" 52 #include "core/command/Functor.h" 53 53 54 54 #include "InputBuffer.h" … … 61 61 { 62 62 SetCommandLineSwitch(keyboard_no_grab).information("Whether not to exclusively grab the keyboard"); 63 64 static const std::string __CC_InputManager_name = "InputManager"; 65 static const std::string __CC_calibrate_name = "calibrate"; 66 static const std::string __CC_reload_name = "reload"; 67 68 SetConsoleCommand(__CC_InputManager_name, __CC_calibrate_name, &InputManager::calibrate).addShortcut(); 69 SetConsoleCommand(__CC_InputManager_name, __CC_reload_name, &InputManager::reload ); 63 70 64 71 // Abuse of this source file for the InputHandler … … 118 125 this->updateActiveStates(); 119 126 120 // calibrate console command 121 this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&InputManager::calibrate, this), "calibrate"), true); 122 // reload console command 123 this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&InputManager::reload, this), "reload"), false); 127 ModifyConsoleCommand(__CC_InputManager_name, __CC_calibrate_name).setObject(this); 128 ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(this); 124 129 125 130 CCOUT(4) << "Construction complete." << std::endl; … … 287 292 if (!(internalState_ & Bad)) 288 293 this->destroyDevices(); 294 295 // Reset console commands 296 ModifyConsoleCommand(__CC_InputManager_name, __CC_calibrate_name).setObject(0); 297 ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(0); 289 298 290 299 CCOUT(3) << "Destruction complete." << std::endl; -
code/trunk/src/libraries/core/input/InputState.cc
r6746 r7284 28 28 29 29 #include "InputState.h" 30 #include "core/ Functor.h"30 #include "core/command/Functor.h" 31 31 32 32 namespace orxonox -
code/trunk/src/libraries/core/input/InputState.h
r6746 r7284 150 150 void left(); 151 151 //! Sets a functor to be called upon activation of the state 152 void setEnterFunctor( Functor*functor) { this->enterFunctor_ = functor; }152 void setEnterFunctor(const FunctorPtr& functor) { this->enterFunctor_ = functor; } 153 153 //! Sets a functor to be called upon deactivation of the state 154 void setLeaveFunctor( Functor*functor) { this->leaveFunctor_ = functor; }154 void setLeaveFunctor(const FunctorPtr& functor) { this->leaveFunctor_ = functor; } 155 155 156 156 private: … … 172 172 //! Handler to be used for all joy sticks (needs to be saved in case another joy stick gets attached) 173 173 InputHandler* joyStickHandlerAll_; 174 Functor *enterFunctor_; //!< Functor to be executed on enter175 Functor *leaveFunctor_; //!< Functor to be executed on leave174 FunctorPtr enterFunctor_; //!< Functor to be executed on enter 175 FunctorPtr leaveFunctor_; //!< Functor to be executed on leave 176 176 }; 177 177 -
code/trunk/src/libraries/core/input/KeyBinderManager.cc
r6417 r7284 31 31 #include "util/Debug.h" 32 32 #include "util/Exception.h" 33 #include "util/ScopedSingletonManager.h" 33 34 #include "core/ConfigValueIncludes.h" 34 #include "core/ConsoleCommand.h"35 35 #include "core/CoreIncludes.h" 36 #include "core/ScopedSingletonManager.h" 36 #include "core/LuaState.h" 37 #include "core/command/ConsoleCommand.h" 37 38 #include "InputManager.h" 38 39 #include "KeyDetector.h" … … 41 42 { 42 43 ManageScopedSingleton(KeyBinderManager, ScopeID::Graphics, false); 44 45 static const std::string __CC_keybind_name = "keybind"; 46 static const std::string __CC_tkeybind_name = "tkeybind"; 47 static const std::string __CC_unbind_name = "unbind"; 48 static const std::string __CC_tunbind_name = "tunbind"; 49 50 SetConsoleCommand(__CC_keybind_name, &KeyBinderManager::keybind).defaultValues("").argumentCompleter(0, autocompletion::command()); 51 SetConsoleCommand(__CC_tkeybind_name, &KeyBinderManager::tkeybind).defaultValues("").argumentCompleter(0, autocompletion::command()); 52 SetConsoleCommand(__CC_unbind_name, &KeyBinderManager::unbind).defaultValues(""); 53 SetConsoleCommand(__CC_tunbind_name, &KeyBinderManager::tunbind).defaultValues(""); 43 54 44 55 KeyBinderManager::KeyBinderManager() … … 51 62 52 63 // keybind console commands 53 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::keybind, this), "keybind" )) 54 .defaultValues(""); 55 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::tkeybind, this), "tkeybind")) 56 .defaultValues(""); 57 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::unbind, this), "unbind")) 58 .defaultValues(""); 59 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::tunbind, this), "tunbind")) 60 .defaultValues(""); 64 ModifyConsoleCommand(__CC_keybind_name ).setObject(this); 65 ModifyConsoleCommand(__CC_tkeybind_name).setObject(this); 66 ModifyConsoleCommand(__CC_unbind_name ).setObject(this); 67 ModifyConsoleCommand(__CC_tunbind_name ).setObject(this); 61 68 62 69 // Load default key binder … … 69 76 for (std::map<std::string, KeyBinder*>::const_iterator it = this->binders_.begin(); it != this->binders_.end(); ++it) 70 77 delete it->second; 78 79 // Reset console commands 80 ModifyConsoleCommand(__CC_keybind_name ).setObject(0); 81 ModifyConsoleCommand(__CC_tkeybind_name).setObject(0); 82 ModifyConsoleCommand(__CC_unbind_name ).setObject(0); 83 ModifyConsoleCommand(__CC_tunbind_name ).setObject(0); 71 84 } 72 85 … … 156 169 { 157 170 COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl; 158 KeyDetector::getInstance().setCallback( shared_ptr<Functor>(createFunctor(&KeyBinderManager::keybindKeyPressed, this)));171 KeyDetector::getInstance().setCallback(createFunctor(&KeyBinderManager::keybindKeyPressed, this)); 159 172 InputManager::getInstance().enterState("detector"); 160 173 this->command_ = command; … … 187 200 // else: A key was probably pressed within the same tick, ignore it. 188 201 } 202 203 void KeyBinderManager::registerKeybindCallback(LuaFunctor* function) 204 { 205 this->callbackFunction_ = function; 206 } 189 207 } -
code/trunk/src/libraries/core/input/KeyBinderManager.h
r6417 r7284 99 99 void unbind(const std::string& binding); //tolua_export 100 100 void tunbind(const std::string& binding); 101 inline void registerKeybindCallback(Functor* function) { this->callbackFunction_.reset(function); } //tolua_export101 void registerKeybindCallback(LuaFunctor* function); //tolua_export 102 102 103 103 private: … … 114 114 115 115 // keybind command related 116 shared_ptr<Functor> callbackFunction_;//! Function to be called when key was pressed after "keybind" command116 SharedPtr<LuaFunctor> callbackFunction_; //! Function to be called when key was pressed after "keybind" command 117 117 bool bBinding_; //! Tells whether a key binding process is active 118 118 bool bTemporary_; //! Stores tkeybind/keybind value -
code/trunk/src/libraries/core/input/KeyDetector.cc
r6428 r7284 29 29 #include "KeyDetector.h" 30 30 31 #include " core/ConsoleCommand.h"31 #include "util/ScopedSingletonManager.h" 32 32 #include "core/CoreIncludes.h" 33 #include "core/ ScopedSingletonManager.h"33 #include "core/command/ConsoleCommand.h" 34 34 #include "Button.h" 35 35 #include "InputManager.h" … … 38 38 namespace orxonox 39 39 { 40 std::string KeyDetector::callbackCommand_s = "KeyDetectorKeyPressed";41 40 ManageScopedSingleton(KeyDetector, ScopeID::Graphics, false); 41 42 static const std::string __CC_KeyDetector_callback_name = "KeyDetectorKeyPressed"; 43 DeclareConsoleCommand(__CC_KeyDetector_callback_name, &prototype::void__string).hide(); 42 44 43 45 KeyDetector::KeyDetector() … … 46 48 RegisterObject(KeyDetector); 47 49 48 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyDetector::callback, this), callbackCommand_s)); 50 ModifyConsoleCommand(__CC_KeyDetector_callback_name).setFunction(&KeyDetector::callback, this); 51 49 52 this->assignCommands(); 50 53 … … 59 62 inputState_->setHandler(NULL); 60 63 InputManager::getInstance().destroyState("detector"); 64 ModifyConsoleCommand(__CC_KeyDetector_callback_name).resetFunction(); 61 65 } 62 66 … … 65 69 // Assign every button/axis the same command, but with its name as argument 66 70 for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it) 67 it->second->parse( callbackCommand_s+ ' ' + it->second->groupName_ + "." + it->second->name_);71 it->second->parse(__CC_KeyDetector_callback_name + ' ' + it->second->groupName_ + "." + it->second->name_); 68 72 } 69 73 -
code/trunk/src/libraries/core/input/KeyDetector.h
r6417 r7284 46 46 ~KeyDetector(); 47 47 48 void setCallback(const shared_ptr<Functor>& function) { this->callbackFunction_ = function; }48 void setCallback(const FunctorPtr& function) { this->callbackFunction_ = function; } 49 49 50 50 private: … … 55 55 void assignCommands(); 56 56 57 shared_ptr<Functor>callbackFunction_;57 FunctorPtr callbackFunction_; 58 58 InputState* inputState_; 59 static std::string callbackCommand_s;60 59 static KeyDetector* singletonPtr_s; 61 60 }; -
code/trunk/src/libraries/core/input/Mouse.cc
r5929 r7284 30 30 31 31 #include <ois/OISMouse.h> 32 #include "core/ConsoleCommand.h"33 32 #include "core/CoreIncludes.h" 33 #include "core/command/ConsoleCommand.h" 34 34 #include "InputState.h" 35 35 … … 41 41 namespace orxonox 42 42 { 43 #ifdef ORXONOX_PLATFORM_LINUX 44 static const std::string __CC_Mouse_name = "Mouse"; 45 static const std::string __CC_grab_name = "grab"; 46 static const std::string __CC_ungrab_name = "ungrab"; 47 48 SetConsoleCommand(__CC_Mouse_name, __CC_grab_name, &Mouse::grab); 49 SetConsoleCommand(__CC_Mouse_name, __CC_ungrab_name, &Mouse::ungrab); 50 #endif 51 43 52 Mouse::Mouse(unsigned int id, OIS::InputManager* oisInputManager) 44 53 : super(id, oisInputManager) … … 48 57 49 58 #ifdef ORXONOX_PLATFORM_LINUX 50 // Mouse grab console command 51 this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&Mouse::grab, this), "grab"), false); 52 // Mouse ungrab console command 53 this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&Mouse::ungrab, this), "ungrab"), false); 59 ModifyConsoleCommand(__CC_Mouse_name, __CC_grab_name).setObject(this); 60 ModifyConsoleCommand(__CC_Mouse_name, __CC_ungrab_name).setObject(this); 61 #endif 62 } 63 64 Mouse::~Mouse() 65 { 66 #ifdef ORXONOX_PLATFORM_LINUX 67 ModifyConsoleCommand(__CC_Mouse_name, __CC_grab_name).setObject(0); 68 ModifyConsoleCommand(__CC_Mouse_name, __CC_ungrab_name).setObject(0); 54 69 #endif 55 70 } -
code/trunk/src/libraries/core/input/Mouse.h
r5781 r7284 64 64 //! Only sets the clipping size. Initialising is done in the base class. 65 65 Mouse(unsigned int id, OIS::InputManager* oisInputManager); 66 ~Mouse() { }66 ~Mouse(); 67 67 68 68 #ifdef ORXONOX_PLATFORM_LINUX
Note: See TracChangeset
for help on using the changeset viewer.