Changeset 9406 in orxonox.OLD for trunk/src/lib/lang
- Timestamp:
- Jul 24, 2006, 11:09:47 AM (18 years ago)
- Location:
- trunk/src/lib/lang
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/lang/base_object.cc
r8145 r9406 21 21 #include "util/loading/load_param.h" 22 22 #include "class_list.h" 23 24 #include "synchronizeable.h"25 26 using namespace std;27 28 23 29 24 /** … … 50 45 ClassList::removeFromClassList(this); 51 46 52 // delete []this->className;53 47 if (this->xmlElem != NULL) 54 48 delete this->xmlElem; … … 61 55 void BaseObject::loadParams(const TiXmlElement* root) 62 56 { 63 // all loadParams should sometime arrive here.57 // all loadParams should arrive here, and be tested for (root != NULL) 64 58 assert (root != NULL); 65 59 60 // copy the xml-element for to know how it was loaded. 66 61 if (this->xmlElem != NULL) 67 62 delete this->xmlElem; 68 63 this->xmlElem = root->Clone(); 64 69 65 // name setup 70 66 LoadParam(root, "name", this, BaseObject, setName) … … 92 88 /** 93 89 * @brief set the name of the Object 90 * @param objectName The new name of the Object. 94 91 */ 95 92 void BaseObject::setName (const std::string& objectName) … … 164 161 * @returns true on match, false otherwise. 165 162 */ 166 bool BaseObject::operator==(const std::string& objectName) 163 bool BaseObject::operator==(const std::string& objectName) const 167 164 { 168 165 return (this->objectName == objectName); 169 166 } 170 167 171 172 /**173 * @brief displays everything this class is174 * @TODO REIMPLEMENT WITH SENSE.175 */176 void BaseObject::whatIs() const177 {178 179 } -
trunk/src/lib/lang/base_object.h
r8362 r9406 1 1 /*! 2 2 * @file base_object.h 3 * Definition of the base object class. 4 5 This is a global handler for all classes. 6 */ 3 * @brief Definition of the BaseObject class. 4 * 5 * This is a global handler for all classes Object and Class names 6 * 7 * BaseObject is the class, that handles object registration and 8 * is the only write-access member of ClassList, where the Objects 9 * References are stored. 10 */ 7 11 8 12 9 #ifndef _ BASE_OBJECT_H10 #define _ BASE_OBJECT_H13 #ifndef __BASE_OBJECT_H_ 14 #define __BASE_OBJECT_H_ 11 15 12 16 #include "class_id.h" 17 #include "sigslot/slot.h" 18 13 19 #include <string> 14 20 … … 18 24 19 25 //! A class all other classes are derived from 20 class BaseObject 26 class BaseObject : public sigslot::has_slots<> 21 27 { 22 28 … … 29 35 void setName (const std::string& newName); 30 36 /** returns the Name of this Object */ 31 inline const char* getName ()const { return this->objectName.c_str(); }; 37 inline const std::string& getName() const { return this->objectName; }; 38 /** returns the Name of this Object as a C-compliant string (const char*) */ 39 inline const char* getCName() const { return this->objectName.c_str(); }; 32 40 /** @returns the XML-Element with whicht this Object was loaded */ 33 41 inline TiXmlNode* getXmlElem() const { return this->xmlElem; }; 34 42 35 43 /** @returns the className of the corresponding Object */ 36 inline const char* getClassName() const { return this->className.c_str(); }; 44 inline const std::string& getClassName() const { return this->className; } 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(); }; 37 47 /** @returns the classID of the corresponding Object */ 38 48 inline int getClassID() const { return this->classID; }; … … 41 51 bool isA (ClassID classID) const; 42 52 bool isA (const std::string& className) const; 43 void whatIs() const;44 53 45 bool operator==(const std::string& objectName);46 54 /** @param classID comparer for a ClassID @returns true on match, false otherwise */ 47 bool operator==(ClassID classID) { return this->isA(classID); }; 55 bool operator==(ClassID classID) const { return this->isA(classID); }; 56 bool operator==(const std::string& objectName) const; 48 57 49 58 protected: … … 54 63 55 64 private: 56 57 65 std::string className; //!< the name of the class 58 66 long classID; //!< this is the id from the class_id.h enumeration … … 64 72 }; 65 73 66 #endif /* _ BASE_OBJECT_H*/74 #endif /* __BASE_OBJECT_H_ */ -
trunk/src/lib/lang/class_list.cc
r8783 r9406 23 23 #include <cmath> 24 24 25 using namespace std; 25 26 26 27 27 /** … … 61 61 { 62 62 if (unlikely(classList == NULL)) 63 ClassList::classList = new list<ClassList>();63 ClassList::classList = new std::list<ClassList>(); 64 64 65 65 PRINTF(5)("subscribe a '%s'\n", className.c_str() ); … … 85 85 void ClassList::removeFromClassList(BaseObject* objectPointer) 86 86 { 87 list<ClassList>::iterator cl;87 std::list<ClassList>::iterator cl; 88 88 for(cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 89 89 { … … 110 110 ClassList::classNames.clear(); 111 111 112 list<ClassList>::const_iterator cl;112 std::list<ClassList>::const_iterator cl; 113 113 for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 114 114 ClassList::classNames.push_back((*cl).className); … … 207 207 std::list<BaseObject*>::iterator bo; 208 208 for (bo = cl->objectList.begin(); bo != cl->objectList.end(); bo++) 209 if ( (*bo)->getName() != NULL &&objectName == (*bo)->getName())209 if (objectName == (*bo)->getName()) 210 210 return (*bo); 211 211 } … … 213 213 else 214 214 { 215 list<ClassList>::iterator cl;215 std::list<ClassList>::iterator cl; 216 216 for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 217 217 { 218 218 std::list<BaseObject*>::iterator bo; 219 219 for (bo = (*cl).objectList.begin(); bo != (*cl).objectList.end(); bo++) 220 if ( (*bo)->getName() != NULL &&objectName == (*bo)->getName())220 if (objectName == (*bo)->getName()) 221 221 return (*bo); 222 222 } … … 241 241 std::list<BaseObject*>::iterator bo; 242 242 for (bo = cl->objectList.begin(); bo != cl->objectList.end(); bo++) 243 if ( (*bo)->getName() != NULL &&objectName == (*bo)->getName())243 if (objectName == (*bo)->getName()) 244 244 return (*bo); 245 245 } … … 268 268 else 269 269 { 270 list<ClassList>::iterator cl;270 std::list<ClassList>::iterator cl; 271 271 for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 272 272 { … … 286 286 std::list<BaseObject*>::iterator bo; 287 287 for (bo = cl->objectList.begin(); bo != cl->objectList.end(); bo++) 288 if ( (*bo)->getName() != NULL &&objectName == (*bo)->getName())288 if (objectName == (*bo)->getName()) 289 289 return true; 290 290 } … … 299 299 void ClassList::whatIs(const BaseObject* object) 300 300 { 301 list<ClassList>::iterator cl;301 std::list<ClassList>::iterator cl; 302 302 for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 303 303 if (object->isA((*cl).classID)) … … 359 359 int lenCount = 0; 360 360 361 list<ClassList>::iterator cl;361 std::list<ClassList>::iterator cl; 362 362 for (cl = ClassList::classList->begin(); cl != ClassList::classList->end(); cl++) 363 363 { … … 377 377 { 378 378 PRINT(0)("| Listing Instances:\n"); 379 list<BaseObject*>::const_iterator bo;379 std::list<BaseObject*>::const_iterator bo; 380 380 for (bo = (*cl).objectList.begin(); bo != (*cl).objectList.end(); bo++) 381 381 { 382 PRINT(0)("| %s::%s::(0x%.8X->%p ", (*bo)->getClass Name(), (*bo)->getName(), (*bo)->getClassID(), (*bo));382 PRINT(0)("| %s::%s::(0x%.8X->%p ", (*bo)->getClassCName(), (*bo)->getCName(), (*bo)->getClassID(), (*bo)); 383 383 if (debugLevel == 3) 384 384 ClassList::whatIs(*bo);
Note: See TracChangeset
for help on using the changeset viewer.