coeng

view src/comp.cc @ 3:66d1762eb203

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 05 Feb 2015 23:20:20 +0200
parents 4a1c9597f4d3
children 49a2e70ac455
line source
1 #include <map>
2 #include <string>
3 #include "comp.h"
5 static std::map<std::string, Component *(*)()> comp_cons;
7 Component::Component()
8 {
9 name = "unknown";
10 gobj = 0;
11 upd_prio = 0;
12 }
14 Component::~Component()
15 {
16 }
18 const char *Component::get_name() const
19 {
20 return name;
21 }
23 void Component::update()
24 {
25 }
27 bool Component::operator <(const Component &c) const
28 {
29 return upd_prio < c.upd_prio;
30 }
33 void register_component(const char *name, Component *(*cons_func)())
34 {
35 if(!comp_cons[name]) {
36 printf("register component: %s\n", name);
37 comp_cons[name] = cons_func;
38 }
39 }
41 Component *create_component(const char *name)
42 {
43 Component *(*cons)() = comp_cons[name];
44 if(cons) {
45 return cons();
46 }
47 return 0;
48 }