[4743] | 1 | /*! |
---|
[5039] | 2 | * @file class_list.h |
---|
[4836] | 3 | * Definition of the Class List, that handles a Class-Specific-Control structure |
---|
[4743] | 4 | |
---|
[4747] | 5 | */ |
---|
[4743] | 6 | |
---|
| 7 | #ifndef _CLASS_LIST_H |
---|
| 8 | #define _CLASS_LIST_H |
---|
| 9 | |
---|
[4744] | 10 | #include "class_id.h" |
---|
| 11 | |
---|
[4743] | 12 | // FORWARD DEFINITION |
---|
[4744] | 13 | class BaseObject; |
---|
| 14 | template<class T> class tList; |
---|
[4743] | 15 | |
---|
| 16 | |
---|
[4747] | 17 | //! A class that handles Pointers to Objects of all type. |
---|
| 18 | /** |
---|
[4764] | 19 | * here all the Pointers to all the Object of orxonox are stored, that implement BaseObject |
---|
| 20 | * for now. |
---|
| 21 | * You can get Any Object's Reference to BaseObject with dynamic_cast<T>(ClassList::getObject(name, CL_T_NAME)); |
---|
| 22 | * where: T: is the Class to cast to, |
---|
| 23 | * name: the name of the Object (not className) |
---|
| 24 | * CL_T_NAME: the class Identifier, (if CL_NULL or nothing it will take longer, because all BaseObject's are searched through) |
---|
| 25 | * |
---|
| 26 | * There is also the exists-function, that just checks, if a Reference is still in existence. |
---|
| 27 | * |
---|
| 28 | * @see ClassID, BaseObject, dynamic_cast |
---|
[4747] | 29 | */ |
---|
[4743] | 30 | class ClassList { |
---|
| 31 | |
---|
[4747] | 32 | public: |
---|
| 33 | ClassList(const long& classID, const char* className); |
---|
| 34 | virtual ~ClassList(); |
---|
[4743] | 35 | |
---|
[4756] | 36 | // STATIC FUNCTIONS |
---|
[4840] | 37 | static void addToClassList(BaseObject* objectPointer, const long& classID, const char* className); |
---|
| 38 | static void removeFromClassList(BaseObject* objectPointer); |
---|
[4743] | 39 | |
---|
[4840] | 40 | static tList<BaseObject>* getList(long classID = CL_NULL); |
---|
| 41 | static BaseObject* getObject(const char* name, long classID = CL_NULL); |
---|
[4874] | 42 | static bool exists(const BaseObject* object, long classID = CL_NULL); |
---|
[4754] | 43 | |
---|
[4874] | 44 | static void whatIs(const BaseObject* object); |
---|
[4871] | 45 | static void debug(unsigned int debugLevel = 0, long classID = CL_NULL); |
---|
[4743] | 46 | |
---|
[4747] | 47 | private: |
---|
[4752] | 48 | tList<BaseObject>* objectList; //!< A list of Objects belonging to this Class |
---|
[4744] | 49 | |
---|
[4748] | 50 | long classID; //!< ClassID stored in this ClassList \see ClassID |
---|
| 51 | const char* className; //!< Name of the Class Stored here |
---|
[4744] | 52 | |
---|
[4748] | 53 | ClassList* next; //!< Pointer to the next class in the List |
---|
[4747] | 54 | |
---|
[4752] | 55 | // STATIC MEMBERS |
---|
[4782] | 56 | static ClassList* first; //!< The first Class in the List |
---|
[4748] | 57 | static unsigned int classCount; //!< The Count of classes that have been registered (should match the lower description) |
---|
[4743] | 58 | }; |
---|
| 59 | |
---|
| 60 | #endif /* _CLASS_LIST_H */ |
---|