27 lines
671 B
C++
27 lines
671 B
C++
#include "component_registry.h"
|
|
#include <iostream>
|
|
|
|
namespace gencpp {
|
|
namespace registry {
|
|
|
|
ComponentRegistry& ComponentRegistry::Instance() {
|
|
static ComponentRegistry instance;
|
|
return instance;
|
|
}
|
|
|
|
void ComponentRegistry::Register(const std::string& type, ComponentCreator creator) {
|
|
std::cout << "Registering component type: " << type << std::endl;
|
|
m_creators[type] = creator;
|
|
}
|
|
|
|
std::unique_ptr<core::BaseComponent<void*>> ComponentRegistry::Create(const std::string& type) {
|
|
auto it = m_creators.find(type);
|
|
if (it != m_creators.end()) {
|
|
return it->second();
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
} // namespace registry
|
|
} // namespace gencpp
|