Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9709 in orxonox.OLD for branches/new_class_id/src/lib


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

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

Location:
branches/new_class_id/src/lib
Files:
40 edited
2 moved

Legend:

Unmodified
Added
Removed
  • branches/new_class_id/src/lib/BuildLibs.am

    r9668 r9709  
    11
    22libORXlibs_a_LIBRARIES_ = \
    3                 $(LIB_PREFIX)/util/libORXlibutil.a \
    4                 $(LIB_PREFIX)/shell/libORXshell.a \
    53                $(LIB_PREFIX)/event/libORXevent.a \
    64                $(LIB_PREFIX)/gui/qt/libORXqtgui.a \
    75                $(LIB_PREFIX)/gui/gl/libORXglgui.a \
    86                $(LIB_PREFIX)/gui/libORXbasegui.a \
    9                 $(LIB_PREFIX)/script_engine/libORXscript.a \
    10                 $(LIB_PREFIX)/graphics/importer/libORXimporter.a \
    117                $(LIB_PREFIX)/graphics/libORXgraphics.a \
    12                 $(LIB_PREFIX)/graphics/importer/libtc.a \
    13                 $(LIB_PREFIX)/sound/libORXsound.a \
    148                $(LIB_PREFIX)/particles/libORXparticles.a \
    159                $(LIB_PREFIX)/collision_detection/libORXcd.a \
     
    2317                $(LIB_PREFIX)/physics/libORXphysics.a \
    2418                $(LIB_PREFIX)/gui/gl/libORXglgui.a \
     19                \
     20                $(LIB_PREFIX)/util/libORXlibutil.a \
     21                \
     22                $(LIB_PREFIX)/graphics/importer/libORXimporter.a \
     23                $(LIB_PREFIX)/graphics/importer/libtc.a \
     24                $(LIB_PREFIX)/sound/libORXsound.a \
    2525                $(LIB_PREFIX)/shell/libORXshell.a \
    26                 $(LIB_PREFIX)/math/libORXmath.a \
     26                $(LIB_PREFIX)/script_engine/libORXscript.a \
     27                $(LIB_PREFIX)/util/libORXexecutor.a \
    2728                $(LIB_PREFIX)/util/libORXlibutil.a \
    2829                $(LIB_PREFIX)/lang/libORXlang.a \
    29                 $(LIB_PREFIX)/libORXlibs.a
     30                $(LIB_PREFIX)/libORXlibs.a \
     31                $(LIB_PREFIX)/math/libORXmath.a
  • branches/new_class_id/src/lib/Makefile.am

    r9705 r9709  
    1616                data/data_tank.h
    1717
    18 SUBDIRS =
    19 #       . \
     18SUBDIRS = \
     19        . \
    2020        math \
    2121        lang \
  • branches/new_class_id/src/lib/coord/p_node.cc

    r9691 r9709  
    2929#include "color.h"
    3030
     31
     32NewObjectListDefinition(PNode);
    3133/**
    3234 * @brief standard constructor
  • branches/new_class_id/src/lib/graphics/effects/cloud_effect.cc

    r9686 r9709  
    4040float     CloudEffect::fadeTime;
    4141
     42NewObjectListDefinitionID(CloudEffect, CL_CLOUD_EFFECT);
    4243
    4344
     
    5657
    5758
    58 CREATE_FACTORY(CloudEffect, CL_CLOUD_EFFECT);
    59 NewObjectListDefinitionID(CloudEffect, CL_CLOUD_EFFECT);
     59CREATE_FACTORY(CloudEffect);
    6060
    6161CloudEffect::CloudEffect(const TiXmlElement* root) {
  • branches/new_class_id/src/lib/graphics/effects/fog_effect.cc

    r9686 r9709  
    2222#include "cloud_effect.h"
    2323
     24NewObjectListDefinition(FogEffect);
    2425// Define shell commands
    2526//SHELL_COMMAND(activate, FogEffect, activateFog);
     
    3738                       );
    3839
    39 CREATE_FACTORY(FogEffect, CL_FOG_EFFECT);
    40 NewObjectListDefinition(FogEffect);
     40CREATE_FACTORY(FogEffect);
    4141
    4242/**
  • branches/new_class_id/src/lib/graphics/effects/lense_flare.cc

    r9686 r9709  
    3535#include "class_id.h"
    3636
    37 CREATE_FACTORY(LenseFlare, CL_LENSE_FLARE);
    3837NewObjectListDefinitionID(LenseFlare, CL_LENSE_FLARE);
     38CREATE_FACTORY(LenseFlare);
    3939
    4040/**
  • branches/new_class_id/src/lib/graphics/effects/lightning_effect.cc

    r9686 r9709  
    2929#include "class_id.h"
    3030
     31NewObjectListDefinitionID(LightningEffect, CL_LIGHTNING_EFFECT);
     32
    3133SHELL_COMMAND(activate, LightningEffect, activateLightning);
    3234SHELL_COMMAND(deactivate, LightningEffect, deactivateLightning);
     
    3739                       );
    3840
    39 CREATE_FACTORY(LightningEffect, CL_LIGHTNING_EFFECT);
    40 NewObjectListDefinitionID(LightningEffect, CL_LIGHTNING_EFFECT);
     41CREATE_FACTORY(LightningEffect);
    4142
    4243LightningEffect::LightningEffect(const TiXmlElement* root) {
  • branches/new_class_id/src/lib/graphics/effects/rain_effect.cc

    r9686 r9709  
    3333#include "class_id.h"
    3434
     35NewObjectListDefinitionID(RainEffect, CL_RAIN_EFFECT);
     36
    3537// Define shell commands
    3638//SHELL_COMMAND(activate, RainEffect, activateRain);
     
    4850                       );
    4951
    50 CREATE_FACTORY(RainEffect, CL_RAIN_EFFECT);
    51 NewObjectListDefinitionID(RainEffect, CL_RAIN_EFFECT);
     52CREATE_FACTORY(RainEffect);
    5253
    5354/**
  • branches/new_class_id/src/lib/graphics/effects/snow_effect.cc

    r9686 r9709  
    3232#include "class_id.h"
    3333
     34NewObjectListDefinitionID(SnowEffect, CL_SNOW_EFFECT);
    3435SHELL_COMMAND(activate, SnowEffect, activateSnow);
    3536SHELL_COMMAND(deactivate, SnowEffect, deactivateSnow);
     
    4142                       );
    4243
    43 CREATE_FACTORY(SnowEffect, CL_SNOW_EFFECT);
    44 NewObjectListDefinitionID(SnowEffect, CL_SNOW_EFFECT);
     44CREATE_FACTORY(SnowEffect);
    4545
    4646SnowEffect::SnowEffect(const TiXmlElement* root)
  • branches/new_class_id/src/lib/graphics/effects/volfog_effect.cc

    r9686 r9709  
    4848
    4949#include "class_id.h"
    50 
    51 CREATE_FACTORY(VolFogEffect, CL_VOLFOG_EFFECT);
    5250NewObjectListDefinitionID(VolFogEffect, CL_VOLFOG_EFFECT);
     51CREATE_FACTORY(VolFogEffect);
    5352
    5453VolFogEffect::VolFogEffect(const TiXmlElement* root) {
  • branches/new_class_id/src/lib/graphics/light.cc

    r9685 r9709  
    2929#include "class_id.h"
    3030
    31 CREATE_FACTORY(Light, CL_LIGHT);
    3231NewObjectListDefinitionID(Light, CL_LIGHT);
     32CREATE_FACTORY(Light);
    3333
    3434//! Definition of the Lights and their Names
  • branches/new_class_id/src/lib/graphics/render2D/image_plane.cc

    r9685 r9709  
    2525
    2626#include "class_id.h"
    27 CREATE_FACTORY(ImagePlane, CL_IMAGE_ENTITY);
    2827
    29 NewObjectListDefinitionID(ImagePlane, CL_IMAGE_ENTITY);
     28NewObjectListDefinitionID(ImagePlane, CL_IMAGE_PLANE);
     29CREATE_FACTORY(ImagePlane);
    3030
    3131
  • branches/new_class_id/src/lib/gui/gl/glmenu/glmenu_imagescreen.cc

    r9689 r9709  
    2626
    2727#include "class_id.h"
    28 CREATE_FACTORY(GLMenuImageScreen, CL_GLMENU_IMAGE_SCREEN);
    2928NewObjectListDefinitionID(GLMenuImageScreen, CL_GLMENU_IMAGE_SCREEN);
     29CREATE_FACTORY(GLMenuImageScreen);
    3030
    3131/**
  • branches/new_class_id/src/lib/lang/base_object.h

    r9705 r9709  
    4444  //inline const std::string& getClassName() const { return this->className; }
    4545  /** @returns the className of the corresponding Object as a C-compliant string (const char*) */
    46   inline const char* getClassCName() const { return this->className.c_str(); };
     46  inline const char* getClassCName() const { return _classes.front()._objectList->name().c_str(); };
    4747  /** @returns the ClassName of the Topmost Object of the ClassStack */
    48   inline const std::string& getClassName() const { return _classes.front()._objectList->name(); }
     48  inline const std::string& getClassName() const { return _classes.front()._objectList->name(); };
    4949
    5050  inline const NewClassID& getClassID() const { return *_leafClassID; }
  • branches/new_class_id/src/lib/lang/new_class_id.cc

    r9701 r9709  
    1919#include "new_object_list.h"
    2020
     21/**
     22 * @brief a Default Constructor.
     23 * this Always points to the ID of the NullClass.
     24 */
    2125NewClassID::NewClassID()
    2226{
    23   *this = NullClass::classID();
     27  NullClass::acquireID(this->_id, this->_name);
    2428};
    2529
    26 NewClassID::NewClassID(const NewObjectListBase* objList)
     30/**
     31 * @brief Acquiring the ID of a objectList.
     32 * @param objList The NewObjectList to acquire the ID from.
     33 */
     34NewClassID::NewClassID(const NewObjectListBase* const objList)
    2735{
    28 
    29   objList->acquireID(_id, _name);
    30 
     36  objList->acquireID(this->_id, this->_name);
    3137}
    3238
    3339
    3440NewClassID NullClass::_classID;
     41
     42int NullClass::_nullID;
     43const std::string NullClass::_nullName = std::string("NullClass");
  • branches/new_class_id/src/lib/lang/new_class_id.h

    r9701 r9709  
    1212class NewObjectListBase;
    1313
    14 //! A class to dynamically allocate ClassID's and support a isA operator
     14//! A class to dynamically allocate ClassID's and to support a isA operator
     15/**
     16 * A NewClassID can only be aquired over a NewObjectList,
     17 * thus enabling the developer to have permanent access to the correct ID and ClassName
     18 *
     19 * The Idea behind this concept is, that storing a NewClassID that changes its internal state
     20 * all NewClassID's will be updated correctly.
     21 *
     22 * Since the Existance of any NewObjectList is a requirement during the working process all
     23 * ID's should reference a valid ID and ClassName
     24 */
    1525class NewClassID
    1626{
    1727public:
    1828  NewClassID();
    19   NewClassID(const NewObjectListBase* id);
    20   // the copy constructor is also defined.
     29  NewClassID(const NewObjectListBase* const id);
     30  /// the copy constructor is also defined implicitely.
     31
     32  /** @returns A constant reference to the ID. */
    2133  const int& id() const { return *_id; };
     34  /** @returns A constant reference to the Name. */
    2235  const std::string& name() const { return *_name; };
    2336
     37  /** @param id the id to compare @returns true on match (match is same ID) @brief compares two id's */
    2438  bool operator==(const NewClassID& id) const { return *_id == *id._id /* || _name == id._name */; };
     39  /** @param id the id to compare @returns true on match (match is same ID) @brief compares two id's */
    2540  bool operator==(int id) const { return *_id == id; };
     41  /** @param name the id to compare @returns true on match (match is same Name) @brief compares an ID with a ClassName */
    2642  bool operator==(const std::string& name) const { return *_name == name; };
     43  /** @param id the id to compare @returns false on match (match is same ID) @brief compares two id's */
    2744  bool operator!=(const NewClassID& id) const { return *_id != *id._id /* && _name != id._name*/;  };
     45  /** @param id the id to compare @returns false on match (match is same ID) @brief compares two id's */
    2846  bool operator!=(int id) const { return *_id != id; };
     47  /** @param name the id to compare @returns false on match (match is same Name) @brief compares an ID with a ClassName */
    2948  bool operator!=(const std::string& name) const { return *_name != name; };
    3049
    3150private:
    32   const int*                _id;
    33   const std::string*        _name;
     51  const int*                _id;           //!< A pointer to the ID of the ClassID.
     52  const std::string*        _name;         //!< A pointer to the Name of the ClassID.
    3453};
    3554
     55//! A NullClass. This is the Null of the ClassID.
     56/**
     57 * implemented as a Class id can be used to reference NullObjects.
     58 */
    3659class NullClass
    3760{
    3861public:
    39   static NewClassID classID() { return NullClass::_classID; }
     62  /** @returns the NullClass' ID. */
     63  static const NewClassID& classID() { return NullClass::_classID; }
     64  /** @param id the ID to acquire @param name the name to acquire @brief acquires the ID of this Class */
     65  static void acquireID(const int*& id, const std::string*& name) { id = &_nullID; name = &_nullName; };
     66
    4067private:
    41   NullClass();
     68  NullClass() {}; //!< The Default Constructor is hidden from the User.
     69
    4270private:
    43   static NewClassID _classID;
     71  static NewClassID         _classID;      //!< The NullClass' ID
     72  static const std::string  _nullName;     //!< The NullClass' Name ("NullClass")
     73  static int                _nullID;       //!< The NullClass' ID
    4474};
    4575
  • branches/new_class_id/src/lib/lang/new_object_list.cc

    r9705 r9709  
    2020
    2121
     22#include <stdio.h>
     23
    2224/**
    2325 * @brief Constructor, that creates an ObjectList while checking (development mode) for uniqueness of all Keys (names and ID's)
     
    2729 */
    2830NewObjectListBase::NewObjectListBase(const std::string& className, int id)
    29   : _name(className)
    30 {
     31    : _name(className)
     32{
     33  printf("NewObjectList, Registered %s::%d\n", className.c_str(), id);
    3134  if (NewObjectListBase::_classesByID == NULL)
    3235  {
     
    4750  _id = id;
    4851  /// Some Output, that will fall out later
    49   //std::cout << "register new ObjectList " << className << " ID: " << this->_id << std::endl;
     52  std::cout << "register new ObjectList " << className << " ID: " << this->_id << std::endl;
    5053
    5154  this->_identity = NewClassID(this);
     
    98101 * @return true if such a class already exists.
    99102 */
     103bool NewObjectListBase::classIDExists(int id)
     104{
     105  return (NewObjectListBase::_classesByID->find(id) != NewObjectListBase::_classesByID->end());
     106}
     107
     108/**
     109 * @brief Checks if a Class with name already exists.
     110 * @param name The Name of the Class to check.
     111 * @return true if such a class already exists.
     112 */
    100113bool NewObjectListBase::classNameExists(const std::string& name)
    101114{
     
    108121 * @returns the ClassID if found and NullClass' identity if not.
    109122 */
    110 const NewClassID& NewObejctListBase::retrieveIdentity(int id)
     123const NewClassID& NewObjectListBase::retrieveIdentity(int id)
    111124{
    112125  const NewObjectListBase* const base = NewObjectListBase::getObjectList(id);
     
    117130    return NullClass::classID();
    118131}
     132
    119133
    120134/**
     
    130144    return base->_identity;
    131145  else
    132     return NullObject::classID();
    133 }
    134 
    135 
    136 /**
    137  * @brief Checks if a Class with name already exists.
    138  * @param name The Name of the Class to check.
    139  * @return true if such a class already exists.
    140  */
    141 bool NewObjectListBase::classIDExists(int id)
    142 {
    143   return (NewObjectListBase::_classesByID->find(id) != NewObjectListBase::_classesByID->end());
     146    return NullClass::classID();
    144147}
    145148
     
    230233}
    231234
     235#include "base_object.h"
     236
     237/**
     238 * @brief Prints out some debugging information about a given List.
     239 */
     240void NewObjectListBase::debug(unsigned int level) const
     241{
     242  base_list list;
     243  this->getBaseObjectList(&list);
     244
     245  if (level > 1 || !list.empty())
     246    printf(" ObjectList of class %s(id:%d) contains %d objects\n", this->name().c_str(), this->id(), list.size());
     247
     248  if (level >= 2)
     249  {
     250    printf("  - listing Instances: \n");
     251    for (base_iterator it = list.begin();
     252         it != list.end();
     253         ++it)
     254    {
     255      printf("   + %s::%s\n", (*it)->getClassCName(), (*it)->getCName());
     256    }
     257  }
     258}
     259
     260
     261void NewObjectListBase::debugAll(unsigned int level)
     262{
     263  printf("Listing all %d ObjectLists \n", NewObjectListBase::_classesByID->size());
     264
     265  for (classNameMap::const_iterator it = NewObjectListBase::_classesByName->begin();
     266       it != NewObjectListBase::_classesByName->end();
     267       ++it)
     268  {
     269    (*it).second->debug(level);
     270
     271  }
     272
     273}
     274
     275
    232276
    233277/**
  • branches/new_class_id/src/lib/lang/new_object_list.h

    r9705 r9709  
    4848  class IteratorBase { };
    4949
    50   typedef std::list<BaseObject*>            base_list;
    51   typedef base_list::iterator               base_iterator;
     50  /** @brief A Typedefinition for the Base-List that can be retrieved with getBaseObjectList(base_list*) */
     51  typedef std::list<BaseObject*>        base_list;
     52  /** @brief An iterator for the base_list */
     53  typedef base_list::iterator           base_iterator;
    5254
    5355public:
    5456  /** @returns The Identity of the Class stored within. */
    55   inline const NewClassID& identity() const { return _identity; }
     57  inline const NewClassID&              identity() const { return _identity; }
    5658  /** @returns the ID of the Identity of the ObjectList */
    57   inline int id() const { return _id; };
     59  inline int                            id() const { return _id; };
    5860  /** @returns The Name of the Class stored in this ObjectList */
    59   inline const std::string& name() const { return _name; };
     61  inline const std::string&             name() const { return _name; };
    6062  /** @param id The id to compare @returns true on match, false otherwise */
    61   inline bool operator==(int id) const { return _id == id; };
     63  inline bool                           operator==(int id) const { return _id == id; };
    6264  /** @param id The id to compare @returns true on match, false otherwise */
    63   inline bool operator==(const NewClassID& id) const { return id == _id; };
     65  inline bool                           operator==(const NewClassID& id) const { return id == _id; };
    6466  /** @param name The name to compare @returns true on match, false otherwise */
    65   inline bool operator==(const std::string& name) const { return _name == name; };
     67  inline bool                           operator==(const std::string& name) const { return _name == name; };
    6668  /** @param id The id to check @returns true on match, false otherwise */
    67   inline void acquireID(const int*& id, const std::string*& name) const { id = &_id; name = &_name; };
     69  inline void                           acquireID(const int*& id, const std::string*& name) const { id = &_id; name = &_name; };
    6870  /** @brief fills a list of Objects into a BaseObject*-List. @param list the list to fill */
    69   virtual void getBaseObjectList(base_list* list) const = 0;
    70 
    71   static const NewClassID& retrieveIdentity(int id);
    72   static const NewClassID& retrieveIdentity(const std::string& name);
     71  virtual void                          getBaseObjectList(base_list* list) const = 0;
     72
     73  static const NewClassID&              retrieveIdentity(int id);
     74  static const NewClassID&              retrieveIdentity(const std::string& name);
    7375
    7476  static const NewObjectListBase* const getObjectList(int classID);
     
    7678  static const NewObjectListBase* const getObjectList(const NewClassID& classID);
    7779
    78   static BaseObject* getBaseObject(int classID, const std::string& objectName);
    79   static BaseObject* getBaseObject(const std::string& className, const std::string& objectName);
    80   static BaseObject* getBaseObject(const NewClassID& classID, const std::string& objectName);
     80  static BaseObject*                    getBaseObject(int classID, const std::string& objectName);
     81  static BaseObject*                    getBaseObject(const std::string& className, const std::string& objectName);
     82  static BaseObject*                    getBaseObject(const NewClassID& classID, const std::string& objectName);
    8183
    8284  /** @returns an Object with Name name out of this List @param name the name of the Object. */
    83   virtual BaseObject* getBaseObject(const std::string& name) const = 0;
     85  virtual BaseObject*                   getBaseObject(const std::string& name) const = 0;
    8486
    8587  static const std::list<std::string>&  getClassNames();
    8688
     89
    8790  static unsigned int                   classCount();
     91  void                                  debug(unsigned int level) const;
     92  static void                           debugAll(unsigned int level);
     93
    8894  static const std::string&             IDToString(int classID);
    8995  static int                            StringToID(const std::string& className);
    9096
    91   virtual void debug() const = 0;
    92 
    9397  //! Only uset to unsubscribe a BaseObject.
    94   virtual void unregisterObject(IteratorBase* _iterators) = 0;
     98  virtual void                          unregisterObject(IteratorBase* _iterators) = 0;
    9599
    96100protected:
     
    101105  NewObjectListBase(const NewObjectListBase&);
    102106
    103   static bool classIDExists(int id);
    104   static bool classNameExists(const std::string& className);
     107  static bool                         classIDExists(int id);
     108  static bool                         classNameExists(const std::string& className);
    105109
    106110
     
    126130//! Defines a ObjectsList handler for objects of type T.
    127131/**
     132 * The ObjectList is a generic way to store every object created from a Class 'T'
     133 *  into a List. The list can be retrieved, and used constantly over iterators,
     134 *  as with normal std::list.
     135 *
     136 * Furthermore the linkage over the single Lists is given over the Superclass NewObjectListBase.
     137 *
     138 *
     139 *
     140 *
    128141 * To define a Class with a ObjectList, you have to:
    129142 *  1. Include 'NewObjectListDeclaration(T);' in its Declaration (at the beginning)
     
    132145 *
    133146 * @note The Class must define the compare with const std::string& operator for this to work.
     147 *
     148 *
     149 *
     150 * Limitations:
     151 *  ObjectList cannot be used with other Factory style Classes, if the class is also a BaseObject,
     152 *   and not loaded before the ObjectList.
     153 *
     154 * @example Iterating: Iteration is made easy, and fast as follows:
     155 *   for (NewObjectList<PlayerStats>::const_iterator it = PlayerStats::objectList().begin();
     156 *      it != PlayerStats::objectList().end();
     157 *     ++it)
     158 *   {
     159 *    (*it)->dosomething
     160 *   }
     161 *
     162 * @example Find an Object:
     163 * Playable* playable = Playable::objectList("orxonox-super-rocket-fighter"); // searches an Object By its name.
     164 *
    134165 */
    135166template<class T>
     
    154185  ~NewObjectList();
    155186
    156   virtual BaseObject*     getBaseObject(const std::string& name) const;
    157   T*                      getObject(const std::string& name) const;
    158   inline const list&      objects() const { return _objects; };
    159   bool exists(const T* const object) const;
    160 
    161   inline iterator begin() { return _objects.begin(); };
    162   inline const_iterator begin() const { return _objects.begin(); };
    163   inline iterator  end() { return _objects.end(); };
    164   inline const_iterator  end() const { return _objects.end(); };
    165 
    166   inline bool empty() const { return _objects.empty(); };
    167   inline int size() const { return _objects.size(); };
    168   inline T* front() const { return _objects.front(); };
    169   inline T* back() const { return _objects.back(); };
    170 
    171 
    172   NewObjectListBase::IteratorBase* registerObject(T* object);
    173   virtual void unregisterObject(IteratorBase* iterator);
    174 
    175   virtual void debug() const;
     187  virtual BaseObject*                getBaseObject(const std::string& name) const;
     188  T*                                 getObject(const std::string& name) const;
     189  inline const list&                 objects() const { return _objects; };
     190  bool                               exists(const T* const object) const;
     191
     192  /** @returns an Iterator to the beginning of the List. */
     193  inline iterator                    begin() { return _objects.begin(); };
     194  /** @returns a constant Iterator to the beginning of the List. */
     195  inline const_iterator              begin() const { return _objects.begin(); };
     196  /** @returns an Iterator to the end of the List. */
     197  inline iterator                    end() { return _objects.end(); };
     198  /** @returns a constant Iterator to the beginning of the List. */
     199  inline const_iterator              end() const { return _objects.end(); };
     200
     201  /** @returns true if the List is empty. */
     202  inline bool                        empty() const { return _objects.empty(); };
     203  /** @returns the size of the List */
     204  inline int                         size() const { return _objects.size(); };
     205  /** @returns the frontmost Element of the list (normaly the last added Object). */
     206  inline T*                          front() const { return _objects.front(); };
     207  /** @returns the last added Object */
     208  inline T*                          back() const { return _objects.back(); };
     209
     210
     211  NewObjectListBase::IteratorBase*   registerObject(T* object);
     212  virtual void                       unregisterObject(IteratorBase* iterator);
    176213
    177214protected:
    178   virtual void getBaseObjectList(NewObjectListBase::base_list* list) const;
     215  virtual void                       getBaseObjectList(NewObjectListBase::base_list* list) const;
    179216
    180217
     
    184221
    185222private:
    186   list                _objects;
     223  list                _objects;     //!< The List of stored Objects of Type T.
    187224};
    188225
     
    212249  if (!_objects.empty())
    213250  {
    214     std::cout << "There are still Object in the ObjectList of " << this->name() << "(id:" << this->id() << ")\n";
    215     this->debug();
     251    // std::cout << "There are " << this->size() << " objects from class " << this->name() << "(id:" << this->id() << ") in existance\n";
    216252  }
    217253}
     
    279315NewObjectListBase::IteratorBase* NewObjectList<T>::registerObject(T* object)
    280316{
    281   this->_objects.push_front(object);
    282   return new Iterator(this->_objects.begin());
     317  this->_objects.push_back(object);
     318  return new Iterator(--this->_objects.end());
    283319}
    284320
     
    294330}
    295331
    296 /**
    297  * @brief print out some debug information
    298  * @note this function will most probably vanish from here and be completely moved to the base class.
    299  */
    300 template <class T>
    301 void NewObjectList<T>::debug() const
    302 {
    303   const_iterator it;
    304   for (it = this->_objects.begin(); it != this->_objects.end(); ++it)
    305   {
    306     std::cout << (*it)->getName() << std::endl;
    307   }
    308 }
    309 
    310332#endif /* _NEW_OBJECT_LIST_H */
  • branches/new_class_id/src/lib/network/monitor/network_stats_widget.cc

    r9691 r9709  
    2929// SHELL_COMMAND(gui, NetworkStatsWidget, toggleGUI)
    3030// ->setAlias("ProxyGui");
    31 
    32 NewObjectListDefinition(NetworkStatsWidget);
    3331
    3432HostWidget::HostWidget(const std::string& name, const IP& ip)
     
    212210//======================================================//
    213211
     212
     213NewObjectListDefinition(NetworkStatsWidget);
    214214/**
    215215 * @brief standard constructor
  • branches/new_class_id/src/lib/network/network_stream.cc

    r9691 r9709  
    11941194          }
    11951195          else
    1196             b = Factory::fabricate( leafClassId );
     1196            ; /// FIXME NEW_CLASS_ID :: b = Factory::fabricate( leafClassId );
    11971197
    11981198          if ( !b )
  • branches/new_class_id/src/lib/network/player_stats.cc

    r9691 r9709  
    3232#include "class_id.h"
    3333
    34 CREATE_FACTORY(PlayerStats, CL_PLAYER_STATS);
    3534NewObjectListDefinitionID(PlayerStats, CL_PLAYER_STATS);
     35CREATE_FACTORY(PlayerStats);
    3636
    3737/**
  • branches/new_class_id/src/lib/particles/box_emitter.cc

    r9686 r9709  
    2626#include "class_id.h"
    2727
    28 CREATE_FACTORY(BoxEmitter, CL_BOX_EMITTER);
    2928NewObjectListDefinitionID(BoxEmitter, CL_BOX_EMITTER);
     29CREATE_FACTORY(BoxEmitter);
     30
    3031/**
    3132 *  standard constructor
  • branches/new_class_id/src/lib/particles/dot_emitter.cc

    r9686 r9709  
    2727
    2828#include "class_id.h"
    29 CREATE_FACTORY(DotEmitter, CL_DOT_EMITTER);
    3029NewObjectListDefinitionID(DotEmitter, CL_DOT_EMITTER);
     30CREATE_FACTORY(DotEmitter);
    3131
    3232/**
  • branches/new_class_id/src/lib/particles/dot_particles.cc

    r9687 r9709  
    2626#include "class_id.h"
    2727
    28 CREATE_FACTORY(DotParticles, CL_DOT_PARTICLES);
    2928NewObjectListDefinitionID(DotParticles, CL_DOT_PARTICLES);
     29CREATE_FACTORY(DotParticles);
    3030
    3131SHELL_COMMAND(texture, DotParticles, setMaterialTexture)
  • branches/new_class_id/src/lib/particles/model_particles.cc

    r9687 r9709  
    2626#include "class_id.h"
    2727
    28 CREATE_FACTORY(ModelParticles, CL_MODEL_PARTICLES);
    2928NewObjectListDefinitionID(ModelParticles, CL_MODEL_PARTICLES);
     29CREATE_FACTORY(ModelParticles);
    3030
    3131SHELL_COMMAND(texture, ModelParticles, setMaterialTexture)
  • branches/new_class_id/src/lib/particles/plane_emitter.cc

    r9686 r9709  
    2626#include "class_id.h"
    2727
    28 CREATE_FACTORY(PlaneEmitter, CL_PLANE_EMITTER);
    2928NewObjectListDefinitionID(PlaneEmitter, CL_PLANE_EMITTER);
     29CREATE_FACTORY(PlaneEmitter);
    3030
    3131/**
  • branches/new_class_id/src/lib/particles/spark_particles.cc

    r9687 r9709  
    2626#include "class_id.h"
    2727
    28 CREATE_FACTORY(SparkParticles, CL_SPARK_PARTICLES);
    2928NewObjectListDefinitionID(SparkParticles, CL_SPARK_PARTICLES);
     29CREATE_FACTORY(SparkParticles);
    3030
    3131/**
  • branches/new_class_id/src/lib/particles/sprite_particles.cc

    r9687 r9709  
    2626#include "class_id.h"
    2727
    28 CREATE_FACTORY(SpriteParticles, CL_SPRITE_PARTICLES);
    2928NewObjectListDefinitionID(SpriteParticles, CL_SPRITE_PARTICLES);
     29CREATE_FACTORY(SpriteParticles);
    3030
    3131SHELL_COMMAND(texture, SpriteParticles, setMaterialTexture)
  • branches/new_class_id/src/lib/physics/fields/gravity.cc

    r9686 r9709  
    2424NewObjectListDefinitionID(Gravity, CL_FIELD_GRAVITY);
    2525
    26 CREATE_FACTORY(Gravity, CL_FIELD_GRAVITY);
     26CREATE_FACTORY(Gravity);
    2727
    2828Gravity::Gravity(const TiXmlElement* root)
  • branches/new_class_id/src/lib/physics/physics_connection.cc

    r9686 r9709  
    2828
    2929#include "class_id.h"
    30 
    31 CREATE_FACTORY(PhysicsConnection, CL_PHYSICS_CONNECTION);
    3230NewObjectListDefinition(PhysicsConnection);
     31CREATE_FACTORY(PhysicsConnection);
    3332/**
    3433 *  creates a PhysicsConnection
  • branches/new_class_id/src/lib/script_engine/script.cc

    r9699 r9709  
    2222#include "loading/load_param.h"
    2323#include "parser/tinyxml/tinyxml.h"
     24
     25NewObjectListDefinition(Script);
    2426
    2527CREATE_SCRIPTABLE_CLASS(Script, Script::classID(),
     
    3032                     );
    3133
    32 NewObjectListDefinition(Script);
    3334
    3435Script::Script(const TiXmlElement* root)
  • branches/new_class_id/src/lib/script_engine/script_class.h

    r9699 r9709  
    2929public:
    3030  virtual ~ScriptClass();
    31 
    32   const std::string& getName() const { return this->getName(); }
    33   bool operator==(const std::string& name) const { return (this->getName() == name); }
    34   bool operator==(NewClassID classID) const { return (this->_classID == classID); }
    3531
    3632  virtual void registerClass(Script* script) = 0;
  • branches/new_class_id/src/lib/shell/Makefile.am

    r7428 r9709  
    1818                shell_buffer.h \
    1919                shell_input.h \
     20                shell_command_class.h \
    2021                shell_command.h \
    21                 shell_command_class.h \
    2222                shell_completion.h \
    2323                shell_completion_plugin.h
  • branches/new_class_id/src/lib/shell/shell_command.cc

    r9702 r9709  
    2626namespace OrxShell
    2727{
     28  NewObjectListDefinition(ShellCommand);
    2829  SHELL_COMMAND(debug, ShellCommandClass, help);
    29   NewObjectListDefinition(ShellCommand);
    3030
    3131
  • branches/new_class_id/src/lib/shell/shell_completion.cc

    r9697 r9709  
    141141      type = ClassCompletion;
    142142
    143     /// FIXME
    144 //     if (!this->addToCompleteList(*boList, objectBegin, type))
    145 //       return false;
     143    NewObjectListBase::base_list list;
     144    objectList->getBaseObjectList(&list);
     145
     146    if (!this->addToCompleteList(list, objectBegin, type))
     147     return false;
    146148
    147149    return true;
  • branches/new_class_id/src/lib/shell/some_shell_commands.cc

    r8623 r9709  
    3434  SHELL_COMMAND(nick, PlayerStats, shellNick)->setAlias("nick");
    3535
    36 #include "class_list.h"
    37   SHELL_COMMAND(debug, ClassList, ClassList::debugS)
    38       ->describe("Shows all registered classes, if param1: is a valid ClassName only values of this class are shown. param2: how much output")
    39       ->defaultValues(MT_NULL, 1);
     36// #include "class_list.h"
     37//   SHELL_COMMAND(debug, ClassList, ClassList::debugS)
     38//       ->describe("Shows all registered classes, if param1: is a valid ClassName only values of this class are shown. param2: how much output")
     39//       ->defaultValues(MT_NULL, 1);
    4040
    4141#include "p_node.h"
  • branches/new_class_id/src/lib/util/Makefile.am

    r9406 r9709  
    22include $(MAINSRCDIR)/defs/include_paths.am
    33
    4 noinst_LIBRARIES = libORXlibutil.a
     4noinst_LIBRARIES = \
     5                libORXlibutil.a \
     6                libORXexecutor.a
     7
     8libORXexecutor_a_SOURCES = \
     9                executor/executor.cc \
     10                executor/executor_functional.cc \
     11                executor/executor_lua.cc
    512
    613libORXlibutil_a_SOURCES = \
     
    916                helper_functions.cc \
    1017                multi_type.cc \
    11                 executor/executor.cc \
    12                 executor/executor_functional.cc \
    13                 executor/executor_lua.cc \
    1418                \
    1519                loading/resource_manager.cc \
     
    1923                loading/load_param_description.cc \
    2024                loading/factory.cc \
    21                 loading/dynamic_loader.cc \
     25                loading/fast_factory.cc \
    2226                \
    2327                filesys/file.cc \
     
    2832                threading.cc \
    2933                timer.cc
     34
     35#               loading/dynamic_loader.cc
    3036
    3137
     
    5561                loading/load_param_description.h \
    5662                loading/factory.h \
     63                loading/fast_factory.h \
    5764                loading/dynamic_loader.h \
    5865                \
  • branches/new_class_id/src/lib/util/loading/dynamic_loader.cc

    r9684 r9709  
    3131*/
    3232DynamicLoader::DynamicLoader (const std::string& libName)
    33     : Factory(NULL, 0)
     33    : Factory(libName)
    3434{
    3535  this->registerObject(this, DynamicLoader::_objectList);
  • branches/new_class_id/src/lib/util/loading/factory.cc

    r9695 r9709  
    2828 * set everything to zero and define factoryName
    2929 */
    30 Factory::Factory (const std::string& factoryName, int classID)
    31     : _classID(classID), _className(factoryName)
     30Factory::Factory (const NewClassID& classID)
     31    : _classID(classID)
    3232{
    33   this->registerObject(this, Factory::_objectList);
    34   this->setName(factoryName);
     33  printf("Factory::create(%s::%d)\n", classID.name().c_str(), classID.id());
     34  //this->registerObject(this, Factory::_objectList);
     35  this->setName(classID.name());
    3536
    3637  if( Factory::_factoryList == NULL)
     
    7980}
    8081
    81 /**
    82  * @brief Compares the Factories Name against a given ClassName
    83  * @param className the Name of the Class to Query
    84  * @returns true on match, false otherwise.
    85  */
    86 bool Factory::operator==(const char* className) const
    87 {
    88   return (className != NULL && this->_className == className);
    89 }
    9082
    9183/**
     
    9688bool Factory::operator==(const std::string& className) const
    9789{
    98   return (this->_className == className);
     90  return (this->_classID.name() == className);
    9991}
    10092
     
    143135}
    144136
    145 
    146137/**
    147138 * @brief Creates a new Object of type classID
     
    149140 * @returns a new Object of Type classID on match, NULL otherwise
    150141 */
    151 BaseObject* Factory::fabricate(int classID)
     142BaseObject* Factory::fabricate(const NewClassID& classID)
    152143{
    153144  if (Factory::_factoryList == NULL)
     
    157148  for (factory = Factory::_factoryList->begin(); factory != Factory::_factoryList->end(); factory++)
    158149    if (*(*factory) == classID)
    159     {
    160       PRINTF(4)("Create a new Object of type %s\n", (*factory)->getCName());
    161       return (*factory)->fabricateObject(NULL);
     150  {
     151    PRINTF(4)("Create a new Object of type %s\n", (*factory)->getCName());
     152    return (*factory)->fabricateObject(NULL);
    162153
    163     }
    164   PRINTF(2)("Could not Fabricate an Object of ClassID '0x%h'\n", classID);
     154  }
     155  PRINTF(2)("Could not Fabricate an Object of ClassID '%d'\n", classID.id());
    165156  return NULL;
    166157}
    167 
    168 
    169 /**
    170  * @brief Creates a new Object of type classID
    171  * @param classID the ClassID to match for the newly created Object
    172  * @returns a new Object of Type classID on match, NULL otherwise
    173  */
    174 BaseObject* Factory::fabricate(const NewClassID& classID)
    175 {
    176   return Factory::fabricate(classID.id());
    177 }
  • 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*)
  • branches/new_class_id/src/lib/util/loading/fast_factory.h

    r9707 r9709  
    122122{
    123123public:
    124   static tFastFactory<T>* getFastFactory(const NewClassID& classID, const std::string& fastFactoryName = NULL);
     124  static tFastFactory<T>* getFastFactory(const NewClassID& classID, const std::string& fastFactoryName);
    125125
    126126private:
Note: See TracChangeset for help on using the changeset viewer.