Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 27, 2008, 6:49:38 PM (16 years ago)
Author:
landauf
Message:
  • 3 times the (almost) same implementation + macro
File:
1 edited

Legend:

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

    r933 r939  
    5959    bool Executor::parse(const std::string& params, const std::string& delimiter) const
    6060    {
    61         unsigned int paramCount = this->functor_->getParamCount();
    62 
    63         if (paramCount == 0)
    64         {
    65             COUT(5) << "Calling Executor " << this->name_ << " through parser without parameters." << std::endl;
    66             (*this->functor_)();
    67         }
    68         else if (paramCount == 1)
    69         {
    70             std::string temp = getStripped(params);
    71             if ((temp != "") && (temp.size() != 0))
    72             {
    73                 COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using whole string: " << params << std::endl;
    74                 (*this->functor_)(MultiTypeMath(params));
    75             }
    76             else if (this->bAddedDefaultValue_[0])
    77             {
    78                 COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using default value: " << this->defaultValue_[0] << std::endl;
    79                 (*this->functor_)(this->defaultValue_[0]);
    80             }
    81             else
    82             {
    83                 COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input: " << temp << ")." << std::endl;
    84                 return false;
    85             }
    86         }
    87         else
    88         {
    89             SubString tokens(params, delimiter, SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
    90 
    91             for (unsigned int i = tokens.size(); i < this->functor_->getParamCount(); i++)
    92             {
    93                 if (!this->bAddedDefaultValue_[i])
    94                 {
    95                     COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input:" << params << ")." << std::endl;
    96                     return false;
    97                 }
    98             }
    99 
    100             MultiTypeMath param[paramCount];
    101             COUT(5) << "Calling Executor " << this->name_ << " through parser with " << paramCount << " parameters, using " << tokens.size() << " tokens (";
    102             for (unsigned int i = 0; i < tokens.size(); i++)
    103             {
    104                 param[i] = tokens[i];
    105                 if (i != 0)
    106                 {
    107                     COUT(5) << ", ";
    108                 }
    109                 COUT(5) << tokens[i];
    110             }
    111             COUT(5) << ") and " << (paramCount - tokens.size()) << " default values (";
    112             for (unsigned int i = tokens.size(); i < paramCount; i++)
    113             {
    114                 param[i] = this->defaultValue_[i];
    115                 if (i != 0)
    116                 {
    117                     COUT(5) << ", ";
    118                 }
    119                 COUT(5) << this->defaultValue_[i];
    120             }
    121             COUT(5) << ")." << std::endl;
    122 
    123             switch(paramCount)
    124             {
    125                 case 2:
    126                     (*this->functor_)(param[0], param[1]);
    127                     break;
    128                 case 3:
    129                     (*this->functor_)(param[0], param[1], param[2]);
    130                     break;
    131                 case 4:
    132                     (*this->functor_)(param[0], param[1], param[2], param[3]);
    133                     break;
    134                 case 5:
    135                     (*this->functor_)(param[0], param[1], param[2], param[3], param[4]);
    136                     break;
    137             }
    138         }
    139 
    140         return true;
     61        EXECUTOR_PARSE(normal);
    14162    }
    14263
Note: See TracChangeset for help on using the changeset viewer.