Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/lang/class_list.h @ 5845

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

orxonox/trunk: sync

File size: 3.2 KB
RevLine 
[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"
[5779]11#include <list>
[5791]12#ifndef NULL
13#define NULL     0    //!< NULL
14#endif
[4744]15
[5405]16// FORWARD DECLARATION
[4744]17class BaseObject;
[4743]18
[4747]19//! A class that handles Pointers to Objects of all type.
20/**
[4764]21 * here all the Pointers to all the Object of orxonox are stored, that implement BaseObject
22 * for now.
23 * You can get Any Object's Reference to BaseObject with dynamic_cast<T>(ClassList::getObject(name, CL_T_NAME));
24 *  where: T: is the Class to cast to,
25 *   name: the name of the Object (not className)
26 *   CL_T_NAME: the class Identifier, (if CL_NULL or nothing it will take longer, because all BaseObject's are searched through)
27 *
28 * There is also the exists-function, that just checks, if a Reference is still in existence.
29 *
30 * @see ClassID, BaseObject, dynamic_cast
[4747]31 */
[4743]32class ClassList {
33
[4747]34  public:
35    ClassList(const long& classID, const char* className);
36    virtual ~ClassList();
[4743]37
[4756]38    // STATIC FUNCTIONS
[5791]39    static void                           addToClassList(BaseObject* objectPointer, ClassID classID, const char* className);
40    static void                           removeFromClassList(BaseObject* objectPointer);
[4743]41
[5791]42    static std::list<BaseObject*>*        getList(ClassID classID = CL_NULL);// { return (ClassList* fl = ClassList::getClassList(classID) != NULL)? &(fl->objectList) : NULL; };
43    static std::list<BaseObject*>*        getList(const char* className); // { return (ClassList* fl = ClassList::getClassList(className) != NULL)? &(fl->objectList) : NULL;  };
44    static const std::list<const char*>*  getClassNames();
45    static BaseObject*                    getObject(const char* name, ClassID classID = CL_NULL);
46    static bool                           exists(const BaseObject* object, ClassID classID = CL_NULL);
[4754]47
[5791]48    static void                           whatIs(const BaseObject* object);
[5105]49
[5791]50    static const char*                    IDToString(ClassID classID = CL_NULL);
51    static long                           StringToID(const char* className);
52    static void                           debug(unsigned int debugLevel = 0, long classID = CL_NULL);
53    static void                           debugS(const char* className = 0x0, unsigned int debugLevel = 0);
[5113]54
[5821]55    inline bool                           operator==(ClassID classID) { return (this->classID == classID); };
[5791]56    bool                                  operator==(const char* className);
[5113]57
[5791]58  private:
59    static ClassList*                     getClassList(ClassID classID);
60    static ClassList*                     getClassList(const char* className);
[5779]61
[4747]62  private:
[4744]63
[5113]64    long                            classID;                //!< ClassID stored in this ClassList \see ClassID
65    const char*                     className;              //!< Name of the Class Stored here
[4744]66
[5791]67    std::list<BaseObject*>          objectList;             //!< A list of Objects belonging to this Class
[4747]68
[4752]69    // STATIC MEMBERS
[5792]70    static std::list<ClassList>*    classList;              //!< The first Class in the List
[5791]71    static std::list<const char*>   classNames;             //!< a List of all Names of all classes, that have registered so far.
[4743]72};
73
74#endif /* _CLASS_LIST_H */
Note: See TracBrowser for help on using the repository browser.