Infinity Engine v0.6.20
C++ API Documentation
Loading...
Searching...
No Matches
Infinity::Plugin::ComponentLibrary Class Referenceabstract

Base class for plugin component libraries that provide custom ProceduralComponents. More...

#include <Plugin.hpp>

Public Member Functions

virtual ~ComponentLibrary ()=default
 Virtual destructor.
 
virtual void registerComponents ()=0
 Register all components provided by this plugin.
 

Public Attributes

ankerl::unordered_dense::map< Infinity::Procedural::ComponentID, std::pair< CreateComponentFunction *, DeleteComponentFunction * > > registrants
 Registry mapping ComponentIDs to their creation and deletion functions.
 

Protected Member Functions

template<typename T >
void registerComponent (const std::string &group, const std::string &name)
 Registers a component type with the specified group and name.
 
template<typename T >
void registerComponent (const Infinity::Procedural::ComponentID &id)
 Registers a component type with the specified ComponentID.
 

Detailed Description

Base class for plugin component libraries that provide custom ProceduralComponents.

ComponentLibrary defines the interface that all Infinity Engine plugins must implement to register their custom procedural generation components. Plugin developers should inherit from this class and implement the registerComponents() method to register all component types their plugin provides.

The library maintains a registry of component factory functions that the engine uses to instantiate components by their ComponentID (group and name).

See also
INFINITY_PLUGIN macro for convenient plugin definition.

Constructor & Destructor Documentation

◆ ~ComponentLibrary()

virtual Infinity::Plugin::ComponentLibrary::~ComponentLibrary ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ registerComponent() [1/2]

template<typename T >
void Infinity::Plugin::ComponentLibrary::registerComponent ( const Infinity::Procedural::ComponentID id)
inlineprotected

Registers a component type with the specified ComponentID.

Creates factory functions for instantiating and destroying the component type, and adds them to the registrants map. The component type must inherit from ProceduralComponent and have a constructor accepting ProceduralComponentDescription.

Template Parameters
TThe component type to register. Must inherit from ProceduralComponent.
Parameters
idThe ComponentID (group and name) for this component.

◆ registerComponent() [2/2]

template<typename T >
void Infinity::Plugin::ComponentLibrary::registerComponent ( const std::string &  group,
const std::string &  name 
)
inlineprotected

Registers a component type with the specified group and name.

Template Parameters
TThe component type to register. Must inherit from ProceduralComponent.
Parameters
groupThe component's group identifier (e.g., "My.Company.Components").
nameThe component's name within the group (e.g., "MeshGenerator").

◆ registerComponents()

virtual void Infinity::Plugin::ComponentLibrary::registerComponents ( )
pure virtual

Register all components provided by this plugin.

Plugin developers should override this method to register each component type their plugin provides using the registerComponent<T>(...) template method.

Example implementation:

void registerComponents() override
{
// Register a mesh generator component
registerComponent<MyMeshGenerator>("My.Group.Components", "MyMeshGenerator");
// Register a texture processor component
registerComponent<MyTextureProcessor>("My.Group.Components", "MyTextureProcessor");
// Register as many component types as needed
registerComponent<MyNoiseGenerator>("My.Group.Components", "NoiseGenerator");
}
virtual void registerComponents()=0
Register all components provided by this plugin.

Each registered component type must:

The group and name strings will be used by the host application to request creation of specific component types from your plugin.

Member Data Documentation

◆ registrants

ankerl::unordered_dense::map<Infinity::Procedural::ComponentID, std::pair<CreateComponentFunction*, DeleteComponentFunction*> > Infinity::Plugin::ComponentLibrary::registrants

Registry mapping ComponentIDs to their creation and deletion functions.

Maps each registered component's ID to a pair of function pointers: one for creating component instances and one for destroying them.