Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 31, 2010, 3:37:40 AM (14 years ago)
Author:
landauf
Message:

merged consolecommands3 branch back to trunk.

note: the console command interface has changed completely, but the documentation is not yet up to date. just copy an existing command and change it to your needs, it's pretty self-explanatory. also the include files related to console commands are now located in core/command/. in the game it should work exactly like before, except for some changes in the auto-completion.

Location:
code/trunk
Files:
28 deleted
42 edited
30 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/BaseObject.cc

    r7163 r7284  
    3939#include "Event.h"
    4040#include "EventIncludes.h"
    41 #include "Functor.h"
    4241#include "Iterator.h"
    4342#include "Template.h"
     
    4544#include "XMLNameListener.h"
    4645#include "XMLPort.h"
     46#include "command/Functor.h"
    4747
    4848namespace orxonox
     
    477477                if (!container)
    478478                {
    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 + ')');
    481481                    setfunctor->setDefaultValue(1, statename);
    482482                    getfunctor->setDefaultValue(1, statename);
  • code/trunk/src/libraries/core/BaseObject.h

    r7163 r7284  
    196196            mbool                   bVisible_;                 //!< True = the object is visible
    197197            std::string             mainStateName_;
    198             Functor              mainStateFunctor_;
     198            FunctorPtr              mainStateFunctor_;
    199199            std::set<std::string>   networkTemplateNames_;
    200200
  • code/trunk/src/libraries/core/CMakeLists.txt

    r7163 r7284  
    1919
    2020SET_SOURCE_FILES(CORE_SRC_FILES
     21  CommandLineParser.cc
    2122  ConfigValueContainer.cc
    2223  Core.cc
     
    2930  GraphicsManager.cc
    3031  GUIManager.cc
    31   IOConsole.cc
    3232  Language.cc
    3333  LuaState.cc
     
    3535  OrxonoxClass.cc
    3636  Resource.cc
    37   ScopedSingletonManager.cc
    3837  WindowEventListener.cc
    39 
    40   # command
    41   CommandEvaluation.cc
    42   CommandExecutor.cc
    43   CommandLineParser.cc
    44   ConsoleCommand.cc
    45   ConsoleCommandCompilation.cc
    46   Executor.cc
    4738
    4839  # hierarchy
     
    6051  XMLNameListener.cc
    6152
    62   # shell
    63   IRC.cc
    64   Shell.cc
    65   TclBind.cc
    66 
    6753COMPILATION_BEGIN FilesystemCompilation.cc
    68   ArgumentCompletionFunctions.cc
     54  command/ArgumentCompletionFunctions.cc
    6955  ConfigFileManager.cc
    7056  MemoryArchive.cc
     
    7561  ThreadPool.cc
    7662COMPILATION_BEGIN ThreadCompilation.cc
    77   TclThreadManager.cc
     63  command/TclThreadManager.cc
    7864  Thread.cc
    7965COMPILATION_END
    8066)
    8167
     68ADD_SUBDIRECTORY(command)
    8269ADD_SUBDIRECTORY(input)
    8370
     
    8572  FIND_HEADER_FILES
    8673  TOLUA_FILES
    87     CommandExecutor.h
     74    command/CommandExecutor.h
    8875    ConfigFileManager.h
    8976    Game.h
  • code/trunk/src/libraries/core/CommandLineParser.cc

    r6417 r7284  
    335335    {
    336336        std::vector<std::string> args;
    337         SubString tokens(cmdLine, " ", " ", false, '\\', true, '"', true, '(', ')', false);
     337        SubString tokens(cmdLine, " ", " ", false, '\\', true, '"', true, '\0', '\0', false);
    338338        for (unsigned i = 0; i < tokens.size(); ++i)
    339339            args.push_back(tokens[i]);
     
    363363                //if (!(line[0] == '#' || line[0] == '%'))
    364364                //{
    365                 SubString tokens(line, " ", " ", false, '\\', true, '"', true, '(', ')', false, '#');
     365                SubString tokens(line, " ", " ", false, '\\', true, '"', true, '\0', '\0', false, '#');
    366366                for (unsigned i = 0; i < tokens.size(); ++i)
    367367                    if (tokens[i][0] != '#')
  • code/trunk/src/libraries/core/CommandLineParser.h

    r6021 r7284  
    6464        Note the difference between "-" and "--"!
    6565        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.
    6767
    6868        Retrieving an argument is possible with the getCommandLineArgument function of the
  • code/trunk/src/libraries/core/ConfigFileManager.cc

    r7163 r7284  
    3434#include "util/Math.h"
    3535#include "util/StringUtils.h"
    36 #include "ConsoleCommand.h"
    3736#include "ConfigValueContainer.h"
    3837#include "PathConfig.h"
     38#include "command/ConsoleCommand.h"
    3939
    4040namespace orxonox
     
    277277                            if (commentposition == std::string::npos)
    278278                            {
    279                                 value = removeTrailingWhitespaces(line.substr(pos1 + 1));
     279                                value = line.substr(pos1 + 1);
    280280                            }
    281281                            else
    282282                            {
    283                                 value = removeTrailingWhitespaces(line.substr(pos1 + 1, commentposition - pos1 - 1));
     283                                value = line.substr(pos1 + 1, commentposition - pos1 - 1);
    284284                                comment = removeTrailingWhitespaces(line.substr(commentposition));
    285285                            }
     286
     287                            value = removeTrailingWhitespaces(value);
     288                            value = removeSlashes(value);
    286289
    287290                            if (pos2 != std::string::npos && pos3 != std::string::npos && pos3 > pos2 + 1)
     
    425428    ////////////////////////
    426429
     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
    427442    SettingsConfigFile* SettingsConfigFile::singletonPtr_s = 0;
    428443
     
    430445        : ConfigFile(filename)
    431446    {
    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);
    442452    }
    443453
    444454    SettingsConfigFile::~SettingsConfigFile()
    445455    {
     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);
    446461    }
    447462
     
    543558    }
    544559
    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;
    553570    }
    554571
  • code/trunk/src/libraries/core/ConfigFileManager.h

    r7163 r7284  
    331331            void clean(bool bCleanComments = false); // tolua_export
    332332
    333             bool config(const std::string& section, const std::string& entry, const std::string& value); // tolua_export
    334             bool tconfig(const std::string& section, const std::string& entry, const std::string& value); // tolua_export
     333            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
    335335            std::string getConfig(const std::string& section, const std::string& entry); // tolua_export
    336336
  • code/trunk/src/libraries/core/ConfigValueContainer.cc

    r6536 r7284  
    302302    bool ConfigValueContainer::callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiType&), const std::string& input)
    303303    {
    304         SubString token(input, " ", SubString::WhiteSpaces, true, '\\', false, '"', false, '(', ')', false, '\0');
     304        SubString token(input, " ", SubString::WhiteSpaces, true, '\\', false, '"', false, '\0', '\0', false, '\0');
    305305        int index = -1;
    306306        bool success = false;
  • code/trunk/src/libraries/core/Core.cc

    r7175 r7284  
    5252#include "util/Exception.h"
    5353#include "util/Scope.h"
     54#include "util/ScopedSingletonManager.h"
    5455#include "util/SignalHandler.h"
    5556#include "PathConfig.h"
    56 #include "CommandExecutor.h"
    5757#include "CommandLineParser.h"
    5858#include "ConfigFileManager.h"
     
    6565#include "Identifier.h"
    6666#include "Language.h"
    67 #include "IOConsole.h"
    6867#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"
    7272#include "input/InputManager.h"
    7373
     
    8888        : identifierDestroyer_(Identifier::destroyAllIdentifiers)
    8989        // Cleanup guard for external console commands that don't belong to an Identifier
    90         , consoleCommandDestroyer_(CommandExecutor::destroyExternalCommands)
     90        , consoleCommandDestroyer_(ConsoleCommand::destroyAll)
    9191        , bGraphicsLoaded_(false)
    9292        , bStartIOConsole_(true)
  • code/trunk/src/libraries/core/CorePrereqs.h

    r7271 r7284  
    119119    T orxonox_cast(U*);
    120120
    121     class ArgumentCompleter;
    122     class ArgumentCompletionListElement;
    123121    class BaseObject;
    124122    template <class T>
     
    130128    class ClassTreeMaskNode;
    131129    class ClassTreeMaskObjectIterator;
    132     class CommandEvaluation;
    133130    class CommandLineParser;
    134131    class CommandLineArgument;
     
    140137    class ConfigFileSection;
    141138    class ConfigValueContainer;
    142     class ConsoleCommand;
    143139    class Core;
    144140    class DynLib;
     
    146142    struct Event;
    147143    class EventState;
    148     class Executor;
    149     template <class T>
    150     class ExecutorMember;
    151     class ExecutorStatic;
    152144    class Factory;
    153     class Functor;
    154     template <class T>
    155     class FunctorMember;
    156     class FunctorStatic;
    157145    class Game;
    158146    class GameState;
     
    162150    class GUIManager;
    163151    class Identifier;
    164     class IOConsole;
    165     class IRC;
    166152    template <class T>
    167153    class Iterator;
    168154    class Language;
     155    class LuaFunctor;
    169156    class LuaState;
    170157    class MemoryArchive;
     
    187174    struct ResourceInfo;
    188175    class SettingsConfigFile;
    189     class Shell;
    190     class ShellListener;
    191176    template <class T>
    192177    class SmartPtr;
    193178    template <class T>
    194179    class SubclassIdentifier;
    195     class TclBind;
    196     struct TclInterpreterBundle;
    197     template <class T>
    198     class TclThreadList;
    199     class TclThreadManager;
    200180    class Template;
    201181    class Thread;
     
    212192    class XMLPortObjectContainer;
    213193    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;
    214219
    215220    // Input
     
    238243}
    239244
     245#include "command/FunctorPtr.h"
     246#include "command/ExecutorPtr.h"
     247
    240248// CppTcl
    241249namespace Tcl
  • code/trunk/src/libraries/core/Event.cc

    r7271 r7284  
    3434namespace orxonox
    3535{
    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 
    4536    /**
    4637        @brief Processes an event (calls the set-function if the necessary conditions are met).
  • code/trunk/src/libraries/core/Event.h

    r6800 r7284  
    6767    {
    6868        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) {}
    7170
    7271            void process(const Event& event, BaseObject* object);
    7372
    74             Functor* getFunctor() const
     73            const FunctorPtr& getFunctor() const
    7574                { return this->statefunction_; }
    7675
     
    7877            bool        bProcessingEvent_;  //!< This becomes true while the container processes an event (used to prevent loops)
    7978            int         activeEvents_;      //!< The number of events which affect this state and are currently active
    80             Functor  statefunction_;     //!< A functor to set the state
     79            FunctorPtr  statefunction_;     //!< A functor to set the state
    8180            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)
    8281            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  
    3131
    3232#include "CorePrereqs.h"
    33 #include "Executor.h"
    3433#include "XMLPort.h"
     34#include "command/Executor.h"
    3535
    3636/**
     
    7676
    7777#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); \
    8082    XMLPortObjectGeneric(xmlport##name, classname, orxonox::BaseObject, statename, xmlsetfunctor##name, xmlgetfunctor##name, xmlelement, mode, false, true)
    8183
  • code/trunk/src/libraries/core/GUIManager.cc

    r7163 r7284  
    5757#include "util/Exception.h"
    5858#include "util/OrxAssert.h"
    59 #include "ConsoleCommand.h"
    6059#include "Core.h"
    6160#include "GraphicsManager.h"
     
    6362#include "PathConfig.h"
    6463#include "Resource.h"
     64#include "command/ConsoleCommand.h"
    6565#include "input/InputManager.h"
    6666#include "input/InputState.h"
     
    7171    static void key_esc()
    7272        { GUIManager::getInstance().keyESC(); }
    73     SetConsoleCommandShortcutExternAlias(key_esc, "keyESC");
     73    SetConsoleCommand("keyESC", &key_esc);
    7474
    7575    class CEGUILogger : public CEGUI::DefaultLogger
     
    9999    GUIManager* GUIManager::singletonPtr_s = 0;
    100100
    101     SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, false).defaultValue(2, true);
    102     SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User);
     101    SetConsoleCommand("showGUI", &GUIManager::showGUI).defaultValue(1, false).defaultValue(2, true);
     102    SetConsoleCommand("hideGUI", &GUIManager::hideGUI);
    103103
    104104    /**
  • code/trunk/src/libraries/core/Game.cc

    r7266 r7284  
    4545#include "util/SubString.h"
    4646#include "CommandLineParser.h"
    47 #include "ConsoleCommand.h"
    4847#include "Core.h"
    4948#include "CoreIncludes.h"
     
    5251#include "GameState.h"
    5352#include "GUIManager.h"
     53#include "command/ConsoleCommand.h"
    5454
    5555namespace orxonox
     
    5757    static void stop_game()
    5858        { Game::getInstance().stop(); }
    59     SetConsoleCommandShortcutExternAlias(stop_game, "exit");
     59    SetConsoleCommand("exit", &stop_game);
    6060    static void printFPS()
    6161        { COUT(0) << Game::getInstance().getAvgFPS() << std::endl; }
    62     SetConsoleCommandShortcutExternAlias(printFPS, "printFPS");
     62    SetConsoleCommand("printFPS", &printFPS);
    6363    static void printTickTime()
    6464        { COUT(0) << Game::getInstance().getAvgTickTime() << std::endl; }
    65     SetConsoleCommandShortcutExternAlias(printTickTime, "printTickTime");
     65    SetConsoleCommand("printTickTime", &printTickTime);
    6666
    6767    std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s;
  • code/trunk/src/libraries/core/GraphicsManager.cc

    r6524 r7284  
    5252#include "util/StringUtils.h"
    5353#include "util/SubString.h"
    54 #include "ConsoleCommand.h"
    5554#include "ConfigValueIncludes.h"
    5655#include "CoreIncludes.h"
     
    6261#include "WindowEventListener.h"
    6362#include "XMLFile.h"
     63#include "command/ConsoleCommand.h"
    6464
    6565namespace orxonox
    6666{
     67    static const std::string __CC_printScreen_name = "printScreen";
     68    DeclareConsoleCommand(__CC_printScreen_name, &prototype::void__void);
     69
    6770    class OgreWindowEventListener : public Ogre::WindowEventListener
    6871    {
     
    131134
    132135        Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_.get());
    133         // TODO: Destroy the console command
     136        ModifyConsoleCommand(__CC_printScreen_name).resetFunction();
    134137
    135138        // Undeclare the resources
     
    290293        boost::filesystem::path folder(ogrePluginsDirectory_);
    291294        // 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');
    293296        // Use backslash paths on Windows! file_string() already does that though.
    294297        for (unsigned int i = 0; i < plugins.size(); ++i)
     
    321324
    322325        // add console commands
    323         ccPrintScreen_ = createConsoleCommand(createFunctor(&GraphicsManager::printScreen, this), "printScreen");
    324         CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_);
     326        ModifyConsoleCommand(__CC_printScreen_name).setFunction(&GraphicsManager::printScreen, this);
    325327    }
    326328
  • code/trunk/src/libraries/core/GraphicsManager.h

    r6417 r7284  
    114114        int                 ogreLogLevelCritical_;     //!< Corresponding Orxonox debug level for LL_CRITICAL
    115115
    116         // console commands
    117         ConsoleCommand*     ccPrintScreen_;
    118 
    119116        static GraphicsManager* singletonPtr_s;        //!< Pointer to the Singleton
    120117    };
  • code/trunk/src/libraries/core/Identifier.cc

    r6536 r7284  
    3838#include "util/StringUtils.h"
    3939#include "ConfigValueContainer.h"
    40 #include "ConsoleCommand.h"
    4140#include "ClassFactory.h"
    4241#include "XMLPort.h"
     
    6463
    6564        this->bHasConfigValues_ = false;
    66         this->bHasConsoleCommands_ = false;
    6765
    6866        // Default network ID is the class ID
     
    8078            delete this->factory_;
    8179
    82         for (std::map<std::string, ConsoleCommand*>::iterator it = this->consoleCommands_.begin(); it != this->consoleCommands_.end(); ++it)
    83             delete (it->second);
    8480        for (std::map<std::string, ConfigValueContainer*>::iterator it = this->configValues_.begin(); it != this->configValues_.end(); ++it)
    8581            delete (it->second);
     
    433429
    434430    /**
    435         @brief Adds a new console command of this class.
    436         @param executor The executor of the command
    437         @param bCreateShortcut If this is true a shortcut gets created so you don't have to add the classname to access this command
    438         @return The executor of the command
    439     */
    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 command
    462         @return The executor of the requested console command
    463     */
    464     ConsoleCommand* Identifier::getConsoleCommand(const std::string& name) const
    465     {
    466         std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(name);
    467         if (it != this->consoleCommands_.end())
    468             return it->second;
    469         else
    470             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 lowercae
    476         @return The executor of the requested console command
    477     */
    478     ConsoleCommand* Identifier::getLowercaseConsoleCommand(const std::string& name) const
    479     {
    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         else
    484             return 0;
    485     }
    486 
    487     /**
    488431        @brief Returns a XMLPortParamContainer that loads a parameter of this class.
    489432        @param paramname The name of the parameter
  • code/trunk/src/libraries/core/Identifier.h

    r7271 r7284  
    202202            void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);
    203203            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;
    229204
    230205
     
    305280            bool bHasConfigValues_;                                        //!< True if this class has at least one assigned config value
    306281            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 command
    309             std::map<std::string, ConsoleCommand*> consoleCommands_;       //!< All console commands of this class
    310             std::map<std::string, ConsoleCommand*> consoleCommands_LC_;    //!< All console commands of this class with their names in lowercase
    311282
    312283            std::map<std::string, XMLPortParamContainer*> xmlportParamContainers_;     //!< All loadable parameters
  • code/trunk/src/libraries/core/Language.cc

    r6417 r7284  
    3636#include <fstream>
    3737#include "util/Debug.h"
     38#include "util/StringUtils.h"
    3839#include "Core.h"
    3940#include "PathConfig.h"
     
    169170        @return The localisation
    170171    */
    171     const std::string& Language::getLocalisation(const LanguageEntryLabel& label) const
     172    const std::string& Language::getLocalisation(const LanguageEntryLabel& label, bool bError) const
    172173    {
    173174        std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(label);
    174175        if (it != this->languageEntries_.end())
    175176            return it->second->getLocalisation();
    176         else
     177        else if (bError)
    177178        {
    178179            // Uh, oh, an undefined entry was requested: return the default string
     
    180181            return this->defaultLocalisation_;
    181182        }
     183        else
     184            return BLANKSTRING;
    182185    }
    183186
  • code/trunk/src/libraries/core/Language.h

    r6536 r7284  
    116116
    117117            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;
    119119
    120120        private:
     
    145145        return Language::getInstance().getLocalisation(label);
    146146    }
     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    }
    147153}
    148154
  • code/trunk/src/libraries/core/LuaState.cc

    r7266 r7284  
    3939#include "util/Debug.h"
    4040#include "util/Exception.h"
    41 #include "IOConsole.h"
    4241#include "Resource.h"
    4342#include "ToluaBindCore.h"
     43#include "command/IOConsole.h"
    4444
    4545namespace orxonox
     
    370370    }
    371371
    372     void LuaFunctor::operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
     372    void LuaFunctor::operator()()
    373373    {
    374374        lua_->doString(this->code_);
  • code/trunk/src/libraries/core/LuaState.h

    r7266 r7284  
    4040#include <loki/ScopeGuard.h>
    4141
    42 #include "Functor.h"
    4342#include "ToluaInterface.h"
    4443
    4544namespace orxonox // tolua_export
    4645{ // tolua_export
    47     class Functor; // tolua_export
     46    class LuaFunctor; // tolua_export
    4847
    49     //! Functor subclass that simply executes code with 0 arguments.
    50     class _CoreExport LuaFunctor : public Functor
     48    //! callback class that executes lua code
     49    class _CoreExport LuaFunctor
    5150    {
    5251        public:
    5352            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()();
    5654
    5755        private:
     
    9189        const shared_ptr<ResourceInfo>& getDefaultResourceInfo() { return this->sourceFileInfo_; }
    9290
    93         Functor* createLuaFunctor(const std::string& code) { return new LuaFunctor(code, this); } // tolua_export
     91        LuaFunctor* createLuaFunctor(const std::string& code) { return new LuaFunctor(code, this); } // tolua_export
    9492        //! Tells about whether IOConsole was activated. The Lua debugger only works with a normal console.
    9593        bool usingIOConsole() const; // tolua_export
  • code/trunk/src/libraries/core/Thread.cc

    r6417 r7284  
    3636
    3737#include "util/Sleep.h"
    38 #include "Executor.h"
     38#include "command/Executor.h"
    3939
    4040namespace orxonox
     
    7575    }
    7676
    77     bool Thread::evaluateExecutor( Executor* executor )
     77    bool Thread::evaluateExecutor( const ExecutorPtr& executor )
    7878    {
    7979        this->isWorkingMutex_->lock();
     
    9292        {
    9393            //this->executorMutex_->lock();
    94             Executor* executor = this->executor_;
     94            ExecutorPtr executor = this->executor_;
    9595            //this->executorMutex_->unlock();
    9696            if( executor )
     
    9898                (*executor)();
    9999                this->executorMutex_->lock();
    100                 delete this->executor_;
    101100                this->executor_ = 0;
    102101                this->executorMutex_->unlock();
  • code/trunk/src/libraries/core/Thread.h

    r6417 r7284  
    4646        bool isWorking();
    4747        void waitUntilFinished();
    48         bool evaluateExecutor( Executor* executor );
     48        bool evaluateExecutor( const ExecutorPtr& executor );
    4949
    5050    private:
    5151        void            threadLoop();
    5252
    53         Executor     executor_;
     53        ExecutorPtr     executor_;
    5454        bool            isWorking_;
    5555        bool            stopThread_;
    5656        boost::thread*  workerThread_;
    5757        boost::mutex*   executorMutex_;
    58         boost::mutex*     isWorkingMutex_;
     58        boost::mutex*   isWorkingMutex_;
    5959        boost::mutex*   stopThreadMutex_;
    6060    };
  • code/trunk/src/libraries/core/ThreadPool.cc

    r6417 r7284  
    8181    }
    8282
    83     bool ThreadPool::passFunction( Executor* executor, bool addThread )
     83    bool ThreadPool::passFunction( const ExecutorPtr& executor, bool addThread )
    8484    {
    8585        std::vector<Thread*>::iterator it;
  • code/trunk/src/libraries/core/ThreadPool.h

    r6417 r7284  
    4646        unsigned int setNrOfThreads( unsigned int nr );
    4747
    48         bool passFunction( Executor* executor, bool addThread=false );
     48        bool passFunction( const ExecutorPtr& executor, bool addThread=false );
    4949        void synchronise();
    5050
  • code/trunk/src/libraries/core/WeakPtr.h

    r7268 r7284  
    3737#include "Identifier.h"
    3838#include "OrxonoxClass.h"
    39 #include "Functor.h"
     39#include "command/Functor.h"
    4040
    4141namespace orxonox
     
    7878                if (this->base_)
    7979                    this->base_->unregisterWeakPtr(this);
    80                 if (this->callback_)
    81                     delete this->callback_;
    8280
    8381            }
     
    169167            }
    170168
    171             inline void setCallback(Functor* callback)
     169            inline void setCallback(const FunctorPtr& callback)
    172170            {
    173171                this->callback_ = callback;
    174172            }
    175173
    176             inline Functor* getFunctor() const
     174            inline const FunctorPtr& getCallback() const
    177175            {
    178176                return this->callback_;
     
    190188            T* pointer_;
    191189            OrxonoxClass* base_;
    192             Functor* callback_;
     190            FunctorPtr callback_;
    193191    };
    194192
  • code/trunk/src/libraries/core/XMLPort.h

    r7271 r7284  
    5353#include "util/StringUtils.h"
    5454#include "Identifier.h"
    55 #include "Executor.h"
    5655#include "BaseObject.h"
     56#include "command/Executor.h"
    5757
    5858// ------------
     
    7575*/
    7676#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); \
    7979    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode)
    8080
     
    9494#define XMLPortParamVariable(classname, paramname, variable, xmlelement, mode) \
    9595    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" ); \
    9898    XMLPortParamGeneric(xmlcontainer##variable, classname, orxonox::XMLPortVariableHelperClass, &xmlcontainer##variable##dummy, paramname, xmlcontainer##variable##loadexecutor, xmlcontainer##variable##saveexecutor, xmlelement, mode)
    9999
     
    110110*/
    111111#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); \
    114114    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode)
    115115
     
    129129*/
    130130#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); \
    132132    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, xmlcontainer##loadfunction##0##loadexecutor, 0, xmlelement, mode)
    133133/**
     
    135135*/
    136136#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); \
    138138    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, xmlcontainer##loadfunction##0##loadexecutor, 0, xmlelement, mode)
    139139
     
    161161*/
    162162#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); \
    165165    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode);
    166166/**
     
    168168*/
    169169#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); \
    172172    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode);
    173173
     
    249249*/
    250250#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); \
    253253    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore)
    254254/**
     
    256256*/
    257257#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); \
    260260    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore)
    261261
     
    267267*/
    268268#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); \
    271271    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, false, true)
    272272/**
     
    274274*/
    275275#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); \
    278278    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode, false, true)
    279279
     
    317317                { return this->paramname_; }
    318318
    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_; }
    321323
    322324            virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param) = 0;
     
    332334            Identifier* identifier_;
    333335            BaseObject* owner_;
     336            std::string description_;
    334337    };
    335338
     
    345348
    346349        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)
    348351            {
    349352                this->paramname_ = paramname;
     
    355358            ~XMLPortClassParamContainer()
    356359            {
    357                 assert(this->loadexecutor_);
    358                 delete this->loadexecutor_;
    359                 if (this->saveexecutor_)
    360                     delete this->saveexecutor_;
    361360            }
    362361
     
    395394                        {
    396395                            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))
    398399                                this->parseResult_ = PR_finished;
    399400                            else
     
    436437            }
    437438
    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 
    443439            virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param)
    444440            {
     
    479475
    480476        private:
    481             ExecutorMember<T>* loadexecutor_;
    482             ExecutorMember<T>* saveexecutor_;
     477            ExecutorMemberPtr<T> loadexecutor_;
     478            ExecutorMemberPtr<T> saveexecutor_;
    483479            ParseParams parseParams_;
    484480    };
     
    502498                { return this->sectionname_; }
    503499
    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_; }
    506504
    507505            bool identifierIsIncludedInLoaderMask(const Identifier* identifier);
     
    513511            Identifier* identifier_;
    514512            Identifier* objectIdentifier_;
     513            std::string description_;
    515514    };
    516515
     
    519518    {
    520519        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)
    522521            {
    523522                this->sectionname_ = sectionname;
     
    533532            ~XMLPortClassObjectContainer()
    534533            {
    535                 assert(this->loadexecutor_);
    536                 delete this->loadexecutor_;
    537                 if (this->saveexecutor_)
    538                     delete this->saveexecutor_;
    539534            }
    540535
     
    549544            }
    550545
    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 
    556546        private:
    557             ExecutorMember<T>* loadexecutor_;
    558             ExecutorMember<T>* saveexecutor_;
     547            ExecutorMemberPtr<T> loadexecutor_;
     548            ExecutorMemberPtr<T> saveexecutor_;
    559549    };
    560550
  • code/trunk/src/libraries/core/input/Button.cc

    r6536 r7284  
    3939#include "util/StringUtils.h"
    4040#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"
    4444#include "core/ConfigFileManager.h"
    4545
     
    117117        // separate the commands
    118118        SubString commandStrings(bindingString_, "|", SubString::WhiteSpaces, false,
    119             '\\', false, '"', false, '(', ')', false, '\0');
     119            '\\', false, '"', false, '{', '}', false, '\0');
    120120
    121121        for (unsigned int iCommand = 0; iCommand < commandStrings.size(); iCommand++)
     
    124124            {
    125125                SubString tokens(commandStrings[iCommand], " ", SubString::WhiteSpaces, false,
    126                     '\\', false, '"', false, '(', ')', false, '\0');
     126                    '\\', false, '"', false, '{', '}', false, '\0');
    127127
    128128                KeybindMode::Value mode = KeybindMode::None;
     
    175175
    176176                // 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))
    179179                {
    180180                    parseError("Command evaluation of \"" + commandStr + "\"failed.", true);
  • code/trunk/src/libraries/core/input/HalfAxis.cc

    r5781 r7284  
    3434
    3535#include "HalfAxis.h"
    36 #include "core/CommandEvaluation.h"
     36#include "core/command/CommandEvaluation.h"
    3737
    3838namespace orxonox
  • code/trunk/src/libraries/core/input/InputCommands.h

    r6417 r7284  
    3737
    3838#include "InputPrereqs.h"
    39 #include "core/CommandEvaluation.h"
     39#include "core/command/CommandEvaluation.h"
    4040
    4141namespace orxonox
  • code/trunk/src/libraries/core/input/InputManager.cc

    r7266 r7284  
    4747#include "core/CoreIncludes.h"
    4848#include "core/ConfigValueIncludes.h"
    49 #include "core/ConsoleCommand.h"
    5049#include "core/CommandLineParser.h"
    51 #include "core/Functor.h"
    5250#include "core/GraphicsManager.h"
     51#include "core/command/ConsoleCommand.h"
     52#include "core/command/Functor.h"
    5353
    5454#include "InputBuffer.h"
     
    6161{
    6262    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   );
    6370
    6471    // Abuse of this source file for the InputHandler
     
    118125        this->updateActiveStates();
    119126
    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);
    124129
    125130        CCOUT(4) << "Construction complete." << std::endl;
     
    287292        if (!(internalState_ & Bad))
    288293            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);
    289298
    290299        CCOUT(3) << "Destruction complete." << std::endl;
  • code/trunk/src/libraries/core/input/InputState.cc

    r6746 r7284  
    2828
    2929#include "InputState.h"
    30 #include "core/Functor.h"
     30#include "core/command/Functor.h"
    3131
    3232namespace orxonox
  • code/trunk/src/libraries/core/input/InputState.h

    r6746 r7284  
    150150        void left();
    151151        //! 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; }
    153153        //! 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; }
    155155
    156156    private:
     
    172172        //! Handler to be used for all joy sticks (needs to be saved in case another joy stick gets attached)
    173173        InputHandler*               joyStickHandlerAll_;
    174         Functor                  enterFunctor_;          //!< Functor to be executed on enter
    175         Functor                  leaveFunctor_;          //!< Functor to be executed on leave
     174        FunctorPtr                  enterFunctor_;          //!< Functor to be executed on enter
     175        FunctorPtr                  leaveFunctor_;          //!< Functor to be executed on leave
    176176    };
    177177
  • code/trunk/src/libraries/core/input/KeyBinderManager.cc

    r6417 r7284  
    3131#include "util/Debug.h"
    3232#include "util/Exception.h"
     33#include "util/ScopedSingletonManager.h"
    3334#include "core/ConfigValueIncludes.h"
    34 #include "core/ConsoleCommand.h"
    3535#include "core/CoreIncludes.h"
    36 #include "core/ScopedSingletonManager.h"
     36#include "core/LuaState.h"
     37#include "core/command/ConsoleCommand.h"
    3738#include "InputManager.h"
    3839#include "KeyDetector.h"
     
    4142{
    4243    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("");
    4354
    4455    KeyBinderManager::KeyBinderManager()
     
    5162
    5263        // 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);
    6168
    6269        // Load default key binder
     
    6976        for (std::map<std::string, KeyBinder*>::const_iterator it = this->binders_.begin(); it != this->binders_.end(); ++it)
    7077            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);
    7184    }
    7285
     
    156169        {
    157170            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));
    159172            InputManager::getInstance().enterState("detector");
    160173            this->command_ = command;
     
    187200        // else: A key was probably pressed within the same tick, ignore it.
    188201    }
     202
     203    void KeyBinderManager::registerKeybindCallback(LuaFunctor* function)
     204    {
     205        this->callbackFunction_ = function;
     206    }
    189207}
  • code/trunk/src/libraries/core/input/KeyBinderManager.h

    r6417 r7284  
    9999        void unbind(const std::string& binding); //tolua_export
    100100        void tunbind(const std::string& binding);
    101         inline void registerKeybindCallback(Functor* function) { this->callbackFunction_.reset(function); } // tolua_export
     101        void registerKeybindCallback(LuaFunctor* function); //tolua_export
    102102
    103103    private:
     
    114114
    115115        // keybind command related
    116         shared_ptr<Functor> callbackFunction_;       //! Function to be called when key was pressed after "keybind" command
     116        SharedPtr<LuaFunctor> callbackFunction_;     //! Function to be called when key was pressed after "keybind" command
    117117        bool bBinding_;                              //! Tells whether a key binding process is active
    118118        bool bTemporary_;                            //! Stores tkeybind/keybind value
  • code/trunk/src/libraries/core/input/KeyDetector.cc

    r6428 r7284  
    2929#include "KeyDetector.h"
    3030
    31 #include "core/ConsoleCommand.h"
     31#include "util/ScopedSingletonManager.h"
    3232#include "core/CoreIncludes.h"
    33 #include "core/ScopedSingletonManager.h"
     33#include "core/command/ConsoleCommand.h"
    3434#include "Button.h"
    3535#include "InputManager.h"
     
    3838namespace orxonox
    3939{
    40     std::string KeyDetector::callbackCommand_s = "KeyDetectorKeyPressed";
    4140    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();
    4244
    4345    KeyDetector::KeyDetector()
     
    4648        RegisterObject(KeyDetector);
    4749
    48         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyDetector::callback,  this), callbackCommand_s));
     50        ModifyConsoleCommand(__CC_KeyDetector_callback_name).setFunction(&KeyDetector::callback, this);
     51
    4952        this->assignCommands();
    5053
     
    5962        inputState_->setHandler(NULL);
    6063        InputManager::getInstance().destroyState("detector");
     64        ModifyConsoleCommand(__CC_KeyDetector_callback_name).resetFunction();
    6165    }
    6266
     
    6569        // Assign every button/axis the same command, but with its name as argument
    6670        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_);
    6872    }
    6973
  • code/trunk/src/libraries/core/input/KeyDetector.h

    r6417 r7284  
    4646        ~KeyDetector();
    4747
    48         void setCallback(const shared_ptr<Functor>& function) { this->callbackFunction_ = function; }
     48        void setCallback(const FunctorPtr& function) { this->callbackFunction_ = function; }
    4949
    5050    private:
     
    5555        void assignCommands();
    5656
    57         shared_ptr<Functor> callbackFunction_;
     57        FunctorPtr callbackFunction_;
    5858        InputState* inputState_;
    59         static std::string callbackCommand_s;
    6059        static KeyDetector* singletonPtr_s;
    6160    };
  • code/trunk/src/libraries/core/input/Mouse.cc

    r5929 r7284  
    3030
    3131#include <ois/OISMouse.h>
    32 #include "core/ConsoleCommand.h"
    3332#include "core/CoreIncludes.h"
     33#include "core/command/ConsoleCommand.h"
    3434#include "InputState.h"
    3535
     
    4141namespace orxonox
    4242{
     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
    4352    Mouse::Mouse(unsigned int id, OIS::InputManager* oisInputManager)
    4453        : super(id, oisInputManager)
     
    4857
    4958#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);
    5469#endif
    5570    }
  • code/trunk/src/libraries/core/input/Mouse.h

    r5781 r7284  
    6464        //! Only sets the clipping size. Initialising is done in the base class.
    6565        Mouse(unsigned int id, OIS::InputManager* oisInputManager);
    66         ~Mouse() { }
     66        ~Mouse();
    6767
    6868#ifdef ORXONOX_PLATFORM_LINUX
Note: See TracChangeset for help on using the changeset viewer.