Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 951


Ignore:
Timestamp:
Mar 29, 2008, 3:37:44 AM (16 years ago)
Author:
landauf
Message:

notation: varname_s to varname_, as they're not static anymore in the singleton

Location:
code/branches/core2/src/orxonox/core
Files:
2 edited

Legend:

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

    r949 r951  
    5353    bool CommandExecutor::addConsoleCommandShortcut(ExecutorStatic* executor)
    5454    {
    55         CommandExecutor::getInstance().consoleCommandShortcuts_s[executor->getName()] = executor;
    56         CommandExecutor::getInstance().consoleCommandShortcuts_LC_s[getLowercase(executor->getName())] = executor;
     55        CommandExecutor::getInstance().consoleCommandShortcuts_[executor->getName()] = executor;
     56        CommandExecutor::getInstance().consoleCommandShortcuts_LC_[getLowercase(executor->getName())] = executor;
    5757        return true;
    5858    }
     
    6565    ExecutorStatic* CommandExecutor::getConsoleCommandShortcut(const std::string& name)
    6666    {
    67         std::map<std::string, ExecutorStatic*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_s.find(name);
    68         if (it != CommandExecutor::getInstance().consoleCommandShortcuts_s.end())
     67        std::map<std::string, ExecutorStatic*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_.find(name);
     68        if (it != CommandExecutor::getInstance().consoleCommandShortcuts_.end())
    6969            return (*it).second;
    7070        else
     
    7979    ExecutorStatic* CommandExecutor::getLowercaseConsoleCommandShortcut(const std::string& name)
    8080    {
    81         std::map<std::string, ExecutorStatic*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_LC_s.find(name);
    82         if (it != CommandExecutor::getInstance().consoleCommandShortcuts_LC_s.end())
     81        std::map<std::string, ExecutorStatic*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_LC_.find(name);
     82        if (it != CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end())
    8383            return (*it).second;
    8484        else
     
    8888    bool CommandExecutor::execute(const std::string& command)
    8989    {
    90         if (CommandExecutor::getInstance().lastProcessedCommand_s != command)
     90        if (CommandExecutor::getInstance().lastProcessedCommand_ != command)
    9191            CommandExecutor::parse(command);
    9292
    93         CommandExecutor::getInstance().tokens_s.split(command, " ", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
    94 
    95         switch (CommandExecutor::getInstance().state_s)
     93        CommandExecutor::getInstance().tokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
     94
     95        switch (CommandExecutor::getInstance().state_)
    9696        {
    9797            case CS_Empty:
     
    104104            case CS_Shortcut_Finished:
    105105                // call the shortcut
    106                 if (CommandExecutor::getInstance().shortcut_s != 0)
    107                     return CommandExecutor::getInstance().shortcut_s->parse(CommandExecutor::getInstance().tokens_s.subSet(1).join());
     106                if (CommandExecutor::getInstance().shortcut_ != 0)
     107                    return CommandExecutor::getInstance().shortcut_->parse(CommandExecutor::getInstance().tokens_.subSet(1).join());
    108108                break;
    109109            case CS_Function:
     
    114114            case CS_Function_Finished:
    115115                // call the shortcut
    116                 if (CommandExecutor::getInstance().function_s != 0)
    117                     return CommandExecutor::getInstance().function_s->parse(CommandExecutor::getInstance().tokens_s.subSet(2).join());
     116                if (CommandExecutor::getInstance().function_ != 0)
     117                    return CommandExecutor::getInstance().function_->parse(CommandExecutor::getInstance().tokens_.subSet(2).join());
    118118                break;
    119119            case CS_ConfigValueClass:
     
    126126            case CS_ConfigValueFinished:
    127127                // set the config value
    128                 if (CommandExecutor::getInstance().configvalue_s != 0)
    129                     return CommandExecutor::getInstance().configvalue_s->parseString(CommandExecutor::getInstance().tokens_s.subSet(3).join());
     128                if (CommandExecutor::getInstance().configvalue_ != 0)
     129                    return CommandExecutor::getInstance().configvalue_->parseString(CommandExecutor::getInstance().tokens_.subSet(3).join());
    130130                break;
    131131            case CS_KeybindKey:
     
    147147    std::string CommandExecutor::complete(const std::string& command)
    148148    {
    149         if (CommandExecutor::getInstance().lastProcessedCommand_s != command)
     149        if (CommandExecutor::getInstance().lastProcessedCommand_ != command)
    150150            CommandExecutor::parse(command);
    151151
    152         CommandExecutor::getInstance().tokens_s.split(command, " ", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
     152        CommandExecutor::getInstance().tokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
    153153
    154154        std::list<const std::string*> temp;
    155         if (CommandExecutor::getInstance().state_s == CS_Empty)
    156         {
    157             temp.insert(temp.end(), CommandExecutor::getInstance().listOfPossibleShortcuts_s.begin(), CommandExecutor::getInstance().listOfPossibleShortcuts_s.end());
    158             temp.insert(temp.end(), CommandExecutor::getInstance().listOfPossibleFunctionClasses_s.begin(), CommandExecutor::getInstance().listOfPossibleFunctionClasses_s.end());
    159         }
    160 
    161         switch (CommandExecutor::getInstance().state_s)
     155        if (CommandExecutor::getInstance().state_ == CS_Empty)
     156        {
     157            temp.insert(temp.end(), CommandExecutor::getInstance().listOfPossibleShortcuts_.begin(), CommandExecutor::getInstance().listOfPossibleShortcuts_.end());
     158            temp.insert(temp.end(), CommandExecutor::getInstance().listOfPossibleFunctionClasses_.begin(), CommandExecutor::getInstance().listOfPossibleFunctionClasses_.end());
     159        }
     160
     161        switch (CommandExecutor::getInstance().state_)
    162162        {
    163163            case CS_Empty:
    164                 return (CommandExecutor::getInstance().tokens_s.subSet(0, CommandExecutor::getInstance().tokens_s.size() - 1).join() + " " + CommandExecutor::getCommonBegin(temp));
     164                return (CommandExecutor::getInstance().tokens_.subSet(0, CommandExecutor::getInstance().tokens_.size() - 1).join() + " " + CommandExecutor::getCommonBegin(temp));
    165165                break;
    166166            case CS_FunctionClass_Or_Shortcut_Or_Keyword:
     
    173173                break;
    174174            case CS_Function:
    175                 return (CommandExecutor::getInstance().tokens_s.subSet(0, CommandExecutor::getInstance().tokens_s.size() - 1).join() + " " + CommandExecutor::getCommonBegin(CommandExecutor::getInstance().listOfPossibleFunctions_s));
     175                return (CommandExecutor::getInstance().tokens_.subSet(0, CommandExecutor::getInstance().tokens_.size() - 1).join() + " " + CommandExecutor::getCommonBegin(CommandExecutor::getInstance().listOfPossibleFunctions_));
    176176                break;
    177177            case CS_Function_Params:
     
    182182                break;
    183183            case CS_ConfigValueClass:
    184                 return (CommandExecutor::getInstance().tokens_s.subSet(0, CommandExecutor::getInstance().tokens_s.size() - 1).join() + " " + CommandExecutor::getCommonBegin(CommandExecutor::getInstance().listOfPossibleConfigValueClasses_s));
     184                return (CommandExecutor::getInstance().tokens_.subSet(0, CommandExecutor::getInstance().tokens_.size() - 1).join() + " " + CommandExecutor::getCommonBegin(CommandExecutor::getInstance().listOfPossibleConfigValueClasses_));
    185185                break;
    186186            case CS_ConfigValue:
    187                 return (CommandExecutor::getInstance().tokens_s.subSet(0, CommandExecutor::getInstance().tokens_s.size() - 1).join() + " " + CommandExecutor::getCommonBegin(CommandExecutor::getInstance().listOfPossibleConfigValues_s));
     187                return (CommandExecutor::getInstance().tokens_.subSet(0, CommandExecutor::getInstance().tokens_.size() - 1).join() + " " + CommandExecutor::getCommonBegin(CommandExecutor::getInstance().listOfPossibleConfigValues_));
    188188                break;
    189189            case CS_ConfigValueType:
     
    194194                break;
    195195            case CS_KeybindKey:
    196                 return (CommandExecutor::getInstance().tokens_s.subSet(0, CommandExecutor::getInstance().tokens_s.size() - 1).join() + " " + CommandExecutor::getCommonBegin(CommandExecutor::getInstance().listOfPossibleKeys_s));
     196                return (CommandExecutor::getInstance().tokens_.subSet(0, CommandExecutor::getInstance().tokens_.size() - 1).join() + " " + CommandExecutor::getCommonBegin(CommandExecutor::getInstance().listOfPossibleKeys_));
    197197                break;
    198198            case CS_KeybindCommand:
     
    206206        }
    207207
    208         return CommandExecutor::getInstance().lastProcessedCommand_s;
     208        return CommandExecutor::getInstance().lastProcessedCommand_;
    209209    }
    210210
    211211    std::string CommandExecutor::hint(const std::string& command)
    212212    {
    213         if (CommandExecutor::getInstance().lastProcessedCommand_s != command)
     213        if (CommandExecutor::getInstance().lastProcessedCommand_ != command)
    214214            CommandExecutor::parse(command);
    215215
    216         CommandExecutor::getInstance().tokens_s.split(command, " ", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
    217 
    218         switch (CommandExecutor::getInstance().state_s)
     216        CommandExecutor::getInstance().tokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
     217
     218        switch (CommandExecutor::getInstance().state_)
    219219        {
    220220            case CS_Empty:
    221                 return (CommandExecutor::dump(CommandExecutor::getInstance().listOfPossibleShortcuts_s) + "\n" + CommandExecutor::dump(CommandExecutor::getInstance().listOfPossibleFunctionClasses_s));
     221                return (CommandExecutor::dump(CommandExecutor::getInstance().listOfPossibleShortcuts_) + "\n" + CommandExecutor::dump(CommandExecutor::getInstance().listOfPossibleFunctionClasses_));
    222222                break;
    223223            case CS_FunctionClass_Or_Shortcut_Or_Keyword:
    224224                break;
    225225            case CS_Shortcut_Params:
    226                 if (CommandExecutor::getInstance().shortcut_s != 0)
    227                     return CommandExecutor::dump(CommandExecutor::getInstance().shortcut_s);
     226                if (CommandExecutor::getInstance().shortcut_ != 0)
     227                    return CommandExecutor::dump(CommandExecutor::getInstance().shortcut_);
    228228                break;
    229229            case CS_Shortcut_Finished:
    230                 if (CommandExecutor::getInstance().shortcut_s != 0)
    231                     return CommandExecutor::dump(CommandExecutor::getInstance().shortcut_s);
     230                if (CommandExecutor::getInstance().shortcut_ != 0)
     231                    return CommandExecutor::dump(CommandExecutor::getInstance().shortcut_);
    232232                break;
    233233            case CS_Function:
    234                 return CommandExecutor::dump(CommandExecutor::getInstance().listOfPossibleFunctions_s);
     234                return CommandExecutor::dump(CommandExecutor::getInstance().listOfPossibleFunctions_);
    235235                break;
    236236            case CS_Function_Params:
    237                 if (CommandExecutor::getInstance().function_s != 0)
    238                     return CommandExecutor::dump(CommandExecutor::getInstance().function_s);
     237                if (CommandExecutor::getInstance().function_ != 0)
     238                    return CommandExecutor::dump(CommandExecutor::getInstance().function_);
    239239                break;
    240240            case CS_Function_Finished:
    241                 if (CommandExecutor::getInstance().function_s != 0)
    242                     return CommandExecutor::dump(CommandExecutor::getInstance().function_s);
     241                if (CommandExecutor::getInstance().function_ != 0)
     242                    return CommandExecutor::dump(CommandExecutor::getInstance().function_);
    243243                break;
    244244            case CS_ConfigValueClass:
    245                 return CommandExecutor::dump(CommandExecutor::getInstance().listOfPossibleConfigValueClasses_s);
     245                return CommandExecutor::dump(CommandExecutor::getInstance().listOfPossibleConfigValueClasses_);
    246246                break;
    247247            case CS_ConfigValue:
    248                 return CommandExecutor::dump(CommandExecutor::getInstance().listOfPossibleConfigValues_s);
     248                return CommandExecutor::dump(CommandExecutor::getInstance().listOfPossibleConfigValues_);
    249249                break;
    250250            case CS_ConfigValueType:
    251                 if (CommandExecutor::getInstance().configvalue_s != 0)
    252                     return CommandExecutor::dump(CommandExecutor::getInstance().configvalue_s);
     251                if (CommandExecutor::getInstance().configvalue_ != 0)
     252                    return CommandExecutor::dump(CommandExecutor::getInstance().configvalue_);
    253253                break;
    254254            case CS_ConfigValueFinished:
    255                 if (CommandExecutor::getInstance().configvalue_s != 0)
    256                     return CommandExecutor::dump(CommandExecutor::getInstance().configvalue_s);
     255                if (CommandExecutor::getInstance().configvalue_ != 0)
     256                    return CommandExecutor::dump(CommandExecutor::getInstance().configvalue_);
    257257                break;
    258258            case CS_KeybindKey:
    259                 return CommandExecutor::dump(CommandExecutor::getInstance().listOfPossibleKeys_s);
     259                return CommandExecutor::dump(CommandExecutor::getInstance().listOfPossibleKeys_);
    260260                break;
    261261            case CS_KeybindCommand:
    262                 if (CommandExecutor::getInstance().key_s != 0)
    263                     return CommandExecutor::dump(CommandExecutor::getInstance().key_s);
     262                if (CommandExecutor::getInstance().key_ != 0)
     263                    return CommandExecutor::dump(CommandExecutor::getInstance().key_);
    264264                break;
    265265            case CS_KeybindFinished:
    266                 if (CommandExecutor::getInstance().key_s != 0)
    267                     return CommandExecutor::dump(CommandExecutor::getInstance().key_s);
     266                if (CommandExecutor::getInstance().key_ != 0)
     267                    return CommandExecutor::dump(CommandExecutor::getInstance().key_);
    268268                break;
    269269            case CS_Error:
     
    277277    void CommandExecutor::parse(const std::string& command, bool bInitialize)
    278278    {
    279         CommandExecutor::getInstance().tokens_s.split((command + COMMAND_EXECUTOR_CURSOR), " ", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
    280         CommandExecutor::getInstance().lastProcessedCommand_s = command;
     279        CommandExecutor::getInstance().tokens_.split((command + COMMAND_EXECUTOR_CURSOR), " ", SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
     280        CommandExecutor::getInstance().lastProcessedCommand_ = command;
    281281
    282282        if (bInitialize)
    283283            CommandExecutor::initialize();
    284284
    285         switch (CommandExecutor::getInstance().state_s)
     285        switch (CommandExecutor::getInstance().state_)
    286286        {
    287287            case CS_Empty:
     
    290290                    // We want a hint for the first token
    291291                    // Check if there is already a perfect match
    292                     CommandExecutor::getInstance().functionclass_s = CommandExecutor::getIdentifierOfPossibleFunctionClass(CommandExecutor::getToken(0));
    293                     CommandExecutor::getInstance().shortcut_s = CommandExecutor::getExecutorOfPossibleShortcut(CommandExecutor::getToken(0));
    294 
    295                     if ((CommandExecutor::getInstance().functionclass_s != 0) || (CommandExecutor::getInstance().shortcut_s != 0))
     292                    CommandExecutor::getInstance().functionclass_ = CommandExecutor::getIdentifierOfPossibleFunctionClass(CommandExecutor::getToken(0));
     293                    CommandExecutor::getInstance().shortcut_ = CommandExecutor::getExecutorOfPossibleShortcut(CommandExecutor::getToken(0));
     294
     295                    if ((CommandExecutor::getInstance().functionclass_ != 0) || (CommandExecutor::getInstance().shortcut_ != 0))
    296296                    {
    297297                        // Yes, there is a class or a shortcut with the searched name
    298298                        // Add a whitespace and continue parsing
    299                         CommandExecutor::getInstance().state_s = CS_FunctionClass_Or_Shortcut_Or_Keyword;
     299                        CommandExecutor::getInstance().state_ = CS_FunctionClass_Or_Shortcut_Or_Keyword;
    300300                        CommandExecutor::parse(command + " ", false);
    301301                        return;
     
    310310                {
    311311                    // There is at least one argument: Check if it's a shortcut, a classname or a special keyword
    312                     CommandExecutor::getInstance().state_s = CS_FunctionClass_Or_Shortcut_Or_Keyword;
     312                    CommandExecutor::getInstance().state_ = CS_FunctionClass_Or_Shortcut_Or_Keyword;
    313313                    CommandExecutor::parse(command, false);
    314314                    return;
     
    321321                    {
    322322                        // We want to set a config value
    323                         CommandExecutor::getInstance().state_s = CS_ConfigValueClass;
     323                        CommandExecutor::getInstance().state_ = CS_ConfigValueClass;
    324324                        CommandExecutor::parse(command, false);
    325325                        return;
     
    328328                    {
    329329                        // We want to set a keybinding
    330                         CommandExecutor::getInstance().state_s = CS_KeybindKey;
     330                        CommandExecutor::getInstance().state_ = CS_KeybindKey;
    331331                        CommandExecutor::parse(command, false);
    332332                        return;
    333333                    }
    334334
    335                     if (CommandExecutor::getInstance().functionclass_s == 0)
    336                         CommandExecutor::getInstance().functionclass_s = CommandExecutor::getIdentifierOfPossibleFunctionClass(CommandExecutor::getToken(0));
    337                     if (CommandExecutor::getInstance().shortcut_s == 0)
    338                         CommandExecutor::getInstance().shortcut_s = CommandExecutor::getExecutorOfPossibleShortcut(CommandExecutor::getToken(0));
    339 
    340                     if ((CommandExecutor::getInstance().functionclass_s == 0) && (CommandExecutor::getInstance().shortcut_s == 0))
     335                    if (CommandExecutor::getInstance().functionclass_ == 0)
     336                        CommandExecutor::getInstance().functionclass_ = CommandExecutor::getIdentifierOfPossibleFunctionClass(CommandExecutor::getToken(0));
     337                    if (CommandExecutor::getInstance().shortcut_ == 0)
     338                        CommandExecutor::getInstance().shortcut_ = CommandExecutor::getExecutorOfPossibleShortcut(CommandExecutor::getToken(0));
     339
     340                    if ((CommandExecutor::getInstance().functionclass_ == 0) && (CommandExecutor::getInstance().shortcut_ == 0))
    341341                    {
    342342                        // Argument 1 seems to be wrong
    343343                        AddLanguageEntry("CommandExecutor::NoSuchCommandOrClassName", "No such command or classname");
    344                         CommandExecutor::getInstance().errorMessage_s = (CommandExecutor::getToken(0) + ": " + GetLocalisation("CommandExecutor::NoSuchCommandOrClassName"));
    345                         CommandExecutor::getInstance().state_s = CS_Error;
    346                         return;
    347                     }
    348                     else if (CommandExecutor::getInstance().shortcut_s != 0)
     344                        CommandExecutor::getInstance().errorMessage_ = (CommandExecutor::getToken(0) + ": " + GetLocalisation("CommandExecutor::NoSuchCommandOrClassName"));
     345                        CommandExecutor::getInstance().state_ = CS_Error;
     346                        return;
     347                    }
     348                    else if (CommandExecutor::getInstance().shortcut_ != 0)
    349349                    {
    350350                        // Argument 1 is a shortcut: Return the needed parameter types
    351                         CommandExecutor::getInstance().state_s = CS_Shortcut_Params;
     351                        CommandExecutor::getInstance().state_ = CS_Shortcut_Params;
    352352                        CommandExecutor::parse(command, false);
    353353                        return;
     
    356356                    {
    357357                        // Argument 1 is a classname: Return the possible functions
    358                         CommandExecutor::getInstance().state_s = CS_Function;
     358                        CommandExecutor::getInstance().state_ = CS_Function;
    359359                        CommandExecutor::parse(command, false);
    360360                        return;
     
    363363                else
    364364                {
    365                     CommandExecutor::getInstance().state_s = CS_Error;
     365                    CommandExecutor::getInstance().state_ = CS_Error;
    366366                    return;
    367367                }
    368368                break;
    369369            case CS_Shortcut_Params:
    370                 if (CommandExecutor::getInstance().shortcut_s != 0)
     370                if (CommandExecutor::getInstance().shortcut_ != 0)
    371371                {
    372372                    // Valid command
    373373                    // Check if there are enough parameters
    374                     if (CommandExecutor::enoughParametersGiven(1, CommandExecutor::getInstance().shortcut_s))
    375                     {
    376                         CommandExecutor::getInstance().state_s = CS_Shortcut_Finished;
     374                    if (CommandExecutor::enoughParametersGiven(1, CommandExecutor::getInstance().shortcut_))
     375                    {
     376                        CommandExecutor::getInstance().state_ = CS_Shortcut_Finished;
    377377                        return;
    378378                    }
     
    381381                {
    382382                    // Something is wrong
    383                     CommandExecutor::getInstance().state_s = CS_Error;
     383                    CommandExecutor::getInstance().state_ = CS_Error;
    384384                    return;
    385385                }
    386386                break;
    387387            case CS_Function:
    388                 if (CommandExecutor::getInstance().functionclass_s != 0)
     388                if (CommandExecutor::getInstance().functionclass_ != 0)
    389389                {
    390390                    // We have a valid classname
     
    393393                    {
    394394                        // There is a second argument: Check if it's a valid functionname
    395                         CommandExecutor::getInstance().function_s = CommandExecutor::getExecutorOfPossibleFunction(CommandExecutor::getToken(1), CommandExecutor::getInstance().functionclass_s);
    396                         if (CommandExecutor::getInstance().function_s == 0)
     395                        CommandExecutor::getInstance().function_ = CommandExecutor::getExecutorOfPossibleFunction(CommandExecutor::getToken(1), CommandExecutor::getInstance().functionclass_);
     396                        if (CommandExecutor::getInstance().function_ == 0)
    397397                        {
    398398                            // Argument 2 seems to be wrong
    399399                            AddLanguageEntry("CommandExecutor::NoSuchFunctionnameIn", "No such functionname in");
    400                             CommandExecutor::getInstance().errorMessage_s = (CommandExecutor::getToken(1) + ": " + GetLocalisation("CommandExecutor::NoSuchFunctionnameIn") + " " + CommandExecutor::getInstance().functionclass_s->getName());
    401                             CommandExecutor::getInstance().state_s = CS_Error;
     400                            CommandExecutor::getInstance().errorMessage_ = (CommandExecutor::getToken(1) + ": " + GetLocalisation("CommandExecutor::NoSuchFunctionnameIn") + " " + CommandExecutor::getInstance().functionclass_->getName());
     401                            CommandExecutor::getInstance().state_ = CS_Error;
    402402                            return;
    403403                        }
     
    405405                        {
    406406                            // Argument 2 seems to be a valid functionname: Get the parameters
    407                             CommandExecutor::getInstance().state_s = CS_Function_Params;
     407                            CommandExecutor::getInstance().state_ = CS_Function_Params;
    408408                            CommandExecutor::parse(command, false);
    409409                            return;
     
    414414                        // There is no finished second argument
    415415                        // Check if there's already a perfect match
    416                         if (CommandExecutor::getInstance().tokens_s.size() >= 2)
    417                         {
    418                             CommandExecutor::getInstance().function_s = CommandExecutor::getExecutorOfPossibleFunction(CommandExecutor::getToken(1), CommandExecutor::getInstance().functionclass_s);
    419                             if (CommandExecutor::getInstance().function_s != 0)
     416                        if (CommandExecutor::getInstance().tokens_.size() >= 2)
     417                        {
     418                            CommandExecutor::getInstance().function_ = CommandExecutor::getExecutorOfPossibleFunction(CommandExecutor::getToken(1), CommandExecutor::getInstance().functionclass_);
     419                            if (CommandExecutor::getInstance().function_ != 0)
    420420                            {
    421421                                // There is a perfect match: Add a whitespace and continue parsing
    422                                 CommandExecutor::getInstance().state_s = CS_Function_Params;
     422                                CommandExecutor::getInstance().state_ = CS_Function_Params;
    423423                                CommandExecutor::parse(command + " ", false);
    424424                                return;
     
    427427
    428428                        // No perfect match: Create the list of all possible functions and return
    429                         CommandExecutor::createListOfPossibleFunctions(CommandExecutor::getToken(1), CommandExecutor::getInstance().functionclass_s);
     429                        CommandExecutor::createListOfPossibleFunctions(CommandExecutor::getToken(1), CommandExecutor::getInstance().functionclass_);
    430430                        return;
    431431                    }
     
    433433                else
    434434                {
    435                     CommandExecutor::getInstance().state_s = CS_Error;
     435                    CommandExecutor::getInstance().state_ = CS_Error;
    436436                    return;
    437437                }
    438438                break;
    439439            case CS_Function_Params:
    440                 if ((CommandExecutor::getInstance().functionclass_s != 0) && (CommandExecutor::getInstance().function_s != 0))
     440                if ((CommandExecutor::getInstance().functionclass_ != 0) && (CommandExecutor::getInstance().function_ != 0))
    441441                {
    442442                    // Valid command
    443443                    // Check if there are enough parameters
    444                     if (CommandExecutor::enoughParametersGiven(2, CommandExecutor::getInstance().function_s))
    445                     {
    446                         CommandExecutor::getInstance().state_s = CS_Function_Finished;
     444                    if (CommandExecutor::enoughParametersGiven(2, CommandExecutor::getInstance().function_))
     445                    {
     446                        CommandExecutor::getInstance().state_ = CS_Function_Finished;
    447447                        return;
    448448                    }
     
    451451                {
    452452                    // Something is wrong
    453                     CommandExecutor::getInstance().state_s = CS_Error;
     453                    CommandExecutor::getInstance().state_ = CS_Error;
    454454                    return;
    455455                }
     
    463463                    {
    464464                        // There is a second argument: Check if it's a valid classname
    465                         CommandExecutor::getInstance().configvalueclass_s = CommandExecutor::getIdentifierOfPossibleConfigValueClass(CommandExecutor::getToken(1));
    466                         if (CommandExecutor::getInstance().configvalueclass_s == 0)
     465                        CommandExecutor::getInstance().configvalueclass_ = CommandExecutor::getIdentifierOfPossibleConfigValueClass(CommandExecutor::getToken(1));
     466                        if (CommandExecutor::getInstance().configvalueclass_ == 0)
    467467                        {
    468468                            // Argument 2 seems to be wrong
    469469                            AddLanguageEntry("CommandExecutor::NoSuchClassWithConfigValues", "No such class with config values");
    470                             CommandExecutor::getInstance().errorMessage_s = (CommandExecutor::getToken(1) + ": " + GetLocalisation("CommandExecutor::NoSuchClassWithConfigValues"));
    471                             CommandExecutor::getInstance().state_s = CS_Error;
     470                            CommandExecutor::getInstance().errorMessage_ = (CommandExecutor::getToken(1) + ": " + GetLocalisation("CommandExecutor::NoSuchClassWithConfigValues"));
     471                            CommandExecutor::getInstance().state_ = CS_Error;
    472472                            return;
    473473                        }
     
    475475                        {
    476476                            // Argument 2 seems to be a valid classname: Search for possible config values
    477                             CommandExecutor::getInstance().state_s = CS_ConfigValue;
     477                            CommandExecutor::getInstance().state_ = CS_ConfigValue;
    478478                            CommandExecutor::parse(command, false);
    479479                            return;
     
    484484                        // There's no finished second argument
    485485                        // Check if there's already a perfect match
    486                         if (CommandExecutor::getInstance().tokens_s.size() >= 2)
    487                         {
    488                             CommandExecutor::getInstance().configvalueclass_s = CommandExecutor::getIdentifierOfPossibleConfigValueClass(CommandExecutor::getToken(1));
    489                             if (CommandExecutor::getInstance().configvalueclass_s != 0)
     486                        if (CommandExecutor::getInstance().tokens_.size() >= 2)
     487                        {
     488                            CommandExecutor::getInstance().configvalueclass_ = CommandExecutor::getIdentifierOfPossibleConfigValueClass(CommandExecutor::getToken(1));
     489                            if (CommandExecutor::getInstance().configvalueclass_ != 0)
    490490                            {
    491491                                // There is a perfect match: Add a whitespace and continue parsing
    492                                 CommandExecutor::getInstance().state_s = CS_ConfigValue;
     492                                CommandExecutor::getInstance().state_ = CS_ConfigValue;
    493493                                CommandExecutor::parse(command + " ", false);
    494494                                return;
     
    504504                {
    505505                    // Something is wrong
    506                     CommandExecutor::getInstance().state_s = CS_Error;
     506                    CommandExecutor::getInstance().state_ = CS_Error;
    507507                    return;
    508508                }
    509509                break;
    510510            case CS_ConfigValue:
    511                 if (((CommandExecutor::getToken(0) == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE) || (CommandExecutor::getToken(0) == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE_TEMPORARY)) && (CommandExecutor::getInstance().configvalueclass_s != 0))
     511                if (((CommandExecutor::getToken(0) == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE) || (CommandExecutor::getToken(0) == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE_TEMPORARY)) && (CommandExecutor::getInstance().configvalueclass_ != 0))
    512512                {
    513513                    // Check if there is a third argument
     
    515515                    {
    516516                        // There is a third argument: Check if it's a valid config value
    517                         CommandExecutor::getInstance().configvalue_s = CommandExecutor::getContainerOfPossibleConfigValue(CommandExecutor::getToken(2), CommandExecutor::getInstance().configvalueclass_s);
    518                         if (CommandExecutor::getInstance().configvalue_s == 0)
     517                        CommandExecutor::getInstance().configvalue_ = CommandExecutor::getContainerOfPossibleConfigValue(CommandExecutor::getToken(2), CommandExecutor::getInstance().configvalueclass_);
     518                        if (CommandExecutor::getInstance().configvalue_ == 0)
    519519                        {
    520520                            // Argument 3 seems to be wrong
    521521                            AddLanguageEntry("CommandExecutor::NoSuchConfigValueIn", "No such config value in");
    522                             CommandExecutor::getInstance().errorMessage_s = (CommandExecutor::getToken(2) + ": " + GetLocalisation("CommandExecutor::NoSuchConfigValueIn") + " " + CommandExecutor::getInstance().configvalueclass_s->getName());
    523                             CommandExecutor::getInstance().state_s = CS_Error;
     522                            CommandExecutor::getInstance().errorMessage_ = (CommandExecutor::getToken(2) + ": " + GetLocalisation("CommandExecutor::NoSuchConfigValueIn") + " " + CommandExecutor::getInstance().configvalueclass_->getName());
     523                            CommandExecutor::getInstance().state_ = CS_Error;
    524524                            return;
    525525                        }
     
    527527                        {
    528528                            // Argument 3 seems to be a valid config value: Get the type
    529                             CommandExecutor::getInstance().state_s = CS_ConfigValueType;
     529                            CommandExecutor::getInstance().state_ = CS_ConfigValueType;
    530530                            CommandExecutor::parse(command, false);
    531531                            return;
     
    536536                        // There is no finished third argument
    537537                        // Check if there's already a perfect match
    538                         if (CommandExecutor::getInstance().tokens_s.size() >= 3)
    539                         {
    540                             CommandExecutor::getInstance().configvalue_s = CommandExecutor::getContainerOfPossibleConfigValue(CommandExecutor::getToken(2), CommandExecutor::getInstance().configvalueclass_s);
    541                             if (CommandExecutor::getInstance().configvalueclass_s != 0)
     538                        if (CommandExecutor::getInstance().tokens_.size() >= 3)
     539                        {
     540                            CommandExecutor::getInstance().configvalue_ = CommandExecutor::getContainerOfPossibleConfigValue(CommandExecutor::getToken(2), CommandExecutor::getInstance().configvalueclass_);
     541                            if (CommandExecutor::getInstance().configvalueclass_ != 0)
    542542                            {
    543543                                // There is a perfect match: Add a whitespace and continue parsing
    544                                 CommandExecutor::getInstance().state_s = CS_ConfigValueType;
     544                                CommandExecutor::getInstance().state_ = CS_ConfigValueType;
    545545                                CommandExecutor::parse(command + " ", false);
    546546                                return;
     
    549549
    550550                        // No perfect match: Create the list of all possible config values
    551                         CommandExecutor::createListOfPossibleConfigValues(CommandExecutor::getToken(2), CommandExecutor::getInstance().configvalueclass_s);
     551                        CommandExecutor::createListOfPossibleConfigValues(CommandExecutor::getToken(2), CommandExecutor::getInstance().configvalueclass_);
    552552                        return;
    553553                    }
     
    556556                {
    557557                    // Something is wrong
    558                     CommandExecutor::getInstance().state_s = CS_Error;
     558                    CommandExecutor::getInstance().state_ = CS_Error;
    559559                    return;
    560560                }
    561561                break;
    562562            case CS_ConfigValueType:
    563                 if (((CommandExecutor::getToken(0) == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE) || (CommandExecutor::getToken(0) == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE_TEMPORARY)) && (CommandExecutor::getInstance().configvalueclass_s != 0) && (CommandExecutor::getInstance().configvalue_s != 0))
     563                if (((CommandExecutor::getToken(0) == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE) || (CommandExecutor::getToken(0) == COMMAND_EXECUTOR_KEYWORD_SET_CONFIG_VALUE_TEMPORARY)) && (CommandExecutor::getInstance().configvalueclass_ != 0) && (CommandExecutor::getInstance().configvalue_ != 0))
    564564                {
    565565                    // Valid command
    566566                    // Check if there are enough parameters
    567                     if (CommandExecutor::getInstance().tokens_s.size() >= 4)
    568                     {
    569                         CommandExecutor::getInstance().state_s = CS_ConfigValueFinished;
     567                    if (CommandExecutor::getInstance().tokens_.size() >= 4)
     568                    {
     569                        CommandExecutor::getInstance().state_ = CS_ConfigValueFinished;
    570570                        return;
    571571                    }
     
    574574                {
    575575                    // Something is wrong
    576                     CommandExecutor::getInstance().state_s = CS_Error;
     576                    CommandExecutor::getInstance().state_ = CS_Error;
    577577                    return;
    578578                }
     
    586586                {
    587587                    // Something is wrong
    588                     CommandExecutor::getInstance().state_s = CS_Error;
     588                    CommandExecutor::getInstance().state_ = CS_Error;
    589589                    return;
    590590                }
     
    595595                    // Valid command
    596596                    // Check if there are enough parameters
    597                     if (CommandExecutor::getInstance().tokens_s.size() >= 3)
    598                     {
    599                         CommandExecutor::getInstance().state_s = CS_KeybindFinished;
     597                    if (CommandExecutor::getInstance().tokens_.size() >= 3)
     598                    {
     599                        CommandExecutor::getInstance().state_ = CS_KeybindFinished;
    600600                        return;
    601601                    }
     
    605605                {
    606606                    // Something is wrong
    607                     CommandExecutor::getInstance().state_s = CS_Error;
     607                    CommandExecutor::getInstance().state_ = CS_Error;
    608608                    return;
    609609                }
     
    629629    void CommandExecutor::initialize()
    630630    {
    631         CommandExecutor::getInstance().listOfPossibleFunctionClasses_s.clear();
    632         CommandExecutor::getInstance().listOfPossibleShortcuts_s.clear();
    633         CommandExecutor::getInstance().listOfPossibleFunctions_s.clear();
    634         CommandExecutor::getInstance().listOfPossibleConfigValueClasses_s.clear();
    635         CommandExecutor::getInstance().listOfPossibleConfigValues_s.clear();
    636         CommandExecutor::getInstance().listOfPossibleKeys_s.clear();
    637 
    638         CommandExecutor::getInstance().functionclass_s = 0;
    639         CommandExecutor::getInstance().configvalueclass_s = 0;
    640         CommandExecutor::getInstance().shortcut_s = 0;
    641         CommandExecutor::getInstance().function_s = 0;
    642         CommandExecutor::getInstance().configvalue_s = 0;
    643         CommandExecutor::getInstance().key_s = 0;
    644 
    645         CommandExecutor::getInstance().errorMessage_s = "";
    646         CommandExecutor::getInstance().state_s = CS_Empty;
     631        CommandExecutor::getInstance().listOfPossibleFunctionClasses_.clear();
     632        CommandExecutor::getInstance().listOfPossibleShortcuts_.clear();
     633        CommandExecutor::getInstance().listOfPossibleFunctions_.clear();
     634        CommandExecutor::getInstance().listOfPossibleConfigValueClasses_.clear();
     635        CommandExecutor::getInstance().listOfPossibleConfigValues_.clear();
     636        CommandExecutor::getInstance().listOfPossibleKeys_.clear();
     637
     638        CommandExecutor::getInstance().functionclass_ = 0;
     639        CommandExecutor::getInstance().configvalueclass_ = 0;
     640        CommandExecutor::getInstance().shortcut_ = 0;
     641        CommandExecutor::getInstance().function_ = 0;
     642        CommandExecutor::getInstance().configvalue_ = 0;
     643        CommandExecutor::getInstance().key_ = 0;
     644
     645        CommandExecutor::getInstance().errorMessage_ = "";
     646        CommandExecutor::getInstance().state_ = CS_Empty;
    647647    }
    648648
     
    651651        // Because we added a cursor we have +1 arguments
    652652        // There are num arguments given if there are at least num arguments + one cursor
    653         return (CommandExecutor::getInstance().tokens_s.size() >= (num + 1));
     653        return (CommandExecutor::getInstance().tokens_.size() >= (num + 1));
    654654    }
    655655
     
    657657    {
    658658        // Because we added a cursor we have +1 arguments
    659         if (CommandExecutor::getInstance().tokens_s.size() >= 1)
    660             return (CommandExecutor::getInstance().tokens_s.size() - 1);
     659        if (CommandExecutor::getInstance().tokens_.size() >= 1)
     660            return (CommandExecutor::getInstance().tokens_.size() - 1);
    661661        else
    662662            return 0;
     
    665665    std::string CommandExecutor::getToken(unsigned int index)
    666666    {
    667         if ((index >= 0) && (index < (CommandExecutor::getInstance().tokens_s.size() - 1)))
    668             return CommandExecutor::getInstance().tokens_s[index];
    669         else if (index == (CommandExecutor::getInstance().tokens_s.size() - 1))
    670             return CommandExecutor::getInstance().tokens_s[index].substr(0, CommandExecutor::getInstance().tokens_s[index].size() - 1);
     667        if ((index >= 0) && (index < (CommandExecutor::getInstance().tokens_.size() - 1)))
     668            return CommandExecutor::getInstance().tokens_[index];
     669        else if (index == (CommandExecutor::getInstance().tokens_.size() - 1))
     670            return CommandExecutor::getInstance().tokens_[index].substr(0, CommandExecutor::getInstance().tokens_[index].size() - 1);
    671671        else
    672672            return "";
     
    683683                break;
    684684        }
    685         return (CommandExecutor::getInstance().tokens_s.size() >= neededParams);
     685        return (CommandExecutor::getInstance().tokens_.size() >= neededParams);
    686686    }
    687687
     
    694694                if ((*it).first.find(getLowercase(fragment)) == 0)
    695695                {
    696                     CommandExecutor::getInstance().listOfPossibleFunctionClasses_s.push_back(&(*it).first);
     696                    CommandExecutor::getInstance().listOfPossibleFunctionClasses_.push_back(&(*it).first);
    697697                }
    698698            }
    699699        }
    700700
    701         CommandExecutor::getInstance().listOfPossibleFunctionClasses_s.sort(CommandExecutor::compareStringsInList);
     701        CommandExecutor::getInstance().listOfPossibleFunctionClasses_.sort(CommandExecutor::compareStringsInList);
    702702    }
    703703
     
    708708            if ((*it).first.find(getLowercase(fragment)) == 0)
    709709            {
    710                 CommandExecutor::getInstance().listOfPossibleShortcuts_s.push_back(&(*it).first);
     710                CommandExecutor::getInstance().listOfPossibleShortcuts_.push_back(&(*it).first);
    711711            }
    712712        }
    713713
    714         CommandExecutor::getInstance().listOfPossibleShortcuts_s.sort(CommandExecutor::compareStringsInList);
     714        CommandExecutor::getInstance().listOfPossibleShortcuts_.sort(CommandExecutor::compareStringsInList);
    715715    }
    716716
     
    721721            if ((*it).first.find(getLowercase(fragment)) == 0)
    722722            {
    723                 CommandExecutor::getInstance().listOfPossibleFunctions_s.push_back(&(*it).first);
     723                CommandExecutor::getInstance().listOfPossibleFunctions_.push_back(&(*it).first);
    724724            }
    725725        }
    726726
    727         CommandExecutor::getInstance().listOfPossibleFunctions_s.sort(CommandExecutor::compareStringsInList);
     727        CommandExecutor::getInstance().listOfPossibleFunctions_.sort(CommandExecutor::compareStringsInList);
    728728    }
    729729
     
    736736                if ((*it).first.find(getLowercase(fragment)) == 0)
    737737                {
    738                     CommandExecutor::getInstance().listOfPossibleConfigValueClasses_s.push_back(&(*it).first);
     738                    CommandExecutor::getInstance().listOfPossibleConfigValueClasses_.push_back(&(*it).first);
    739739                }
    740740            }
    741741        }
    742742
    743         CommandExecutor::getInstance().listOfPossibleConfigValueClasses_s.sort(CommandExecutor::compareStringsInList);
     743        CommandExecutor::getInstance().listOfPossibleConfigValueClasses_.sort(CommandExecutor::compareStringsInList);
    744744    }
    745745
     
    750750            if ((*it).first.find(getLowercase(fragment)) == 0)
    751751            {
    752                 CommandExecutor::getInstance().listOfPossibleConfigValues_s.push_back(&(*it).first);
     752                CommandExecutor::getInstance().listOfPossibleConfigValues_.push_back(&(*it).first);
    753753            }
    754754        }
    755755
    756         CommandExecutor::getInstance().listOfPossibleConfigValues_s.sort(CommandExecutor::compareStringsInList);
     756        CommandExecutor::getInstance().listOfPossibleConfigValues_.sort(CommandExecutor::compareStringsInList);
    757757    }
    758758
     
    761761        // todo
    762762
    763         CommandExecutor::getInstance().listOfPossibleKeys_s.sort(CommandExecutor::compareStringsInList);
     763        CommandExecutor::getInstance().listOfPossibleKeys_.sort(CommandExecutor::compareStringsInList);
    764764    }
    765765
  • code/branches/core2/src/orxonox/core/CommandExecutor.h

    r950 r951  
    7171
    7272            /** @brief Returns the map that stores all console commands. @return The const_iterator */
    73             static inline const std::map<std::string, ExecutorStatic*>& getConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_s; }
     73            static inline const std::map<std::string, ExecutorStatic*>& getConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_; }
    7474            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands. @return The const_iterator */
    75             static inline std::map<std::string, ExecutorStatic*>::const_iterator getConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_s.begin(); }
     75            static inline std::map<std::string, ExecutorStatic*>::const_iterator getConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_.begin(); }
    7676            /** @brief Returns a const_iterator to the end of the map that stores all console commands. @return The const_iterator */
    77             static inline std::map<std::string, ExecutorStatic*>::const_iterator getConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_s.end(); }
     77            static inline std::map<std::string, ExecutorStatic*>::const_iterator getConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_.end(); }
    7878
    7979            /** @brief Returns the map that stores all console commands with their names in lowercase. @return The const_iterator */
    80             static inline const std::map<std::string, ExecutorStatic*>& getLowercaseConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_s; }
     80            static inline const std::map<std::string, ExecutorStatic*>& getLowercaseConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_; }
    8181            /** @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 */
    82             static inline std::map<std::string, ExecutorStatic*>::const_iterator getLowercaseConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_s.begin(); }
     82            static inline std::map<std::string, ExecutorStatic*>::const_iterator getLowercaseConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_.begin(); }
    8383            /** @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 */
    84             static inline std::map<std::string, ExecutorStatic*>::const_iterator getLowercaseConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_s.end(); }
     84            static inline std::map<std::string, ExecutorStatic*>::const_iterator getLowercaseConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end(); }
    8585
    8686        private:
     
    123123            static ConfigValueContainer* getContainerOfPossibleKey(const std::string& name);
    124124
    125             std::string lastProcessedCommand_s;
    126             SubString tokens_s;
    127             std::list<const std::string*> listOfPossibleFunctionClasses_s;
    128             std::list<const std::string*> listOfPossibleShortcuts_s;
    129             std::list<const std::string*> listOfPossibleFunctions_s;
    130             std::list<const std::string*> listOfPossibleConfigValueClasses_s;
    131             std::list<const std::string*> listOfPossibleConfigValues_s;
    132             std::list<const std::string*> listOfPossibleKeys_s;
     125            std::string lastProcessedCommand_;
     126            SubString tokens_;
     127            std::list<const std::string*> listOfPossibleFunctionClasses_;
     128            std::list<const std::string*> listOfPossibleShortcuts_;
     129            std::list<const std::string*> listOfPossibleFunctions_;
     130            std::list<const std::string*> listOfPossibleConfigValueClasses_;
     131            std::list<const std::string*> listOfPossibleConfigValues_;
     132            std::list<const std::string*> listOfPossibleKeys_;
    133133
    134             Identifier* functionclass_s;
    135             Identifier* configvalueclass_s;
    136             ExecutorStatic* shortcut_s;
    137             ExecutorStatic* function_s;
    138             ConfigValueContainer* configvalue_s;
    139             ConfigValueContainer* key_s;
     134            Identifier* functionclass_;
     135            Identifier* configvalueclass_;
     136            ExecutorStatic* shortcut_;
     137            ExecutorStatic* function_;
     138            ConfigValueContainer* configvalue_;
     139            ConfigValueContainer* key_;
    140140
    141             std::string errorMessage_s;
    142             CommandState state_s;
     141            std::string errorMessage_;
     142            CommandState state_;
    143143
    144             std::map<std::string, ExecutorStatic*> consoleCommandShortcuts_s;
    145             std::map<std::string, ExecutorStatic*> consoleCommandShortcuts_LC_s;
     144            std::map<std::string, ExecutorStatic*> consoleCommandShortcuts_;
     145            std::map<std::string, ExecutorStatic*> consoleCommandShortcuts_LC_;
    146146    };
    147147}
Note: See TracChangeset for help on using the changeset viewer.