Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Nov 24, 2005, 12:13:22 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the WorldEntities into the Trunk.
Merged with command:
svn merge branches/world_entities/ trunk/ -r5516:HEAD

conflics from world_entities changed in favor of branches/world_entity
all other conflict in favor of the trunk

Location:
trunk/src/util
Files:
4 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/util/Makefile.am

    r5546 r5750  
    55
    66libORXutils_a_SOURCES = fast_factory.cc \
     7                        object_manager.cc \
    78                        loading/factory.cc \
    89                        garbage_collector.cc \
     
    1819                        track/pilot_node.cc \
    1920                        track/track_manager.cc \
    20                         track/track_node.cc
     21                        track/track_node.cc 
    2122
    2223noinst_HEADERS =        fast_factory.h \
     24                        object_manager.h \
    2325                        garbage_collector.h \
    2426                        state.h \
  • trunk/src/util/fast_factory.cc

    r5041 r5750  
    1313*/
    1414
    15 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_OBJECT_MANAGER
     15#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_LOAD
    1616
    1717#include "fast_factory.h"
  • trunk/src/util/loading/factory.cc

    r5298 r5750  
    3434   set everything to zero and define factoryName
    3535*/
    36 Factory::Factory (const char* factoryName)
     36Factory::Factory (const char* factoryName, ClassID classID)
    3737{
    3838  this->setClassID(CL_FACTORY, "Factory");
     
    4040
    4141  this->next = NULL;
     42  this->classID = classID;
    4243
    4344  Factory::registerFactory(this);
  • trunk/src/util/loading/factory.h

    r5357 r5750  
    3333 * this should be used at the beginning of all the Classes that should be loadable (in the cc-file)
    3434*/
    35 #define CREATE_FACTORY(CLASS_NAME) \
    36     tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>(#CLASS_NAME)
     35#define CREATE_FACTORY(CLASS_NAME, CLASS_ID) \
     36    tFactory<CLASS_NAME>* global_##CLASS_NAME##_Factory = new tFactory<CLASS_NAME>(#CLASS_NAME, CLASS_ID)
    3737
    3838//! The Factory is a loadable object handler
     
    4040
    4141 public:
    42   Factory (const char* factoryName = NULL);
     42  Factory (const char* factoryName = NULL, ClassID classID = CL_NULL);
    4343  virtual ~Factory ();
    4444
    4545  void fabricate(const char* className, const char* entityName);
     46  virtual BaseObject* fabricate(ClassID classID) = NULL;
    4647  virtual BaseObject* fabricate(const TiXmlElement* root) = NULL;
    4748  virtual BaseObject* fabricateDirect() = NULL;
     
    5758    Factory* getNext() const { return this->next; };
    5859
     60
     61  protected:
     62    ClassID           classID;              //!< The CLass-Identifyer of the Factory.
     63
    5964  private:
    6065    Factory*          next;                 //!< pointer to the next factory.
     
    6469/**
    6570 *  a factory that is able to load any kind of Object
    66    (this is a Functor)
    67 */
     71 * (this is a Functor)
     72 */
    6873template<class T> class tFactory : public Factory
    6974{
    70  public:
    71   tFactory(const char* factoryName);
    72   virtual ~tFactory();
     75  public:
     76    tFactory(const char* factoryName, ClassID classID);
     77    virtual ~tFactory();
    7378
    7479  private:
    75   virtual BaseObject* fabricate(const TiXmlElement* root);
    76   virtual BaseObject* fabricateDirect();
     80    virtual BaseObject* fabricate(ClassID classID);
     81    virtual BaseObject* fabricate(const TiXmlElement* root);
     82    virtual BaseObject* fabricateDirect();
    7783};
    7884
     
    8288*/
    8389template<class T>
    84 tFactory<T>::tFactory(const char* factoryName) : Factory(factoryName)
     90    tFactory<T>::tFactory(const char* factoryName, ClassID classID) : Factory(factoryName, classID)
    8591{
    8692  PRINTF(4)("Class: %s loadable\n", this->getName());
    8793}
    8894
    89 
     95/**
     96 * destructs the type-Factory
     97 */
    9098template<class T>
    91 tFactory<T>::~tFactory()
     99    tFactory<T>::~tFactory()
    92100{}
    93101
     102/**
     103 * fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*)
     104 * @param root the TiXmlElement T should load parameters from.
     105 * @return the newly fabricated T, NULL otherwise.
     106 */
    94107template<class T>
    95 BaseObject* tFactory<T>::fabricate(const TiXmlElement* root)
     108    BaseObject* tFactory<T>::fabricate(const TiXmlElement* root)
    96109{
    97110  if (root == NULL)
     
    106119}
    107120
     121
     122/**
     123 * fabricates an Object of type T, with the constructor T::T(const TiXmlElemnt*)
     124 * @param classID the ClassID of T that should be created.
     125 * @return the newly fabricated T if fabricated NULL otherwise.
     126 */
     127template<class T>
     128    BaseObject* tFactory<T>::fabricate(ClassID classID)
     129{
     130  if(classID == this->classID)
     131    return this->fabricateDirect();
     132  else if( getNext() != NULL)
     133    return getNext()->fabricate( classID);
     134  else
     135    return NULL;
     136}
     137
     138/**
     139 * directly fabricate an Entity of this factory.
     140 */
    108141template<class T>
    109142    BaseObject* tFactory<T>::fabricateDirect()
Note: See TracChangeset for help on using the changeset viewer.