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 namespace meta
13 {
14 void SystemFactory::create_system(const std::string& name, SystemStack& stack)
15 {
16 const auto hash = math::fnv1a(name.c_str());
17 if (m_factory.contains(hash))
18 {
19 m_factory[hash](stack);
20 }
21 else
22 {
23 GALAXY_LOG(GALAXY_ERROR, "System {0} doesnt exist in factory.", name);
24 }
25 }
26 } // namespace meta
27} // namespace galaxy
#define GALAXY_LOG(level, msg,...)
Definition Log.hpp:29
#define GALAXY_ERROR
Definition Log.hpp:25
void create_system(const std::string &name, SystemStack &stack)
Create a system using the factory.
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.
constexpr bits fnv1a(const char *const str, const bits value=fnv_1a_params< bits >::offset) noexcept
Convert string to hash.
Definition FNV1a.hpp:64
std::vector< std::unique_ptr< systems::System > > SystemStack
Timer.hpp galaxy.
Definition Async.hpp:17