Changeset 7284 for code/trunk/src/libraries
- Timestamp:
- Aug 31, 2010, 3:37:40 AM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 28 deleted
- 63 edited
- 37 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 -
code/trunk/src/libraries/network/Client.cc
r7163 r7284 45 45 #include "util/Clock.h" 46 46 #include "util/Debug.h" 47 #include "util/ScopedSingletonManager.h" 47 48 #include "synchronisable/Synchronisable.h" 48 49 #include "packet/Chat.h" … … 52 53 #include "core/CommandLineParser.h" 53 54 #include "core/Game.h" 54 #include "core/ScopedSingletonManager.h"55 55 56 56 namespace orxonox … … 107 107 return ClientConnection::closeConnection(); 108 108 } 109 109 110 110 void Client::setDestination(const std::string& serverAddress, unsigned int port) 111 111 { -
code/trunk/src/libraries/network/ClientConnection.cc
r6417 r7284 149 149 uint32_t ClientConnection::getRTT() 150 150 { 151 assert(server_); 152 return server_->roundTripTime; 151 if (server_) 152 return server_->roundTripTime; 153 else 154 return 0; 153 155 } 154 156 -
code/trunk/src/libraries/network/GamestateManager.cc
r7163 r7284 47 47 48 48 #include "util/Debug.h" 49 #include "core/Executor.h"50 49 #include "core/ThreadPool.h" 50 #include "core/command/Executor.h" 51 51 #include "ClientInformation.h" 52 52 #include "packet/Acknowledgement.h" -
code/trunk/src/libraries/network/Host.cc
r7163 r7284 32 32 #include <string> 33 33 34 #include "core/ConsoleCommand.h"35 34 #include "core/ObjectList.h" 35 #include "core/command/ConsoleCommand.h" 36 36 #include "ChatListener.h" 37 37 38 38 namespace orxonox { 39 39 40 SetConsoleCommandShortcut(Host, Chat); 40 static const std::string __CC_printRTT_name = "printRTT"; 41 42 SetConsoleCommand("chat", &Host::Chat); 43 SetConsoleCommand(__CC_printRTT_name, &Host::printRTT); 41 44 42 45 // Host* Host::instance_=0; … … 52 55 // assert(instance_==0); 53 56 instances_s.push_back(this); 54 this->printRTTCC_ = createConsoleCommand( createFunctor(&Host::printRTT, this), "printRTT" ); 55 CommandExecutor::addConsoleCommandShortcut( this->printRTTCC_ ); 57 ModifyConsoleCommand(__CC_printRTT_name).setObject(this); 56 58 this->bIsActive_ = false; 57 59 } … … 65 67 assert( std::find( instances_s.begin(), instances_s.end(), this )!=instances_s.end() ); 66 68 instances_s.erase(std::find( instances_s.begin(), instances_s.end(), this )); 67 if( this->printRTTCC_ ) 68 delete this->printRTTCC_; 69 ModifyConsoleCommand(__CC_printRTT_name).setObject(0); 69 70 } 70 71 … … 89 90 } 90 91 91 boolHost::Chat(const std::string& message)92 void Host::Chat(const std::string& message) 92 93 { 93 94 if(instances_s.size()==0) … … 95 96 for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it) 96 97 it->incomingChat(message, 0); 97 return true;98 // return true; 98 99 } 99 100 else … … 108 109 } 109 110 } 110 return result;111 // return result; 111 112 } 112 113 } … … 139 140 for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it) 140 141 it->incomingChat(message, playerID); 141 142 142 143 bool result = true; 143 144 for( std::vector<Host*>::iterator it = instances_s.begin(); it!=instances_s.end(); ++it ) -
code/trunk/src/libraries/network/Host.h
r7163 r7284 79 79 static void setShipID(unsigned int id){ shipID_s = id; } 80 80 static bool isServer(); 81 static boolChat(const std::string& message);81 static void Chat(const std::string& message); 82 82 static bool Broadcast(const std::string& message); 83 83 static bool incomingChat(const std::string& message, unsigned int playerID); … … 85 85 bool isActive(){ return bIsActive_; } 86 86 private: 87 ConsoleCommand* printRTTCC_;88 87 static uint32_t clientID_s; 89 88 static uint32_t shipID_s; -
code/trunk/src/libraries/network/LANDiscovery.cc
r7163 r7284 32 32 #include <cstring> 33 33 34 #include "util/ScopedSingletonManager.h" 34 35 #include "core/CoreIncludes.h" 35 #include "core/ScopedSingletonManager.h"36 36 37 37 38 38 namespace orxonox 39 { 39 { 40 40 ManageScopedSingleton(LANDiscovery, ScopeID::Root, true); 41 41 42 42 LANDiscovery::LANDiscovery() 43 43 { … … 49 49 enet_host_destroy(this->host_); 50 50 } 51 51 52 52 void LANDiscovery::discover() 53 53 { … … 56 56 enet_address_set_host(&address, "255.255.255.255"); 57 57 address.port = LAN_DISCOVERY_PORT; 58 58 59 59 ENetPeer* peer; 60 60 peer = enet_host_connect(this->host_, &address, 0); 61 61 62 62 ENetEvent event; 63 63 while( enet_host_service(this->host_, &event, 1000 ) ) … … 93 93 } 94 94 } 95 95 96 96 std::string LANDiscovery::getServerListItemName(unsigned int index) 97 97 { … … 101 101 return this->servers_[index].getServerName(); 102 102 } 103 103 104 104 std::string LANDiscovery::getServerListItemIP(unsigned int index) 105 105 { … … 109 109 return this->servers_[index].getServerIP(); 110 110 } 111 112 111 112 113 113 } // namespace orxonox -
code/trunk/src/libraries/network/NetworkFunction.cc
r6417 r7284 68 68 69 69 70 NetworkFunctionStatic::NetworkFunctionStatic( FunctorStatic*functor, const std::string& name, const NetworkFunctionPointer& p):70 NetworkFunctionStatic::NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p): 71 71 NetworkFunctionBase(name) 72 72 { … … 76 76 NetworkFunctionStatic::getFunctorMap()[p] = this; 77 77 NetworkFunctionStatic::getIdMap()[ this->getNetworkID() ] = this; 78 }79 80 NetworkFunctionStatic::~NetworkFunctionStatic()81 {82 delete this->functor_;83 78 } 84 79 -
code/trunk/src/libraries/network/NetworkFunction.h
r6417 r7284 39 39 #include <boost/static_assert.hpp> 40 40 41 #include "core/Functor.h"42 41 #include "core/Identifier.h" 42 #include "core/command/Functor.h" 43 43 #include "FunctionCallManager.h" 44 44 #include "synchronisable/Synchronisable.h" … … 102 102 class _NetworkExport NetworkFunctionStatic: public NetworkFunctionBase { 103 103 public: 104 NetworkFunctionStatic(FunctorStatic* functor, const std::string& name, const NetworkFunctionPointer& p); 105 ~NetworkFunctionStatic(); 104 NetworkFunctionStatic(const FunctorStaticPtr& functor, const std::string& name, const NetworkFunctionPointer& p); 106 105 107 106 inline void call(){ (*this->functor_)(); } … … 124 123 static std::map<NetworkFunctionPointer, NetworkFunctionStatic*>& getFunctorMap(); 125 124 static std::map<uint32_t, NetworkFunctionStatic*>& getIdMap(); 126 FunctorStatic *functor_;125 FunctorStaticPtr functor_; 127 126 128 127 }; … … 155 154 template <class T> class NetworkMemberFunction: public NetworkMemberFunctionBase { 156 155 public: 157 NetworkMemberFunction(FunctorMember<T>* functor, const std::string& name, const NetworkFunctionPointer& p); 158 ~NetworkMemberFunction(); 156 NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p); 159 157 160 158 inline void call(uint32_t objectID) … … 190 188 191 189 private: 192 FunctorMember <T>*functor_;193 }; 194 195 template <class T> NetworkMemberFunction<T>::NetworkMemberFunction( FunctorMember<T>*functor, const std::string& name, const NetworkFunctionPointer& p):190 FunctorMemberPtr<T> functor_; 191 }; 192 193 template <class T> NetworkMemberFunction<T>::NetworkMemberFunction(const FunctorMemberPtr<T>& functor, const std::string& name, const NetworkFunctionPointer& p): 196 194 NetworkMemberFunctionBase(name, p), functor_(functor) 197 195 { 198 }199 template <class T> NetworkMemberFunction<T>::~NetworkMemberFunction()200 {201 delete this->functor_;202 196 } 203 197 -
code/trunk/src/libraries/network/Server.cc
r7163 r7284 49 49 #include "util/Debug.h" 50 50 #include "core/ObjectList.h" 51 #include "core/ Executor.h"51 #include "core/command/Executor.h" 52 52 #include "packet/Chat.h" 53 53 #include "packet/ClassID.h" -
code/trunk/src/libraries/network/synchronisable/Serialise.h
r7266 r7284 42 42 #include "core/CorePrereqs.h" 43 43 #include "core/CoreIncludes.h" 44 #include "core/SmartPtr.h" 44 #include "core/BaseObject.h" // remove this if circular dependencies in BaseObject/SmartPtr are fixed 45 //#include "core/SmartPtr.h" 45 46 46 47 namespace orxonox{ 47 48 48 49 // These functions implement loading / saving / etc. for pointer types 49 50 50 51 /** @brief returns the size of the objectID needed to synchronise the pointer */ 51 52 template <class T> inline uint32_t returnSize( T*& variable ) … … 53 54 return sizeof(uint32_t); 54 55 } 55 56 56 57 /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */ 57 58 template <class T> inline void loadAndIncrease( T*& variable, uint8_t*& mem ) … … 60 61 mem += returnSize( variable ); 61 62 } 62 63 63 64 /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */ 64 65 template <class T> inline void saveAndIncrease( T*& variable, uint8_t*& mem ) … … 70 71 mem += returnSize( variable ); 71 72 } 72 73 73 74 /** @brief checks whether the objectID of the variable is the same as in the bytestream */ 74 75 template <class T> inline bool checkEquality( T*& variable, uint8_t* mem ) … … 79 80 return variable == variable->getSynchronisable(*(uint32_t*)(mem)); 80 81 } 81 82 82 83 // These functions implement loading / saving / etc. for SmartPtr<T> 83 84 84 85 /** @brief returns the size of the objectID needed to synchronise the pointer */ 85 86 template <class T> inline uint32_t returnSize( const SmartPtr<T>& variable ) … … 87 88 return sizeof(uint32_t); 88 89 } 89 90 90 91 /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */ 91 92 template <class T> inline void loadAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem ) … … 95 96 mem += returnSize( variable ); 96 97 } 97 98 98 99 /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */ 99 100 template <class T> inline void saveAndIncrease( const SmartPtr<T>& variable, uint8_t*& mem ) … … 105 106 mem += returnSize( variable ); 106 107 } 107 108 108 109 /** @brief checks whether the objectID of the variable is the same as in the bytestream */ 109 110 template <class T> inline bool checkEquality( const SmartPtr<T>& variable, uint8_t* mem ) … … 114 115 return *(uint32_t*)(mem) == OBJECTID_UNKNOWN; 115 116 } 116 117 117 118 // These functions implement loading / saving / etc. for WeakPtr<T> 118 119 119 120 /** @brief returns the size of the objectID needed to synchronise the pointer */ 120 121 template <class T> inline uint32_t returnSize( const WeakPtr<T>& variable ) … … 122 123 return sizeof(uint32_t); 123 124 } 124 125 125 126 /** @brief reads the objectID of a pointer out of the bytestream and increases the mem pointer */ 126 127 template <class T> inline void loadAndIncrease( const WeakPtr<T>& variable, uint8_t*& mem ) … … 130 131 mem += returnSize( variable ); 131 132 } 132 133 133 134 /** @brief saves the objectID of a pointer into the bytestream and increases the mem pointer */ 134 135 template <class T> inline void saveAndIncrease( const WeakPtr<T>& variable, uint8_t*& mem ) … … 140 141 mem += returnSize( variable ); 141 142 } 142 143 143 144 /** @brief checks whether the objectID of the variable is the same as in the bytestream */ 144 145 template <class T> inline bool checkEquality( const WeakPtr<T>& variable, uint8_t* mem ) -
code/trunk/src/libraries/tools/Timer.cc
r6417 r7284 33 33 #include "util/Clock.h" 34 34 #include "core/CoreIncludes.h" 35 #include "core/ ConsoleCommand.h"36 #include "core/ CommandExecutor.h"37 #include "core/ Functor.h"35 #include "core/command/ConsoleCommand.h" 36 #include "core/command/CommandExecutor.h" 37 #include "core/command/Functor.h" 38 38 39 39 namespace orxonox 40 40 { 41 SetConsoleCommand ShortcutExtern(delay);42 SetConsoleCommand ShortcutExtern(killdelays);41 SetConsoleCommand("delay", &delay).argumentCompleter(1, autocompletion::command()); 42 SetConsoleCommand("killdelays", &killdelays); 43 43 44 44 static std::set<Timer*> delaytimerset; … … 54 54 delaytimerset.insert(delaytimer); 55 55 56 ExecutorStatic*delayexecutor = createExecutor(createFunctor(&executeDelayedCommand));56 const ExecutorStaticPtr& delayexecutor = createExecutor(createFunctor(&executeDelayedCommand)); 57 57 delayexecutor->setDefaultValues(delaytimer, command); 58 58 delaytimer->setTimer(delay, false, delayexecutor); … … 97 97 @param exeuctor A executor of the function to call 98 98 */ 99 Timer::Timer(float interval, bool bLoop, Executor*executor, bool bKillAfterCall)99 Timer::Timer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall) 100 100 { 101 101 this->init(); … … 103 103 104 104 this->setTimer(interval, bLoop, executor, bKillAfterCall); 105 }106 107 /**108 @brief Deletes the executor.109 */110 Timer::~Timer()111 {112 this->deleteExecutor();113 105 } 114 106 … … 138 130 if (temp) 139 131 this->destroy(); 140 }141 142 /**143 @brief Deletes the executor.144 */145 void Timer::deleteExecutor()146 {147 if (this->executor_)148 delete this->executor_;149 132 } 150 133 -
code/trunk/src/libraries/tools/Timer.h
r6417 r7284 44 44 45 45 source.cc: 46 include "core/Executor.h"46 #include "core/command/Executor.h" 47 47 48 48 ClassName::ClassName() … … 63 63 #include "tools/ToolsPrereqs.h" 64 64 65 #include "core/Executor.h"66 65 #include "core/OrxonoxClass.h" 66 #include "core/command/Executor.h" 67 67 #include "tools/interfaces/TimeFactorListener.h" 68 68 … … 78 78 public: 79 79 Timer(); 80 ~Timer();81 80 82 Timer(float interval, bool bLoop, Executor*executor, bool bKillAfterCall = false);81 Timer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false); 83 82 84 83 /** … … 89 88 @param executor A executor of the function to call 90 89 */ 91 void setTimer(float interval, bool bLoop, Executor*executor, bool bKillAfterCall = false)90 void setTimer(float interval, bool bLoop, const ExecutorPtr& executor, bool bKillAfterCall = false) 92 91 { 93 this->deleteExecutor();94 95 92 this->setInterval(interval); 96 93 this->bLoop_ = bLoop; … … 103 100 104 101 void run(); 105 void deleteExecutor();106 102 107 103 /** @brief Starts the Timer: Function-call after 'interval' seconds. */ … … 141 137 void init(); 142 138 143 Executor *executor_; //!< The executor of the function that should be called when the time expires139 ExecutorPtr executor_; //!< The executor of the function that should be called when the time expires 144 140 145 long long interval_; //!< The time-interval in micro seconds146 bool bLoop_; //!< If true, the function gets called every 'interval' seconds147 bool bActive_; //!< If true, the Timer ticks and calls the function if the time's up148 bool bKillAfterCall_; //!< If true the timer gets deleted after it called the function141 long long interval_; //!< The time-interval in micro seconds 142 bool bLoop_; //!< If true, the function gets called every 'interval' seconds 143 bool bActive_; //!< If true, the Timer ticks and calls the function if the time's up 144 bool bKillAfterCall_; //!< If true the timer gets deleted after it called the function 149 145 150 long long time_; //!< Internal variable, counting the time till the next function-call146 long long time_; //!< Internal variable, counting the time till the next function-call 151 147 }; 152 148 } -
code/trunk/src/libraries/util/CMakeLists.txt
r7226 r7284 31 31 CRC32.cc 32 32 OutputHandler.cc 33 ScopedSingletonManager.cc 34 SharedPtr.cc 33 35 SignalHandler.cc 34 36 Sleep.cc 37 SmallObjectAllocator.cc 35 38 SubString.cc 36 39 COMPILATION_END -
code/trunk/src/libraries/util/Convert.h
r7266 r7284 109 109 } 110 110 }; 111 112 //////////// 113 // upcast // 114 //////////// 115 namespace detail 116 { 117 // perform a static cast if ToType is a base of FromType 118 template<class ToType, class FromType> 119 FORCEINLINE ToType upcast(FromType input, Loki::Int2Type<true>) 120 { 121 return static_cast<ToType>(input); 122 } 123 124 // return zero if ToType is not a base of FromType 125 template<class ToType, class FromType> 126 FORCEINLINE ToType upcast(FromType input, Loki::Int2Type<false>) 127 { 128 return 0; 129 } 130 } 131 132 // performs an upcast if ToType is a base of FromType, returns zero otherwise 133 template <class ToType, class FromType> 134 FORCEINLINE ToType upcast(FromType input) 135 { 136 enum { probe = ImplicitConversion<FromType, ToType>::exists }; 137 return detail::upcast<ToType, FromType>(input, Loki::Int2Type<probe>()); 138 } 111 139 } 112 140 -
code/trunk/src/libraries/util/Math.cc
r7184 r7284 234 234 bool ConverterFallback<std::string, orxonox::Vector2>::convert(orxonox::Vector2* output, const std::string& input) 235 235 { 236 size_t opening_parenthesis, closing_parenthesis = input.find(' )');237 if ((opening_parenthesis = input.find(' (')) == std::string::npos)236 size_t opening_parenthesis, closing_parenthesis = input.find('}'); 237 if ((opening_parenthesis = input.find('{')) == std::string::npos) 238 238 opening_parenthesis = 0; 239 239 else … … 257 257 bool ConverterFallback<std::string, orxonox::Vector3>::convert(orxonox::Vector3* output, const std::string& input) 258 258 { 259 size_t opening_parenthesis, closing_parenthesis = input.find(' )');260 if ((opening_parenthesis = input.find(' (')) == std::string::npos)259 size_t opening_parenthesis, closing_parenthesis = input.find('}'); 260 if ((opening_parenthesis = input.find('{')) == std::string::npos) 261 261 opening_parenthesis = 0; 262 262 else … … 282 282 bool ConverterFallback<std::string, orxonox::Vector4>::convert(orxonox::Vector4* output, const std::string& input) 283 283 { 284 size_t opening_parenthesis, closing_parenthesis = input.find(' )');285 if ((opening_parenthesis = input.find(' (')) == std::string::npos)284 size_t opening_parenthesis, closing_parenthesis = input.find('}'); 285 if ((opening_parenthesis = input.find('{')) == std::string::npos) 286 286 opening_parenthesis = 0; 287 287 else … … 309 309 bool ConverterFallback<std::string, orxonox::Quaternion>::convert(orxonox::Quaternion* output, const std::string& input) 310 310 { 311 size_t opening_parenthesis, closing_parenthesis = input.find(')'); 312 if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; } 311 size_t opening_parenthesis, closing_parenthesis = input.find('}'); 312 if ((opening_parenthesis = input.find('{')) == std::string::npos) 313 opening_parenthesis = 0; 314 else 315 opening_parenthesis++; 313 316 314 317 SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0'); … … 332 335 bool ConverterFallback<std::string, orxonox::ColourValue>::convert(orxonox::ColourValue* output, const std::string& input) 333 336 { 334 size_t opening_parenthesis, closing_parenthesis = input.find(')'); 335 if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; } 337 size_t opening_parenthesis, closing_parenthesis = input.find('}'); 338 if ((opening_parenthesis = input.find('{')) == std::string::npos) 339 opening_parenthesis = 0; 340 else 341 opening_parenthesis++; 336 342 337 343 SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0'); -
code/trunk/src/libraries/util/MultiType.h
r7268 r7284 77 77 #include <OgreColourValue.h> 78 78 #include <loki/TypeTraits.h> 79 #include "mbool.h" 79 80 80 81 namespace orxonox … … 265 266 inline MultiType(const orxonox::Radian& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 266 267 inline MultiType(const orxonox::Degree& value) : value_(0) { this->assignValue(value); } /** @brief Constructor: Assigns the given value and sets the type. */ 268 inline MultiType(const orxonox::mbool& value) : value_(0) { this->assignValue((bool)value); } /** @brief Constructor: Assigns the given mbool and converts it to bool. */ 267 269 inline MultiType(const char* value) : value_(0) { this->setValue(std::string(value)); } /** @brief Constructor: Converts the char array to a std::string, assigns the value and sets the type. */ 268 270 inline MultiType(const MultiType& other) : value_(0) { this->setValue(other); } /** @brief Copyconstructor: Assigns value and type of the other MultiType. */ … … 318 320 inline void copy(const MultiType& other) { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; } 319 321 320 template <typename T> inline bool convert() { return this->setValue<T>(( T)(*this)); } /** @brief Converts the current value to type T. */322 template <typename T> inline bool convert() { return this->setValue<T>((typename Loki::TypeTraits<T>::UnqualifiedReferredType)(*this)); } /** @brief Converts the current value to type T. */ 321 323 inline bool convert(const MultiType& other) { return this->convert(other.getType()); } /** @brief Converts the current value to the type of the other MultiType. */ 322 324 bool convert(MT_Type::Value type); … … 350 352 351 353 /** @brief Checks whether the value is a default one. */ 352 bool hasDefaultValue() const { return this->value_->hasDefaultValue(); } 354 bool hasDefaultValue() const { return this->value_->hasDefaultValue(); } 355 356 /** @brief Checks if the MT contains no value. */ 357 bool null() const { return (!this->value_); } 353 358 354 359 operator char() const; … … 487 492 template <> inline bool MultiType::isType<orxonox::Degree>() const { return (this->value_ && this->value_->type_ == MT_Type::Degree); } /** @brief Returns true if the current type equals the given type. */ 488 493 494 template <> inline bool MultiType::convert<void>() { this->reset(); return true; } /** @brief Deletes the content, type becomes MT_Type::Null. */ 495 489 496 // Specialization to avoid ambiguities with the conversion operator 490 497 template <> inline bool MultiType::convert<std::string>() { return this->setValue<std::string> (this->operator std::string()); } /** @brief Converts the current value to the given type. */ -
code/trunk/src/libraries/util/OutputHandler.h
r6105 r7284 104 104 105 105 //! Writes to all output devices 106 static inline const std::string&log(const std::string& text)107 { OutputHandler::getOutStream(0).output(text) << std::endl; return text;}106 static inline void log(const std::string& text) 107 { OutputHandler::getOutStream(0).output(text) << std::endl; } 108 108 109 109 //! Writes an error message to the output 110 static inline const std::string&error(const std::string& text)111 { OutputHandler::getOutStream(1).output(text) << std::endl; return text;}110 static inline void error(const std::string& text) 111 { OutputHandler::getOutStream(1).output(text) << std::endl; } 112 112 113 113 //! Writes a warning message to the output 114 static inline const std::string&warning(const std::string& text)115 { OutputHandler::getOutStream(2).output(text) << std::endl; return text;}114 static inline void warning(const std::string& text) 115 { OutputHandler::getOutStream(2).output(text) << std::endl; } 116 116 117 117 //! Writes an informational message to the output 118 static inline const std::string&info(const std::string& text)119 { OutputHandler::getOutStream(3).output(text) << std::endl; return text;}118 static inline void info(const std::string& text) 119 { OutputHandler::getOutStream(3).output(text) << std::endl; } 120 120 121 121 //! Writes a debug message to the output 122 static inline const std::string&debug(const std::string& text)123 { OutputHandler::getOutStream(4).output(text) << std::endl; return text;}122 static inline void debug(const std::string& text) 123 { OutputHandler::getOutStream(4).output(text) << std::endl; } 124 124 125 125 //! Registers an object that receives output via a provided std::ostream -
code/trunk/src/libraries/util/StringUtils.cc
r6424 r7284 35 35 36 36 #include <cctype> 37 #include <boost/scoped_array.hpp> 37 38 #include "Convert.h" 38 39 #include "Math.h" … … 514 515 @return Number of replacements 515 516 */ 516 _UtilExportsize_t replaceCharacters(std::string& str, char target, char replacement)517 size_t replaceCharacters(std::string& str, char target, char replacement) 517 518 { 518 519 size_t j = 0; … … 527 528 return j; 528 529 } 530 531 /** 532 @brief Calculates the Levenshtein distance between two strings. 533 534 The Levenshtein distance is defined by the number of transformations needed to convert str1 535 into str2. Possible transformations are substituted, added, or removed characters. 536 */ 537 unsigned int getLevenshteinDistance(const std::string& str1, const std::string& str2) 538 { 539 size_t cols = str1.size() + 1; 540 size_t rows = str2.size() + 1; 541 boost::scoped_array<int> matrix(new int[rows * cols]); 542 543 for (size_t r = 0; r < rows; ++r) 544 for (size_t c = 0; c < cols; ++c) 545 matrix[r*cols + c] = 0; 546 547 for (size_t i = 1; i < cols; ++i) 548 matrix[0*cols + i] = i; 549 for (size_t i = 1; i < rows; ++i) 550 matrix[i*cols + 0] = i; 551 552 for (size_t r = 1; r < rows; ++r) 553 for (size_t c = 1; c < cols; ++c) 554 matrix[r*cols + c] = (str1[c-1] != str2[r-1]); 555 556 for (size_t r = 1; r < rows; ++r) 557 for (size_t c = 1; c < cols; ++c) 558 matrix[r*cols + c] = std::min(std::min(matrix[(r-1)*cols + c] + 1, 559 matrix[r*cols + c-1] + 1), 560 matrix[(r-1)*cols + c-1] + (str1[c-1] != str2[r-1])); 561 562 return matrix[(rows-1)*cols + cols-1]; 563 } 529 564 } -
code/trunk/src/libraries/util/StringUtils.h
r5738 r7284 43 43 _UtilExport std::string getUniqueNumberString(); 44 44 45 _UtilExport void strip(std::string* str);46 _UtilExport std::string getStripped(const std::string& str);45 _UtilExport void strip(std::string* str); 46 _UtilExport std::string getStripped(const std::string& str); 47 47 48 _UtilExport std::string removeTrailingWhitespaces(const std::string& str);48 _UtilExport std::string removeTrailingWhitespaces(const std::string& str); 49 49 50 _UtilExport size_t getNextQuote(const std::string& str, size_t start);51 _UtilExport bool isBetweenQuotes(const std::string& str, size_t pos);50 _UtilExport size_t getNextQuote(const std::string& str, size_t start); 51 _UtilExport bool isBetweenQuotes(const std::string& str, size_t pos); 52 52 53 _UtilExport bool hasStringBetweenQuotes(const std::string& str);54 _UtilExport std::string getStringBetweenQuotes(const std::string& str);53 _UtilExport bool hasStringBetweenQuotes(const std::string& str); 54 _UtilExport std::string getStringBetweenQuotes(const std::string& str); 55 55 56 _UtilExport std::string stripEnclosingQuotes(const std::string& str);57 _UtilExport std::string stripEnclosingBraces(const std::string& str);56 _UtilExport std::string stripEnclosingQuotes(const std::string& str); 57 _UtilExport std::string stripEnclosingBraces(const std::string& str); 58 58 59 _UtilExport bool isEmpty(const std::string& str);60 _UtilExport bool isComment(const std::string& str);61 _UtilExport bool isNumeric(const std::string& str);59 _UtilExport bool isEmpty(const std::string& str); 60 _UtilExport bool isComment(const std::string& str); 61 _UtilExport bool isNumeric(const std::string& str); 62 62 63 _UtilExport std::string addSlashes(const std::string& str);64 _UtilExport std::string removeSlashes(const std::string& str);63 _UtilExport std::string addSlashes(const std::string& str); 64 _UtilExport std::string removeSlashes(const std::string& str); 65 65 66 _UtilExport void lowercase(std::string* str);67 _UtilExport std::string getLowercase(const std::string& str);66 _UtilExport void lowercase(std::string* str); 67 _UtilExport std::string getLowercase(const std::string& str); 68 68 69 _UtilExport void uppercase(std::string* str);70 _UtilExport std::string getUppercase(const std::string& str);69 _UtilExport void uppercase(std::string* str); 70 _UtilExport std::string getUppercase(const std::string& str); 71 71 72 _UtilExport int nocaseCmp(const std::string& s1, const std::string& s2);73 _UtilExport int nocaseCmp(const std::string& s1, const std::string& s2, size_t len);72 _UtilExport int nocaseCmp(const std::string& s1, const std::string& s2); 73 _UtilExport int nocaseCmp(const std::string& s1, const std::string& s2, size_t len); 74 74 75 _UtilExport bool hasComment(const std::string& str);76 _UtilExport std::string getComment(const std::string& str);77 _UtilExport size_t getCommentPosition(const std::string& str);78 _UtilExport size_t getNextCommentPosition(const std::string& str, size_t start = 0);75 _UtilExport bool hasComment(const std::string& str); 76 _UtilExport std::string getComment(const std::string& str); 77 _UtilExport size_t getCommentPosition(const std::string& str); 78 _UtilExport size_t getNextCommentPosition(const std::string& str, size_t start = 0); 79 79 80 _UtilExport size_t replaceCharacters(std::string& str, char target, char replacement); 80 _UtilExport size_t replaceCharacters(std::string& str, char target, char replacement); 81 82 _UtilExport unsigned int getLevenshteinDistance(const std::string& str1, const std::string& str2); 81 83 } 82 84 -
code/trunk/src/libraries/util/SubString.cc
r7165 r7284 309 309 * @param line the inputLine to split 310 310 * @param delimiters a String of Delimiters (here the input will be splitted) 311 * @param delimiterNeighbours N aighbours to the Delimitter, that will be removed if they are to the left or the right of a Delimiter.311 * @param delimiterNeighbours Neighbours to the Delimiter, that will be removed if they are to the left or the right of a Delimiter. 312 312 * @param emptyEntries: if empty Strings are added to the List of Strings. 313 313 * @param escape_char: Escape carater (escapes splitters) -
code/trunk/src/libraries/util/SubString.h
r5738 r7284 81 81 SL_SAFEESCAPE, //!< In safe mode with the internal escape character, that escapes even the savemode character. 82 82 SL_COMMENT, //!< In Comment mode. 83 SL_PARENTHESES, //!< Between parentheses (usually ' (' and ')')83 SL_PARENTHESES, //!< Between parentheses (usually '{' and '}') 84 84 SL_PARENTHESESESCAPE, //!< Between parentheses with the internal escape character, that escapes even the closing paranthesis character. 85 85 } SPLIT_LINE_STATE; … … 92 92 const std::string& delimiters, const std::string& delimiterNeighbours = "", bool emptyEntries=false, 93 93 char escapeChar ='\\', bool removeEscapeChar = true, char safemode_char = '"', bool removeSafemodeChar = true, 94 char openparenthesis_char = ' (', char closeparenthesis_char = ')', bool removeParenthesisChars = true, char comment_char = '\0');94 char openparenthesis_char = '{', char closeparenthesis_char = '}', bool removeParenthesisChars = true, char comment_char = '\0'); 95 95 SubString(unsigned int argc, const char** argv); 96 96 /** @brief create a Substring as a copy of another one. @param subString the SubString to copy. */ … … 116 116 const std::string& delimiters, const std::string& delimiterNeighbours = "", bool emptyEntries = false, 117 117 char escapeChar ='\\', bool removeExcapeChar = true, char safemode_char = '"', bool removeSafemodeChar = true, 118 char openparenthesis_char = ' (', char closeparenthesis_char = ')', bool removeParenthesisChars = true, char comment_char = '\0');118 char openparenthesis_char = '{', char closeparenthesis_char = '}', bool removeParenthesisChars = true, char comment_char = '\0'); 119 119 std::string join(const std::string& delimiter = " ") const; 120 120 //////////////////////////////////////// … … 155 155 char safemode_char = '"', 156 156 bool removeSafemodeChar = true, 157 char openparenthesis_char = ' (',158 char closeparenthesis_char = ' )',157 char openparenthesis_char = '{', 158 char closeparenthesis_char = '}', 159 159 bool removeParenthesisChars = true, 160 160 char comment_char = '\0',
Note: See TracChangeset
for help on using the changeset viewer.