Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4597 in orxonox.OLD for orxonox/trunk/src/util/loading/factory.h


Ignore:
Timestamp:
Jun 11, 2005, 12:55:48 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: setClassID implemented in all files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/util/loading/factory.h

    r4492 r4597  
    1 /* 
     1/*
    22   orxonox - the future of 3D-vertical-scrollers
    33
     
    1414*/
    1515
    16 /*! 
     16/*!
    1717  \file factory.h
    1818  \brief A loadable object handler
     
    2727#include "tinyxml.h"
    2828#include "load_param.h"
     29#include "base_object.h"
    2930#include "debug.h"
    3031
    31 /** 
     32/**
    3233    Creates a factory to a Loadable Class.
    3334    this should be used at the beginning of all the Classes that should be loadable (in the cc-file)
     35  \todo make factoryName a BaseObject-parameter. (else it would be redundant)
    3436*/
    35 #define CREATE_FACTORY(CLASS_NAME) tFactory<CLASS_NAME>* global_##CLASS_NAME##Factory = new tFactory<CLASS_NAME>(#CLASS_NAME)           
     37#define CREATE_FACTORY(CLASS_NAME) tFactory<CLASS_NAME>* global_##CLASS_NAME##Factory = new tFactory<CLASS_NAME>(#CLASS_NAME)
    3638
    3739//! The Factory is a loadable object handler
    38 class Factory {
     40class Factory : public BaseObject {
    3941
    4042 public:
    4143  Factory (const char* factoryName = NULL);
    4244  ~Factory ();
    43  
     45
    4446
    4547  virtual BaseObject* fabricate(const TiXmlElement* root);
     
    5355  /** \returns the next factory */
    5456  Factory* getNext(void) const { return this->next; };
    55        
     57
    5658 protected:
    5759  char*         factoryName;          //!< the name of the factory
     
    6971  tFactory(const char* factoryName);
    7072  virtual ~tFactory();
    71  
     73
    7274  private:
    7375  BaseObject* fabricate(const TiXmlElement* root);
     
    8385  PRINTF(5)("fileName: %s loadable\n", this->factoryName);
    8486}
    85  
     87
    8688
    8789template<class T>
     
    9092
    9193template<class T>
    92 BaseObject* tFactory<T>::fabricate(const TiXmlElement* root) 
    93 { 
     94BaseObject* tFactory<T>::fabricate(const TiXmlElement* root)
     95{
    9496  if(!strcmp(root->Value(), getFactoryName()))
    9597    return new T ( root);
    96   else if( getNext() != NULL) 
     98  else if( getNext() != NULL)
    9799    return getNext()->fabricate( root);
    98   else 
     100  else
    99101    return NULL;
    100102}
Note: See TracChangeset for help on using the changeset viewer.