Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

added debug output to executor

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.