Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 932


Ignore:
Timestamp:
Mar 27, 2008, 4:42:53 AM (16 years ago)
Author:
landauf
Message:

added debug output to executor

Location:
code/branches/core2/src/orxonox/core
Files:
2 edited

Legend:

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

    r931 r932  
    2929#include "Executor.h"
    3030#include "Language.h"
    31 #include "util/String.h"
    3231
    3332namespace orxonox
     
    6463        if (paramCount == 0)
    6564        {
     65            COUT(5) << "Calling Executor " << this->name_ << " through parser without parameters." << std::endl;
    6666            (*this->functor_)();
    6767        }
    6868        else if (paramCount == 1)
    6969        {
    70             (*this->functor_)(MultiTypeMath(params));
     70            std::string temp = getStripped(params);
     71            if ((temp != "") && (temp.size() != 0))
     72            {
     73                COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using whole string: " << params << std::endl;
     74                (*this->functor_)(MultiTypeMath(params));
     75            }
     76            else if (this->bAddedDefaultValue_[0])
     77            {
     78                COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using default value: " << this->defaultValue_[0] << std::endl;
     79                (*this->functor_)(this->defaultValue_[0]);
     80            }
     81            else
     82            {
     83                COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given." << std::endl;
     84                return false;
     85            }
    7186        }
    7287        else
     
    7590
    7691            for (unsigned int i = tokens.size(); i < this->functor_->getParamCount(); i++)
     92            {
    7793                if (!this->bAddedDefaultValue_[i])
     94                {
     95                    COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given." << std::endl;
    7896                    return false;
     97                }
     98            }
    7999
    80100            MultiTypeMath param[paramCount];
     101            COUT(5) << "Calling Executor " << this->name_ << " through parser with " << paramCount << " parameters, using " << tokens.size() << " tokens (";
    81102            for (unsigned int i = 0; i < tokens.size(); i++)
     103            {
    82104                param[i] = tokens[i];
     105                if (i != 0)
     106                {
     107                    COUT(5) << ", ";
     108                }
     109                COUT(5) << tokens[i];
     110            }
     111            COUT(5) << ") and " << (paramCount - tokens.size()) << " default values (";
    83112            for (unsigned int i = tokens.size(); i < paramCount; i++)
     113            {
    84114                param[i] = this->defaultValue_[i];
     115                if (i != 0)
     116                {
     117                    COUT(5) << ", ";
     118                }
     119                COUT(5) << this->defaultValue_[i];
     120            }
     121            COUT(5) << ")." << std::endl;
    85122
    86123            switch(paramCount)
  • code/branches/core2/src/orxonox/core/Executor.h

    r931 r932  
    3232#include "CorePrereqs.h"
    3333#include "Functor.h"
     34#include "Debug.h"
    3435#include "util/SubString.h"
    35 
     36#include "util/String.h"
    3637
    3738namespace orxonox
     
    160161                if (paramCount == 0)
    161162                {
     163                    COUT(5) << "Calling Executor " << this->name_ << " through parser without parameters." << std::endl;
    162164                    (*((FunctorMember<T>*)this->functor_))(object);
    163165                }
    164166                else if (paramCount == 1)
    165167                {
    166                     (*((FunctorMember<T>*)this->functor_))(object, MultiTypeMath(params));
     168                    std::string temp = getStripped(params);
     169                    if ((temp != "") && (temp.size() != 0))
     170                    {
     171                        COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using whole string: " << params << std::endl;
     172                        (*((FunctorMember<T>*)this->functor_))(object, MultiTypeMath(params));
     173                    }
     174                    else if (this->bAddedDefaultValue_[0])
     175                    {
     176                        COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using default value: " << this->defaultValue_[0] << std::endl;
     177                        (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0]);
     178                    }
     179                    else
     180                    {
     181                        COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given." << std::endl;
     182                        return false;
     183                    }
    167184                }
    168185                else
     
    171188
    172189                    for (unsigned int i = tokens.size(); i < this->functor_->getParamCount(); i++)
     190                    {
    173191                        if (!this->bAddedDefaultValue_[i])
     192                        {
     193                            COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given." << std::endl;
    174194                            return false;
     195                        }
     196                    }
    175197
    176198                    MultiTypeMath param[paramCount];
     199                    COUT(5) << "Calling Executor " << this->name_ << " through parser with " << paramCount << " parameters, using " << tokens.size() << " tokens (";
    177200                    for (unsigned int i = 0; i < tokens.size(); i++)
     201                    {
    178202                        param[i] = tokens[i];
     203                        if (i != 0)
     204                        {
     205                            COUT(5) << ", ";
     206                        }
     207                        COUT(5) << tokens[i];
     208                    }
     209                    COUT(5) << ") and " << (paramCount - tokens.size()) << " default values (";
    179210                    for (unsigned int i = tokens.size(); i < paramCount; i++)
     211                    {
    180212                        param[i] = this->defaultValue_[i];
     213                        if (i != 0)
     214                        {
     215                            COUT(5) << ", ";
     216                        }
     217                        COUT(5) << this->defaultValue_[i];
     218                    }
     219                    COUT(5) << ")." << std::endl;
    181220
    182221                    switch(paramCount)
     
    206245                if (paramCount == 0)
    207246                {
     247                    COUT(5) << "Calling Executor " << this->name_ << " through parser without parameters." << std::endl;
    208248                    (*((FunctorMember<T>*)this->functor_))(object);
    209249                }
    210250                else if (paramCount == 1)
    211251                {
    212                     (*((FunctorMember<T>*)this->functor_))(object, MultiTypeMath(params));
     252                    std::string temp = getStripped(params);
     253                    if ((temp != "") && (temp.size() != 0))
     254                    {
     255                        COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using whole string: " << params << std::endl;
     256                        (*((FunctorMember<T>*)this->functor_))(object, MultiTypeMath(params));
     257                    }
     258                    else if (this->bAddedDefaultValue_[0])
     259                    {
     260                        COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using default value: " << this->defaultValue_[0] << std::endl;
     261                        (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0]);
     262                    }
     263                    else
     264                    {
     265                        COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given." << std::endl;
     266                        return false;
     267                    }
    213268                }
    214269                else
     
    217272
    218273                    for (unsigned int i = tokens.size(); i < this->functor_->getParamCount(); i++)
     274                    {
    219275                        if (!this->bAddedDefaultValue_[i])
     276                        {
     277                            COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given." << std::endl;
    220278                            return false;
     279                        }
     280                    }
    221281
    222282                    MultiTypeMath param[paramCount];
     283                    COUT(5) << "Calling Executor " << this->name_ << " through parser with " << paramCount << " parameters, using " << tokens.size() << " tokens (";
    223284                    for (unsigned int i = 0; i < tokens.size(); i++)
     285                    {
    224286                        param[i] = tokens[i];
     287                        if (i != 0)
     288                        {
     289                            COUT(5) << ", ";
     290                        }
     291                        COUT(5) << tokens[i];
     292                    }
     293                    COUT(5) << ") and " << (paramCount - tokens.size()) << " default values (";
    225294                    for (unsigned int i = tokens.size(); i < paramCount; i++)
     295                    {
    226296                        param[i] = this->defaultValue_[i];
     297                        if (i != 0)
     298                        {
     299                            COUT(5) << ", ";
     300                        }
     301                        COUT(5) << this->defaultValue_[i];
     302                    }
     303                    COUT(5) << ")." << std::endl;
    227304
    228305                    switch(paramCount)
Note: See TracChangeset for help on using the changeset viewer.