Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 19, 2010, 2:14:54 AM (14 years ago)
Author:
landauf
Message:

Moved ability to possess descriptions from Executor to ConsoleCommand, since no other executors use this feature. Also simplified this code a little by introducing a new shortcut in Language.h. XMLPort has to use a temporary solution for descriptions without Language support atm.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/consolecommands3/src/libraries/core/Executor.cc

    r7163 r7186  
    3636#include "util/StringUtils.h"
    3737#include "util/SubString.h"
    38 #include "Language.h"
    3938
    4039namespace orxonox
     
    4443        this->functor_ = functor;
    4544        this->name_ = name;
    46 
    47         this->bAddedDescription_ = false;
    48         this->bAddedDescriptionReturnvalue_ = false;
    49 
    50         this->bAddedDescriptionParam_[0] = false;
    51         this->bAddedDescriptionParam_[1] = false;
    52         this->bAddedDescriptionParam_[2] = false;
    53         this->bAddedDescriptionParam_[3] = false;
    54         this->bAddedDescriptionParam_[4] = false;
    5545
    5646        this->bAddedDefaultValue_[0] = false;
     
    6959    {
    7060        unsigned int paramCount = this->functor_->getParamCount();
    71        
     61
    7262        if (paramCount == 0)
    7363        {
     
    9787        {
    9888            SubString tokens(params, delimiter, SubString::WhiteSpaces, false, '\\', true, '"', true, '(', ')', true, '\0');
    99            
     89
    10090            for (unsigned int i = tokens.size(); i < this->functor_->getParamCount(); i++)
    10191            {
     
    10696                }
    10797            }
    108            
     98
    10999            MultiType param[MAX_FUNCTOR_ARGUMENTS];
    110100            COUT(5) << "Calling Executor " << this->name_ << " through parser with " << paramCount << " parameters, using " << tokens.size() << " tokens (";
     
    129119            }
    130120            COUT(5) << ")." << std::endl;
    131            
     121
    132122            if ((tokens.size() > paramCount) && (this->functor_->getTypenameParam(paramCount - 1) == "string"))
    133123                param[paramCount - 1] = tokens.subSet(paramCount - 1).join();
    134            
     124
    135125            switch(paramCount)
    136126            {
     
    198188            return true;
    199189        }
    200     }
    201 
    202     Executor& Executor::setDescription(const std::string& description)
    203     {
    204         if (!this->bAddedDescription_)
    205         {
    206             this->description_ = std::string("ExecutorDescription::" + this->name_ + "::function");
    207             AddLanguageEntry(this->description_, description);
    208             this->bAddedDescription_ = true;
    209         }
    210         return (*this);
    211     }
    212 
    213     const std::string& Executor::getDescription() const
    214     {
    215         return GetLocalisation(this->description_);
    216     }
    217 
    218     Executor& Executor::setDescriptionParam(unsigned int param, const std::string& description)
    219     {
    220         if (param < MAX_FUNCTOR_ARGUMENTS)
    221         {
    222             if (!this->bAddedDescriptionParam_[param])
    223             {
    224                 std::string paramnumber;
    225                 if (!convertValue(&paramnumber, param))
    226                     return (*this);
    227 
    228                 this->descriptionParam_[param] = std::string("ExecutorDescription::" + this->name_ + "::param" + paramnumber);
    229                 AddLanguageEntry(this->descriptionParam_[param], description);
    230                 this->bAddedDescriptionParam_[param] = true;
    231             }
    232         }
    233         return (*this);
    234     }
    235 
    236     const std::string& Executor::getDescriptionParam(unsigned int param) const
    237     {
    238         if (param < MAX_FUNCTOR_ARGUMENTS)
    239             return GetLocalisation(this->descriptionParam_[param]);
    240 
    241         return this->descriptionParam_[0];
    242     }
    243 
    244     Executor& Executor::setDescriptionReturnvalue(const std::string& description)
    245     {
    246         if (!this->bAddedDescriptionReturnvalue_)
    247         {
    248             this->descriptionReturnvalue_ = std::string("ExecutorDescription::" + this->name_ + "::returnvalue");
    249             AddLanguageEntry(this->descriptionReturnvalue_, description);
    250             this->bAddedDescriptionReturnvalue_ = true;
    251         }
    252         return (*this);
    253     }
    254 
    255     const std::string& Executor::getDescriptionReturnvalue(int param) const
    256     {
    257         return GetLocalisation(this->descriptionReturnvalue_);
    258190    }
    259191
Note: See TracChangeset for help on using the changeset viewer.