| 71 | |
| 72 | template < typename DerivedClass > |
| 73 | static void register_creator( Key key ) |
| 74 | { |
| 75 | static_assert( std::is_base_of_v< BaseClass, DerivedClass >, |
| 76 | "DerivedClass is not a subclass of BaseClass" ); |
| 77 | static_assert( std::is_constructible_v< DerivedClass, Args... >, |
| 78 | "DerivedClass is not constructible with Args..." ); |
| 79 | auto &store = get_store(); |
| 80 | if( !store |
| 81 | .emplace( std::move( key ), |
| 82 | Creator( create_function_impl< DerivedClass > ) ) |
| 83 | .second ) |
| 84 | { |
| 85 | Logger::warn( |
| 86 | "Factory: Trying to register twice the same key" ); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | [[nodiscard]] static std::unique_ptr< BaseClass > create( |
| 91 | const Key &key, Args... args ) |