Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 29, 2008, 2:30:10 AM (16 years ago)
Author:
landauf
Message:

made CommandExecutor a singleton

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core2/src/orxonox/core/CommandExecutor.h

    r948 r949  
    3333#include <list>
    3434
     35#include "util/SubString.h"
    3536#include "CorePrereqs.h"
    3637
    37 class SubString;
     38#define COMMAND_EXECUTOR_CURSOR '$'
    3839
    3940namespace orxonox
     
    7071
    7172            /** @brief Returns the map that stores all console commands. @return The const_iterator */
    72             static inline const std::map<std::string, ExecutorStatic*>& getConsoleCommandShortcutMap() { return CommandExecutor::consoleCommandShortcuts_s; }
     73            static inline const std::map<std::string, ExecutorStatic*>& getConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_s; }
    7374            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands. @return The const_iterator */
    74             static inline std::map<std::string, ExecutorStatic*>::const_iterator getConsoleCommandShortcutMapBegin() { return CommandExecutor::consoleCommandShortcuts_s.begin(); }
     75            static inline std::map<std::string, ExecutorStatic*>::const_iterator getConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_s.begin(); }
    7576            /** @brief Returns a const_iterator to the end of the map that stores all console commands. @return The const_iterator */
    76             static inline std::map<std::string, ExecutorStatic*>::const_iterator getConsoleCommandShortcutMapEnd() { return CommandExecutor::consoleCommandShortcuts_s.end(); }
     77            static inline std::map<std::string, ExecutorStatic*>::const_iterator getConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_s.end(); }
    7778
    7879            /** @brief Returns the map that stores all console commands with their names in lowercase. @return The const_iterator */
    79             static inline const std::map<std::string, ExecutorStatic*>& getLowercaseConsoleCommandShortcutMap() { return CommandExecutor::consoleCommandShortcuts_LC_s; }
     80            static inline const std::map<std::string, ExecutorStatic*>& getLowercaseConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_s; }
    8081            /** @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 */
    81             static inline std::map<std::string, ExecutorStatic*>::const_iterator getLowercaseConsoleCommandShortcutMapBegin() { return CommandExecutor::consoleCommandShortcuts_LC_s.begin(); }
     82            static inline std::map<std::string, ExecutorStatic*>::const_iterator getLowercaseConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_s.begin(); }
    8283            /** @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 */
    83             static inline std::map<std::string, ExecutorStatic*>::const_iterator getLowercaseConsoleCommandShortcutMapEnd() { return CommandExecutor::consoleCommandShortcuts_LC_s.end(); }
     84            static inline std::map<std::string, ExecutorStatic*>::const_iterator getLowercaseConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_s.end(); }
    8485
    8586        private:
     87            static CommandExecutor& getInstance();
     88
    8689            static void parse(const std::string& command, bool bInitialize = true);
    8790            static void initialize();
     
    116119            static ConfigValueContainer* getContainerOfPossibleKey(const std::string& name);
    117120
    118             static const char cursor_s = '$';
     121            std::string lastProcessedCommand_s;
     122            SubString tokens_s;
     123            std::list<const std::string*> listOfPossibleFunctionClasses_s;
     124            std::list<const std::string*> listOfPossibleShortcuts_s;
     125            std::list<const std::string*> listOfPossibleFunctions_s;
     126            std::list<const std::string*> listOfPossibleConfigValueClasses_s;
     127            std::list<const std::string*> listOfPossibleConfigValues_s;
     128            std::list<const std::string*> listOfPossibleKeys_s;
    119129
    120             static std::string lastProcessedCommand_s;
    121             static SubString tokens_s;
    122             static std::list<const std::string*> listOfPossibleFunctionClasses_s;
    123             static std::list<const std::string*> listOfPossibleShortcuts_s;
    124             static std::list<const std::string*> listOfPossibleFunctions_s;
    125             static std::list<const std::string*> listOfPossibleConfigValueClasses_s;
    126             static std::list<const std::string*> listOfPossibleConfigValues_s;
    127             static std::list<const std::string*> listOfPossibleKeys_s;
     130            Identifier* functionclass_s;
     131            Identifier* configvalueclass_s;
     132            ExecutorStatic* shortcut_s;
     133            ExecutorStatic* function_s;
     134            ConfigValueContainer* configvalue_s;
     135            ConfigValueContainer* key_s;
    128136
    129             static Identifier* functionclass_s;
    130             static Identifier* configvalueclass_s;
    131             static ExecutorStatic* shortcut_s;
    132             static ExecutorStatic* function_s;
    133             static ConfigValueContainer* configvalue_s;
    134             static ConfigValueContainer* key_s;
     137            std::string errorMessage_s;
     138            CommandState state_s;
    135139
    136             static std::string errorMessage_s;
    137             static CommandState state_s;
    138 
    139             static std::map<std::string, ExecutorStatic*> consoleCommandShortcuts_s;
    140             static std::map<std::string, ExecutorStatic*> consoleCommandShortcuts_LC_s;
     140            std::map<std::string, ExecutorStatic*> consoleCommandShortcuts_s;
     141            std::map<std::string, ExecutorStatic*> consoleCommandShortcuts_LC_s;
    141142    };
    142143}
Note: See TracChangeset for help on using the changeset viewer.