|
Infinity Engine v0.6.20
C++ API Documentation
|
Global registry for ProceduralComponent types and their factory functions. More...
Functions | |
| INFINITY_API_PUBLIC ComponentID | registerComponentWithString (const std::string &description, const std::filesystem::path &packagePath="") |
| Registers a component from a YAML description string. | |
| INFINITY_API_PUBLIC std::vector< ComponentID > | registerComponentLibrary (const std::filesystem::path &path) |
| Registers all components from a shared library plugin. | |
| INFINITY_API_PUBLIC std::vector< ComponentID > | registerComponentsInDirectory (const std::filesystem::path &path) |
| Registers all components found in a directory. | |
| INFINITY_API_PUBLIC ComponentID | registerComponentWithFilepath (const std::filesystem::path &descriptorFile) |
| Registers a component from a descriptor file. | |
| INFINITY_API_PUBLIC ComponentID | registerComponentWithDescriptor (const ProceduralComponentDescription &description) |
| Registers a component from a ProceduralComponentDescription object. | |
| INFINITY_API_PUBLIC ComponentID | registerComponentWithFactory (const ProceduralComponentDescription &description, CreateComponentFunction *createComponent, DeleteComponentFunction *deleteComponent) |
| Registers a component with custom factory functions. | |
| template<typename T > | |
| ComponentID | registerComponent (const ProceduralComponentDescription &description) |
| Registers a component type with automatic factory function generation. | |
| INFINITY_API_PUBLIC ProceduralComponent * | createComponent (const std::string &group, const std::string &name) |
| Creates a component instance by group and name. | |
| INFINITY_API_PUBLIC ProceduralComponent * | createComponent (const ComponentID &id) |
| Creates a component instance by ComponentID. | |
| INFINITY_API_PUBLIC bool | hasComponent (const ComponentID &id) |
| Checks if a component type is registered. | |
| INFINITY_API_PUBLIC std::filesystem::path | pathToComponent (const ComponentID &id) |
| Gets the package path for a registered component. | |
| INFINITY_API_PUBLIC const ProceduralComponentDescription & | descriptionForComponent (const ComponentID &id) |
| Gets the description for a registered component. | |
| INFINITY_API_PUBLIC std::vector< ComponentID > | getAvailableComponents () |
| Gets all registered component IDs. | |
Global registry for ProceduralComponent types and their factory functions.
The Registry namespace provides functions for registering and creating ProceduralComponent instances. Components must be registered before they can be instantiated by the engine. Registration can occur through multiple mechanisms:
Once registered, components are identified by their ComponentID (group and name) and can be instantiated on demand throughout the application lifecycle.
| INFINITY_API_PUBLIC ProceduralComponent * Infinity::Procedural::Registry::createComponent | ( | const ComponentID & | id | ) |
Creates a component instance by ComponentID.
Instantiates a registered component using its ComponentID.
| id | The ComponentID of the component type to instantiate. |
| std::runtime_error | if the component type is not registered. |
| INFINITY_API_PUBLIC ProceduralComponent * Infinity::Procedural::Registry::createComponent | ( | const std::string & | group, |
| const std::string & | name | ||
| ) |
Creates a component instance by group and name.
Instantiates a registered component using its group and name identifiers.
| group | The component's group identifier. |
| name | The component's name within the group. |
| std::runtime_error | if the component type is not registered. |
| INFINITY_API_PUBLIC const ProceduralComponentDescription & Infinity::Procedural::Registry::descriptionForComponent | ( | const ComponentID & | id | ) |
Gets the description for a registered component.
Returns the ProceduralComponentDescription that was used to register the component type.
| id | The ComponentID to query. |
| std::runtime_error | if the component type is not registered. |
| INFINITY_API_PUBLIC std::vector< ComponentID > Infinity::Procedural::Registry::getAvailableComponents | ( | ) |
Gets all registered component IDs.
Returns a list of all component types currently registered in the global registry.
| INFINITY_API_PUBLIC bool Infinity::Procedural::Registry::hasComponent | ( | const ComponentID & | id | ) |
Checks if a component type is registered.
| id | The ComponentID to check. |
| INFINITY_API_PUBLIC std::filesystem::path Infinity::Procedural::Registry::pathToComponent | ( | const ComponentID & | id | ) |
Gets the package path for a registered component.
Returns the base directory containing the component's files, including the shared library (if applicable) and any component-specific assets.
| id | The ComponentID to query. |
| std::runtime_error | if the component type is not registered. |
| ComponentID Infinity::Procedural::Registry::registerComponent | ( | const ProceduralComponentDescription & | description | ) |
Registers a component type with automatic factory function generation.
Template function that registers a component type and automatically generates appropriate factory functions for creating and destroying instances. The component type T must inherit from ProceduralComponent and have a constructor accepting ProceduralComponentDescription.
| T | The component type to register. Must inherit from ProceduralComponent. |
| description | The component description containing metadata and configuration. |
| std::runtime_error | if registration fails. |
Example usage:
| INFINITY_API_PUBLIC std::vector< ComponentID > Infinity::Procedural::Registry::registerComponentLibrary | ( | const std::filesystem::path & | path | ) |
Registers all components from a shared library plugin.
Loads a component library (shared library/DLL) and registers all component types provided by the plugin. The library must implement the plugin API defined in Infinity::Plugin::ComponentLibrary.
| path | Path to the shared library file (.dll, .so, or .dylib). |
| std::runtime_error | if the library cannot be loaded or doesn't implement the required plugin interface. |
| INFINITY_API_PUBLIC std::vector< ComponentID > Infinity::Procedural::Registry::registerComponentsInDirectory | ( | const std::filesystem::path & | path | ) |
Registers all components found in a directory.
Recursively scans the specified directory for component descriptor files (.pcd) and component libraries, registering all discovered components.
| path | Path to the directory to scan. |
| std::runtime_error | if the directory cannot be accessed or if any component registration fails. |
| INFINITY_API_PUBLIC ComponentID Infinity::Procedural::Registry::registerComponentWithDescriptor | ( | const ProceduralComponentDescription & | description | ) |
Registers a component from a ProceduralComponentDescription object.
Registers a component using an already-constructed component description. This is useful when building component descriptions programmatically.
| description | The component description to register. |
| std::runtime_error | if registration fails. |
| INFINITY_API_PUBLIC ComponentID Infinity::Procedural::Registry::registerComponentWithFactory | ( | const ProceduralComponentDescription & | description, |
| CreateComponentFunction * | createComponent, | ||
| DeleteComponentFunction * | deleteComponent | ||
| ) |
Registers a component with custom factory functions.
Registers a component type with explicit create and delete functions. This provides maximum control over component instantiation and destruction, which is essential for plugin systems and cross-DLL memory management.
| description | The component description containing metadata and configuration. |
| createComponent | Function pointer for creating component instances. |
| deleteComponent | Function pointer for destroying component instances. |
| std::runtime_error | if registration fails. |
| INFINITY_API_PUBLIC ComponentID Infinity::Procedural::Registry::registerComponentWithFilepath | ( | const std::filesystem::path & | descriptorFile | ) |
Registers a component from a descriptor file.
Loads a component descriptor file (.pcd) and registers the component type. The descriptor file can be in YAML or FlatBuffer format.
| descriptorFile | Path to the component descriptor file. |
| std::runtime_error | if the file cannot be read, parsed, or registration fails. |
| INFINITY_API_PUBLIC ComponentID Infinity::Procedural::Registry::registerComponentWithString | ( | const std::string & | description, |
| const std::filesystem::path & | packagePath = "" |
||
| ) |
Registers a component from a YAML description string.
Parses the provided YAML string as a component description and registers the component type in the global registry.
| description | YAML-formatted string containing the component description. |
| packagePath | Optional package path for resolving component files (default: empty). |
| std::runtime_error | if the YAML cannot be parsed or registration fails. |