Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7189


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.
Location:
code/branches/consolecommands3/src/libraries
Files:
15 edited

Legend:

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

    r6417 r7189  
    7474    bool CommandEvaluation::execute() const
    7575    {
     76        bool success;
     77        this->query(&success);
     78        return success;
     79    }
     80
     81    MultiType CommandEvaluation::query(bool* success) const
     82    {
     83        if (success)
     84            *success = false;
     85
    7686        if (!this->isValid())
    77             return false;
     87            return MT_Type::Null;
    7888
    7989        if (this->bEvaluatedParams_ && this->function_)
    8090        {
     91            if (success)
     92                *success = true;
    8193            COUT(6) << "CE_execute (evaluation): " << this->function_->getName() << ' ' << this->param_[0] << ' ' << this->param_[1] << ' ' << this->param_[2] << ' ' << this->param_[3] << ' ' << this->param_[4] << std::endl;
    82             (*this->function_)(this->param_[0], this->param_[1], this->param_[2], this->param_[3], this->param_[4]);
    83             return true;
     94            return (*this->function_)(this->param_[0], this->param_[1], this->param_[2], this->param_[3], this->param_[4]);
    8495        }
    8596
     
    90101            unsigned int startindex = this->getStartindex();
    91102            if (this->commandTokens_.size() > startindex)
    92                 return this->function_->parse(removeSlashes(this->commandTokens_.subSet(startindex).join() + this->getAdditionalParameter()));
     103                return this->function_->parse(removeSlashes(this->commandTokens_.subSet(startindex).join() + this->getAdditionalParameter()), success);
    93104            else
    94                 return this->function_->parse(removeSlashes(this->additionalParameter_));
    95         }
    96 
    97         return false;
     105                return this->function_->parse(removeSlashes(this->additionalParameter_), success);
     106        }
     107
     108        return MT_Type::Null;
    98109    }
    99110
     
    233244    }
    234245
    235     bool CommandEvaluation::hasReturnvalue() const
    236     {
    237         if (this->function_)
    238             return this->function_->hasReturnvalue();
    239 
    240         return MT_Type::Null;
    241     }
    242 
    243     MultiType CommandEvaluation::getReturnvalue() const
    244     {
    245         if (this->function_)
    246             return this->function_->getReturnvalue();
    247 
    248         return MultiType();
    249     }
    250 
    251 
    252246    unsigned int CommandEvaluation::getStartindex() const
    253247    {
  • code/branches/consolecommands3/src/libraries/core/CommandEvaluation.h

    r6417 r7189  
    6666
    6767            bool execute() const;
     68            MultiType query(bool* success = 0) const;
     69
    6870            const std::string& complete();
    6971            std::string hint() const;
     
    8688            void setEvaluatedParameter(unsigned int index, MultiType param);
    8789            MultiType getEvaluatedParameter(unsigned int index) const;
    88 
    89             bool hasReturnvalue() const;
    90             MultiType getReturnvalue() const;
    9190
    9291        private:
  • code/branches/consolecommands3/src/libraries/core/CommandExecutor.cc

    r6417 r7189  
    104104    {
    105105        if (useTcl)
    106             return TclBind::eval(command);
    107 
    108         CommandExecutor::parseIfNeeded(command);
    109         return CommandExecutor::getEvaluation().execute();
    110     }
    111 
    112     MultiType CommandExecutor::getReturnValue()
    113     {
    114         return CommandExecutor::getEvaluation().getReturnvalue();
    115     }
    116 
    117     std::string CommandExecutor::getReturnValueString()
    118     {
    119         return CommandExecutor::getEvaluation().getReturnvalue().getString();
     106        {
     107            bool success;
     108            TclBind::eval(command, &success);
     109            return success;
     110        }
     111        else
     112        {
     113            CommandExecutor::parseIfNeeded(command);
     114            return CommandExecutor::getEvaluation().execute();
     115        }
     116    }
     117
     118    MultiType CommandExecutor::queryMT(const std::string& command, bool* success, bool useTcl)
     119    {
     120        if (useTcl)
     121        {
     122            return TclBind::eval(command, success);
     123        }
     124        else
     125        {
     126            CommandExecutor::parseIfNeeded(command);
     127            return CommandExecutor::getEvaluation().query(success);
     128        }
     129    }
     130
     131    std::string CommandExecutor::query(const std::string& command, bool* success, bool useTcl)
     132    {
     133        if (useTcl)
     134        {
     135            return TclBind::eval(command, success);
     136        }
     137        else
     138        {
     139            CommandExecutor::parseIfNeeded(command);
     140            return CommandExecutor::getEvaluation().query(success).getString();
     141        }
    120142    }
    121143
  • code/branches/consolecommands3/src/libraries/core/CommandExecutor.h

    r6417 r7189  
    4747        public:
    4848            static bool execute(const std::string& command, bool useTcl = true); // tolua_export
    49             static MultiType getReturnValue();
    50             static std::string getReturnValueString(); // tolua_export
     49
     50            static MultiType queryMT(const std::string& command, bool* success = 0, bool useTcl = true);
     51            static std::string query(const std::string& command, bool* success = 0, bool useTcl = true); // tolua_export
    5152
    5253            static std::string complete(const std::string& command);
  • 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
  • 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
  • code/branches/consolecommands3/src/libraries/core/Functor.h

    r7188 r7189  
    104104            virtual ~Functor() {}
    105105
    106             virtual void operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
    107 
    108             inline const MultiType& getReturnvalue() const { return this->returnedValue_; }
     106            virtual MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
    109107
    110108            virtual Type::Enum getType() const = 0;
     
    121119
    122120            virtual const std::type_info& getHeaderIdentifier() const = 0;
    123 
    124         protected:
    125             MultiType returnedValue_;
    126121    };
    127122
     
    130125        public:
    131126            virtual ~FunctorStatic() {}
    132             virtual void operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
     127            virtual MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
    133128    };
    134129
     
    144139            virtual ~FunctorMember() {}
    145140
    146             virtual void operator()(T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
    147             virtual void operator()(const T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
    148 
    149             virtual void operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null)
     141            virtual MultiType operator()(T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
     142            virtual MultiType operator()(const T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) = 0;
     143
     144            virtual MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null)
    150145            {
    151146                if (this->object_)
    152                     (*this)(this->object_, param1, param2, param3, param4, param5);
     147                    return (*this)(this->object_, param1, param2, param3, param4, param5);
    153148                else if (this->constObject_)
    154                     (*this)(this->constObject_, param1, param2, param3, param4, param5);
     149                    return (*this)(this->constObject_, param1, param2, param3, param4, param5);
    155150                else
    156151                {
    157152                    COUT(1) << "An error occurred in Functor.h:" << std::endl;
    158153                    COUT(1) << "Error: No object set." << std::endl;
     154                    return MT_Type::Null;
    159155                }
    160156            }
     
    340336
    341337#define FUNCTOR_STORE_RETURNVALUE(returnvalue, functioncall) FUNCTOR_STORE_RETURNVALUE##returnvalue(functioncall)
    342 #define FUNCTOR_STORE_RETURNVALUE0(functioncall) functioncall
    343 #define FUNCTOR_STORE_RETURNVALUE1(functioncall) this->returnedValue_ = functioncall
     338#define FUNCTOR_STORE_RETURNVALUE0(functioncall) functioncall; return MT_Type::Null
     339#define FUNCTOR_STORE_RETURNVALUE1(functioncall) return functioncall
    344340
    345341
     
    395391            } \
    396392    \
    397             void operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \
     393            MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \
    398394            { \
    399395                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
     
    441437            } \
    442438    \
    443             void operator()(T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \
     439            MultiType operator()(T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \
    444440            { \
    445441                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
    446442            } \
    447443    \
    448             void operator()(const T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \
     444            MultiType operator()(const T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \
    449445            { \
    450446                COUT(1) << "An error occurred in Functor.h:" << std::endl; \
    451447                COUT(1) << "Error: Function is not const." << std::endl; \
     448                return MT_Type::Null; \
    452449            } \
    453450    \
     
    482479            } \
    483480    \
    484             void operator()(T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \
     481            MultiType operator()(T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \
    485482            { \
    486483                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
    487484            } \
    488485    \
    489             void operator()(const T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \
     486            MultiType operator()(const T* object, const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null) \
    490487            { \
    491488                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
  • code/branches/consolecommands3/src/libraries/core/LuaState.cc

    r6763 r7189  
    370370    }
    371371
    372     void LuaFunctor::operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
     372    MultiType LuaFunctor::operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
    373373    {
    374374        lua_->doString(this->code_);
     375        return MT_Type::Null;
    375376    }
    376377}
  • code/branches/consolecommands3/src/libraries/core/LuaState.h

    r7188 r7189  
    5252        public:
    5353            LuaFunctor(const std::string& code, LuaState* luaState);
    54             void operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null);
     54            MultiType operator()(const MultiType& param1 = MT_Type::Null, const MultiType& param2 = MT_Type::Null, const MultiType& param3 = MT_Type::Null, const MultiType& param4 = MT_Type::Null, const MultiType& param5 = MT_Type::Null);
    5555            void evaluateParam(unsigned int index, MultiType& param) const {}
    5656
  • code/branches/consolecommands3/src/libraries/core/Shell.cc

    r7167 r7189  
    308308        this->updateListeners<&ShellListener::executed>();
    309309
    310         if (!CommandExecutor::execute(this->inputBuffer_->get()))
     310        bool success;
     311        const std::string& result = CommandExecutor::query(this->inputBuffer_->get(), &success);
     312        if (!success)
    311313        {
    312314            this->outputBuffer_ << "Error: Can't execute \"" << this->inputBuffer_->get() << "\"." << std::endl;
    313315            this->outputChanged(Error);
     316        }
     317        else if (result != "")
     318        {
     319            this->outputBuffer_ << result << std::endl;
     320            this->outputChanged(Command);
    314321        }
    315322
  • code/branches/consolecommands3/src/libraries/core/TclBind.cc

    r7174 r7189  
    134134        const std::string& command = stripEnclosingBraces(args.get());
    135135
    136         if (!CommandExecutor::execute(command, false))
     136        bool success;
     137        const std::string& result = CommandExecutor::query(command, &success, false);
     138        if (!success)
    137139        {
    138140            COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl;
    139141        }
    140142
    141         if (CommandExecutor::getLastEvaluation().hasReturnvalue())
    142             return CommandExecutor::getLastEvaluation().getReturnvalue().getString();
    143 
    144         return "";
     143        return result;
    145144    }
    146145
     
    181180    }
    182181
    183     bool TclBind::eval(const std::string& tclcode)
     182    std::string TclBind::eval(const std::string& tclcode, bool* success)
    184183    {
     184        if (success)
     185            *success = true;
     186
    185187        try
    186188        {
    187             TclBind::getInstance().interpreter_->eval(tclcode);
    188             return true;
     189            return TclBind::getInstance().interpreter_->eval(tclcode);
    189190        }
    190191        catch (Tcl::tcl_error const &e)
    191192        {   COUT(1) << "Tcl error: " << e.what() << std::endl;   }
    192193
    193         return false;
     194        if (success)
     195            *success = false;
     196        return "";
    194197    }
    195198}
  • code/branches/consolecommands3/src/libraries/core/TclBind.h

    r6417 r7189  
    5959            static void tcl_execute(Tcl::object const &args);
    6060
    61             static bool eval(const std::string& tclcode);
     61            static std::string eval(const std::string& tclcode, bool* success = 0);
    6262
    6363        private:
  • code/branches/consolecommands3/src/libraries/core/TclThreadManager.cc

    r7174 r7189  
    439439                        // It's a query to the CommandExecutor
    440440                        TclThreadManager::debug("TclThread_query -> CE: " + command);
    441                         if (!CommandExecutor::execute(command, false))
     441                        bool success;
     442                        output = CommandExecutor::query(command, &success, false);
     443                        if (!success)
    442444                            TclThreadManager::error("Error: Can't execute command \"" + command + "\"!");
    443 
    444                         if (CommandExecutor::getLastEvaluation().hasReturnvalue())
    445                             output = CommandExecutor::getLastEvaluation().getReturnvalue().getString();
    446445                    }
    447446                    else
  • code/branches/consolecommands3/src/libraries/core/XMLPort.h

    r7186 r7189  
    398398                        {
    399399                            COUT(5) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << std::endl << this->owner_->getLoaderIndentation();
    400                             if (this->loadexecutor_->parse(object, attributeValue, ",") || (mode  == XMLPort::ExpandObject))
     400                            bool success;
     401                            this->loadexecutor_->parse(object, attributeValue, &success, ",");
     402                            if (success || (mode  == XMLPort::ExpandObject))
    401403                                this->parseResult_ = PR_finished;
    402404                            else
  • code/branches/consolecommands3/src/libraries/util/MultiType.h

    r7187 r7189  
    7878
    7979#include "TypeTraits.h"
     80#include "mbool.h"
    8081
    8182namespace orxonox
     
    266267            inline MultiType(const orxonox::Radian& value)      : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
    267268            inline MultiType(const orxonox::Degree& value)      : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
     269            inline MultiType(const orxonox::mbool& value)       : value_(0) { this->assignValue((bool)value); }     /** @brief Constructor: Assigns the given mbool and converts it to bool. */
    268270            inline MultiType(const char* value)                 : value_(0) { this->setValue(std::string(value)); } /** @brief Constructor: Converts the char array to a std::string, assigns the value and sets the type. */
    269271            inline MultiType(const MultiType& other)            : value_(0) { this->setValue(other); }              /** @brief Copyconstructor: Assigns value and type of the other MultiType. */
Note: See TracChangeset for help on using the changeset viewer.