coeng
view src/comp.h @ 10:305c8f6abef1
the plane doesn't need a PRS really
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 15 Feb 2015 05:25:04 +0200 |
parents | 2f872a179914 |
children |
line source
1 #ifndef COMP_H_
2 #define COMP_H_
4 #include <string>
6 #ifdef NDEBUG
7 #define COCAST(type, x) ((type*)x)
8 #else
9 #define COCAST(type, x) dynamic_cast<type*>(x)
10 #endif
12 // for the second arg of the various gobj_co_whatever() functions
13 #define COGET_NOFAIL true
14 #define COGET_FAIL false
16 class GObject;
18 class Component {
19 protected:
20 const char *name;
21 GObject *gobj;
23 /* attach/detach to a particular GObject.
24 * This is only called from GObject::add_component and
25 * GObject::remove_component respectively
26 */
27 virtual void attach(GObject *gobj);
28 virtual void detach();
30 /* Returns an array of component names which depend on this and
31 * must not be updated first if both exist in the same object.
32 * Terminated by a null pointer.
33 */
34 virtual const char **update_before() const;
36 public:
37 Component();
38 virtual ~Component();
40 const char *get_name() const;
41 GObject *get_object() const;
43 virtual void update(float dt);
44 virtual void draw() const;
46 friend class GObject;
47 };
49 void register_component(const char *name, Component *(*cons_func)());
50 Component *create_component(const char *name);
52 #endif // COMP_H_