Changeset 9709 in orxonox.OLD for branches/new_class_id/src/lib
- Timestamp:
- Aug 31, 2006, 10:51:08 PM (18 years ago)
- 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 1 1 2 2 libORXlibs_a_LIBRARIES_ = \ 3 $(LIB_PREFIX)/util/libORXlibutil.a \4 $(LIB_PREFIX)/shell/libORXshell.a \5 3 $(LIB_PREFIX)/event/libORXevent.a \ 6 4 $(LIB_PREFIX)/gui/qt/libORXqtgui.a \ 7 5 $(LIB_PREFIX)/gui/gl/libORXglgui.a \ 8 6 $(LIB_PREFIX)/gui/libORXbasegui.a \ 9 $(LIB_PREFIX)/script_engine/libORXscript.a \10 $(LIB_PREFIX)/graphics/importer/libORXimporter.a \11 7 $(LIB_PREFIX)/graphics/libORXgraphics.a \ 12 $(LIB_PREFIX)/graphics/importer/libtc.a \13 $(LIB_PREFIX)/sound/libORXsound.a \14 8 $(LIB_PREFIX)/particles/libORXparticles.a \ 15 9 $(LIB_PREFIX)/collision_detection/libORXcd.a \ … … 23 17 $(LIB_PREFIX)/physics/libORXphysics.a \ 24 18 $(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 \ 25 25 $(LIB_PREFIX)/shell/libORXshell.a \ 26 $(LIB_PREFIX)/math/libORXmath.a \ 26 $(LIB_PREFIX)/script_engine/libORXscript.a \ 27 $(LIB_PREFIX)/util/libORXexecutor.a \ 27 28 $(LIB_PREFIX)/util/libORXlibutil.a \ 28 29 $(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 16 16 data/data_tank.h 17 17 18 SUBDIRS = 19 #. \18 SUBDIRS = \ 19 . \ 20 20 math \ 21 21 lang \ -
branches/new_class_id/src/lib/coord/p_node.cc
r9691 r9709 29 29 #include "color.h" 30 30 31 32 NewObjectListDefinition(PNode); 31 33 /** 32 34 * @brief standard constructor -
branches/new_class_id/src/lib/graphics/effects/cloud_effect.cc
r9686 r9709 40 40 float CloudEffect::fadeTime; 41 41 42 NewObjectListDefinitionID(CloudEffect, CL_CLOUD_EFFECT); 42 43 43 44 … … 56 57 57 58 58 CREATE_FACTORY(CloudEffect, CL_CLOUD_EFFECT); 59 NewObjectListDefinitionID(CloudEffect, CL_CLOUD_EFFECT); 59 CREATE_FACTORY(CloudEffect); 60 60 61 61 CloudEffect::CloudEffect(const TiXmlElement* root) { -
branches/new_class_id/src/lib/graphics/effects/fog_effect.cc
r9686 r9709 22 22 #include "cloud_effect.h" 23 23 24 NewObjectListDefinition(FogEffect); 24 25 // Define shell commands 25 26 //SHELL_COMMAND(activate, FogEffect, activateFog); … … 37 38 ); 38 39 39 CREATE_FACTORY(FogEffect, CL_FOG_EFFECT); 40 NewObjectListDefinition(FogEffect); 40 CREATE_FACTORY(FogEffect); 41 41 42 42 /** -
branches/new_class_id/src/lib/graphics/effects/lense_flare.cc
r9686 r9709 35 35 #include "class_id.h" 36 36 37 CREATE_FACTORY(LenseFlare, CL_LENSE_FLARE);38 37 NewObjectListDefinitionID(LenseFlare, CL_LENSE_FLARE); 38 CREATE_FACTORY(LenseFlare); 39 39 40 40 /** -
branches/new_class_id/src/lib/graphics/effects/lightning_effect.cc
r9686 r9709 29 29 #include "class_id.h" 30 30 31 NewObjectListDefinitionID(LightningEffect, CL_LIGHTNING_EFFECT); 32 31 33 SHELL_COMMAND(activate, LightningEffect, activateLightning); 32 34 SHELL_COMMAND(deactivate, LightningEffect, deactivateLightning); … … 37 39 ); 38 40 39 CREATE_FACTORY(LightningEffect, CL_LIGHTNING_EFFECT); 40 NewObjectListDefinitionID(LightningEffect, CL_LIGHTNING_EFFECT); 41 CREATE_FACTORY(LightningEffect); 41 42 42 43 LightningEffect::LightningEffect(const TiXmlElement* root) { -
branches/new_class_id/src/lib/graphics/effects/rain_effect.cc
r9686 r9709 33 33 #include "class_id.h" 34 34 35 NewObjectListDefinitionID(RainEffect, CL_RAIN_EFFECT); 36 35 37 // Define shell commands 36 38 //SHELL_COMMAND(activate, RainEffect, activateRain); … … 48 50 ); 49 51 50 CREATE_FACTORY(RainEffect, CL_RAIN_EFFECT); 51 NewObjectListDefinitionID(RainEffect, CL_RAIN_EFFECT); 52 CREATE_FACTORY(RainEffect); 52 53 53 54 /** -
branches/new_class_id/src/lib/graphics/effects/snow_effect.cc
r9686 r9709 32 32 #include "class_id.h" 33 33 34 NewObjectListDefinitionID(SnowEffect, CL_SNOW_EFFECT); 34 35 SHELL_COMMAND(activate, SnowEffect, activateSnow); 35 36 SHELL_COMMAND(deactivate, SnowEffect, deactivateSnow); … … 41 42 ); 42 43 43 CREATE_FACTORY(SnowEffect, CL_SNOW_EFFECT); 44 NewObjectListDefinitionID(SnowEffect, CL_SNOW_EFFECT); 44 CREATE_FACTORY(SnowEffect); 45 45 46 46 SnowEffect::SnowEffect(const TiXmlElement* root) -
branches/new_class_id/src/lib/graphics/effects/volfog_effect.cc
r9686 r9709 48 48 49 49 #include "class_id.h" 50 51 CREATE_FACTORY(VolFogEffect, CL_VOLFOG_EFFECT);52 50 NewObjectListDefinitionID(VolFogEffect, CL_VOLFOG_EFFECT); 51 CREATE_FACTORY(VolFogEffect); 53 52 54 53 VolFogEffect::VolFogEffect(const TiXmlElement* root) { -
branches/new_class_id/src/lib/graphics/light.cc
r9685 r9709 29 29 #include "class_id.h" 30 30 31 CREATE_FACTORY(Light, CL_LIGHT);32 31 NewObjectListDefinitionID(Light, CL_LIGHT); 32 CREATE_FACTORY(Light); 33 33 34 34 //! Definition of the Lights and their Names -
branches/new_class_id/src/lib/graphics/render2D/image_plane.cc
r9685 r9709 25 25 26 26 #include "class_id.h" 27 CREATE_FACTORY(ImagePlane, CL_IMAGE_ENTITY);28 27 29 NewObjectListDefinitionID(ImagePlane, CL_IMAGE_ENTITY); 28 NewObjectListDefinitionID(ImagePlane, CL_IMAGE_PLANE); 29 CREATE_FACTORY(ImagePlane); 30 30 31 31 -
branches/new_class_id/src/lib/gui/gl/glmenu/glmenu_imagescreen.cc
r9689 r9709 26 26 27 27 #include "class_id.h" 28 CREATE_FACTORY(GLMenuImageScreen, CL_GLMENU_IMAGE_SCREEN);29 28 NewObjectListDefinitionID(GLMenuImageScreen, CL_GLMENU_IMAGE_SCREEN); 29 CREATE_FACTORY(GLMenuImageScreen); 30 30 31 31 /** -
branches/new_class_id/src/lib/lang/base_object.h
r9705 r9709 44 44 //inline const std::string& getClassName() const { return this->className; } 45 45 /** @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(); }; 47 47 /** @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(); }; 49 49 50 50 inline const NewClassID& getClassID() const { return *_leafClassID; } -
branches/new_class_id/src/lib/lang/new_class_id.cc
r9701 r9709 19 19 #include "new_object_list.h" 20 20 21 /** 22 * @brief a Default Constructor. 23 * this Always points to the ID of the NullClass. 24 */ 21 25 NewClassID::NewClassID() 22 26 { 23 *this = NullClass::classID();27 NullClass::acquireID(this->_id, this->_name); 24 28 }; 25 29 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 */ 34 NewClassID::NewClassID(const NewObjectListBase* const objList) 27 35 { 28 29 objList->acquireID(_id, _name); 30 36 objList->acquireID(this->_id, this->_name); 31 37 } 32 38 33 39 34 40 NewClassID NullClass::_classID; 41 42 int NullClass::_nullID; 43 const std::string NullClass::_nullName = std::string("NullClass"); -
branches/new_class_id/src/lib/lang/new_class_id.h
r9701 r9709 12 12 class NewObjectListBase; 13 13 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 */ 15 25 class NewClassID 16 26 { 17 27 public: 18 28 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. */ 21 33 const int& id() const { return *_id; }; 34 /** @returns A constant reference to the Name. */ 22 35 const std::string& name() const { return *_name; }; 23 36 37 /** @param id the id to compare @returns true on match (match is same ID) @brief compares two id's */ 24 38 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 */ 25 40 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 */ 26 42 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 */ 27 44 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 */ 28 46 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 */ 29 48 bool operator!=(const std::string& name) const { return *_name != name; }; 30 49 31 50 private: 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. 34 53 }; 35 54 55 //! A NullClass. This is the Null of the ClassID. 56 /** 57 * implemented as a Class id can be used to reference NullObjects. 58 */ 36 59 class NullClass 37 60 { 38 61 public: 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 40 67 private: 41 NullClass(); 68 NullClass() {}; //!< The Default Constructor is hidden from the User. 69 42 70 private: 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 44 74 }; 45 75 -
branches/new_class_id/src/lib/lang/new_object_list.cc
r9705 r9709 20 20 21 21 22 #include <stdio.h> 23 22 24 /** 23 25 * @brief Constructor, that creates an ObjectList while checking (development mode) for uniqueness of all Keys (names and ID's) … … 27 29 */ 28 30 NewObjectListBase::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); 31 34 if (NewObjectListBase::_classesByID == NULL) 32 35 { … … 47 50 _id = id; 48 51 /// 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; 50 53 51 54 this->_identity = NewClassID(this); … … 98 101 * @return true if such a class already exists. 99 102 */ 103 bool 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 */ 100 113 bool NewObjectListBase::classNameExists(const std::string& name) 101 114 { … … 108 121 * @returns the ClassID if found and NullClass' identity if not. 109 122 */ 110 const NewClassID& NewOb ejctListBase::retrieveIdentity(int id)123 const NewClassID& NewObjectListBase::retrieveIdentity(int id) 111 124 { 112 125 const NewObjectListBase* const base = NewObjectListBase::getObjectList(id); … … 117 130 return NullClass::classID(); 118 131 } 132 119 133 120 134 /** … … 130 144 return base->_identity; 131 145 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(); 144 147 } 145 148 … … 230 233 } 231 234 235 #include "base_object.h" 236 237 /** 238 * @brief Prints out some debugging information about a given List. 239 */ 240 void 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 261 void 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 232 276 233 277 /** -
branches/new_class_id/src/lib/lang/new_object_list.h
r9705 r9709 48 48 class IteratorBase { }; 49 49 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; 52 54 53 55 public: 54 56 /** @returns The Identity of the Class stored within. */ 55 inline const NewClassID& identity() const { return _identity; }57 inline const NewClassID& identity() const { return _identity; } 56 58 /** @returns the ID of the Identity of the ObjectList */ 57 inline int id() const { return _id; };59 inline int id() const { return _id; }; 58 60 /** @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; }; 60 62 /** @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; }; 62 64 /** @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; }; 64 66 /** @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; }; 66 68 /** @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; }; 68 70 /** @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); 73 75 74 76 static const NewObjectListBase* const getObjectList(int classID); … … 76 78 static const NewObjectListBase* const getObjectList(const NewClassID& classID); 77 79 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); 81 83 82 84 /** @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; 84 86 85 87 static const std::list<std::string>& getClassNames(); 86 88 89 87 90 static unsigned int classCount(); 91 void debug(unsigned int level) const; 92 static void debugAll(unsigned int level); 93 88 94 static const std::string& IDToString(int classID); 89 95 static int StringToID(const std::string& className); 90 96 91 virtual void debug() const = 0;92 93 97 //! Only uset to unsubscribe a BaseObject. 94 virtual void unregisterObject(IteratorBase* _iterators) = 0;98 virtual void unregisterObject(IteratorBase* _iterators) = 0; 95 99 96 100 protected: … … 101 105 NewObjectListBase(const NewObjectListBase&); 102 106 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); 105 109 106 110 … … 126 130 //! Defines a ObjectsList handler for objects of type T. 127 131 /** 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 * 128 141 * To define a Class with a ObjectList, you have to: 129 142 * 1. Include 'NewObjectListDeclaration(T);' in its Declaration (at the beginning) … … 132 145 * 133 146 * @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 * 134 165 */ 135 166 template<class T> … … 154 185 ~NewObjectList(); 155 186 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); 176 213 177 214 protected: 178 virtual void getBaseObjectList(NewObjectListBase::base_list* list) const;215 virtual void getBaseObjectList(NewObjectListBase::base_list* list) const; 179 216 180 217 … … 184 221 185 222 private: 186 list _objects; 223 list _objects; //!< The List of stored Objects of Type T. 187 224 }; 188 225 … … 212 249 if (!_objects.empty()) 213 250 { 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"; 216 252 } 217 253 } … … 279 315 NewObjectListBase::IteratorBase* NewObjectList<T>::registerObject(T* object) 280 316 { 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()); 283 319 } 284 320 … … 294 330 } 295 331 296 /**297 * @brief print out some debug information298 * @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() const302 {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 310 332 #endif /* _NEW_OBJECT_LIST_H */ -
branches/new_class_id/src/lib/network/monitor/network_stats_widget.cc
r9691 r9709 29 29 // SHELL_COMMAND(gui, NetworkStatsWidget, toggleGUI) 30 30 // ->setAlias("ProxyGui"); 31 32 NewObjectListDefinition(NetworkStatsWidget);33 31 34 32 HostWidget::HostWidget(const std::string& name, const IP& ip) … … 212 210 //======================================================// 213 211 212 213 NewObjectListDefinition(NetworkStatsWidget); 214 214 /** 215 215 * @brief standard constructor -
branches/new_class_id/src/lib/network/network_stream.cc
r9691 r9709 1194 1194 } 1195 1195 else 1196 1196 ; /// FIXME NEW_CLASS_ID :: b = Factory::fabricate( leafClassId ); 1197 1197 1198 1198 if ( !b ) -
branches/new_class_id/src/lib/network/player_stats.cc
r9691 r9709 32 32 #include "class_id.h" 33 33 34 CREATE_FACTORY(PlayerStats, CL_PLAYER_STATS);35 34 NewObjectListDefinitionID(PlayerStats, CL_PLAYER_STATS); 35 CREATE_FACTORY(PlayerStats); 36 36 37 37 /** -
branches/new_class_id/src/lib/particles/box_emitter.cc
r9686 r9709 26 26 #include "class_id.h" 27 27 28 CREATE_FACTORY(BoxEmitter, CL_BOX_EMITTER);29 28 NewObjectListDefinitionID(BoxEmitter, CL_BOX_EMITTER); 29 CREATE_FACTORY(BoxEmitter); 30 30 31 /** 31 32 * standard constructor -
branches/new_class_id/src/lib/particles/dot_emitter.cc
r9686 r9709 27 27 28 28 #include "class_id.h" 29 CREATE_FACTORY(DotEmitter, CL_DOT_EMITTER);30 29 NewObjectListDefinitionID(DotEmitter, CL_DOT_EMITTER); 30 CREATE_FACTORY(DotEmitter); 31 31 32 32 /** -
branches/new_class_id/src/lib/particles/dot_particles.cc
r9687 r9709 26 26 #include "class_id.h" 27 27 28 CREATE_FACTORY(DotParticles, CL_DOT_PARTICLES);29 28 NewObjectListDefinitionID(DotParticles, CL_DOT_PARTICLES); 29 CREATE_FACTORY(DotParticles); 30 30 31 31 SHELL_COMMAND(texture, DotParticles, setMaterialTexture) -
branches/new_class_id/src/lib/particles/model_particles.cc
r9687 r9709 26 26 #include "class_id.h" 27 27 28 CREATE_FACTORY(ModelParticles, CL_MODEL_PARTICLES);29 28 NewObjectListDefinitionID(ModelParticles, CL_MODEL_PARTICLES); 29 CREATE_FACTORY(ModelParticles); 30 30 31 31 SHELL_COMMAND(texture, ModelParticles, setMaterialTexture) -
branches/new_class_id/src/lib/particles/plane_emitter.cc
r9686 r9709 26 26 #include "class_id.h" 27 27 28 CREATE_FACTORY(PlaneEmitter, CL_PLANE_EMITTER);29 28 NewObjectListDefinitionID(PlaneEmitter, CL_PLANE_EMITTER); 29 CREATE_FACTORY(PlaneEmitter); 30 30 31 31 /** -
branches/new_class_id/src/lib/particles/spark_particles.cc
r9687 r9709 26 26 #include "class_id.h" 27 27 28 CREATE_FACTORY(SparkParticles, CL_SPARK_PARTICLES);29 28 NewObjectListDefinitionID(SparkParticles, CL_SPARK_PARTICLES); 29 CREATE_FACTORY(SparkParticles); 30 30 31 31 /** -
branches/new_class_id/src/lib/particles/sprite_particles.cc
r9687 r9709 26 26 #include "class_id.h" 27 27 28 CREATE_FACTORY(SpriteParticles, CL_SPRITE_PARTICLES);29 28 NewObjectListDefinitionID(SpriteParticles, CL_SPRITE_PARTICLES); 29 CREATE_FACTORY(SpriteParticles); 30 30 31 31 SHELL_COMMAND(texture, SpriteParticles, setMaterialTexture) -
branches/new_class_id/src/lib/physics/fields/gravity.cc
r9686 r9709 24 24 NewObjectListDefinitionID(Gravity, CL_FIELD_GRAVITY); 25 25 26 CREATE_FACTORY(Gravity , CL_FIELD_GRAVITY);26 CREATE_FACTORY(Gravity); 27 27 28 28 Gravity::Gravity(const TiXmlElement* root) -
branches/new_class_id/src/lib/physics/physics_connection.cc
r9686 r9709 28 28 29 29 #include "class_id.h" 30 31 CREATE_FACTORY(PhysicsConnection, CL_PHYSICS_CONNECTION);32 30 NewObjectListDefinition(PhysicsConnection); 31 CREATE_FACTORY(PhysicsConnection); 33 32 /** 34 33 * creates a PhysicsConnection -
branches/new_class_id/src/lib/script_engine/script.cc
r9699 r9709 22 22 #include "loading/load_param.h" 23 23 #include "parser/tinyxml/tinyxml.h" 24 25 NewObjectListDefinition(Script); 24 26 25 27 CREATE_SCRIPTABLE_CLASS(Script, Script::classID(), … … 30 32 ); 31 33 32 NewObjectListDefinition(Script);33 34 34 35 Script::Script(const TiXmlElement* root) -
branches/new_class_id/src/lib/script_engine/script_class.h
r9699 r9709 29 29 public: 30 30 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); }35 31 36 32 virtual void registerClass(Script* script) = 0; -
branches/new_class_id/src/lib/shell/Makefile.am
r7428 r9709 18 18 shell_buffer.h \ 19 19 shell_input.h \ 20 shell_command_class.h \ 20 21 shell_command.h \ 21 shell_command_class.h \22 22 shell_completion.h \ 23 23 shell_completion_plugin.h -
branches/new_class_id/src/lib/shell/shell_command.cc
r9702 r9709 26 26 namespace OrxShell 27 27 { 28 NewObjectListDefinition(ShellCommand); 28 29 SHELL_COMMAND(debug, ShellCommandClass, help); 29 NewObjectListDefinition(ShellCommand);30 30 31 31 -
branches/new_class_id/src/lib/shell/shell_completion.cc
r9697 r9709 141 141 type = ClassCompletion; 142 142 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; 146 148 147 149 return true; -
branches/new_class_id/src/lib/shell/some_shell_commands.cc
r8623 r9709 34 34 SHELL_COMMAND(nick, PlayerStats, shellNick)->setAlias("nick"); 35 35 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); 40 40 41 41 #include "p_node.h" -
branches/new_class_id/src/lib/util/Makefile.am
r9406 r9709 2 2 include $(MAINSRCDIR)/defs/include_paths.am 3 3 4 noinst_LIBRARIES = libORXlibutil.a 4 noinst_LIBRARIES = \ 5 libORXlibutil.a \ 6 libORXexecutor.a 7 8 libORXexecutor_a_SOURCES = \ 9 executor/executor.cc \ 10 executor/executor_functional.cc \ 11 executor/executor_lua.cc 5 12 6 13 libORXlibutil_a_SOURCES = \ … … 9 16 helper_functions.cc \ 10 17 multi_type.cc \ 11 executor/executor.cc \12 executor/executor_functional.cc \13 executor/executor_lua.cc \14 18 \ 15 19 loading/resource_manager.cc \ … … 19 23 loading/load_param_description.cc \ 20 24 loading/factory.cc \ 21 loading/ dynamic_loader.cc \25 loading/fast_factory.cc \ 22 26 \ 23 27 filesys/file.cc \ … … 28 32 threading.cc \ 29 33 timer.cc 34 35 # loading/dynamic_loader.cc 30 36 31 37 … … 55 61 loading/load_param_description.h \ 56 62 loading/factory.h \ 63 loading/fast_factory.h \ 57 64 loading/dynamic_loader.h \ 58 65 \ -
branches/new_class_id/src/lib/util/loading/dynamic_loader.cc
r9684 r9709 31 31 */ 32 32 DynamicLoader::DynamicLoader (const std::string& libName) 33 : Factory( NULL, 0)33 : Factory(libName) 34 34 { 35 35 this->registerObject(this, DynamicLoader::_objectList); -
branches/new_class_id/src/lib/util/loading/factory.cc
r9695 r9709 28 28 * set everything to zero and define factoryName 29 29 */ 30 Factory::Factory (const std::string& factoryName, intclassID)31 : _classID(classID) , _className(factoryName)30 Factory::Factory (const NewClassID& classID) 31 : _classID(classID) 32 32 { 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()); 35 36 36 37 if( Factory::_factoryList == NULL) … … 79 80 } 80 81 81 /**82 * @brief Compares the Factories Name against a given ClassName83 * @param className the Name of the Class to Query84 * @returns true on match, false otherwise.85 */86 bool Factory::operator==(const char* className) const87 {88 return (className != NULL && this->_className == className);89 }90 82 91 83 /** … … 96 88 bool Factory::operator==(const std::string& className) const 97 89 { 98 return (this->_class Name== className);90 return (this->_classID.name() == className); 99 91 } 100 92 … … 143 135 } 144 136 145 146 137 /** 147 138 * @brief Creates a new Object of type classID … … 149 140 * @returns a new Object of Type classID on match, NULL otherwise 150 141 */ 151 BaseObject* Factory::fabricate( intclassID)142 BaseObject* Factory::fabricate(const NewClassID& classID) 152 143 { 153 144 if (Factory::_factoryList == NULL) … … 157 148 for (factory = Factory::_factoryList->begin(); factory != Factory::_factoryList->end(); factory++) 158 149 if (*(*factory) == classID) 159 160 161 150 { 151 PRINTF(4)("Create a new Object of type %s\n", (*factory)->getCName()); 152 return (*factory)->fabricateObject(NULL); 162 153 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()); 165 156 return NULL; 166 157 } 167 168 169 /**170 * @brief Creates a new Object of type classID171 * @param classID the ClassID to match for the newly created Object172 * @returns a new Object of Type classID on match, NULL otherwise173 */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 20 20 21 21 22 #ifndef _ FACTORY_H23 #define _ FACTORY_H22 #ifndef __FACTORY_H 23 #define __FACTORY_H 24 24 25 25 class BaseObject; … … 27 27 #include "parser/tinyxml/tinyxml.h" 28 28 #include "base_object.h" 29 #include <vector>30 29 #include <list> 31 30 … … 34 33 * this should be used at the beginning of all the Classes that should be loadable (in the cc-file) 35 34 */ 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()) 38 37 39 38 //! The Factory is a loadable object handler … … 48 47 static BaseObject* fabricate(const std::string& className); 49 48 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); 52 50 53 51 54 52 bool operator==(int classID) const; 55 bool operator==(const char* className) const;56 53 bool operator==(const std::string& className) const; 54 bool operator==(const NewClassID& classID) const { return _classID == classID; }; 57 55 58 56 protected: 59 Factory (const std::string& factoryName, int classID);57 Factory (const NewClassID& id); 60 58 virtual BaseObject* fabricateObject(const TiXmlElement* root = NULL) const = 0; 61 59 60 private: 61 Factory (const Factory&) {}; 62 62 63 protected: 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. 65 65 static std::list<Factory*>* _factoryList; //!< List of Registered Factories 66 66 }; … … 78 78 * @param classID the ID of the Class to be created. 79 79 */ 80 tFactory (const char* factoryName, intclassID)81 : Factory( factoryName,classID)80 tFactory (const NewClassID& classID) 81 : Factory(classID) 82 82 { } 83 83 84 84 private: 85 tFactory (const tFactory&) {}; 85 86 /** 86 87 * @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 122 122 { 123 123 public: 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); 125 125 126 126 private:
Note: See TracChangeset
for help on using the changeset viewer.