| 1 | /*! | 
|---|
| 2 |  * @file base_object.h | 
|---|
| 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 |  */ | 
|---|
| 11 |  | 
|---|
| 12 |  | 
|---|
| 13 | #ifndef __BASE_OBJECT_H_ | 
|---|
| 14 | #define __BASE_OBJECT_H_ | 
|---|
| 15 |  | 
|---|
| 16 | #include "class_id.h" | 
|---|
| 17 | #include <string> | 
|---|
| 18 |  | 
|---|
| 19 | class TiXmlNode; | 
|---|
| 20 | class TiXmlElement; | 
|---|
| 21 | class ClassList; | 
|---|
| 22 |  | 
|---|
| 23 | //! A class all other classes are derived from | 
|---|
| 24 | class BaseObject | 
|---|
| 25 | { | 
|---|
| 26 |  | 
|---|
| 27 | public: | 
|---|
| 28 |   BaseObject (const std::string& objectName = ""); | 
|---|
| 29 |  | 
|---|
| 30 |   virtual ~BaseObject (); | 
|---|
| 31 |  | 
|---|
| 32 |   virtual void loadParams(const TiXmlElement* root); | 
|---|
| 33 |   void setName (const std::string& newName); | 
|---|
| 34 |   /** returns the Name of this Object */ | 
|---|
| 35 |   inline const char* getName ()const { return this->objectName.c_str(); }; | 
|---|
| 36 |   /** @returns the XML-Element with whicht this Object was loaded */ | 
|---|
| 37 |   inline TiXmlNode* getXmlElem() const { return this->xmlElem; }; | 
|---|
| 38 |  | 
|---|
| 39 |   /** @returns the className of the corresponding Object */ | 
|---|
| 40 |   inline const char* getClassName() const { return this->className.c_str(); }; | 
|---|
| 41 |   /** @returns the classID of the corresponding Object */ | 
|---|
| 42 |   inline int getClassID() const { return this->classID; }; | 
|---|
| 43 |   const ClassID& getLeafClassID() const; | 
|---|
| 44 |  | 
|---|
| 45 |   bool isA (ClassID classID) const; | 
|---|
| 46 |   bool isA (const std::string& className) const; | 
|---|
| 47 |  | 
|---|
| 48 |   /** @param classID comparer for a ClassID @returns true on match, false otherwise */ | 
|---|
| 49 |   bool operator==(ClassID classID) const  { return this->isA(classID); }; | 
|---|
| 50 |   bool operator==(const std::string& objectName) const; | 
|---|
| 51 |  | 
|---|
| 52 | protected: | 
|---|
| 53 |   void setClassID(ClassID classID, const std::string& className); | 
|---|
| 54 |  | 
|---|
| 55 | protected: | 
|---|
| 56 |   std::string        objectName;       //!< The name of this object | 
|---|
| 57 |  | 
|---|
| 58 | private: | 
|---|
| 59 |   std::string        className;        //!< the name of the class | 
|---|
| 60 |   long               classID;          //!< this is the id from the class_id.h enumeration | 
|---|
| 61 |   ClassID            leafClassID;      //!< The Leaf Class ID | 
|---|
| 62 |  | 
|---|
| 63 |   ClassList*         classList;        //!< Pointer to the ClassList this Object is inside of | 
|---|
| 64 |  | 
|---|
| 65 |   TiXmlNode*         xmlElem;          //!< The XML Element with wich this Object was loaded(saved). | 
|---|
| 66 | }; | 
|---|
| 67 |  | 
|---|
| 68 | #endif /* __BASE_OBJECT_H_ */ | 
|---|