Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 19, 2010, 4:57:06 PM (14 years ago)
Author:
landauf
Message:

changed passing of the returnvalue in the command execution pipeline:

  • Functor: operator() directly returns the returnvalue of the executed function (if any, otherwise a MultiType whose null() function evaluates to true). The returnvalue is no longer stored in the Functor.
  • Executor: The same behavior of operator() like in Functor. Additionally the parse() function returns the returnvalue of the executed function instead of a boolean status. The status can be retrieved by passing a pointer to a bool to the function.
  • CommandExecutor: execute() works like before (returns only a boolean status), but added a new function query() which returns the returnvalue of the executed command. The status of query() can be retrieved by optionally passing an pointer to a bool.
  • CommandEvaluation: same as for CommandExecutor: execute() like before, added query()
  • TclBind::eval() returns the returnvalue of the evaluated tcl command. The status can also be retrieved by passing a pointer to a bool.
  • The Shell prints the returnvalue (if available) of an executed command
  • added a constructor to MultiType to directly create it from an mbool. The mbool will be converted to a bool, so it loses it's internal state.
File:
1 edited

Legend:

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

    r7187 r7189  
    5050    }
    5151
    52     bool Executor::parse(const std::string& params, const std::string& delimiter) const
    53     {
     52    MultiType Executor::parse(const std::string& params, bool* success, const std::string& delimiter) const
     53    {
     54        if (success)
     55            *success = true;
     56
    5457        unsigned int paramCount = this->functor_->getParamCount();
    5558
     
    5760        {
    5861            COUT(5) << "Calling Executor " << this->name_ << " through parser without parameters." << std::endl;
    59             (*this->functor_)();
     62            return (*this->functor_)();
    6063        }
    6164        else if (paramCount == 1)
     
    6568            {
    6669                COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using whole string: " << params << std::endl;
    67                 (*this->functor_)(MultiType(params));
     70                return (*this->functor_)(MultiType(params));
    6871            }
    6972            else if (!this->defaultValue_[0].null())
    7073            {
    7174                COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using default value: " << this->defaultValue_[0] << std::endl;
    72                 (*this->functor_)(this->defaultValue_[0]);
     75                return (*this->functor_)(this->defaultValue_[0]);
    7376            }
    7477            else
    7578            {
    7679                COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input: " << temp << ")." << std::endl;
    77                 return false;
     80                if (success)
     81                    *success = false;
     82                return MT_Type::Null;
    7883            }
    7984        }
     
    8792                {
    8893                    COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input:" << params << ")." << std::endl;
    89                     return false;
     94                    if (success)
     95                        *success = false;
     96                    return MT_Type::Null;
    9097                }
    9198            }
     
    120127            {
    121128                case 2:
    122                     (*this->functor_)(param[0], param[1]);
    123                     break;
     129                    return (*this->functor_)(param[0], param[1]);
    124130                case 3:
    125                     (*this->functor_)(param[0], param[1], param[2]);
    126                     break;
     131                    return (*this->functor_)(param[0], param[1], param[2]);
    127132                case 4:
    128                     (*this->functor_)(param[0], param[1], param[2], param[3]);
    129                     break;
     133                    return (*this->functor_)(param[0], param[1], param[2], param[3]);
    130134                case 5:
    131                     (*this->functor_)(param[0], param[1], param[2], param[3], param[4]);
    132                     break;
    133             }
    134         }
    135 
    136         return true;
     135                    return (*this->functor_)(param[0], param[1], param[2], param[3], param[4]);
     136            }
     137        }
     138
     139        return MT_Type::Null;
    137140    }
    138141
Note: See TracChangeset for help on using the changeset viewer.