Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4254 in orxonox.OLD for orxonox


Ignore:
Timestamp:
May 22, 2005, 1:43:16 AM (20 years ago)
Author:
bensch
Message:

orxonox/branches/levelLoader: capabilities for documentation are close by

Location:
orxonox/branches/levelLoader/src/util/loading
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/levelLoader/src/util/loading/factory.cc

    r4253 r4254  
    9393  const TiXmlNode* node;
    9494       
    95   assert( root != NULL);
     95  if (root == NULL)
     96    return NULL;
    9697  assert( name != NULL);
    9798       
  • orxonox/branches/levelLoader/src/util/loading/factory.h

    r4253 r4254  
    3333    this should be used at the beginning of all the Classes that should be loadable (in the cc-file)
    3434*/
    35 #define CREATE_FACTORY(CLASS_NAME) tFactory<CLASS_NAME>* global_##CLASS_NAME##Factory = new tFactory<CLASS_NAME>(#CLASS_NAME); \
    36         CREATE_LOAD_DOC(CLASS_NAME)
    37 
    38 
    39                
     35#define CREATE_FACTORY(CLASS_NAME) tFactory<CLASS_NAME>* global_##CLASS_NAME##Factory = new tFactory<CLASS_NAME>(#CLASS_NAME)           
    4036//! The Factory is
    4137class Factory {
  • orxonox/branches/levelLoader/src/util/loading/load_param.cc

    r4252 r4254  
    1616#include "load_param.h"
    1717
     18#include "list.h"
     19#include "base_object.h"
    1820
    19 BaseLoadParam::BaseLoadParam(BaseObject* object, const char* type1, const char* type2,
    20                 const char* type3, const char* type4, const char* type5)
     21#include <stdarg.h>
     22
     23
     24BaseLoadParam::BaseLoadParam(BaseObject* object, const char* paramName, int paramCount, ...)
    2125{
    22  
     26  if (LoadClassDescription::parametersDescription)
     27    {
     28      // locating the class
     29      this->classDesc = LoadClassDescription::addClass(object->getClassName());
     30      this->paramDesc = this->classDesc->addParam(paramName);
     31
     32      this->paramDesc->types = new char*[paramCount];
     33      this->paramDesc->paramCount = paramCount;
     34
     35      va_list types;
     36      va_start (types, paramCount);
     37      for(int i = 0; i < paramCount; i++)
     38        {
     39          const char* tmpTypeName = va_arg (types, const char*);
     40          this->paramDesc->types[i] = new char[strlen(tmpTypeName)+1];
     41          strcpy(this->paramDesc->types[i], tmpTypeName);
     42        }
     43      va_end(types); 
     44
     45      int argCount = 0;
     46    }
    2347}
     48
     49
     50void BaseLoadParam::describe(const char* descriptionText)
     51{
     52  if (this->paramDesc)
     53    {
     54     
     55    }
     56
     57}
     58
     59
     60LoadParamDescription::LoadParamDescription(const char* paramName)
     61{
     62  this->types = NULL;
     63  this->paramName = new char[strlen(paramName)+1];
     64  strcpy(this->paramName, paramName);
     65}
     66
     67LoadParamDescription::~LoadParamDescription(void)
     68{
     69  for(int i = 0; i < this->paramCount; i++)
     70    {
     71      delete this->types[i];
     72    }
     73  delete []this->types;
     74  delete []this->paramName;
     75}
     76
     77
     78tList<LoadClassDescription>* LoadClassDescription::classList = new tList<LoadClassDescription>;
    2479
    2580/**
    2681   \brief if the description of Parameters should be executed
    2782*/
    28 bool LoadClassDescription::parametersDescription = false;
     83bool LoadClassDescription::parametersDescription = true;
     84
     85LoadClassDescription::LoadClassDescription(const char* className)
     86{
     87  this->className = new char[strlen(className)+1];
     88  strcpy(this->className, className);
     89
     90  classList->add(this);
     91
     92  this->paramList = new tList<LoadParamDescription>;
     93}
     94
     95LoadClassDescription::~LoadClassDescription(void)
     96{
     97  delete []this->className;
     98
     99  tIterator<LoadParamDescription>* iterator = this->paramList->getIterator();
     100  LoadParamDescription* enumParamDesc = iterator->nextElement();
     101  while (enumParamDesc)
     102    {
     103      delete enumParamDesc;
     104      enumParamDesc = iterator->nextElement();
     105    }
     106  delete iterator;
     107
     108}
     109
     110
     111LoadClassDescription* LoadClassDescription::addClass(const char* className)
     112{
     113  tIterator<LoadClassDescription>* iterator = LoadClassDescription::classList->getIterator();
     114  LoadClassDescription* enumClassDesc = iterator->nextElement();
     115  while (enumClassDesc)
     116    {
     117      if (!strcmp(enumClassDesc->className, className))
     118        {
     119          delete iterator;
     120          return enumClassDesc;
     121        }
     122      enumClassDesc = iterator->nextElement();
     123    }
     124  delete iterator;
     125
     126  return new LoadClassDescription(className);
     127}
     128
     129
     130LoadParamDescription* LoadClassDescription::addParam(const char* paramName)
     131{
     132  tIterator<LoadParamDescription>* iterator = this->paramList->getIterator();
     133  LoadParamDescription* enumParamDesc = iterator->nextElement();
     134  while (enumParamDesc)
     135    {
     136      if (!strcmp(enumParamDesc->paramName, paramName))
     137        {
     138          delete iterator;
     139          this->paramList->add(enumParamDesc);
     140          return enumParamDesc;
     141        }
     142      enumParamDesc = iterator->nextElement();
     143    }
     144  delete iterator;
     145
     146  this->paramList->add(new LoadParamDescription(paramName));
     147  return paramList->lastElement();
     148}
  • orxonox/branches/levelLoader/src/util/loading/load_param.h

    r4253 r4254  
    6565#define LoadParam1(type1) \
    6666 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE)) \
    67   : BaseLoadParam(pt2Object, type1##_NAME) \
     67  : BaseLoadParam(pt2Object, paramName, 1, type1##_NAME) \
    6868    { \
    6969      const char* loadString = grabParameter(root, paramName); \
     
    7878#define LoadParam2(type1, type2) \
    7979 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE)) \
    80   : BaseLoadParam(pt2Object, type1##_NAME, type2##_NAME) \
     80  : BaseLoadParam(pt2Object, paramName, 2, type1##_NAME, type2##_NAME) \
    8181    { \
    8282      const char* loadString = grabParameter(root, paramName); \
     
    9898#define LoadParam3(type1, type2, type3) \
    9999 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE))\
    100   : BaseLoadParam(pt2Object, type1##_NAME, type2##_NAME, type3##_NAME) \
     100  : BaseLoadParam(pt2Object, paramName, 3, type1##_NAME, type2##_NAME, type3##_NAME) \
    101101    { \
    102102      const char* loadString = grabParameter(root, paramName); \
     
    118118#define LoadParam4(type1, type2, type3, type4) \
    119119 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE)) \
    120   : BaseLoadParam(pt2Object, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME) \
     120  : BaseLoadParam(pt2Object, paramName, 4, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME) \
    121121    { \
    122122      const char* loadString = grabParameter(root, paramName); \
     
    138138#define LoadParam5(type1, type2, type3, type4, type5) \
    139139 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE, type5##_TYPE)) \
    140   : BaseLoadParam(pt2Object, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME, type5##_NAME) \
     140  : BaseLoadParam(pt2Object, paramName, 5, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME, type5##_NAME) \
    141141    { \
    142142      const char* loadString = grabParameter(root, paramName); \
     
    155155
    156156
    157 
    158 #define CREATE_LOAD_DOC(CLASS_NAME) \
    159   void documentLoadClass##CLASS_NAME(void) \
    160     { \
    161       if(LoadClassDescription::parametersDescription) \
    162         { \
    163           CLASS_NAME docuClass; \
    164           docuClass.loadParams(NULL); \
    165         } \
    166     }
    167 //  documentLoadClass();
    168 
    169 
    170157class LoadParamDescription
    171158{
     159  friend class BaseLoadParam;
     160  friend class LoadClassDescription;
     161 public:
     162  LoadParamDescription(const char* paramName);
     163  ~LoadParamDescription(void);
    172164 private:
     165  char* paramName;
    173166  int paramCount;
    174167  char** types;
    175   const char* className;
    176 
    177168};
    178169
    179170class LoadClassDescription
    180171{
     172  friend class BaseLoadParam;
    181173 public:
    182 
     174  LoadClassDescription(const char* className);
     175  ~LoadClassDescription(void);
     176
     177  static LoadClassDescription* addClass(const char* className);
     178  LoadParamDescription* addParam(const char* paramName);
    183179
    184180  static bool parametersDescription;
    185181 
     182  static tList<LoadClassDescription>* classList;
    186183 private:
     184  char* className;
    187185  tList<LoadParamDescription>* paramList;
    188186};
     
    192190{
    193191 protected:
    194   BaseLoadParam(BaseObject* object, const char* type1 = NULL, const char* type2 = NULL,
    195                 const char* type3 = NULL, const char* type4 = NULL, const char* type5 = NULL);
     192  BaseLoadParam(BaseObject* object, const char* paramName, int paramCount, ...);
     193  void describe(const char* descriptionText);
    196194
    197195 protected:
    198   LoadParamDescription* description;
     196  LoadClassDescription* classDesc;
     197  LoadParamDescription* paramDesc;
    199198};
    200199
Note: See TracChangeset for help on using the changeset viewer.