Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7200 in orxonox.OLD for trunk/src/lib


Ignore:
Timestamp:
Mar 9, 2006, 2:43:47 AM (19 years ago)
Author:
bensch
Message:

orxonox/truink: minor cleanup

Location:
trunk/src/lib/util
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/executor/executor.cc

    r7199 r7200  
    108108  {
    109109    if (*value[i] != MT_NULL)
    110         this->defaultValue[i].setValueOf(*value[i]);
     110    {
     111     // printf("1:::: %s\n", MultiType::MultiTypeToString(this->defaultValue[i].getType()));
     112      //this->defaultValue[i].debug();
     113      this->defaultValue[i].setValueOf(*value[i]);
     114      //printf("2::::%s\n", MultiType::MultiTypeToString(this->defaultValue[i].getType()));
     115      //this->defaultValue[i].debug();
     116    //this->defaultValue[i].setValueOf(*value[i]);
     117    }
    111118  }
    112119  return this;
  • trunk/src/lib/util/executor/executor.h

    r7199 r7200  
    189189//! execute-macro for functions with one parameter
    190190#define ExecutorExecute1(t1) \
    191    else if (this->paramCount == 1 && this->defaultValue[0].getType() == t1##_PARAM) \
     191   else if (this->paramCount == 1 && this->defaultValue[0] == t1##_PARAM) \
    192192    EXECUTOREXECUTER(_1_##t1)(t1##_FUNC((const char*)parameters, t1##_DEFGRAB(0)))
    193193
    194194//! execute-macro for functions with two parameters
    195195#define ExecutorExecute2(t1,t2) \
    196    else if (this->paramCount == 2 && this->defaultValue[0].getType() == t1##_PARAM && this->defaultValue[1].getType() == t2##_PARAM) \
     196   else if (this->paramCount == 2 && this->defaultValue[0] == t1##_PARAM && this->defaultValue[1] == t2##_PARAM) \
    197197    EXECUTOREXECUTER(_2_##t1##_##t2)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)))
    198198
    199199//! execute-macro for functions with three parameters
    200200#define ExecutorExecute3(t1,t2,t3) \
    201    else if (this->paramCount == 3 && this->defaultValue[0].getType() == t1##_PARAM && this->defaultValue[1].getType() == t2##_PARAM && this->defaultValue[2].getType() == t3##_PARAM) \
     201   else if (this->paramCount == 3 && this->defaultValue[0] == t1##_PARAM && this->defaultValue[1] == t2##_PARAM && this->defaultValue[2] == t3##_PARAM) \
    202202    EXECUTOREXECUTER(_3_##t1##_##t2##_##t3)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)), t3##_FUNC(sub.getString(2), t3##_DEFGRAB(2)))
    203203
    204204//! execute-macro for functions with four parameters
    205205#define ExecutorExecute4(t1,t2,t3,t4) \
    206    else if (this->paramCount == 4 && this->defaultValue[0].getType() == t1##_PARAM && this->defaultValue[1].getType() == t2##_PARAM && this->defaultValue[2].getType() == t3##_PARAM && this->defaultValue[3].getType() == t4##_PARAM) \
     206   else if (this->paramCount == 4 && this->defaultValue[0] == t1##_PARAM && this->defaultValue[1] == t2##_PARAM && this->defaultValue[2] == t3##_PARAM && this->defaultValue[3] == t4##_PARAM) \
    207207    EXECUTOREXECUTER(_4_##t1##_##t2##_##t3##_##t4)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)), t3##_FUNC(sub.getString(2), t3##_DEFGRAB(2)), t4##_FUNC(sub.getString(3), t4##_DEFGRAB(3))) \
    208208
     
    210210//! execute-macro for functions with five parameters
    211211#define ExecutorExecute5(t1,t2,t3,t4,t5) \
    212    else if (this->paramCount == 5 && this->defaultValue[0].getType() == t1##_PARAM && this->defaultValue[1].getType() == t2##_PARAM && this->defaultValue[2].getType() == t3##_PARAM && this->defaultValue[3].getType() == t4##_PARAM && this->defaultValue[4].getType() == t5##_PARAM) \
     212   else if (this->paramCount == 5 && this->defaultValue[0] == t1##_PARAM && this->defaultValue[1] == t2##_PARAM && this->defaultValue[2] == t3##_PARAM && this->defaultValue[3] == t4##_PARAM && this->defaultValue[4] == t5##_PARAM) \
    213213    EXECUTOREXECUTER(_5_##t1##_##t2##_##t3##_##t4##_##t5)(t1##_FUNC(sub.getString(0), t1##_DEFGRAB(0)), t2##_FUNC(sub.getString(1), t2##_DEFGRAB(1)), t3##_FUNC(sub.getString(2), t3##_DEFGRAB(2)), t4##_FUNC(sub.getString(3), t4##_DEFGRAB(3)), t5##_FUNC(sub.getString(4), t5##_DEFGRAB(4)))
    214214
     
    269269    {
    270270      SubString sub((const char*) parameters, " \n\t,", '\\');
     271      printf("%s :: %s\n", this->getName(), (const char*) parameters);
    271272//! FUNCTOR_LIST is the List of Executive Functions
    272273#define FUNCTOR_LIST(x) ExecutorExecute ## x
  • trunk/src/lib/util/multi_type.cc

    r7199 r7200  
    3636MultiType::MultiType(MT_Type type)
    3737{
    38   this->init();
    3938  this->type = type;
     39  switch (this->type)
     40  {
     41    case MT_BOOL:
     42      this->value.Bool = false;
     43      break;
     44    case MT_INT:
     45      this->value.Int = 0;
     46      break;
     47    case MT_FLOAT:
     48      this->value.Float = 0.0f;
     49      break;
     50    case MT_CHAR:
     51      this->value.Char = '\0';
     52      break;
     53  }
    4054}
    4155/**
     
    4559MultiType::MultiType(bool value)
    4660{
    47   this->init();
    4861  this->setBool(value);
    4962}
     
    5568MultiType::MultiType(int value)
    5669{
    57   this->init();
    5870  this->setInt(value);
    5971}
     
    6577MultiType::MultiType(double value)
    6678{
    67   this->init();
    6879  this->setFloat(value);
    6980}
     
    7586MultiType::MultiType(char value)
    7687{
    77   this->init();
    7888  this->setChar(value);
    7989}
     
    8595MultiType::MultiType(const char* value)
    8696{
    87   this->init();
    8897  this->setString(value);
    8998}
     
    95104MultiType::MultiType(const std::string& value)
    96105{
    97   this->init();
    98106  this->setString(value);
    99107}
     
    160168
    161169/**
    162  * @brief initializes the MultiType
    163  */
    164 void MultiType::init()
    165 {
    166   this->type = MT_NULL;
    167   this->value.Float = 0.0f;
    168 }
    169 
    170 
    171 /**
    172170 * @brief sets the type of this MultiType and resets to the default value
    173171 * @param type the new Type
     
    365363    if (this->type & MT_BOOL) return (this->value.Bool)? "true" : "false";
    366364
    367     if (this->type & MT_CHAR)
    368     {
    369       char tmpString[2];
    370       tmpString[0] = this->value.Char;
    371       tmpString[1] = '\0';
    372       return tmpString;
    373     }
    374365    else if (this->type & MT_INT)
    375366    {
     
    382373      char tmpString[64];
    383374      sprintf(tmpString, "%f", this->value.Float);
     375      return tmpString;
     376    }
     377    else if (this->type & MT_CHAR)
     378    {
     379      char tmpString[2];
     380      tmpString[0] = this->value.Char;
     381      tmpString[1] = '\0';
    384382      return tmpString;
    385383    }
     
    431429    case MT_BOOL:
    432430      this->setBool(false);
     431      break;
    433432    case MT_INT:
    434433      this->setInt(0);
     
    460459  switch ( type )
    461460  {
    462     default:
    463       return "NONE";
    464461    case MT_BOOL:
    465462      return "bool";
     
    473470      return "string";
    474471  }
     472  return "NONE";
    475473}
    476474
     
    492490  if (!strncmp(type, "string", 6))
    493491    return MT_STRING;
    494 }
     492
     493  return MT_NULL;
     494}
  • trunk/src/lib/util/multi_type.h

    r7199 r7200  
    9898
    9999  private:
    100     void init();
    101 
    102 
    103   private:
    104100    union MultiTypeValue
    105101    {
Note: See TracChangeset for help on using the changeset viewer.