Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 13, 2005, 3:10:49 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/world_entities: merged the Trunk to the world_entities branche
merged with command
svn merge -r5516:HEAD ../trunk/ world_entities/
no conflicts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/world_entities/src/util/loading/load_param.h

    r5499 r5558  
    2323
    2424#include "functor_list.h"
    25 #include "base_object.h"
     25
     26#include "debug.h"
    2627
    2728#include "factory.h"
    28 #include "debug.h"
    2929#include "substring.h"
    3030#include "tinyxml.h"
     31
    3132#include "helper_functions.h"
    3233
    3334// Forward Declaration //
    3435template<class T> class tList;
    35 
    36 /************************
    37 *** DESCRIPTION STUFF ***
    38 ************************/
    39 //! A class that handles the description of loadable parameters
    40 class LoadParamDescription
    41 {
    42   friend class BaseLoadParam;
    43   friend class LoadClassDescription;
    44  public:
    45   LoadParamDescription(const char* paramName);
    46   ~LoadParamDescription();
    47 
    48   void setDescription(const char* descriptionText);
    49   /** @returns the descriptionString */
    50   const char* getDescription() { return this->description; };
    51 
    52   void print() const;
    53  private:
    54   char*         paramName;             //!< The name of the parameter.
    55   int           paramCount;            //!< The count of parameters.
    56   int*          types;                 //!< What kind of parameters does this function take ??
    57   char*         description;           //!< A longer description about this function.
    58   char**        defaultValues;         //!< The 'Default Values'.
    59 };
    60 
    61 //! A class for descriptions of a loadable module
    62 class LoadClassDescription
    63 {
    64   friend class BaseLoadParam;
    65  public:
    66   LoadClassDescription(const char* className);
    67   ~LoadClassDescription();
    68 
    69   static LoadClassDescription* addClass(const char* className);
    70   LoadParamDescription* addParam(const char* paramName);
    71 
    72   static void deleteAllDescriptions();
    73 
    74   static void printAll(const char* fileName = NULL);
    75   static tList<const char>* searchClassWithShort(const char* classNameBegin);
    76 //  static const LoadParamDescription* getClass(const char* className);
    77 
    78  private:
    79   static bool                          parametersDescription;  //!< if parameter-description should be enabled.
    80   static tList<LoadClassDescription>*  classList;              //!< a list, that holds all the loadable classes. (after one instance has been loaded)
    81   char*                                className;              //!< name of the class
    82   tList<LoadParamDescription>*         paramList;              //!< List of parameters this class knows.
    83 };
    84 
     36class LoadClassDescription;
     37class LoadParamDescription;
     38class MultiType;
    8539
    8640/**************************
     
    8842**************************/
    8943//! abstract Base class for a Loadable parameter
    90 class BaseLoadParam : public BaseObject
     44class LoadParamBase : public BaseObject
    9145{
    9246 public:
    93   BaseLoadParam* describe(const char* descriptionText);
     47  LoadParamBase* describe(const char* descriptionText);
     48  LoadParamBase* defaultValues(unsigned int count, ...);
    9449
    9550 protected:
    96   BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName, int paramCount, bool multi, const void* pointerToParam, ...);
     51  LoadParamBase(const TiXmlElement* root, BaseObject* object, const char* paramName, int paramCount, bool multi, const void* pointerToParam, ...);
    9752
    9853 protected:
     
    10156  const char*              loadString;           //!< The string loaded by this LoadParam
    10257  const void*              pointerToParam;       //!< A Pointer to a Parameter.
     58
     59  MultiType*               defaultValue;
    10360};
    10461
     
    14097#define LoadParam0() \
    14198LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(), bool multi = false) \
    142   : BaseLoadParam(root, pt2Object, paramName, 0, multi, NULL, "") \
     99  : LoadParamBase(root, pt2Object, paramName, 0, multi, NULL) \
    143100{ \
    144101  if (loadString != NULL && root != NULL) \
     
    156113 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE), \
    157114           bool multi = false, type1##_TYPE default1 = type1##_DEFAULT) \
    158   : BaseLoadParam(root, pt2Object, paramName, 1, multi, NULL, type1##_PARAM, default1) \
     115  : LoadParamBase(root, pt2Object, paramName, 1, multi, NULL, type1##_PARAM, default1) \
    159116{ \
    160117      if (loadString != NULL && root != NULL) \
     
    175132 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE), \
    176133           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) \
     134  : LoadParamBase(root, pt2Object, paramName, 2, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2) \
    178135{ \
    179136      if (loadString != NULL && root != NULL) \
     
    201158 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE), \
    202159           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) \
     160  : LoadParamBase(root, pt2Object, paramName, 3, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3) \
    204161{ \
    205162      if (loadString != NULL && root != NULL) \
     
    229186           bool multi = false, type1##_TYPE default1 = type1##_DEFAULT, type2##_TYPE default2 = type2##_DEFAULT, type3##_TYPE default3 = type3##_DEFAULT, \
    230187           type4##_TYPE default4 = type4##_DEFAULT) \
    231   : BaseLoadParam(root, pt2Object, paramName, 4, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3, \
     188  : LoadParamBase(root, pt2Object, paramName, 4, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3, \
    232189                  type4##_PARAM, default4) \
    233190{ \
     
    260217           bool multi = false, type1##_TYPE default1 = type1##_DEFAULT, type2##_TYPE default2 = type2##_DEFAULT, type3##_TYPE default3 = type3##_DEFAULT, \
    261218           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, \
     219  : LoadParamBase(root, pt2Object, paramName, 5, multi, NULL, type1##_PARAM, default1, type2##_PARAM, default2, type3##_PARAM, default3, \
    263220                  type4##_PARAM, default4, type5##_PARAM, default5) \
    264221{ \
     
    283240#define LoadParamPT(type1) \
    284241 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) \
     242  : LoadParamBase(root, pt2Object, paramName, 1, multi, pointerToParam, type1##_PARAM) \
    286243{ \
    287244      if (pointerToParam != NULL && root != NULL) \
     
    292249
    293250//! derived template class, so all the Classes can load something.
    294 template<class T> class LoadParam : public BaseLoadParam
     251template<class T> class LoadParam : public LoadParamBase
    295252{
    296253  public:
     
    305262  // loads a Ti-XML-element
    306263  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")
     264  : LoadParamBase(root, pt2Object, paramName, 1, multi, NULL, "XML")
    308265  {
    309266    if (root != NULL)
Note: See TracChangeset for help on using the changeset viewer.