Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/lang/base_object.h @ 6517

Last change on this file since 6517 was 6517, checked in by bensch, 19 years ago

orxonox/trunk: each BaseObject saves its TiXmlElement as a TiXmlNode*.
This will be good for
1.) sync in network
2.) saving entitites

File size: 1.9 KB
Line 
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#ifndef NULL
15#define NULL     0    //!< NULL
16#endif
17
18#include "stdincl.h"
19
20class TiXmlNode;
21class TiXmlElement;
22class ClassList;
23
24//! A class all other classes are derived from
25class BaseObject {
26
27 public:
28  BaseObject ();
29  virtual ~BaseObject ();
30
31  virtual void loadParams(const TiXmlElement* root);
32  void setName (const char* newName);
33  /** returns the Name of this Object */
34  inline const char* getName ()const { return this->objectName; };
35
36  /** @returns the className of the corresponding Object */
37  inline const char* getClassName() const { return this->className; };
38  /** @returns the classID of the corresponding Object */
39  inline int getClassID() const { return this->classID; };
40  ClassID    getLeafClassID() const;
41
42  bool isA (ClassID classID) const;
43  bool isA (const char* className) const;
44  void whatIs() const;
45
46  bool operator==(const char* objectName);
47  /** @param classID comparer for a ClassID @returns true on match, false otherwise */
48  bool operator==(ClassID classID) { return this->isA(classID); };
49
50  int       writeState(const byte* data, int length, int sender);
51  int       readState(byte* data, int maxLength );
52
53 protected:
54  void setClassID(ClassID classID, const char* className);
55
56 private:
57    const char*        className;        //!< the name of the class
58    long               classID;          //!< this is the id from the class_id.h enumeration
59    char*              objectName;       //!< The name of this object
60
61    ClassList*         classList;        //!< Pointer to the ClassList this Object is inside of
62
63    TiXmlNode*         xmlElem;          //!< The XML Element with wich this Object was loaded(saved).
64};
65
66#endif /* _BASE_OBJECT_H */
Note: See TracBrowser for help on using the repository browser.