Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 31, 2008, 12:25:09 AM (16 years ago)
Author:
landauf
Message:

hum, i forgot what i was doing there… oh wait, i remember… it had something to do with executor evaluation. strange thing, no wonder my brain has a leak or something… what's that SVN thing all around my cursor? what's a cursor anyway? oh, and what am i doing here? i feel like having breakfast and it's all dark… stupid clock change…

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core2/src/orxonox/core/Executor.cc

    r957 r967  
    2929#include "Executor.h"
    3030#include "Language.h"
     31#include "util/Math.h"
    3132
    3233namespace orxonox
     
    6263    {
    6364        EXECUTOR_PARSE(normal);
     65    }
     66
     67    bool Executor::evaluate(const std::string& params, MultiTypeMath param[5], const std::string& delimiter) const
     68    {
     69        unsigned int paramCount = this->functor_->getParamCount();
     70
     71        if (paramCount == 1)
     72        {
     73            // only one param: check if there are params given, otherwise try to use default values
     74            std::string temp = getStripped(params);
     75            if ((temp != "") && (temp.size() != 0))
     76            {
     77                param[0] = params;
     78                this->functor_->evaluateParam(0, param[0]);
     79                return true;
     80            }
     81            else if (this->bAddedDefaultValue_[0])
     82            {
     83                param[0] = this->defaultValue_[0];
     84                this->functor_->evaluateParam(0, param[0]);
     85                return true;
     86            }
     87            return false;
     88        }
     89        else
     90        {
     91            // more than one param
     92            SubString tokens(params, delimiter, SubString::WhiteSpaces, false, '\\', '"', '(', ')', '\0');
     93
     94            // if there are not enough params given, check if there are default values
     95            for (unsigned int i = tokens.size(); i < this->functor_->getParamCount(); i++)
     96                if (!this->bAddedDefaultValue_[i])
     97                    return false;
     98
     99            // assign all given arguments to the multitypes
     100            for (unsigned int i = 0; i < min(tokens.size(), (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
     101                param[i] = tokens[i];
     102
     103            // fill the remaining multitypes with default values
     104            for (unsigned int i = tokens.size(); i < min(paramCount, (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
     105                param[i] = this->defaultValue_[i];
     106
     107            // evaluate the param types through the functor
     108            for (unsigned int i = 0; i < min(paramCount, (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
     109                this->functor_->evaluateParam(i, param[i]);
     110
     111            return true;
     112        }
    64113    }
    65114
Note: See TracChangeset for help on using the changeset viewer.