Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 30, 2010, 6:27:59 PM (14 years ago)
Author:
landauf
Message:

use a base-functor instead of a base-executor in ConsoleCommand because the functor of a static executor changes if new functions are assigned to the command.

Location:
code/branches/consolecommands3/src/libraries/core/command
Files:
2 edited

Legend:

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

    r7236 r7267  
    4343
    4444        this->baseName_ = name;
    45         this->baseExecutor_ = executor;
     45        this->baseFunctor_ = executor->getFunctor();
    4646
    4747        this->argumentCompleter_[0] = 0;
     
    112112    bool ConsoleCommand::headersMatch(const FunctorPtr& functor)
    113113    {
    114         unsigned int minparams = std::min(this->baseExecutor_->getParamCount(), functor->getParamCount());
    115 
    116         if (this->baseExecutor_->getFunctor()->getHeaderIdentifier(minparams) != functor->getHeaderIdentifier(minparams))
     114        unsigned int minparams = std::min(this->baseFunctor_->getParamCount(), functor->getParamCount());
     115
     116        if (this->baseFunctor_->getHeaderIdentifier(minparams) != functor->getHeaderIdentifier(minparams))
    117117            return false;
    118         else if (functor->getParamCount() <= this->baseExecutor_->getParamCount())
     118        else if (functor->getParamCount() <= this->baseFunctor_->getParamCount())
    119119            return true;
    120120        else if (!this->executor_)
     
    122122        else
    123123        {
    124             for (unsigned int i = this->baseExecutor_->getParamCount(); i < functor->getParamCount(); ++i)
     124            for (unsigned int i = this->baseFunctor_->getParamCount(); i < functor->getParamCount(); ++i)
     125            {
    125126                if (!this->executor_->defaultValueSet(i))
     127                {
     128                    COUT(2) << "Default value " << i << " is missing" << std::endl;
    126129                    return false;
     130                }
     131            }
    127132
    128133            return true;
     
    132137    bool ConsoleCommand::headersMatch(const ExecutorPtr& executor)
    133138    {
    134         unsigned int minparams = std::min(this->baseExecutor_->getParamCount(), executor->getParamCount());
    135 
    136         if (this->baseExecutor_->getFunctor()->getHeaderIdentifier(minparams) != executor->getFunctor()->getHeaderIdentifier(minparams))
     139        unsigned int minparams = std::min(this->baseFunctor_->getParamCount(), executor->getParamCount());
     140
     141        if (this->baseFunctor_->getHeaderIdentifier(minparams) != executor->getFunctor()->getHeaderIdentifier(minparams))
    137142            return false;
    138         else if (executor->getParamCount() <= this->baseExecutor_->getParamCount())
     143        else if (executor->getParamCount() <= this->baseFunctor_->getParamCount())
    139144            return true;
    140145        else
    141146        {
    142             for (unsigned int i = this->baseExecutor_->getParamCount(); i < executor->getParamCount(); ++i)
     147            for (unsigned int i = this->baseFunctor_->getParamCount(); i < executor->getParamCount(); ++i)
     148            {
    143149                if (!executor->defaultValueSet(i))
     150                {
     151                    COUT(2) << "Default value " << i << " is missing" << std::endl;
    144152                    return false;
     153                }
     154            }
    145155
    146156            return true;
  • code/branches/consolecommands3/src/libraries/core/command/ConsoleCommand.h

    r7239 r7267  
    223223
    224224            const ExecutorPtr& getExecutor() const;
    225             inline const ExecutorPtr& getBaseExecutor() const
    226                 { return this->baseExecutor_; }
     225            inline const FunctorPtr& getBaseFunctor() const
     226                { return this->baseFunctor_; }
    227227
    228228            inline ConsoleCommand& setActive(bool bActive)
     
    311311            AccessLevel::Enum accessLevel_;
    312312            std::string baseName_;
    313             ExecutorPtr baseExecutor_;
     313            FunctorPtr baseFunctor_;
    314314
    315315            ExecutorPtr executor_;
Note: See TracChangeset for help on using the changeset viewer.