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