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 | inline 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->classID; } |
---|
38 | |
---|
39 | bool isA (ClassID classID) const; |
---|
40 | void whatIs(void) const; |
---|
41 | |
---|
42 | /** \returns if the object is finalized */ |
---|
43 | inline bool isFinalized() { return this->finalized; } |
---|
44 | |
---|
45 | |
---|
46 | protected: |
---|
47 | void setClassID(long classID); |
---|
48 | void setClassName(const char* className); |
---|
49 | void setClassID(long classID, const char* className); |
---|
50 | |
---|
51 | /** \brief this finalizes an object and makes it ready to be garbage collected */ |
---|
52 | void finalize(void) { this->finalized = true; }; |
---|
53 | |
---|
54 | private: |
---|
55 | const char* className; //!< the name of the class |
---|
56 | long classID; //!< this is the id from the class_list.h enumeration |
---|
57 | char* objectName; //!< The name of this object |
---|
58 | |
---|
59 | bool finalized; //!< is true if the object is ready to be garbage collected |
---|
60 | }; |
---|
61 | |
---|
62 | #endif /* _BASE_OBJECT_H */ |
---|