Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 21, 2005, 10:31:55 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/levelLoader: some minor changes

File:
1 edited

Legend:

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

    r4249 r4250  
     1/*
     2   orxonox - the future of 3D-vertical-scrollers
     3
     4   Copyright (C) 2004 orx
     5
     6   This program is free software; you can redistribute it and/or modify
     7   it under the terms of the GNU General Public License as published by
     8   the Free Software Foundation; either version 2, or (at your option)
     9   any later version.
     10
     11   ### File Specific:
     12   main-programmer: Benjamin Grauer
     13   co-programmer: ...
     14*/
     15
     16/*!
     17    \file load_param.h
     18    \brief A Class and macro-functions, that makes our lives easy to load-in parameters
     19*/
    120
    221#ifndef _LOAD_PARAM_H
     
    4867
    4968// 2. TYPES
    50 #define LoadParam2(type1, type2)\
     69#define LoadParam2(type1, type2) \
    5170 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE)) \
    5271    { \
     
    6786
    6887// 3. TYPES
    69 #define LoadParam3(type1, type2, type3)\
     88#define LoadParam3(type1, type2, type3) \
    7089 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE)) \
    7190    { \
     
    86105
    87106// 4. TYPES
    88 #define LoadParam4(type1, type2, type3, type4)\
     107#define LoadParam4(type1, type2, type3, type4) \
    89108 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE)) \
    90109    { \
     
    103122    };
    104123
    105 // abstract base class
    106 class baseLoadParam
     124
     125// 5. TYPES
     126#define LoadParam5(type1, type2, type3, type4, type5) \
     127 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE, type5##_TYPE)) \
     128    { \
     129      const char* loadString = grabParameter(root, paramName); \
     130      if (loadString != NULL) \
     131        { \
     132          SubString subLoads(loadString); \
     133          if (subLoads.getCount() == 5) \
     134            (*pt2Object.*function)(type1##_FUNC(subLoads.getString(0)), type2##_FUNC(subLoads.getString(1)), type3##_FUNC(subLoads.getString(2)), type4##_FUNC(subLoads.getString(3)), type5##_FUNC(subLoads.getString(4))); \
     135          else \
     136            PRINTF(2)("Not loaded Parameter %s of %s, because wrong count of arguments.\n -> Should have %d but have %d\n", \
     137                      paramName, pt2Object->getClassName(), 5, subLoads.getCount()); \
     138        } \
     139      else \
     140        PRINTF(2)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \
     141    };
     142
     143
     144class LoadParamDescription
     145{
     146 private:
     147  int paramCount;
     148  char** types;
     149};
     150
     151// abstract Base class
     152class BaseLoadParam
    107153{
    108154 public:
    109   void description(const char* description);
    110155};
    111156
    112157
    113158// derived template class
    114 template<class T> class LoadParam : public baseLoadParam
     159template<class T> class LoadParam : public BaseLoadParam
    115160{
    116161 public:
     
    129174  LoadParam3(l_FLOAT, l_FLOAT, l_FLOAT);
    130175  LoadParam4(l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT);
    131 
    132 
    133176};
    134177
Note: See TracChangeset for help on using the changeset viewer.