[4591] | 1 | /*! |
---|
[5039] | 2 | * @file base_object.h |
---|
[4836] | 3 | * Definition of the base object class. |
---|
[4470] | 4 | |
---|
| 5 | This is a global handler for all classes. |
---|
[3302] | 6 | */ |
---|
| 7 | |
---|
| 8 | |
---|
| 9 | #ifndef _BASE_OBJECT_H |
---|
| 10 | #define _BASE_OBJECT_H |
---|
| 11 | |
---|
[4742] | 12 | #include "class_id.h" |
---|
[5511] | 13 | #include "debug.h" |
---|
[4436] | 14 | #ifndef NULL |
---|
[5279] | 15 | #define NULL 0 //!< NULL |
---|
[4436] | 16 | #endif |
---|
[3302] | 17 | |
---|
[6341] | 18 | #include "stdincl.h" |
---|
| 19 | |
---|
[4436] | 20 | class TiXmlElement; |
---|
[6280] | 21 | class ClassList; |
---|
[4436] | 22 | |
---|
[4382] | 23 | //! A class all other classes are derived from |
---|
[3302] | 24 | class BaseObject { |
---|
| 25 | |
---|
| 26 | public: |
---|
[4436] | 27 | BaseObject (const TiXmlElement* root = NULL); |
---|
[3531] | 28 | virtual ~BaseObject (); |
---|
[3302] | 29 | |
---|
[4436] | 30 | void loadParams(const TiXmlElement* root); |
---|
[4539] | 31 | void setName (const char* newName); |
---|
[5113] | 32 | /** returns the Name of this Object */ |
---|
[4746] | 33 | inline const char* getName ()const { return this->objectName; }; |
---|
[4318] | 34 | |
---|
[4836] | 35 | /** @returns the className of the corresponding Object */ |
---|
[4746] | 36 | inline const char* getClassName() const { return this->className; }; |
---|
[4836] | 37 | /** @returns the classID of the corresponding Object */ |
---|
[4933] | 38 | inline int getClassID() const { return this->classID; }; |
---|
[6280] | 39 | ClassID getLeafClassID() const; |
---|
[3302] | 40 | |
---|
[6077] | 41 | bool isA (ClassID classID) const; |
---|
[5513] | 42 | bool isA (const char* className) const; |
---|
[4746] | 43 | void whatIs() const; |
---|
[4470] | 44 | |
---|
[5791] | 45 | bool operator==(const char* objectName); |
---|
[6077] | 46 | /** @param classID comparer for a ClassID @returns true on match, false otherwise */ |
---|
| 47 | bool operator==(ClassID classID) { return this->isA(classID); }; |
---|
[5626] | 48 | |
---|
[6341] | 49 | int writeState(const byte* data, int length, int sender); |
---|
| 50 | int readState(byte* data, int maxLength ); |
---|
[4539] | 51 | protected: |
---|
[5791] | 52 | void setClassID(ClassID classID, const char* className); |
---|
[4539] | 53 | |
---|
[4742] | 54 | private: |
---|
| 55 | const char* className; //!< the name of the class |
---|
[4744] | 56 | long classID; //!< this is the id from the class_id.h enumeration |
---|
[4742] | 57 | char* objectName; //!< The name of this object |
---|
[6280] | 58 | |
---|
| 59 | ClassList* classList; //!< Pointer to the ClassList this Object is inside of |
---|
[3302] | 60 | }; |
---|
| 61 | |
---|
| 62 | #endif /* _BASE_OBJECT_H */ |
---|