|
Infinity Engine v0.6.20
C++ API Documentation
|
Base class for procedural generation components. More...
#include <ProceduralComponent.hpp>
Public Member Functions | |
| ProceduralComponent (const ProceduralComponentDescription &desc) | |
| Constructs a ProceduralComponent from a component description. | |
| virtual | ~ProceduralComponent () |
| Virtual destructor. | |
| uint32_t | random () |
| Generates a random uint32 value using the component's PRNG. | |
| ComponentID | id () const |
| Gets the ComponentID identifying this component's type. | |
| ProceduralComponentRuntime | runtime () |
| Gets runtime information about this component instance. | |
| virtual void | execute ()=0 |
| Executes the component's procedural generation logic. | |
| bool | hasIn (const std::string &name) const |
| Checks if an input port with the given name exists. | |
| bool | hasOut (const std::string &name) const |
| Checks if an output port with the given name exists. | |
| template<typename T > | |
| const T & | getIn (const std::string &name) const |
| Retrieves typed data from an input port. | |
| template<typename T > | |
| void | setOut (const std::string &name, T &&val) |
| Sets typed data on an output port (rvalue reference overload). | |
| template<typename T > | |
| void | setOut (const std::string &name, const T &val) |
| Sets typed data on an output port (const reference overload). | |
| template<typename T > | |
| void | setOut (const std::string &name, const T *val) |
| Sets typed data on an output port from a pointer (copied). | |
Public Attributes | |
| Infinity::Engine::PRNG | prng |
| Pseudo-random number generator for reproducible randomness. | |
Protected Member Functions | |
| void | forward (const std::string &from, const std::string &to) |
| Forwards data from an input port directly to an output port. | |
| void | logError (const std::string &msg) const |
| Logs an error message. | |
| void | logWarning (const std::string &msg) const |
| Logs a warning message. | |
| void | logInfo (const std::string &msg) const |
| Logs an informational message. | |
| void | logDebug (const std::string &msg) const |
| Logs a debug message. | |
Friends | |
| class | Infinity::Procedural::ProceduralComponentImpl |
Base class for procedural generation components.
ProceduralComponent represents a single unit of procedural behavior in the Infinity Engine. Components are nodes in a procedural generation graph that receive input data, perform computations, and produce output data. They are the fundamental building blocks that plugin developers extend to create custom procedural generation functionality.
Each component has:
To create a custom component, inherit from ProceduralComponent and implement the execute() method to define the component's behavior.
Example implementation:
See Creating Your First Procedural Component for a detailed guide on how to build Procedural Components.
| Infinity::Procedural::ProceduralComponent::ProceduralComponent | ( | const ProceduralComponentDescription & | desc | ) |
Constructs a ProceduralComponent from a component description.
Initializes the component with metadata, input/output port connections, and configuration from the description.
| desc | The component description containing initialization parameters. |
|
virtual |
Virtual destructor.
|
pure virtual |
Executes the component's procedural generation logic.
This pure virtual method must be implemented by derived classes to define the component's behavior. The implementation should read from input ports using getIn(), perform its computations, and write to output ports using setOut().
The execute() method is called by the engine when all of the component's input dependencies are satisfied.
|
protected |
Forwards data from an input port directly to an output port.
Efficiently passes input data through to an output without copying. Useful for passthrough components or when data doesn't need to be modified.
| from | The name of the input port to read from. |
| to | The name of the output port to write to. |
|
inline |
Retrieves typed data from an input port.
If T is derived from Infinity::Types::Core::Data, returns the data directly. Otherwise, unwraps the value from Infinity::Types::Core::Value<T>.
| T | The expected type of the input data. |
| name | The name of the input port. |
| std::bad_cast | if the input data is not of type T. |
| std::runtime_error | if the input port doesn't exist or has no data. |
| bool Infinity::Procedural::ProceduralComponent::hasIn | ( | const std::string & | name | ) | const |
Checks if an input port with the given name exists.
| name | The name of the input port to check. |
| bool Infinity::Procedural::ProceduralComponent::hasOut | ( | const std::string & | name | ) | const |
Checks if an output port with the given name exists.
| name | The name of the output port to check. |
| ComponentID Infinity::Procedural::ProceduralComponent::id | ( | ) | const |
Gets the ComponentID identifying this component's type.
|
protected |
Logs a debug message.
| msg | The debug message to log. |
|
protected |
Logs an error message.
| msg | The error message to log. |
|
protected |
Logs an informational message.
| msg | The info message to log. |
|
protected |
Logs a warning message.
| msg | The warning message to log. |
| uint32_t Infinity::Procedural::ProceduralComponent::random | ( | ) |
Generates a random uint32 value using the component's PRNG.
Convenience method equivalent to calling prng().
| ProceduralComponentRuntime Infinity::Procedural::ProceduralComponent::runtime | ( | ) |
Gets runtime information about this component instance.
|
inline |
Sets typed data on an output port (const reference overload).
If T is derived from Infinity::Types::Core::Data, stores it directly. Otherwise, wraps it in Infinity::Types::Core::Value<T>.
| T | The type of the output data. |
| name | The name of the output port. |
| val | Const reference to the data to set (copied). |
|
inline |
Sets typed data on an output port from a pointer (copied).
| T | The type of the output data. |
| name | The name of the output port. |
| val | Pointer to the data to set (dereferenced and copied). |
|
inline |
Sets typed data on an output port (rvalue reference overload).
If T is derived from Infinity::Types::Core::Data, stores it directly. Otherwise, wraps it in Infinity::Types::Core::Value<T>.
| T | The type of the output data. |
| name | The name of the output port. |
| val | Rvalue reference to the data to set (moved). |
|
friend |
| Infinity::Engine::PRNG Infinity::Procedural::ProceduralComponent::prng |
Pseudo-random number generator for reproducible randomness.