Factory for creating components from configuration.
More...
#include <ComponentFactory.hpp>
|
| void | Register (const std::string &type_name, Creator creator) |
| | Register a component type with custom creator.
|
| std::unique_ptr< Component< Scalar > > | Create (const ComponentConfig &config) |
| | Create a component from config.
|
| bool | HasType (const std::string &type_name) const |
| | Check if a type is registered.
|
| std::vector< std::string > | GetRegisteredTypes () const |
| | Get list of registered type names.
|
| std::size_t | NumRegistered () const |
| | Get number of registered types.
|
| void | Clear () |
| | Clear all registrations (for testing).
|
|
| static ComponentFactory & | Instance () |
| | Get singleton instance.
|
template<typename Scalar>
class icarus::ComponentFactory< Scalar >
Factory for creating components from configuration.
Components register themselves using the ICARUS_REGISTER_COMPONENT macro. The factory creates components by type name from ComponentConfig.
Example usage:
auto component = factory.Create(config);
#define ICARUS_REGISTER_COMPONENT(ComponentType)
Register a component type with the factory (both backends).
Definition ComponentFactory.hpp:156
static ComponentFactory & Instance()
Get singleton instance.
Definition ComponentFactory.hpp:109
◆ Creator
template<typename Scalar>
◆ Clear()
template<typename Scalar>
Clear all registrations (for testing).
◆ Create()
template<typename Scalar>
Create a component from config.
The creator receives the full ComponentConfig including:
- name: Component instance name
- entity: Entity namespace (if any)
- scalars: Scalar parameter values
- vectors: Vector parameter values
- strings: String parameter values
- Parameters
-
- Returns
- Unique pointer to created component
- Exceptions
-
◆ GetRegisteredTypes()
template<typename Scalar>
Get list of registered type names.
◆ HasType()
template<typename Scalar>
Check if a type is registered.
◆ Instance()
template<typename Scalar>
◆ NumRegistered()
template<typename Scalar>
Get number of registered types.
◆ Register()
template<typename Scalar>
Register a component type with custom creator.
- Parameters
-
| type_name | Type name used in config files |
| creator | Function that creates the component from config |
The documentation for this class was generated from the following file: