- Timestamp:
- Dec 25, 2005, 2:46:33 PM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/defs/class_id.h
r6279 r6280 35 35 //! list of all classes to be loadable in via the ObjectManager 36 36 /** 37 * inheritance is done in the following way: Classes are identified by38 * a HEX-number eg: 0xa0b18a0539 * The number has 8^4 entries.40 37 * 41 38 * ------------------------------------------------------------------------------------------- -
trunk/src/lib/lang/base_object.cc
r6278 r6280 27 27 28 28 /** 29 * sets the name from a LoadXML-Element29 * @brief sets the name from a LoadXML-Element 30 30 * @param root the element to load from 31 31 */ … … 36 36 37 37 this->objectName = NULL; 38 this->classList = NULL; 38 39 39 40 if (root) … … 44 45 45 46 /** 46 * standard deconstructor47 * @brief standard deconstructor 47 48 */ 48 49 BaseObject::~BaseObject () … … 56 57 57 58 /** 58 * loads parameters59 * @brief loads parameters 59 60 * @param root the element to load from 60 61 */ … … 67 68 68 69 /** 69 * sets the class identifiers70 * @brief sets the class identifiers 70 71 * @param id a number for the class from class_id.h enumeration 71 72 * @param className the class name … … 79 80 this->className = className; 80 81 81 ClassList::addToClassList(this, classID, this->classID, className);82 this->classList = ClassList::addToClassList(this, classID, this->classID, className); 82 83 } 83 84 85 84 86 /** 85 * @brief briefset the name of the Object87 * @brief set the name of the Object 86 88 */ 87 89 void BaseObject::setName (const char* objectName) … … 98 100 } 99 101 102 /** 103 * @brief queries for the ClassID of the Leaf Class (the last made class of this type 104 * @returns the ClassID of the Leaf Class (e.g. the ID of the Class) 105 * 106 * the returned ID can be used to generate new Objects of the same type through 107 * Factory::fabricate(Object->getLeafClassID()); 108 */ 109 ClassID BaseObject::getLeafClassID() const 110 { 111 assert (this->classList != NULL); 112 return this->classList->getLeafClassID(); 113 } 114 115 100 116 101 117 /** 102 * checks if the class is a classID118 * @brief checks if the class is a classID 103 119 * @param classID the Identifier to check for 104 120 * @returns true if it is, false otherwise … … 128 144 } 129 145 146 147 130 148 /** 131 * checks if the class is a classID149 * @brief checks if the class is a classID 132 150 * @param classID the Identifier to check for 133 151 * @returns true if it is, false otherwise … … 140 158 } 141 159 160 142 161 /** 143 * compares the ObjectName with an external name162 * @brief compares the ObjectName with an external name 144 163 * @param objectName: the name to check. 145 164 * @returns true on match, false otherwise. … … 153 172 154 173 /** 155 * displays everything this class is174 * @brief displays everything this class is 156 175 * @TODO REIMPLEMENT WITH SENSE. 157 176 */ 158 177 void BaseObject::whatIs() const 159 178 { 160 PRINT(0)("object %s of class %s: ", this->getName(), this->getClassName()); 161 if ((this->classID & CL_MASK_SINGLETON) == CL_MASK_SINGLETON) 162 PRINT(0)("is a Singleton-Class "); 163 if (this->classID & CL_MASK_SUPER_CLASS) 164 { 165 PRINT(0)(" ->is a derived from the following superclasses:"); 166 if (this->isA(CL_BASE_OBJECT)) 167 PRINT(0)(" =BaseObject="); 168 if (this->isA(CL_PARENT_NODE)) 169 PRINT(0)(" =PNode="); 170 if (this->isA(CL_WORLD_ENTITY)) 171 PRINT(0)(" =WorldEntity="); 172 if (this->isA(CL_PHYSICS_INTERFACE)) 173 PRINT(0)(" =PhysicsInterface="); 174 if (this->isA(CL_EVENT_LISTENER)) 175 PRINT(0)(" =EventListener="); 176 if (this->isA(CL_STORY_ENTITY)) 177 PRINT(0)(" =StoryEntity="); 178 if (this->isA(CL_ELEMENT_2D)) 179 PRINT(0)(" =Element2D="); 180 PRINT(0)("\n"); 181 } 182 // subsuper-classes 183 if (this->classID & CL_MASK_SUBSUPER_CLASS) 184 { 185 PRINT(0)(" ->further derivations: "); 186 if (this->isA(CL_PLAYER)) 187 PRINT(0)(" -Player-"); 188 if (this->isA(CL_NPC)) 189 PRINT(0)(" -NPC-"); 190 if (this->isA(CL_POWER_UP)) 191 PRINT(0)(" -PowerUp-"); 192 if (this->isA(CL_FIELD)) 193 PRINT(0)(" -Field-"); 194 if (this->isA(CL_PROJECTILE)) 195 PRINT(0)(" -Projectile-"); 196 if (this->isA(CL_WEAPON)) 197 PRINT(0)(" -Weapon-"); 198 PRINT(0)("\n"); 179 199 180 } 200 } -
trunk/src/lib/lang/base_object.h
r6077 r6280 17 17 18 18 class TiXmlElement; 19 class ClassList; 19 20 20 21 //! A class all other classes are derived from … … 34 35 /** @returns the classID of the corresponding Object */ 35 36 inline int getClassID() const { return this->classID; }; 37 ClassID getLeafClassID() const; 36 38 37 39 bool isA (ClassID classID) const; … … 50 52 long classID; //!< this is the id from the class_id.h enumeration 51 53 char* objectName; //!< The name of this object 54 55 ClassList* classList; //!< Pointer to the ClassList this Object is inside of 52 56 }; 53 57 -
trunk/src/lib/lang/class_list.cc
r6278 r6280 59 59 60 60 /** 61 * Adds a new Object to the ClassList (and if necessary a new Class)61 * @brief Adds a new Object to the ClassList (and if necessary a new Class) 62 62 * @param objectPointer Pointer to the Object at hand 63 63 * @param classID ID of the Given ObjectType \see ClassID … … 67 67 * !! Before unsing the ClassList, as it creates the ClassLits 68 68 */ 69 voidClassList::addToClassList(BaseObject* objectPointer, ClassID classID, unsigned long classIDFull, const char* className)69 ClassList* ClassList::addToClassList(BaseObject* objectPointer, ClassID classID, unsigned long classIDFull, const char* className) 70 70 { 71 71 if (unlikely(classList == NULL)) … … 76 76 ClassList* regClass = ClassList::getClassList(classID); 77 77 if (regClass != NULL) 78 { 78 79 regClass->objectList.push_back(objectPointer); 80 return regClass; 81 } 79 82 else 80 83 { 81 84 ClassList::classList->push_back(ClassList(classID, classIDFull, className)); 82 85 ClassList::classList->back().objectList.push_back(objectPointer); 86 return &ClassList::classList->back(); 83 87 } 84 88 } -
trunk/src/lib/lang/class_list.h
r6278 r6280 36 36 37 37 /* MAINTENANCE FUNCTIONS THESE ARE !!ONLY FOR BASEOBJECT !! */ 38 static voidaddToClassList(BaseObject* objectPointer, ClassID classID, unsigned long classIDFull, const char* className);38 static ClassList* addToClassList(BaseObject* objectPointer, ClassID classID, unsigned long classIDFull, const char* className); 39 39 static void removeFromClassList(BaseObject* objectPointer); 40 40 … … 58 58 inline bool operator==(ClassID classID) { return (this->classID == classID); }; 59 59 bool operator==(const char* className); 60 inline ClassID getLeafClassID() const { return this->classID; }; 60 61 61 62 private:
Note: See TracChangeset
for help on using the changeset viewer.