CSEngine
Loading...
Searching...
No Matches
ReflectionMgr.cpp
1#include "ReflectionMgr.h"
2#include "../Object/Base/ReflectionObject.h"
3
4using namespace CSE;
5
6ReflectionMgr::ReflectionMgr() = default;
7
8ReflectionMgr::~ReflectionMgr() = default;
9
10void ReflectionMgr::Init() {
11 for (auto* node = ReflectionMgr::m_defineWrapper.m_defined;;) {
12 if (node == nullptr) break;
13 auto* node_next = node->m_next;
14 m_reflected[node->m_name] = node->m_func;
15 node = node_next;
16 }
17}
18
19ReflectionObject* ReflectionMgr::CreateObject(const std::string& type) {
20 const auto& func = m_reflected.find(type);
21 if(func == m_reflected.end()) return nullptr;
22 return func->second();
23}