nuclear@4: #include nuclear@2: #include nuclear@2: #include nuclear@2: #include "comp.h" nuclear@2: nuclear@4: static std::map *early_comp_cons; nuclear@2: static std::map comp_cons; nuclear@2: nuclear@2: Component::Component() nuclear@2: { nuclear@2: name = "unknown"; nuclear@2: gobj = 0; nuclear@2: upd_prio = 0; nuclear@2: } nuclear@2: nuclear@2: Component::~Component() nuclear@2: { nuclear@2: } nuclear@2: nuclear@2: const char *Component::get_name() const nuclear@2: { nuclear@2: return name; nuclear@2: } nuclear@2: nuclear@2: void Component::update() nuclear@2: { nuclear@2: } nuclear@2: nuclear@2: bool Component::operator <(const Component &c) const nuclear@2: { nuclear@2: return upd_prio < c.upd_prio; nuclear@2: } nuclear@2: nuclear@2: nuclear@2: void register_component(const char *name, Component *(*cons_func)()) nuclear@2: { nuclear@4: if(!early_comp_cons) { nuclear@4: early_comp_cons = new std::map; nuclear@4: } nuclear@4: nuclear@4: if(!(*early_comp_cons)[name]) { nuclear@3: printf("register component: %s\n", name); nuclear@4: (*early_comp_cons)[name] = cons_func; nuclear@3: } nuclear@2: } nuclear@2: nuclear@2: Component *create_component(const char *name) nuclear@2: { nuclear@4: if(early_comp_cons) { nuclear@4: comp_cons = std::move(*early_comp_cons); nuclear@4: delete early_comp_cons; nuclear@4: early_comp_cons = 0; nuclear@4: } nuclear@4: nuclear@2: Component *(*cons)() = comp_cons[name]; nuclear@2: if(cons) { nuclear@2: return cons(); nuclear@2: } nuclear@2: return 0; nuclear@2: }