[4591] | 1 | /*! |
---|
[5039] | 2 | * @file base_object.h |
---|
[9347] | 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 | */ |
---|
[4470] | 11 | |
---|
[3302] | 12 | |
---|
[9347] | 13 | #ifndef __BASE_OBJECT_H_ |
---|
| 14 | #define __BASE_OBJECT_H_ |
---|
[3302] | 15 | |
---|
[4742] | 16 | #include "class_id.h" |
---|
[8035] | 17 | #include <string> |
---|
[3302] | 18 | |
---|
[9361] | 19 | #include "sigslot/slot.h" |
---|
| 20 | |
---|
[6517] | 21 | class TiXmlNode; |
---|
[4436] | 22 | class TiXmlElement; |
---|
[6280] | 23 | class ClassList; |
---|
[4436] | 24 | |
---|
[4382] | 25 | //! A class all other classes are derived from |
---|
[9361] | 26 | class BaseObject : public sigslot::has_slots<> |
---|
[8350] | 27 | { |
---|
[3302] | 28 | |
---|
[8350] | 29 | public: |
---|
| 30 | BaseObject (const std::string& objectName = ""); |
---|
[7779] | 31 | |
---|
[3531] | 32 | virtual ~BaseObject (); |
---|
[3302] | 33 | |
---|
[6512] | 34 | virtual void loadParams(const TiXmlElement* root); |
---|
[7221] | 35 | void setName (const std::string& newName); |
---|
[5113] | 36 | /** returns the Name of this Object */ |
---|
[9371] | 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(); }; |
---|
[6587] | 40 | /** @returns the XML-Element with whicht this Object was loaded */ |
---|
| 41 | inline TiXmlNode* getXmlElem() const { return this->xmlElem; }; |
---|
[4318] | 42 | |
---|
[4836] | 43 | /** @returns the className of the corresponding Object */ |
---|
[9371] | 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(); }; |
---|
[4836] | 47 | /** @returns the classID of the corresponding Object */ |
---|
[4933] | 48 | inline int getClassID() const { return this->classID; }; |
---|
[7954] | 49 | const ClassID& getLeafClassID() const; |
---|
[3302] | 50 | |
---|
[6077] | 51 | bool isA (ClassID classID) const; |
---|
[7221] | 52 | bool isA (const std::string& className) const; |
---|
[4470] | 53 | |
---|
[6077] | 54 | /** @param classID comparer for a ClassID @returns true on match, false otherwise */ |
---|
[9347] | 55 | bool operator==(ClassID classID) const { return this->isA(classID); }; |
---|
| 56 | bool operator==(const std::string& objectName) const; |
---|
[5626] | 57 | |
---|
[8350] | 58 | protected: |
---|
| 59 | void setClassID(ClassID classID, const std::string& className); |
---|
[4539] | 60 | |
---|
[8350] | 61 | protected: |
---|
| 62 | std::string objectName; //!< The name of this object |
---|
[6280] | 63 | |
---|
[8350] | 64 | private: |
---|
| 65 | std::string className; //!< the name of the class |
---|
| 66 | long classID; //!< this is the id from the class_id.h enumeration |
---|
| 67 | ClassID leafClassID; //!< The Leaf Class ID |
---|
| 68 | |
---|
| 69 | ClassList* classList; //!< Pointer to the ClassList this Object is inside of |
---|
| 70 | |
---|
| 71 | TiXmlNode* xmlElem; //!< The XML Element with wich this Object was loaded(saved). |
---|
[3302] | 72 | }; |
---|
| 73 | |
---|
[9347] | 74 | #endif /* __BASE_OBJECT_H_ */ |
---|