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.h

    r7188 r7189  
    4545            virtual ~Executor();
    4646
    47             inline void operator()() const
    48                 { (*this->functor_)(this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    49             inline void operator()(const MultiType& param1) const
    50                 { (*this->functor_)(param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    51             inline void operator()(const MultiType& param1, const MultiType& param2) const
    52                 { (*this->functor_)(param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    53             inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3) const
    54                 { (*this->functor_)(param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
    55             inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
    56                 { (*this->functor_)(param1, param2, param3, param4, this->defaultValue_[4]); }
    57             inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
    58                 { (*this->functor_)(param1, param2, param3, param4, param5); }
    59 
    60             bool parse(const std::string& params, const std::string& delimiter = " ") const;
     47            inline MultiType operator()() const
     48                { return (*this->functor_)(this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
     49            inline MultiType operator()(const MultiType& param1) const
     50                { return (*this->functor_)(param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
     51            inline MultiType operator()(const MultiType& param1, const MultiType& param2) const
     52                { return (*this->functor_)(param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
     53            inline MultiType operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3) const
     54                { return (*this->functor_)(param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
     55            inline MultiType operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
     56                { return (*this->functor_)(param1, param2, param3, param4, this->defaultValue_[4]); }
     57            inline MultiType operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
     58                { return (*this->functor_)(param1, param2, param3, param4, param5); }
     59
     60            MultiType parse(const std::string& params, bool* success = 0, const std::string& delimiter = " ") const;
    6161
    6262            bool evaluate(const std::string& params, MultiType param[5], const std::string& delimiter = " ") const;
     
    7070            inline Functor::Type::Enum getType() const
    7171                { return this->functor_->getType(); }
    72             inline const MultiType& getReturnvalue() const
    73                 { return this->functor_->getReturnvalue(); }
    7472            inline std::string getTypenameParam(unsigned int param) const
    7573                { return this->functor_->getTypenameParam(param); }
     
    128126            using Executor::operator();
    129127
    130             inline void operator()(T* object) const
    131                 { (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    132             inline void operator()(T* object, const MultiType& param1) const
    133                 { (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    134             inline void operator()(T* object, const MultiType& param1, const MultiType& param2) const
    135                 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    136             inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const
    137                 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
    138             inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
    139                 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }
    140             inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
    141                 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); }
    142 
    143 
    144             inline void operator()(const T* object) const
    145                 { (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    146             inline void operator()(const T* object, const MultiType& param1) const
    147                 { (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    148             inline void operator()(const T* object, const MultiType& param1, const MultiType& param2) const
    149                 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
    150             inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const
    151                 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
    152             inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
    153                 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }
    154             inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
    155                 { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); }
     128            inline MultiType operator()(T* object) const
     129                { return (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
     130            inline MultiType operator()(T* object, const MultiType& param1) const
     131                { return (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
     132            inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2) const
     133                { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
     134            inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const
     135                { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
     136            inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
     137                { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }
     138            inline MultiType operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
     139                { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); }
     140
     141
     142            inline MultiType operator()(const T* object) const
     143                { return (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
     144            inline MultiType operator()(const T* object, const MultiType& param1) const
     145                { return (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
     146            inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2) const
     147                { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
     148            inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const
     149                { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
     150            inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
     151                { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }
     152            inline MultiType operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
     153                { return (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); }
    156154
    157155            inline void setObject(T* object) const
     
    162160            using Executor::parse;
    163161
    164             bool parse(T* object, const std::string& params, const std::string& delimiter = " ") const
     162            MultiType parse(T* object, const std::string& params, bool* success = 0, const std::string& delimiter = " ") const
    165163            {
    166164                FunctorMember<T>* functorMember = static_cast<FunctorMember<T>*>(this->functor_);
     
    169167
    170168                functorMember->setObject(object);
    171                 bool result = Executor::parse(params, delimiter);
     169                const MultiType& result = Executor::parse(params, success, delimiter);
    172170                functorMember->setObjects(objects);
    173171
     
    175173            }
    176174
    177             bool parse(const T* object, const std::string& params, const std::string& delimiter = " ") const
     175            MultiType parse(const T* object, const std::string& params, bool* success = 0, const std::string& delimiter = " ") const
    178176            {
    179177                FunctorMember<T>* functorMember = static_cast<FunctorMember<T>*>(this->functor_);
     
    182180
    183181                functorMember->setObject(object);
    184                 bool result = Executor::parse(params, delimiter);
     182                const MultiType& result = Executor::parse(params, success, delimiter);
    185183                functorMember->setObjects(objects);
    186184
Note: See TracChangeset for help on using the changeset viewer.