Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5643 in orxonox.OLD for trunk


Ignore:
Timestamp:
Nov 19, 2005, 12:35:48 AM (19 years ago)
Author:
bensch
Message:

orxonx/trunk: some minor multi-type-cleanup… new functionality

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

Legend:

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

    r5642 r5643  
    1010
    1111   ### File Specific:
    12    main-programmer: ...
     12   main-programmer: Benjamin Grauer
    1313   co-programmer: ...
    1414*/
     
    119119  this->type = MT_NULL;
    120120  this->storedString = NULL;
    121 }
    122 
    123 
    124 
     121  this->value.Bool = false;
     122}
     123
     124
     125/**
     126 * sets the type of this MultiType and resets to the default value
     127 * @param type the new Type
     128 */
    125129void MultiType::setType(int type)
    126130{
    127   this->type = (MT_Type)type;
    128 
    129131  if (this->type != type)
    130132  {
     133    this->type = (MT_Type)type;
     134
    131135    if (this->type == MT_NULL)
    132       this->setString("");
    133 
    134   }
    135   /// @todo check if this works...
    136 
     136      this->reset();
     137  }
    137138}
    138139
     
    348349
    349350/**
     351 * Resets the MultiType to default values.
     352 */
     353void MultiType::reset()
     354{
     355  switch (this->type)
     356  {
     357    default:
     358      break;
     359    case MT_BOOL:
     360      this->setBool(false);
     361    case MT_INT:
     362      this->setInt(0);
     363      break;
     364    case MT_FLOAT:
     365      this->setFloat(0.0f);
     366      break;
     367    case MT_CHAR:
     368      this->setChar('\0');
     369      break;
     370    case MT_STRING:
     371      this->setString("");
     372      break;
     373  }
     374}
     375
     376/**
    350377 * converts a MT_Type into a String
    351378 * @param type: the MT_Type
  • trunk/src/lib/util/multi_type.h

    r5642 r5643  
    6969    const char* getString();
    7070
     71    void reset();
    7172
    7273    void debug();
Note: See TracChangeset for help on using the changeset viewer.