Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7187


Ignore:
Timestamp:
Aug 19, 2010, 2:42:40 AM (14 years ago)
Author:
landauf
Message:

added new function to MultiType to check whether or not it contains a value. using this in executor to improve handling of default values.

Location:
code/branches/consolecommands3/src/libraries
Files:
3 edited

Legend:

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

    r7186 r7187  
    4343        this->functor_ = functor;
    4444        this->name_ = name;
    45 
    46         this->bAddedDefaultValue_[0] = false;
    47         this->bAddedDefaultValue_[1] = false;
    48         this->bAddedDefaultValue_[2] = false;
    49         this->bAddedDefaultValue_[3] = false;
    50         this->bAddedDefaultValue_[4] = false;
    5145    }
    5246
     
    7367                (*this->functor_)(MultiType(params));
    7468            }
    75             else if (this->bAddedDefaultValue_[0])
     69            else if (!this->defaultValue_[0].null())
    7670            {
    7771                COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using default value: " << this->defaultValue_[0] << std::endl;
     
    9084            for (unsigned int i = tokens.size(); i < this->functor_->getParamCount(); i++)
    9185            {
    92                 if (!this->bAddedDefaultValue_[i])
     86                if (this->defaultValue_[i].null())
    9387                {
    9488                    COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input:" << params << ")." << std::endl;
     
    156150                return true;
    157151            }
    158             else if (this->bAddedDefaultValue_[0])
     152            else if (!this->defaultValue_[0].null())
    159153            {
    160154                param[0] = this->defaultValue_[0];
     
    171165            // if there are not enough params given, check if there are default values
    172166            for (unsigned int i = tokens.size(); i < this->functor_->getParamCount(); i++)
    173                 if (!this->bAddedDefaultValue_[i])
     167                if (this->defaultValue_[i].null())
    174168                    return false;
    175169
     
    193187    {
    194188        this->defaultValue_[0] = param1;
    195         this->bAddedDefaultValue_[0] = true;
    196189
    197190        return (*this);
     
    201194    {
    202195        this->defaultValue_[0] = param1;
    203         this->bAddedDefaultValue_[0] = true;
    204         this->defaultValue_[1] = param2;
    205         this->bAddedDefaultValue_[1] = true;
     196        this->defaultValue_[1] = param2;
    206197
    207198        return (*this);
     
    211202    {
    212203        this->defaultValue_[0] = param1;
    213         this->bAddedDefaultValue_[0] = true;
    214         this->defaultValue_[1] = param2;
    215         this->bAddedDefaultValue_[1] = true;
     204        this->defaultValue_[1] = param2;
    216205        this->defaultValue_[2] = param3;
    217         this->bAddedDefaultValue_[2] = true;
    218206
    219207        return (*this);
     
    223211    {
    224212        this->defaultValue_[0] = param1;
    225         this->bAddedDefaultValue_[0] = true;
    226         this->defaultValue_[1] = param2;
    227         this->bAddedDefaultValue_[1] = true;
     213        this->defaultValue_[1] = param2;
    228214        this->defaultValue_[2] = param3;
    229         this->bAddedDefaultValue_[2] = true;
    230215        this->defaultValue_[3] = param4;
    231         this->bAddedDefaultValue_[3] = true;
    232216
    233217        return (*this);
     
    237221    {
    238222        this->defaultValue_[0] = param1;
    239         this->bAddedDefaultValue_[0] = true;
    240         this->defaultValue_[1] = param2;
    241         this->bAddedDefaultValue_[1] = true;
     223        this->defaultValue_[1] = param2;
    242224        this->defaultValue_[2] = param3;
    243         this->bAddedDefaultValue_[2] = true;
    244225        this->defaultValue_[3] = param4;
    245         this->bAddedDefaultValue_[3] = true;
    246226        this->defaultValue_[4] = param5;
    247         this->bAddedDefaultValue_[4] = true;
    248227
    249228        return (*this);
     
    253232    {
    254233        if (index < MAX_FUNCTOR_ARGUMENTS)
    255         {
    256234            this->defaultValue_[index] = param;
    257             this->bAddedDefaultValue_[index] = true;
    258         }
     235
    259236        return (*this);
    260237    }
     
    263240    {
    264241        for (unsigned int i = 0; i < this->functor_->getParamCount(); i++)
    265             if (!this->bAddedDefaultValue_[i])
     242            if (this->defaultValue_[i].null())
    266243                return false;
    267244
  • code/branches/consolecommands3/src/libraries/core/Executor.h

    r7186 r7187  
    101101            {
    102102                if (index < MAX_FUNCTOR_ARGUMENTS)
    103                     return this->bAddedDefaultValue_[index];
     103                    return !this->defaultValue_[index].null();
    104104
    105105                return false;
     
    110110            std::string name_;
    111111            MultiType defaultValue_[MAX_FUNCTOR_ARGUMENTS];
    112             bool bAddedDefaultValue_[MAX_FUNCTOR_ARGUMENTS];
    113112    };
    114113
  • code/branches/consolecommands3/src/libraries/util/MultiType.h

    r7165 r7187  
    351351
    352352            /** @brief Checks whether the value is a default one. */
    353             bool                              hasDefaultValue()         const { return this->value_->hasDefaultValue(); }
     353            bool                              hasDefaultValue() const { return this->value_->hasDefaultValue(); }
     354
     355            /** @brief Checks if the MT contains no value. */
     356            bool                              null() const { return (!this->value_); }
    354357
    355358            operator char()                  const;
Note: See TracChangeset for help on using the changeset viewer.