galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
SystemFactory.cpp
Go to the documentation of this file.
1
7
8#include "SystemFactory.hpp"
9
10namespace galaxy
11{
12 void SystemFactory::create_system(const std::string& name, SystemStack& stack)
13 {
14 const auto hash = math::fnv1a(name.c_str());
15 if (m_factory.contains(hash))
16 {
17 m_factory[hash](stack);
18 }
19 else
20 {
21 GALAXY_LOG(GALAXY_ERROR, "System '{0}' is not registered.", name);
22 }
23 }
24} // namespace galaxy
#define GALAXY_LOG(level, msg,...)
Definition Log.hpp:28
#define GALAXY_ERROR
Definition Log.hpp:24
ankerl::unordered_dense::map< std::uint64_t, std::move_only_function< void(SystemStack &)> > m_factory
Lets us construct a system class from a string representation.
void create_system(const std::string &name, SystemStack &stack)
Create a system using the factory.
constexpr bits fnv1a(const char *const str, const bits value=fnv_1a_params< bits >::offset) noexcept
Convert string to hash.
Definition FNV1a.hpp:64
Animated.cpp galaxy.
Definition Animated.cpp:16
std::vector< std::shared_ptr< System > > SystemStack
System stack typedef.