Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/osx/src/lib/lang/class_list.h @ 7914

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

orxonox/trunk: Font Renders nicer now

File size: 3.8 KB
Line 
1/*!
2 * @file class_list.h
3  *  Definition of the Class List, that handles a Class-Specific-Control structure
4
5 */
6
7#ifndef _CLASS_LIST_H
8#define _CLASS_LIST_H
9
10#include "class_id.h"
11#include <list>
12#include <string>
13
14// FORWARD DECLARATION
15class BaseObject;
16
17//! A class that handles Pointers to Objects of all type.
18/**
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
29 */
30class ClassList {
31  public:
32    ClassList(ClassID classID, unsigned long classIDFull, const std::string& className);
33    virtual ~ClassList();
34
35    /* MAINTENANCE FUNCTIONS THESE ARE !!ONLY FOR BASEOBJECT !! */
36    static ClassList*                     addToClassList(BaseObject* objectPointer, ClassID classID, unsigned long classIDFull, const std::string& className);
37    static void                           removeFromClassList(BaseObject* objectPointer);
38
39
40
41    static const std::list<BaseObject*>*  getList(ClassID classID = CL_NULL);// { return (ClassList* fl = ClassList::getClassList(classID) != NULL)? &(fl->objectList) : NULL; };
42    static const std::list<BaseObject*>*  getList(const std::string& className); // { return (ClassList* fl = ClassList::getClassList(className) != NULL)? &(fl->objectList) : NULL;  };
43    static const std::list<std::string>*  getClassNames();
44    static BaseObject*                    getObject(const std::string& name, ClassID classID = CL_NULL);
45    static bool                           exists(const BaseObject* object, ClassID classID = CL_NULL);
46    static bool                           exists(const std::string& className, const std::string& objectName);
47
48    void                                  sendBack(std::list<BaseObject*>::const_iterator it);
49
50    static void                           whatIs(const BaseObject* object);
51
52    static const std::string&             IDToString(ClassID classID = CL_NULL);
53    static ClassID                        StringToID(const std::string& className);
54    static void                           debug(unsigned int debugLevel = 0, ClassID classID = CL_NULL);
55    static void                           debugS(const std::string& className = "", unsigned int debugLevel = 0);
56
57    inline bool                           operator==(ClassID classID) { return (this->classID == classID); };
58    bool                                  operator==(const std::string& className);
59    inline ClassID                        getLeafClassID() const { return this->classID; };
60
61  private:
62    static ClassList*                     getClassList(ClassID classID);
63    static ClassList*                     getClassList(const std::string& className);
64
65  private:
66    ClassID                               classID;                //!< ClassID stored in this ClassList
67    unsigned long                         classIDFull;            //!< The Full ClassID of this Class.
68
69    const std::string                     className;              //!< Name of the Class Stored here
70
71    std::list<BaseObject*>                objectList;             //!< A list of Objects belonging to this Class
72
73    // STATIC MEMBERS
74    static std::list<ClassList>*          classList;              //!< The first Class in the List
75    static std::list<std::string>         classNames;             //!< a List of all Names of all classes, that have registered so far.
76};
77
78#endif /* _CLASS_LIST_H */
Note: See TracBrowser for help on using the repository browser.