coeng

annotate 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
rev   line source
nuclear@0 1 #ifndef COMP_H_
nuclear@0 2 #define COMP_H_
nuclear@0 3
nuclear@1 4 #include <string>
nuclear@0 5
nuclear@6 6 #ifdef NDEBUG
nuclear@6 7 #define COCAST(type, x) ((type*)x)
nuclear@6 8 #else
nuclear@6 9 #define COCAST(type, x) dynamic_cast<type*>(x)
nuclear@6 10 #endif
nuclear@6 11
nuclear@8 12 // for the second arg of the various gobj_co_whatever() functions
nuclear@8 13 #define COGET_NOFAIL true
nuclear@8 14 #define COGET_FAIL false
nuclear@8 15
nuclear@6 16 class GObject;
nuclear@1 17
nuclear@0 18 class Component {
nuclear@1 19 protected:
nuclear@2 20 const char *name;
nuclear@6 21 GObject *gobj;
nuclear@6 22
nuclear@6 23 /* attach/detach to a particular GObject.
nuclear@6 24 * This is only called from GObject::add_component and
nuclear@6 25 * GObject::remove_component respectively
nuclear@6 26 */
nuclear@6 27 virtual void attach(GObject *gobj);
nuclear@6 28 virtual void detach();
nuclear@6 29
nuclear@6 30 /* Returns an array of component names which depend on this and
nuclear@6 31 * must not be updated first if both exist in the same object.
nuclear@6 32 * Terminated by a null pointer.
nuclear@6 33 */
nuclear@6 34 virtual const char **update_before() const;
nuclear@1 35
nuclear@0 36 public:
nuclear@2 37 Component();
nuclear@2 38 virtual ~Component();
nuclear@1 39
nuclear@1 40 const char *get_name() const;
nuclear@8 41 GObject *get_object() const;
nuclear@1 42
nuclear@6 43 virtual void update(float dt);
nuclear@6 44 virtual void draw() const;
nuclear@1 45
nuclear@6 46 friend class GObject;
nuclear@1 47 };
nuclear@1 48
nuclear@2 49 void register_component(const char *name, Component *(*cons_func)());
nuclear@2 50 Component *create_component(const char *name);
nuclear@0 51
nuclear@0 52 #endif // COMP_H_