/*! * @file base_object.h * Definition of the base object class. This is a global handler for all classes. */ #ifndef _BASE_OBJECT_H #define _BASE_OBJECT_H #include "class_id.h" #include "debug.h" #ifndef NULL #define NULL 0 //!< NULL #endif #include #include "stdincl.h" class TiXmlNode; class TiXmlElement; class ClassList; //! A class all other classes are derived from class BaseObject { public: BaseObject (); virtual ~BaseObject (); virtual void loadParams(const TiXmlElement* root); void setName (const std::string& newName); /** returns the Name of this Object */ inline const char* getName ()const { return this->objectName.c_str(); }; /** @returns the XML-Element with whicht this Object was loaded */ inline TiXmlNode* getXmlElem() const { return this->xmlElem; }; /** @returns the className of the corresponding Object */ inline const char* getClassName() const { return this->className.c_str(); }; /** @returns the classID of the corresponding Object */ inline int getClassID() const { return this->classID; }; ClassID getLeafClassID() const; bool isA (ClassID classID) const; bool isA (const std::string& className) const; void whatIs() const; bool operator==(const std::string& objectName); /** @param classID comparer for a ClassID @returns true on match, false otherwise */ bool operator==(ClassID classID) { return this->isA(classID); }; int writeState(const byte* data, int length, int sender); int readState(byte* data, int maxLength ); protected: void setClassID(ClassID classID, const std::string& className); private: std::string className; //!< the name of the class long classID; //!< this is the id from the class_id.h enumeration std::string objectName; //!< The name of this object ClassList* classList; //!< Pointer to the ClassList this Object is inside of TiXmlNode* xmlElem; //!< The XML Element with wich this Object was loaded(saved). }; #endif /* _BASE_OBJECT_H */