Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 31, 2006, 10:51:08 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/new_class_id: new_class ID working, adapdet many classes, and reinvented some of the ClassID stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/util/loading/factory.h

    r9691 r9709  
    2020
    2121
    22 #ifndef _FACTORY_H
    23 #define _FACTORY_H
     22#ifndef __FACTORY_H
     23#define __FACTORY_H
    2424
    2525class BaseObject;
     
    2727#include "parser/tinyxml/tinyxml.h"
    2828#include "base_object.h"
    29 #include <vector>
    3029#include <list>
    3130
     
    3433 * this should be used at the beginning of all the Classes that should be loadable (in the cc-file)
    3534 */
    36 #define CREATE_FACTORY(CLASS_NAME, CLASS_ID) \
    37     tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>(#CLASS_NAME, CLASS_ID)
     35#define CREATE_FACTORY(CLASS_NAME) \
     36    tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>(CLASS_NAME::classID())
    3837
    3938//! The Factory is a loadable object handler
     
    4847  static  BaseObject* fabricate(const std::string& className);
    4948  static  BaseObject* fabricate(const NewClassID& classID);
    50   static  BaseObject* fabricate(int classID);
    51   static  BaseObject* fabricate(const TiXmlElement* root = NULL);
     49  static  BaseObject* fabricate(const TiXmlElement* root);
    5250
    5351
    5452  bool operator==(int classID) const;
    55   bool operator==(const char* className) const;
    5653  bool operator==(const std::string& className) const;
     54  bool operator==(const NewClassID& classID) const { return _classID == classID; };
    5755
    5856protected:
    59   Factory (const std::string& factoryName, int classID);
     57  Factory (const NewClassID& id);
    6058  virtual BaseObject* fabricateObject(const TiXmlElement* root = NULL) const = 0;
    6159
     60private:
     61  Factory (const Factory&) {};
     62
    6263protected:
    63   const int                     _classID;              //!< The Class-Identifyer of the Factory.
    64   const std::string             _className;            //!< The name of the Class.
     64  const NewClassID              _classID;              //!< The Class-Identifyer of the Factory.
    6565  static std::list<Factory*>*   _factoryList;          //!< List of Registered Factories
    6666};
     
    7878   * @param classID the ID of the Class to be created.
    7979   */
    80   tFactory (const char* factoryName, int classID)
    81       : Factory(factoryName, classID)
     80  tFactory (const NewClassID& classID)
     81      : Factory(classID)
    8282  {  }
    8383
    8484private:
     85  tFactory (const tFactory&) {};
    8586  /**
    8687   * @brief fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*)
Note: See TracChangeset for help on using the changeset viewer.