| 1 | /*! |
|---|
| 2 | \file base_object.h |
|---|
| 3 | \brief Definition of the base object class. |
|---|
| 4 | |
|---|
| 5 | This is a global handler for all classes. |
|---|
| 6 | |
|---|
| 7 | \todo isA() |
|---|
| 8 | */ |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | #ifndef _BASE_OBJECT_H |
|---|
| 12 | #define _BASE_OBJECT_H |
|---|
| 13 | |
|---|
| 14 | #include "class_list.h" |
|---|
| 15 | #ifndef NULL |
|---|
| 16 | #define NULL 0x0 //!< NULL |
|---|
| 17 | #endif |
|---|
| 18 | |
|---|
| 19 | class TiXmlElement; |
|---|
| 20 | |
|---|
| 21 | //! A class all other classes are derived from |
|---|
| 22 | class BaseObject { |
|---|
| 23 | |
|---|
| 24 | public: |
|---|
| 25 | BaseObject (const TiXmlElement* root = NULL); |
|---|
| 26 | virtual ~BaseObject (); |
|---|
| 27 | |
|---|
| 28 | void loadParams(const TiXmlElement* root); |
|---|
| 29 | |
|---|
| 30 | void setName (const char* newName); |
|---|
| 31 | /** \brief returns the Name of this Object */ |
|---|
| 32 | const char* getName (void)const { return this->objectName; }; |
|---|
| 33 | |
|---|
| 34 | /** \returns the className of the corresponding Object */ |
|---|
| 35 | inline const char* getClassName(void) const { return this->className;}; |
|---|
| 36 | /** \returns the classID of the corresponding Object */ |
|---|
| 37 | inline int getClassID(void) const { return this->id; } |
|---|
| 38 | |
|---|
| 39 | // bool isA (char* className); |
|---|
| 40 | |
|---|
| 41 | /** \returns if the object is finalized */ |
|---|
| 42 | inline bool isFinalized() { return this->finalized; } |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | protected: |
|---|
| 46 | void setClassID(int id); |
|---|
| 47 | void setClassName(const char* className); |
|---|
| 48 | void setClassID(int id, const char* className); |
|---|
| 49 | |
|---|
| 50 | /** \brief this finalizes an object and makes it ready to be garbage collected */ |
|---|
| 51 | void finalize(void) { this->finalized = true; }; |
|---|
| 52 | |
|---|
| 53 | private: |
|---|
| 54 | const char* className; //!< the name of the class |
|---|
| 55 | int id; //!< this is the id from the class_list.h enumeration |
|---|
| 56 | bool finalized; //!< is true if the object is ready to be garbage collected |
|---|
| 57 | |
|---|
| 58 | char* objectName; //!< The name of this object |
|---|
| 59 | }; |
|---|
| 60 | |
|---|
| 61 | #endif /* _BASE_OBJECT_H */ |
|---|