Infinity Engine v0.6.20
C++ API Documentation
Loading...
Searching...
No Matches
Registry.hpp
1#pragma once
2
3#include <Infinity/api.h>
4#include <Infinity/Procedural/ProceduralComponent.hpp>
5#include <Infinity/Procedural/ProceduralComponentDescription.hpp>
6#include <Infinity/Procedural/ComponentLoader.h>
7
8#include <filesystem>
9#include <vector>
10#include <utility>
11
28
40INFINITY_API_PUBLIC ComponentID registerComponentWithString(const std::string& description, const std::filesystem::path& packagePath = "");
41
54INFINITY_API_PUBLIC std::vector<ComponentID> registerComponentLibrary(const std::filesystem::path& path);
55
67INFINITY_API_PUBLIC std::vector<ComponentID> registerComponentsInDirectory(const std::filesystem::path& path);
68
79INFINITY_API_PUBLIC ComponentID registerComponentWithFilepath(const std::filesystem::path& descriptorFile);
80
92
107 CreateComponentFunction* createComponent,
108 DeleteComponentFunction* deleteComponent);
109
129template<typename T>
131{
132 return registerComponentWithFactory(description,
133 [](const ProceduralComponentDescription& description) { return dynamic_cast<ProceduralComponent*>(new T(description)); },
134 [](ProceduralComponent* component) { delete component; }
135 );
136}
137
151INFINITY_API_PUBLIC ProceduralComponent* createComponent(const std::string& group, const std::string& name);
152
165INFINITY_API_PUBLIC ProceduralComponent* createComponent(const ComponentID& id);
166
173INFINITY_API_PUBLIC bool hasComponent(const ComponentID& id);
174
185INFINITY_API_PUBLIC std::filesystem::path pathToComponent(const ComponentID& id);
186
198
206INFINITY_API_PUBLIC std::vector<ComponentID> getAvailableComponents();
207
208}
Description and configuration data for a ProceduralComponent instance.
Definition ProceduralComponentDescription.hpp:48
Base class for procedural generation components.
Definition ProceduralComponent.hpp:73
Global registry for ProceduralComponent types and their factory functions.
INFINITY_API_PUBLIC bool hasComponent(const ComponentID &id)
Checks if a component type is registered.
INFINITY_API_PUBLIC std::vector< ComponentID > getAvailableComponents()
Gets all registered component IDs.
ComponentID registerComponent(const ProceduralComponentDescription &description)
Registers a component type with automatic factory function generation.
Definition Registry.hpp:130
INFINITY_API_PUBLIC ProceduralComponent * createComponent(const std::string &group, const std::string &name)
Creates a component instance by group and name.
INFINITY_API_PUBLIC std::vector< ComponentID > registerComponentsInDirectory(const std::filesystem::path &path)
Registers all components found in a directory.
INFINITY_API_PUBLIC ComponentID registerComponentWithFactory(const ProceduralComponentDescription &description, CreateComponentFunction *createComponent, DeleteComponentFunction *deleteComponent)
Registers a component with custom factory 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 const ProceduralComponentDescription & descriptionForComponent(const ComponentID &id)
Gets the description for a registered component.
INFINITY_API_PUBLIC std::vector< ComponentID > registerComponentLibrary(const std::filesystem::path &path)
Registers all components from a shared library plugin.
INFINITY_API_PUBLIC std::filesystem::path pathToComponent(const ComponentID &id)
Gets the package path for a registered component.
INFINITY_API_PUBLIC ComponentID registerComponentWithDescriptor(const ProceduralComponentDescription &description)
Registers a component from a ProceduralComponentDescription object.
INFINITY_API_PUBLIC ComponentID registerComponentWithFilepath(const std::filesystem::path &descriptorFile)
Registers a component from a descriptor file.
Unique identifier for a procedural component.
Definition ComponentID.hpp:35