Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8035 in orxonox.OLD for trunk/src/lib/util


Ignore:
Timestamp:
May 31, 2006, 4:20:51 PM (18 years ago)
Author:
bensch
Message:

gui: merged the gui back to the trunk

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

Legend:

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

    r7725 r8035  
    3838class Executor : public BaseObject
    3939{
    40 public:
    41   virtual ~Executor();
     40  public:
     41    virtual ~Executor();
    4242
    43   virtual Executor* clone () const = 0;
     43    virtual Executor* clone () const = 0;
     44//    virtual bool operator==(const Executor* executor) const = 0;
    4445
    45   // SETTING up the EXECUTOR
    46   Executor* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
    47                           const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
    48                           const MultiType& value4 = MT_NULL);
    49   /** @param i the i'th defaultValue, @returns reference to the MultiType */
    50   inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; };
     46    // SETTING up the EXECUTOR
     47    Executor* defaultValues(const MultiType& value0 = MT_NULL, const MultiType& value1 = MT_NULL,
     48                            const MultiType& value2 = MT_NULL, const MultiType& value3 = MT_NULL,
     49                            const MultiType& value4 = MT_NULL);
     50    /** @param i the i'th defaultValue, @returns reference to the MultiType */
     51    inline MultiType& getDefaultValue(unsigned int i) { return defaultValue[i]; };
    5152
    52   // EXECUTE
    53   /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */
    54   virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0;
    55   /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes @brief here for your convenience*/
    56   void execute (BaseObject* object, const std::string& parameters = "") const { (*this)(object, parameters); };
     53    // EXECUTE
     54    /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     55    virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const = 0;
     56    /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes */
     57    virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const = 0;
     58    /** executes a Command @param object the object to apply this to @param parameters the parameters the command takes @brief here for your convenience*/
     59    void execute (BaseObject* object, const std::string& parameters = "") const { (*this)(object, parameters); };
    5760
    58   // RETRIEVE INFORMATION
    59   /** @returns the Type of this Function (either static or objective) */
    60   inline long getType() const { return this->functorType; };
    61   /** @returns the Count of Parameters this Executor takes */
    62   inline unsigned int getParamCount() const { return this->paramCount; };
    6361
    64   static void debug();
     62    // RETRIEVE INFORMATION
     63    /** @returns the Type of this Function (either static or objective) */
     64    inline long getType() const { return this->functorType; };
     65    /** @returns the Count of Parameters this Executor takes */
     66    inline unsigned int getParamCount() const { return this->paramCount; };
    6567
    66 protected:
    67   Executor(const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL,
    68            const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL,
    69            const MultiType& param4 = MT_NULL);
     68    static void debug();
    7069
    71   void cloning(Executor* executor) const;
     70  protected:
     71    Executor(const MultiType& param0 = MT_NULL, const MultiType& param1 = MT_NULL,
     72             const MultiType& param2 = MT_NULL, const MultiType& param3 = MT_NULL,
     73             const MultiType& param4 = MT_NULL);
    7274
    73 protected:
    74   short                       functorType;      //!< The type of Function we've got (either static or objective).
    75   unsigned int                paramCount;       //!< the count of parameters.
    76   MultiType                   defaultValue[5];  //!< Default Values.
     75    void cloning(Executor* executor) const;
     76
     77  protected:
     78    short                       functorType;      //!< The type of Function we've got (either static or objective).
     79    unsigned int                paramCount;       //!< the count of parameters.
     80    MultiType                   defaultValue[5];  //!< Default Values.
    7781};
    7882
  • trunk/src/lib/util/executor/executor_functional.cc

    r7728 r8035  
    3434template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue) { return ExecutorFunctional_returningString_from = isString(input, defaultValue); };
    3535
     36
     37template<> bool fromMulti<bool>(const MultiType& multi) { return multi.getBool(); };
     38template<> int fromMulti<int>(const MultiType& multi) { return multi.getInt(); }
     39template<> unsigned int fromMulti<unsigned int>(const MultiType& multi) { return multi.getInt(); };
     40template<> float fromMulti<float>(const MultiType& multi) { return multi.getFloat(); };
     41template<> char fromMulti<char>(const MultiType& multi) { return multi.getChar(); };
     42template<> const std::string& fromMulti<const std::string&>(const MultiType& multi) { return multi.getConstString(); };
     43
     44
    3645template<> bool getDefault<bool>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getBool(); };
    3746template<> int getDefault<int>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getInt(); };
     
    4049template<> char getDefault<char>(const MultiType* const defaultValues, unsigned int i) { return defaultValues[i].getChar(); };
    4150template<> const std::string& getDefault<const std::string&>(const MultiType* const defaultValues, unsigned int i) { return ExecutorFunctional_returningString_default = defaultValues[i].getString(); };
     51
     52
    4253
    4354
  • trunk/src/lib/util/executor/executor_functional.h

    r7725 r8035  
    3333template<> MT_Type ExecutorParamType<const std::string&>();
    3434
    35 template<typename type> type fromString(const std::string& input, type defaultValue) {return defaultValue; };
     35template<typename type> type fromString(const std::string& input, type defaultValue) { return defaultValue; };
    3636template<> bool fromString<bool>(const std::string& input, bool defaultValue);
    3737template<> int fromString<int>(const std::string& input, int defaultValue);
     
    4040template<> char fromString<char>(const std::string& input, char defaultValue);
    4141template<> const std::string& fromString<const std::string&>(const std::string& input, const std::string& defaultValue);
     42
     43template<typename type> type fromMulti(const MultiType& multi) { /* return defaultValue; */ };
     44template<> bool fromMulti<bool>(const MultiType& multi);
     45template<> int fromMulti<int>(const MultiType& multi);
     46template<> unsigned int fromMulti<unsigned int>(const MultiType& multi);
     47template<> float fromMulti<float>(const MultiType& multi);
     48template<> char fromMulti<char>(const MultiType& multi);
     49template<> const std::string& fromMulti<const std::string&>(const MultiType& multi);
     50
    4251
    4352template<typename type> type getDefault(const MultiType* const defaultValues, unsigned int i) { return (type)0; };
     
    8190#endif /* EXECUTOR_FUNCTIONAL_USE_STATIC */
    8291
     92///////////
     93//// 0 ////
     94///////////
    8395//! @brief ExecutorClass, that can execute Functions without any parameters.
    8496template<class T> class __EXECUTOR_FUNCTIONAL_NAME(0) : public Executor
     
    110122  };
    111123
     124  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     125  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     126  {
     127    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)();
     128  }
     129
    112130  /**
    113131   * @brief copies the Executor
     
    120138};
    121139
     140
     141
     142///////////
     143//// 1 ////
     144///////////
    122145//! @brief ExecutorClass, that can execute Functions with one parameter.
    123146template<class T, typename type0> class __EXECUTOR_FUNCTIONAL_NAME(1) : public Executor
     
    139162  };
    140163
     164  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     165  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     166  {
     167    return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     168             fromMulti<type0>((count > 0)? values[0] : this->defaultValue[0]) );
     169  }
     170
     171
    141172  /**
    142173   * @brief executes the Functional
     
    146177  virtual void operator()(BaseObject* object, const SubString& sub = SubString()) const
    147178  {
    148 
    149     /* // THE VERY COOL DEBUG
    150       printf("SUB[0] : %s\n", sub[0].c_str());
    151       printf("getDefault<type0>(this->defaultValue, 0):::: %d\n", getDefault<type0>(this->defaultValue, 0));
    152       printf("VALUE: %d\n", fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)));
    153     */
    154179    (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
    155180      fromString<type0>(sub[0], getDefault<type0>(this->defaultValue, 0)) );
     
    166191};
    167192
     193///////////
     194//// 2 ////
     195///////////
    168196//! @brief ExecutorClass, that can execute Functions with two parameters.
    169197template<class T, typename type0, typename type1> class __EXECUTOR_FUNCTIONAL_NAME(2) : public Executor
     
    197225  };
    198226
     227  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     228  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     229  {
     230    return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     231             fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]),
     232             fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]) );
     233  }
     234
    199235  /**
    200236   * @brief copies the Executor
     
    208244
    209245
     246///////////
     247//// 3 ////
     248///////////
    210249//! @brief ExecutorClass, that can execute Functions with three parameters.
    211250template<class T, typename type0, typename type1, typename type2> class __EXECUTOR_FUNCTIONAL_NAME(3) : public Executor
     
    240279  };
    241280
     281  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     282  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     283  {
     284    return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     285             fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]),
     286             fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]),
     287             fromMulti<type2>((count > 2) ? values[2] : this->defaultValue[2]) );
     288  }
     289
    242290  /**
    243291   * @brief copies the Executor
     
    252300
    253301
     302///////////
     303//// 4 ////
     304///////////
    254305//! @brief ExecutorClass, that can execute Functions with four parameters.
    255306template<class T, typename type0, typename type1, typename type2, typename type3> class __EXECUTOR_FUNCTIONAL_NAME(4) : public Executor
     
    285336  };
    286337
     338  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     339  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     340  {
     341    return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     342             fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]),
     343             fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]),
     344             fromMulti<type2>((count > 2) ? values[2] : this->defaultValue[2]),
     345             fromMulti<type3>((count > 3) ? values[3] : this->defaultValue[3]) );
     346  }
     347
    287348  /**
    288349   * @brief copies the Executor
     
    295356};
    296357
     358
     359
     360///////////
     361//// 5 ////
     362///////////
    297363//! @brief ExecutorClass, that can execute Functions with five parameters.
    298364template<class T, typename type0, typename type1, typename type2, typename type3, typename type4> class __EXECUTOR_FUNCTIONAL_NAME(5) : public Executor
     
    329395  };
    330396
     397  /** executes a Command. @param objec the Object, @param count how many values, @param values the Values */
     398  virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     399  {
     400    return (__EXECUTOR_FUNCTIONAL_FUNCTION_EXEC)(
     401             fromMulti<type0>((count > 0) ? values[0] : this->defaultValue[0]),
     402             fromMulti<type1>((count > 1) ? values[1] : this->defaultValue[1]),
     403             fromMulti<type2>((count > 2) ? values[2] : this->defaultValue[2]),
     404             fromMulti<type3>((count > 3) ? values[3] : this->defaultValue[3]),
     405             fromMulti<type4>((count > 4) ? values[4] : this->defaultValue[4]) );
     406  }
     407
    331408  /**
    332409   * @brief copies the Executor
     
    344421 * @brief enables us to easily retrieve an Executor of Class T with modular Argument-count, (without thinking about args at all)
    345422 */
    346 #define EXECUTOR_FUNCTIONAL_CREATOR0() \
    347 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \
     423#define EXECUTOR_FUNCTIONAL_CREATOR0(ret) \
     424template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)() __EXECUTOR_FUNCTIONAL_CONST) \
    348425{ \
    349426  return new __EXECUTOR_FUNCTIONAL_NAME(0)<T>(functionPointer); \
     
    354431 * @param type0 for internal usage: the first Argument
    355432 */
    356 #define EXECUTOR_FUNCTIONAL_CREATOR1(type0) \
    357 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     433#define EXECUTOR_FUNCTIONAL_CREATOR1(ret, type0) \
     434template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
    358435{ \
    359436  return new __EXECUTOR_FUNCTIONAL_NAME(1)<T, type0##_TYPE>(functionPointer); \
     
    365442 * @param type1 for internal usage: the second Argument
    366443 */
    367 #define EXECUTOR_FUNCTIONAL_CREATOR2(type0, type1) \
    368 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     444#define EXECUTOR_FUNCTIONAL_CREATOR2(ret, type0, type1) \
     445template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
    369446{ \
    370447  return new __EXECUTOR_FUNCTIONAL_NAME(2)<T, type0##_TYPE, type1##_TYPE>(functionPointer); \
     
    377454 * @param type2 for internal usage: the third Argument
    378455 */
    379 #define EXECUTOR_FUNCTIONAL_CREATOR3(type0, type1, type2) \
    380 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     456#define EXECUTOR_FUNCTIONAL_CREATOR3(ret, type0, type1, type2) \
     457template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
    381458{ \
    382459  return new __EXECUTOR_FUNCTIONAL_NAME(3)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE>(functionPointer); \
     
    390467 * @param type3 for internal usage: the fourth Argument
    391468 */
    392 #define EXECUTOR_FUNCTIONAL_CREATOR4(type0, type1, type2, type3) \
    393 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     469#define EXECUTOR_FUNCTIONAL_CREATOR4(ret, type0, type1, type2, type3) \
     470template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
    394471{ \
    395472  return new __EXECUTOR_FUNCTIONAL_NAME(4)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE>(functionPointer); \
     
    404481 * @param type4 for internal usage: the fifth Argument
    405482 */
    406 #define EXECUTOR_FUNCTIONAL_CREATOR5(type0, type1, type2, type3, type4) \
    407 template<class T> Executor* createExecutor(void (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
     483#define EXECUTOR_FUNCTIONAL_CREATOR5(ret, type0, type1, type2, type3, type4) \
     484template<class T> Executor* createExecutor(ret (__EXECUTOR_FUNCTIONAL_FUNCTION_POINTER)(type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE) __EXECUTOR_FUNCTIONAL_CONST) \
    408485{ \
    409486    return new __EXECUTOR_FUNCTIONAL_NAME(5)<T, type0##_TYPE, type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE>(functionPointer); \
  • trunk/src/lib/util/executor/executor_specials.h

    r7711 r8035  
    6767    }
    6868
     69    virtual void operator()(BaseObject* object, unsigned int count, const MultiType* values) const
     70    {
     71
     72    }
     73
    6974  private:
    7075    /**
  • trunk/src/lib/util/executor/functor_list.h

    r7785 r8035  
    9090#ifdef FUNCTOR_LIST
    9191
    92   FUNCTOR_LIST(0)();
     92  FUNCTOR_LIST(0)(void);
    9393  //! makes functions with one string
    94   FUNCTOR_LIST(1)(l_STRING);
     94  FUNCTOR_LIST(1)(void, l_STRING);
    9595  //! makes functions with two strings
    96   FUNCTOR_LIST(2)(l_STRING, l_STRING);
     96  FUNCTOR_LIST(2)(void, l_STRING, l_STRING);
    9797  //! makes functions with three strings
    98   FUNCTOR_LIST(3)(l_STRING, l_STRING, l_STRING);
     98  FUNCTOR_LIST(3)(void, l_STRING, l_STRING, l_STRING);
    9999  //! makes functions with four strings
    100   FUNCTOR_LIST(4)(l_STRING, l_STRING, l_STRING, l_STRING);
     100  FUNCTOR_LIST(4)(void, l_STRING, l_STRING, l_STRING, l_STRING);
    101101
    102102
    103103  //! makes functions with one bool
    104   FUNCTOR_LIST(1)(l_BOOL);
     104  FUNCTOR_LIST(1)(void, l_BOOL);
    105105
    106106  //! makes functions with one int
    107   FUNCTOR_LIST(1)(l_INT);
     107  FUNCTOR_LIST(1)(void, l_INT);
    108108  //! makes functions with two ints
    109   FUNCTOR_LIST(2)(l_INT, l_INT);
     109  FUNCTOR_LIST(2)(void, l_INT, l_INT);
    110110  //! makes functions with three ints
    111   FUNCTOR_LIST(3)(l_INT, l_INT, l_INT);
     111  FUNCTOR_LIST(3)(void, l_INT, l_INT, l_INT);
    112112  //! makes functions with four ints
    113   FUNCTOR_LIST(4)(l_INT, l_INT, l_INT, l_INT);
     113  FUNCTOR_LIST(4)(void, l_INT, l_INT, l_INT, l_INT);
    114114
    115115
    116116  //! makes functions with one unsigned int
    117   FUNCTOR_LIST(1)(l_UINT);
     117  FUNCTOR_LIST(1)(void, l_UINT);
    118118  //! makes functions with two unsigned ints
    119   FUNCTOR_LIST(2)(l_UINT, l_UINT);
     119  FUNCTOR_LIST(2)(void, l_UINT, l_UINT);
    120120  //! makes functions with three unsigned ints
    121   FUNCTOR_LIST(3)(l_UINT, l_UINT, l_UINT);
     121  FUNCTOR_LIST(3)(void, l_UINT, l_UINT, l_UINT);
    122122  //! makes functions with four unsigned ints
    123   FUNCTOR_LIST(4)(l_UINT, l_UINT, l_UINT, l_UINT);
     123  FUNCTOR_LIST(4)(void, l_UINT, l_UINT, l_UINT, l_UINT);
    124124
    125125  //! makes functions with one float
    126   FUNCTOR_LIST(1)(l_FLOAT);
     126  FUNCTOR_LIST(1)(void, l_FLOAT);
    127127  //! makes functions with two floats
    128   FUNCTOR_LIST(2)(l_FLOAT, l_FLOAT);
     128  FUNCTOR_LIST(2)(void, l_FLOAT, l_FLOAT);
    129129  //! makes functions with three floats
    130   FUNCTOR_LIST(3)(l_FLOAT, l_FLOAT, l_FLOAT);
     130  FUNCTOR_LIST(3)(void, l_FLOAT, l_FLOAT, l_FLOAT);
    131131  //! makes functions with four floats
    132   FUNCTOR_LIST(4)(l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT);
     132  FUNCTOR_LIST(4)(void, l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT);
    133133  //! makes functions with four floats
    134   FUNCTOR_LIST(5)(l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT);
     134  FUNCTOR_LIST(5)(void, l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT);
    135135
    136136  //! mixed values:
    137   FUNCTOR_LIST(2)(l_STRING, l_FLOAT);
    138   FUNCTOR_LIST(2)(l_UINT, l_LONG);
    139   FUNCTOR_LIST(2)(l_STRING, l_UINT);
     137  FUNCTOR_LIST(2)(void, l_STRING, l_FLOAT);
     138  FUNCTOR_LIST(2)(void, l_UINT, l_LONG);
     139  FUNCTOR_LIST(2)(void, l_STRING, l_UINT);
    140140
    141   FUNCTOR_LIST(3)(l_STRING, l_FLOAT, l_UINT);
    142   FUNCTOR_LIST(4)(l_STRING, l_FLOAT, l_UINT, l_UINT);
    143   FUNCTOR_LIST(3)(l_STRING, l_INT, l_UINT);
    144   FUNCTOR_LIST(3)(l_STRING, l_UINT, l_UINT);
     141  FUNCTOR_LIST(3)(void, l_STRING, l_FLOAT, l_UINT);
     142  FUNCTOR_LIST(4)(void, l_STRING, l_FLOAT, l_UINT, l_UINT);
     143  FUNCTOR_LIST(3)(void, l_STRING, l_INT, l_UINT);
     144  FUNCTOR_LIST(3)(void, l_STRING, l_UINT, l_UINT);
    145145
    146146#endif /* FUNCTOR_LIST */
  • trunk/src/lib/util/multi_type.cc

    r7401 r8035  
    3939  switch (this->type)
    4040  {
    41       default:
     41    default:
    4242      this->value.Float = 0.0f;
    4343      break;
    44       case MT_BOOL:
     44    case MT_BOOL:
    4545      this->value.Bool = false;
    4646      break;
    47       case MT_INT:
     47    case MT_INT:
    4848      this->value.Int = 0;
    4949      break;
    50       case MT_FLOAT:
     50    case MT_FLOAT:
    5151      this->value.Float = 0.0f;
    5252      break;
    53       case MT_CHAR:
     53    case MT_CHAR:
    5454      this->value.Char = '\0';
    5555      break;
    56       case MT_STRING:
     56    case MT_STRING:
    5757      this->storedString = "";
    5858      break;
     
    148148  switch (this->type)
    149149  {
    150       case MT_NULL:
     150    case MT_NULL:
    151151      return true;
    152       case MT_BOOL:
     152    case MT_BOOL:
    153153      return (this->value.Bool == mt.value.Bool);
    154       case MT_INT:
     154    case MT_INT:
    155155      return (this->value.Int == mt.value.Int);
    156       case MT_CHAR:
     156    case MT_CHAR:
    157157      return (this->value.Char == mt.value.Char);
    158       case MT_FLOAT:
     158    case MT_FLOAT:
    159159      return (this->value.Float == mt.value.Float);
    160       case MT_STRING:
     160    case MT_STRING:
    161161      return (this->storedString == mt.storedString);
    162162  }
     
    175175  switch (type)
    176176  {
    177       case MT_BOOL:
     177    case MT_BOOL:
    178178      this->setBool(this->getBool());
    179179      break;
    180       case MT_INT:
     180    case MT_INT:
    181181      this->setInt(this->getInt());
    182182      break;
    183       case MT_FLOAT:
     183    case MT_FLOAT:
    184184      this->setFloat(this->getFloat());
    185185      break;
    186       case MT_CHAR:
     186    case MT_CHAR:
    187187      this->setChar(this->getChar());
    188188      break;
    189       case MT_STRING:
     189    case MT_STRING:
    190190      this->setString(this->getString());
    191191      break;
     
    382382
    383383/**
     384 * @brief returns a Constant string (actually this is slower than getString()
     385 * @returns a constant string of the stored version's one.
     386 * @note this  could lead to a inconsistency of data
     387 */
     388const std::string& MultiType::getConstString() const
     389{
     390
     391  MultiType::constString = this->getString();
     392  return MultiType::constString;
     393}
     394
     395
     396/**
    384397 * @returns a formated c-string of the held value
    385398 */
     
    422435  switch ( this->type )
    423436  {
    424       case MT_BOOL:
     437    case MT_BOOL:
    425438      this->setBool(false);
    426439      break;
    427       case MT_INT:
     440    case MT_INT:
    428441      this->setInt(0);
    429442      break;
    430       case MT_FLOAT:
     443    case MT_FLOAT:
    431444      this->setFloat(0.0f);
    432445      break;
    433       case MT_CHAR:
     446    case MT_CHAR:
    434447      this->setChar('\0');
    435448      break;
    436       case MT_STRING:
     449    case MT_STRING:
    437450      this->setString("");
    438451      break;
    439       default:
     452    default:
    440453#ifdef DEBUG
    441454      PRINTF(2)("Unknown Type not reseting\n");
     
    454467  switch ( type )
    455468  {
    456       case MT_BOOL:
     469    case MT_BOOL:
    457470      return MultiType::typeNames[1];
    458       case MT_INT:
     471    case MT_INT:
    459472      return MultiType::typeNames[2];
    460       case MT_FLOAT:
     473    case MT_FLOAT:
    461474      return MultiType::typeNames[3];
    462       case MT_CHAR:
     475    case MT_CHAR:
    463476      return MultiType::typeNames[4];
    464       case MT_STRING:
     477    case MT_STRING:
    465478      return MultiType::typeNames[5];
    466479  }
     
    490503
    491504
     505std::string MultiType::constString = "";
    492506const std::string MultiType::typeNames[] =
    493507  {
  • trunk/src/lib/util/multi_type.h

    r7401 r8035  
    8787    const char* getCString();
    8888    std::string getString() const;
     89    const std::string& getConstString() const;
    8990
    9091    void reset();
     
    107108    MT_Type                      type;              //!< The Type stored in this MultiType
    108109
     110
     111    static std::string           constString;       //!< A String for returning Constant strings.
     112
    109113    static const std::string     typeNames[];       //!< List of TypeNames for conversion.
    110114};
Note: See TracChangeset for help on using the changeset viewer.