Elevate Engine 1
Loading...
Searching...
No Matches
ComponentRegistry.cpp
Go to the documentation of this file.
1#include "eepch.h"
2#include "ComponentRegistry.h"
3
4std::string Elevate::ComponentRegistry::GetName(const std::type_info& type)
5{
6 auto& entries = GetEntries();
7 auto it = entries.find(std::type_index(type));
8 if (it != entries.end()) {
9 return it->second.name;
10 }
11 else {
12 return type.name();
13 }
14}
15
16std::string Elevate::ComponentRegistry::GetCleanedName(std::string rawName)
17{
18 std::string cleanedName = "";
19
20 for (int i = 0; i < rawName.length(); i++)
21 {
22 char c = rawName.at(i); // Current char
23 if (i == 0)
24 {
25 if ((c == 'm' || c == 's' || c == 'g') && rawName.at(i + 1) == '_') // If we have a notation of Hungarian style : m_myVariable
26 {
27 i = 1;
28 continue;
29 }
30 else
31 {
32 cleanedName += std::toupper(c);
33 }
34 }
35 else if (rawName.length() > i + 1 && std::isupper(c) && std::islower(rawName.at(i + 1)))
36 {
37 cleanedName += ' ';
38 cleanedName += c;
39 }
40 else if (std::isalpha(c) && rawName.at(i - 1) == '_')
41 {
42 cleanedName += std::toupper(c);
43 }
44 else if (c == '_')
45 {
46 cleanedName += ' ';
47 }
48 else
49 {
50 cleanedName += c;
51 }
52 }
53
54 return cleanedName;
55}
56
58{
59#ifdef EE_REGISTRY_LOG
60 EE_CORE_INFO("{}", GetCleanedName(newClass));
61#endif
62 CompilationClassStack().push_back(newClass);
63}
64
66{
67 if (CompilationClassStack().empty())
68 {
69 EE_CORE_ERROR("ERROR: Tried to PopClassStack but stack is empty!");
70 return;
71 }
72
73 std::string fullName;
74 for (int i = 0; i < CompilationClassStack().size(); i++)
75 {
76 fullName.append(CompilationClassStack()[i]);
77 if (i != CompilationClassStack().size() - 1)
78 {
79 fullName.append("/");
80 }
81 }
82 CompilationClassStack().pop_back();
83 ClassPaths().push_back(fullName);
84}
static std::unordered_map< std::type_index, Entry > & GetEntries()
static std::string GetCleanedName(std::string rawName)
static void AddClassToStack(std::string newClass)
static std::string GetName(const std::type_info &type)