Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4598 in orxonox.OLD for orxonox/trunk/src/util


Ignore:
Timestamp:
Jun 11, 2005, 3:08:36 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: campaign now gets loaded via LoadParam

Location:
orxonox/trunk/src/util/loading
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/util/loading/game_loader.cc

    r4597 r4598  
    337337   \param element a XMLElement containing all the needed info
    338338*/
    339 BaseObject* GameLoader::fabricate( TiXmlElement* element)
     339BaseObject* GameLoader::fabricate(const TiXmlElement* element)
    340340{
    341341  assert( element != NULL);
  • orxonox/trunk/src/util/loading/game_loader.h

    r4511 r4598  
    1 /*! 
     1/*!
    22    \file game_loader.h
    33    \brief loads campaigns, worlds and all other story_entities
    4 */ 
     4*/
    55
    66#ifndef _GAME_LOADER_H
     
    6060  bool worldCommand(Command* cmd);
    6161  ErrorMessage loadDebugCampaign(Uint32 campaignID);
    62  
     62
    6363  void registerFactory( Factory* factory );
    64   BaseObject* fabricate( TiXmlElement* data);
     64  BaseObject* fabricate(const TiXmlElement* data);
    6565
    6666  void process(const Event &event);
     
    7878
    7979  Campaign*              currentCampaign;      //!< reference to the current campaign playing
    80  
     80
    8181  EventHandler*          eventHandler;         //!< reference to the eventHandler
    8282
  • orxonox/trunk/src/util/loading/load_param.cc

    r4597 r4598  
    3030*/
    3131BaseLoadParam::BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName,
    32                              int paramCount, bool multi, ...)
     32                             int paramCount, bool multi, const void* pointerToParam, ...)
    3333{
    3434  this->setClassID(CL_LOAD_PARAM, "LoadParam");
    3535  this->loadString = NULL;
    36 
    37   if (paramCount == 0)
     36  this->pointerToParam = pointerToParam;
     37
     38  if (paramCount == 0 || this->pointerToParam)
    3839    this->loadString = "none";
    3940  else
     
    6364
    6465      va_list types;
    65       va_start (types, multi);
     66      va_start (types, pointerToParam);
    6667      for(int i = 0; i < paramCount; i++)
    6768        {
  • orxonox/trunk/src/util/loading/load_param.h

    r4597 r4598  
    2626#include "debug.h"
    2727#include "substring.h"
     28#include "tinyxml.h"
    2829
    2930// Forward Declaration //
     
    4142/**
    4243   useable FunctionParameters are:
    43    l_INT:    int
    44    l_LONG:   long
    45    l_SHORT:  short
    46    l_FLOAT:  float
    47    l_STRING: const char*
    48 */
    49 
    50 #define l_INT_TYPE       int              //!< The type of an INT
    51 #define l_INT_FUNC       atoi             //!< the function to call to parse INT
    52 #define l_INT_NAME       "int"            //!< the name of an INT
    53 
    54 #define l_LONG_TYPE      long             //!< The type of a LONG
    55 #define l_LONG_FUNC      atol             //!< The function to parse a LONG
    56 #define l_LONG_NAME      "long"           //!< The name of a LONG
    57 
    58 #define l_SHORT_TYPE     short            //!< The type of a SHORT
    59 #define l_SHORT_FUNC     atoi             //!< The function to parse a SHORT
    60 #define l_SHORT_NAME     "short"          //!< The name of a SHORT
    61 
    62 #define l_FLOAT_TYPE     float            //!< The type of a FLOAT
    63 #define l_FLOAT_FUNC     atof             //!< The function to parse a FLOAT
    64 #define l_FLOAT_NAME     "float"          //!< The name of a FLOAT
    65 
    66 #define l_STRING_TYPE    const char*      //!< The type fo a STRING
    67 #define l_STRING_FUNC                     //!< The function to parse a STRING
    68 #define l_STRING_NAME    "string"         //!< The name of a STRING
     44   l_INT:       int
     45   l_LONG:      long
     46   l_SHORT:     short
     47   l_FLOAT:     float
     48   l_STRING:    const char*
     49   l_XML_ELEM:  TiXmlElement*
     50*/
     51
     52#define l_INT_TYPE       int                  //!< The type of an INT
     53#define l_INT_FUNC       atoi                 //!< the function to call to parse INT
     54#define l_INT_NAME       "int"                //!< the name of an INT
     55
     56#define l_LONG_TYPE      long                 //!< The type of a LONG
     57#define l_LONG_FUNC      atol                 //!< The function to parse a LONG
     58#define l_LONG_NAME      "long"               //!< The name of a LONG
     59
     60#define l_SHORT_TYPE     short                //!< The type of a SHORT
     61#define l_SHORT_FUNC     atoi                 //!< The function to parse a SHORT
     62#define l_SHORT_NAME     "short"              //!< The name of a SHORT
     63
     64#define l_FLOAT_TYPE     float                //!< The type of a FLOAT
     65#define l_FLOAT_FUNC     atof                 //!< The function to parse a FLOAT
     66#define l_FLOAT_NAME     "float"              //!< The name of a FLOAT
     67
     68#define l_STRING_TYPE    const char*          //!< The type of a STRING
     69#define l_STRING_FUNC                         //!< The function to parse a STRING
     70#define l_STRING_NAME    "string"             //!< The name of a STRING
     71
     72#define l_XML_ELEM_TYPE  const TiXmlElement*  //!< The type of an XML_ELEM
     73#define l_XML_ELEM_FUNC                       //!< The function to parse an XML_ELEM
     74#define l_XML_ELEM_NAME  "XML"                //!< The name of an XML_ELEM
    6975
    7076// 1. TYPE
     
    7581#define LoadParam1(type1) \
    7682 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE), bool multi = false) \
    77    : BaseLoadParam(root, pt2Object, paramName, 1, multi, type1##_NAME)          \
     83  : BaseLoadParam(root, pt2Object, paramName, 1, multi, NULL, type1##_NAME) \
    7884    { \
    7985      if (loadString != NULL && root != NULL) \
     
    9298#define LoadParam2(type1, type2) \
    9399 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE), bool multi = false) \
    94    : BaseLoadParam(root, pt2Object, paramName, 2, multi, type1##_NAME, type2##_NAME) \
     100  : BaseLoadParam(root, pt2Object, paramName, 2, multi, NULL, type1##_NAME, type2##_NAME) \
    95101    { \
    96102      if (loadString != NULL && root != NULL) \
     
    117123#define LoadParam3(type1, type2, type3) \
    118124 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE), bool multi = false)\
    119    : BaseLoadParam(root, pt2Object, paramName, 3, multi, type1##_NAME, type2##_NAME, type3##_NAME) \
     125  : BaseLoadParam(root, pt2Object, paramName, 3, multi, NULL, type1##_NAME, type2##_NAME, type3##_NAME) \
    120126    { \
    121127      if (loadString != NULL && root != NULL) \
     
    143149#define LoadParam4(type1, type2, type3, type4) \
    144150 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE), bool multi = false) \
    145    : BaseLoadParam(root, pt2Object, paramName, 4, multi, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME) \
     151  : BaseLoadParam(root, pt2Object, paramName, 4, multi, NULL, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME) \
    146152    { \
    147153      if (loadString != NULL && root != NULL) \
     
    170176#define LoadParam5(type1, type2, type3, type4, type5) \
    171177 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE, type2##_TYPE, type3##_TYPE, type4##_TYPE, type5##_TYPE), bool multi = false) \
    172    : BaseLoadParam(root, pt2Object, paramName, 5, multi, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME, type5##_NAME) \
     178  : BaseLoadParam(root, pt2Object, paramName, 5, multi, NULL, type1##_NAME, type2##_NAME, type3##_NAME, type2##_NAME, type4##_NAME, type5##_NAME) \
    173179    { \
    174180      if (loadString != NULL && root != NULL) \
     
    185191    }
    186192
     193// Pointer TYPE
     194/**
     195   \brief a Macro to easily implement many different Constructors for the LoadParam-Class with 1 argument
     196   \param type1 The type of the Pointer
     197 */
     198#define LoadParamPT(type1) \
     199 LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(type1##_TYPE), type1##_TYPE pointerToParam, bool multi = false) \
     200  : BaseLoadParam(root, pt2Object, paramName, 1, multi, pointerToParam, type1##_NAME) \
     201{ \
     202      if (pointerToParam != NULL && root != NULL) \
     203        (*pt2Object.*function)((type1##_TYPE) pointerToParam); \
     204      else \
     205        PRINTF(4)("Not loaded parameter %s of %s\n", paramName, pt2Object->getClassName()); \
     206}
    187207
    188208//! A class that handles the description of loadable parameters
     
    235255
    236256 protected:
    237   BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName, int paramCount, bool multi, ...);
     257  BaseLoadParam(const TiXmlElement* root, BaseObject* object, const char* paramName, int paramCount, bool multi, const void* pointerToParam, ...);
    238258
    239259 protected:
     
    241261  LoadParamDescription*    paramDesc;            //!< The LoadParameterDescription of this LoadParameter
    242262  const char*              loadString;           //!< The string loaded by this LoadParam
     263  const void*              pointerToParam;       //!< A Pointer to a Parameter.
    243264};
    244265
     
    249270 public:
    250271  LoadParam(const TiXmlElement* root, const char* paramName, T* pt2Object, void(T::*function)(), bool multi = false)
    251     : BaseLoadParam(root, pt2Object, paramName, 0, multi, "")
     272    : BaseLoadParam(root, pt2Object, paramName, 0, multi, NULL, "")
    252273    {
    253274      if (loadString != NULL && root != NULL)
     
    284305  //! makes functions with four floats loadable
    285306  LoadParam4(l_FLOAT, l_FLOAT, l_FLOAT, l_FLOAT);
     307
     308  LoadParamPT(l_XML_ELEM);
    286309};
    287310
Note: See TracChangeset for help on using the changeset viewer.