18 #ifndef __H__OCULAR_CORE_SCENE_COMPONENT_FACTORY__H__
19 #define __H__OCULAR_CORE_SCENE_COMPONENT_FACTORY__H__
21 #include <unordered_map>
53 T* createComponent(std::string
const& name)
56 const auto find = m_ComponentMap.find(name);
58 if(find != m_ComponentMap.end())
60 result = find->second();
70 bool registerComponent(std::string name)
73 const auto find = m_ComponentMap.find(name);
75 if(find == m_ComponentMap.end())
77 m_ComponentMap.insert(std::make_pair(name, [](){
return new S; }));
84 std::vector<std::string> getRegisteredKeys()
const
86 std::vector<std::string> result;
87 result.reserve(m_ComponentMap.size());
89 for(
auto keyvalue : m_ComponentMap)
91 result.emplace_back(keyvalue.first);
101 std::unordered_map<std::string, std::function<T*()>> m_ComponentMap;
Definition: ComponentFactory.hpp:43
Note: Once this library is made dynamic, this will no longer be needed.
Definition: Common.hpp:70