Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5545 in orxonox.OLD for trunk


Ignore:
Timestamp:
Nov 11, 2005, 4:32:28 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: renaming of BaseLoadParam to LoadParamBase

Location:
trunk/src
Files:
4 edited

Legend:

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

    r5544 r5545  
    1717
    1818#include "multi_type.h"
    19 #include <stddef.h>
    20 #include <stdlib.h>
    21 #include <string.h>
    22 #include <stdio.h>
     19#include "stdincl.h"
     20// #include <stddef.h>
     21// #include <stdlib.h>
     22// #include <string.h>
     23// #include <stdio.h>
    2324
    2425using namespace std;
    2526
     27/**
     28 * creates a multiType without any stored value at all.
     29 */
    2630MultiType::MultiType()
    2731{
     
    3034}
    3135
    32 
     36/**
     37 * creates a multiType out of a boolean
     38 * @param value the Value of this MulitType
     39 */
    3340MultiType::MultiType(bool value)
    3441{
     
    3744}
    3845
     46/**
     47 * creates a multiType out of an integer
     48 * @param value the Value of this MulitType
     49 */
    3950MultiType::MultiType(int value)
    4051{
     
    4354}
    4455
    45 
     56/**
     57 * creates a multiType out of a float (double)
     58 * @param value the Value of this MulitType
     59 */
    4660MultiType::MultiType(double value)
    4761{
     
    5064}
    5165
    52 
     66/**
     67 * creates a multiType out of a char
     68 * @param value the Value of this MulitType
     69 */
    5370MultiType::MultiType(char value)
    5471{
     
    5774}
    5875
    59 
     76/**
     77 * creates a multiType out of a String
     78 * @param value the Value of this MulitType
     79 */
    6080MultiType::MultiType(const char* value)
    6181{
     
    91111}
    92112
     113/**
     114 * initializes the MultiType
     115 */
    93116void MultiType::init()
    94117{
     
    104127}
    105128
     129/**
     130 * sets a new Value to the MultiType
     131 * @param value the new Value as a bool
     132 */
    106133void MultiType::setBool(bool value)
    107134{
     
    110137}
    111138
    112 
     139/**
     140 * sets a new Value to the MultiType
     141 * @param value the new Value as an int
     142 */
    113143void MultiType::setInt(int value)
    114144{
     
    117147}
    118148
    119 
     149/**
     150 * sets a new Value to the MultiType
     151 * @param value the new Value as a float
     152 */
    120153void MultiType::setFloat(float value)
    121154{
     
    125158}
    126159
    127 
     160/**
     161 * sets a new Value to the MultiType
     162 * @param value the new Value as a char
     163 */
    128164void MultiType::setChar(char value)
    129165{
     
    132168}
    133169
    134 
     170/**
     171 * sets a new Value to the MultiType
     172 * @param value the new Value as a String
     173 */
    135174void MultiType::setString(const char* value)
    136175{
    137176  this->type = MT_STRING;
    138   this->value.String = new char[strlen(value)+1];
    139   strcpy(this->value.String, value);
    140 
    141   this->storedString = this->value.String;
    142 }
    143 
    144 
    145 
    146 
    147 
    148 
     177
     178  if (this->storedString != NULL)
     179    delete[] this->storedString;
     180  this->storedString = new char[strlen(value)+1];
     181  strcpy(storedString, value);
     182
     183  this->value.String = this->storedString;
     184}
     185
     186
     187
     188
     189
     190/**
     191 * @returns the Value of this MultiType as a int
     192 */
    149193bool MultiType::getBool() const
    150194{
     
    161205}
    162206
    163 
     207/**
     208 * @returns the Value of this MultiType as a int
     209 */
    164210int MultiType::getInt() const
    165211{
     
    182228}
    183229
    184 
     230/**
     231 * @returns the Value of this MultiType as a float
     232 */
    185233float MultiType::getFloat() const
    186234{
     
    204252
    205253
     254/**
     255 * @returns the Value of this MultiType as a char
     256 */
    206257char MultiType::getChar() const
    207258{
     
    217268}
    218269
     270/**
     271 * @returns the Value of this MultiType as a String
     272 */
    219273const char* MultiType::getString()
    220274{
     
    253307}
    254308
    255 
     309/**
     310 * prints out some nice debug output
     311 */
    256312void MultiType::debug()
    257313{
     
    268324}
    269325
     326/**
     327 * converts a MT_Type into a String
     328 * @param type: the MT_Type
     329 * @returns: the Type as a constant String (do not delete)
     330 */
    270331const char* MultiType::MultiTypeToString(MT_Type type)
    271332{
     
    287348}
    288349
     350/**
     351 * converts a String into a MT_Type
     352 * @param type: the Type as a String
     353 * @returns: the Type as MT_Type
     354 */
    289355MT_Type MultiType::StringToMultiType(const char* type)
    290356{
  • trunk/src/lib/util/multi_type.h

    r5544 r5545  
    22 * @file multi_type.h
    33 * @brief Definition of ...
    4 */
     4 */
    55
    66#ifndef _MULTI_TYPE_H
     
    2929class MultiType {
    3030
    31  public:
    32    MultiType();
    33    MultiType(bool value);
    34    MultiType(int value);
    35    MultiType(double value);
    36    MultiType(char value);
    37    MultiType(const char* value);
    38    virtual ~MultiType();
    39    void init();
     31  public:
     32    MultiType();
     33    MultiType(bool value);
     34    MultiType(int value);
     35    MultiType(double value);
     36    MultiType(char value);
     37    MultiType(const char* value);
     38    virtual ~MultiType();
    4039
    41    MultiType operator= (const MultiType& mt);
     40    MultiType operator= (const MultiType& mt);
    4241
    43    void setType(MT_Type);
     42    void setType(MT_Type);
    4443
    45    void setBool(bool value);
    46    void setInt(int value);
    47    void setFloat(float value);
    48    void setChar(char value);
    49    void setString(const char* value);
     44    void setBool(bool value);
     45    void setInt(int value);
     46    void setFloat(float value);
     47    void setChar(char value);
     48    void setString(const char* value);
    5049
    51    inline void setValue(bool value) { this->setBool(value); };
    52    inline void setValue(int value) { this->setInt(value); };
    53    inline void setValue(float value) { this->setFloat(value); };
    54    inline void setValue(char value) { this->setChar(value); };
    55    inline void setValue(const char* value) { this->setString(value); };
     50    inline void setValue(bool value) { this->setBool(value); };
     51    inline void setValue(int value) { this->setInt(value); };
     52    inline void setValue(float value) { this->setFloat(value); };
     53    inline void setValue(char value) { this->setChar(value); };
     54    inline void setValue(const char* value) { this->setString(value); };
    5655
    57   /** @returns the Type of the Value stored in this MultiType */
    58   inline MT_Type getType() const { return this->type; };
     56    /** @returns the Type of the Value stored in this MultiType */
     57    inline MT_Type getType() const { return this->type; };
    5958
    60   bool getBool() const;
    61   int getInt() const;
    62   float getFloat() const;
    63   char getChar() const;
    64   const char* getString();
     59    bool getBool() const;
     60    int getInt() const;
     61    float getFloat() const;
     62    char getChar() const;
     63    const char* getString();
    6564
    6665
    67   void debug();
     66    void debug();
    6867
    69   static const char* MultiTypeToString(MT_Type type);
    70   static MT_Type StringToMultiType(const char* type);
     68    static const char* MultiTypeToString(MT_Type type);
     69    static MT_Type StringToMultiType(const char* type);
    7170
    72  private:
    73    MT_Type             type;
    74    union Type
    75    {
    76      bool              Bool;
    77      int               Int;
    78      float             Float;
    79      char              Char;
    80      char*             String;
     71  private:
     72    void init();
    8173
    82    }                   value;
    8374
    84    char*               storedString;
     75  private:
     76    MT_Type             type;
     77    union Type
     78    {
     79      bool              Bool;
     80      int               Int;
     81      float             Float;
     82      char              Char;
     83      char*             String;
     84
     85    }                   value;
     86
     87    char*               storedString;
    8588};
    8689
  • trunk/src/util/loading/load_param.cc

    r5534 r5545  
    3131 * @param ...: the parameter information (1. Parameter, 2. Default Value for the Parameter, ...)
    3232*/
    33 BaseLoadParam::BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName,
     33LoadParamBase::LoadParamBase(const TiXmlElement* root, BaseObject* object, const char* paramName,
    3434                             int paramCount, bool multi, const void* pointerToParam, ...)
    3535{
     
    110110 * @returns a pointer to itself.
    111111*/
    112 BaseLoadParam* BaseLoadParam::describe(const char* descriptionText)
     112LoadParamBase* LoadParamBase::describe(const char* descriptionText)
    113113{
    114114  if (LoadClassDescription::parametersDescription && this->paramDesc && !this->paramDesc->getDescription())
  • trunk/src/util/loading/load_param.h

    r5499 r5545  
    4040class LoadParamDescription
    4141{
    42   friend class BaseLoadParam;
     42  friend class LoadParamBase;
    4343  friend class LoadClassDescription;
    4444 public:
     
    6262class LoadClassDescription
    6363{
    64   friend class BaseLoadParam;
     64  friend class LoadParamBase;
    6565 public:
    6666  LoadClassDescription(const char* className);
     
    8888**************************/
    8989//! abstract Base class for a Loadable parameter
    90 class BaseLoadParam : public BaseObject
     90class LoadParamBase : public BaseObject
    9191{
    9292 public:
    93   BaseLoadParam* describe(const char* descriptionText);
     93  LoadParamBase* describe(const char* descriptionText);
    9494
    9595 protected:
    96   BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName, int paramCount, bool multi, const void* pointerToParam, ...);
     96  LoadParamBase(const TiXmlElement* root, BaseObject* object, const char* paramName, int paramCount, bool multi, const void* pointerToParam, ...);
    9797
    9898 protected:
     
    140140#define LoadParam0() \
    141141LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(), bool multi = false) \
    142   : BaseLoadParam(root, pt2Object, paramName, 0, multi, NULL, "") \
     142  : LoadParamBase(root, pt2Object, paramName, 0, multi, NULL, "") \
    143143{ \
    144144  if (loadString != NULL && root != NULL) \
     
    156156 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE), \
    157157           bool multi = false, type1##_TYPE default1 = type1##_DEFAULT) \
    158   : BaseLoadParam(root, pt2Object, paramName, 1, multi, NULL, type1##_PARAM, default1) \
     158  : LoadParamBase(root, pt2Object, paramName, 1, multi, NULL, type1##_PARAM, default1) \
    159159{ \
    160160      if (loadString != NULL && root != NULL) \
     
    175175 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE), \
    176176           bool multi = false,  type1##_TYPE default1 = type1##_DEFAULT,  type2##_TYPE default2 = type2##_DEFAULT) \
    177   : BaseLoadParam(root, pt2Object, paramName, 2, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2) \
     177  : LoadParamBase(root, pt2Object, paramName, 2, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2) \
    178178{ \
    179179      if (loadString != NULL && root != NULL) \
     
    201201 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE), \
    202202           bool multi = false, type1##_TYPE default1 = type1##_DEFAULT, type2##_TYPE default2 = type2##_DEFAULT, type3##_TYPE default3 = type3##_DEFAULT)\
    203   : BaseLoadParam(root, pt2Object, paramName, 3, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3) \
     203  : LoadParamBase(root, pt2Object, paramName, 3, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3) \
    204204{ \
    205205      if (loadString != NULL && root != NULL) \
     
    229229           bool multi = false, type1##_TYPE default1 = type1##_DEFAULT, type2##_TYPE default2 = type2##_DEFAULT, type3##_TYPE default3 = type3##_DEFAULT, \
    230230           type4##_TYPE default4 = type4##_DEFAULT) \
    231   : BaseLoadParam(root, pt2Object, paramName, 4, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3, \
     231  : LoadParamBase(root, pt2Object, paramName, 4, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3, \
    232232                  type4##_PARAM, default4) \
    233233{ \
     
    260260           bool multi = false, type1##_TYPE default1 = type1##_DEFAULT, type2##_TYPE default2 = type2##_DEFAULT, type3##_TYPE default3 = type3##_DEFAULT, \
    261261           type4##_TYPE default4 = type4##_DEFAULT, type5##_TYPE default5 = type5##_DEFAULT ) \
    262   : BaseLoadParam(root, pt2Object, paramName, 5, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3, \
     262  : LoadParamBase(root, pt2Object, paramName, 5, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3, \
    263263                  type4##_PARAM, default4, type5##_PARAM, default5) \
    264264{ \
     
    283283#define LoadParamPT(type1) \
    284284 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE), type1##_TYPE pointerToParam, bool multi = false) \
    285   : BaseLoadParam(root, pt2Object, paramName, 1, multi, pointerToParam, type1##_PARAM) \
     285  : LoadParamBase(root, pt2Object, paramName, 1, multi, pointerToParam, type1##_PARAM) \
    286286{ \
    287287      if (pointerToParam != NULL && root != NULL) \
     
    292292
    293293//! derived template class, so all the Classes can load something.
    294 template<class T> class LoadParam : public BaseLoadParam
     294template<class T> class LoadParam : public LoadParamBase
    295295{
    296296  public:
     
    305305  // loads a Ti-XML-element
    306306  LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(const TiXmlElement*), bool multi = false)
    307   : BaseLoadParam(root, pt2Object, paramName, 1, multi, NULL, "XML")
     307  : LoadParamBase(root, pt2Object, paramName, 1, multi, NULL, "XML")
    308308  {
    309309    if (root != NULL)
Note: See TracChangeset for help on using the changeset viewer.