Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Jun 29, 2005, 1:46:15 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: loading fields

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

Legend:

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

    r4729 r4730  
    3535  this->setName(factoryName);
    3636
     37  if (Factory::first == NULL)
     38    Factory::first = this;
    3739  next = NULL;
    3840
    3941  initialize();
    4042}
     43
     44Factory* Factory::first = NULL;
    4145
    4246/**
     
    5559
    5660/**
    57    \brief generates the associated object from data
    58 */
    59 BaseObject* Factory::fabricate(const TiXmlElement* data)
    60 {
    61   return NULL;
    62 }
    63 
    64 /**
    6561   \brief make this particular factory known to the LevelFactory
    6662*/
    6763void Factory::initialize()
    6864{
    69 #ifdef IS_ORXONOX
    7065  GameLoader::getInstance()->registerFactory( this);
    71 #endif /* IS_ORXONOX */
    7266}
    7367
  • orxonox/trunk/src/util/loading/factory.h

    r4729 r4730  
    3535  \todo make factoryName a BaseObject-parameter. (else it would be redundant)
    3636*/
    37 #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)
    3838
    3939//! The Factory is a loadable object handler
     
    4545
    4646
    47   virtual BaseObject* fabricate(const TiXmlElement* root);
     47  virtual BaseObject* fabricate(const TiXmlElement* root) = NULL;
    4848  void initialize();
    4949  void registerFactory( Factory* factory);
    5050  /** \brief sets the Next factory in the list \param nextFactory the next factory */
    5151  inline void setNext( Factory* nextFactory) { this->next = nextFactory; };
     52  /** \returns the first factory */
     53  static Factory* getFirst(void) { return Factory::first; };
    5254  /** \returns the next factory */
    5355  Factory* getNext(void) const { return this->next; };
     56
    5457
    5558 private:
     
    6972
    7073  private:
    71   BaseObject* fabricate(const TiXmlElement* root);
     74  virtual BaseObject* fabricate(const TiXmlElement* root);
    7275};
    7376
     
    7982tFactory<T>::tFactory(const char* factoryName) : Factory(factoryName)
    8083{
    81   PRINTF(5)("fileName: %s loadable\n", this->getName());
     84  PRINTF(5)("Class: %s loadable\n", this->getName());
    8285}
    8386
     
    9093BaseObject* tFactory<T>::fabricate(const TiXmlElement* root)
    9194{
    92   if(!strcmp(root->Value(), getName()))
     95  if(!strcmp(root->Value(), this->getName()))
    9396    return new T ( root);
    9497  else if( getNext() != NULL)
Note: See TracChangeset for help on using the changeset viewer.