Infinity Engine v0.6.20
C++ API Documentation
Loading...
Searching...
No Matches
Infinity::Procedural::ProceduralComponentDescription Class Reference

Description and configuration data for a ProceduralComponent instance. More...

#include <ProceduralComponentDescription.hpp>

Public Member Functions

 ProceduralComponentDescription (const std::filesystem::path &loadPath)
 Loads a ProceduralComponentDescription from a file.
 
 ProceduralComponentDescription (const std::string &yamlString, const std::filesystem::path &loadPath={})
 Creates a ProceduralComponentDescription from a YAML string.
 
 ProceduralComponentDescription (const uint8_t *buffer, const size_t size, const std::filesystem::path &loadPath={})
 Creates a ProceduralComponentDescription from a binary FlatBuffer.
 
 ProceduralComponentDescription (ProceduralComponentDescription &&other)
 Move constructor.
 
 ProceduralComponentDescription (const ProceduralComponentDescription &copy)
 Copy constructor.
 
 ~ProceduralComponentDescription ()
 Destructor.
 
ProceduralComponentDescriptionoperator= (ProceduralComponentDescription &&other)
 Move assignment operator.
 
ProceduralComponentDescriptionoperator= (const ProceduralComponentDescription &copy)
 Copy assignment operator.
 
bool isFilePCDFlatbuffer (const std::filesystem::path &filepath)
 Checks if a file is a FlatBuffer-format component description.
 
void dump (const std::filesystem::path &path, Infinity::IO::Filetype type=Infinity::IO::Filetype::Flatbuffer) const
 Serializes this description to a file.
 
const std::filesystem::path & getLoadPath () const
 Gets the package path associated with this description.
 

Friends

class Infinity::Procedural::ProceduralComponentDescriptionImpl
 
INFINITY_API_PUBLIC std::ostream & operator<< (std::ostream &os, const ProceduralComponentDescription &desc)
 Stream insertion operator for debugging and logging.
 

Detailed Description

Description and configuration data for a ProceduralComponent instance.

ProceduralComponentDescription encapsulates all the metadata, configuration, and connection information needed to instantiate and initialize a ProceduralComponent. Descriptions can be loaded from files (YAML or FlatBuffer formats), created from strings or binary buffers, and serialized back to disk.

The description includes:

  • Component type identification (ComponentID)
  • Input and output port definitions and connections
  • Configuration parameters
  • Package path for locating component files
Note
Internally, descriptions are always stored as FlatBuffer in-memory, regardless of the source format. This means that YAML formatting and comments are not preserved when dumping back to YAML. Loading from FlatBuffer format provides significant performance benefits compared to YAML parsing.

Example usage:

// Load from file (auto-detects format)
ProceduralComponentDescription desc("components/mesh_generator.prcc");
// Create component from description
auto component = std::make_unique<MyComponent>(desc);
// Save description to file
desc.dump("output/saved_component.prcc", Infinity::IO::Filetype::YAML);
Description and configuration data for a ProceduralComponent instance.
Definition ProceduralComponentDescription.hpp:48
@ YAML
Definition Filetype.hpp:19

Constructor & Destructor Documentation

◆ ProceduralComponentDescription() [1/5]

Infinity::Procedural::ProceduralComponentDescription::ProceduralComponentDescription ( const std::filesystem::path &  loadPath)

Loads a ProceduralComponentDescription from a file.

Automatically detects whether the file is in YAML or FlatBuffer format and deserializes accordingly. FlatBuffer files load significantly faster than YAML files.

Parameters
loadPathPath to the component description file (.prcc).
Exceptions
std::runtime_errorif the file cannot be read or parsed.

◆ ProceduralComponentDescription() [2/5]

Infinity::Procedural::ProceduralComponentDescription::ProceduralComponentDescription ( const std::string &  yamlString,
const std::filesystem::path &  loadPath = {} 
)

Creates a ProceduralComponentDescription from a YAML string.

Parameters
yamlStringYAML-formatted string containing the component description.
loadPathOptional path indicating where this description conceptually resides (used as the package path for loading component files).
Exceptions
std::runtime_errorif the YAML cannot be parsed.

◆ ProceduralComponentDescription() [3/5]

Infinity::Procedural::ProceduralComponentDescription::ProceduralComponentDescription ( const uint8_t *  buffer,
const size_t  size,
const std::filesystem::path &  loadPath = {} 
)

Creates a ProceduralComponentDescription from a binary FlatBuffer.

Parameters
bufferPointer to the FlatBuffer binary data.
sizeSize of the buffer in bytes.
loadPathOptional path indicating where this description conceptually resides (used as the package path for loading component files).
Exceptions
std::runtime_errorif the buffer is invalid or cannot be parsed.

◆ ProceduralComponentDescription() [4/5]

Infinity::Procedural::ProceduralComponentDescription::ProceduralComponentDescription ( ProceduralComponentDescription &&  other)

Move constructor.

Parameters
otherThe ProceduralComponentDescription to move from.

◆ ProceduralComponentDescription() [5/5]

Infinity::Procedural::ProceduralComponentDescription::ProceduralComponentDescription ( const ProceduralComponentDescription copy)

Copy constructor.

Parameters
copyThe ProceduralComponentDescription to copy from.

◆ ~ProceduralComponentDescription()

Infinity::Procedural::ProceduralComponentDescription::~ProceduralComponentDescription ( )

Destructor.

Member Function Documentation

◆ dump()

void Infinity::Procedural::ProceduralComponentDescription::dump ( const std::filesystem::path &  path,
Infinity::IO::Filetype  type = Infinity::IO::Filetype::Flatbuffer 
) const

Serializes this description to a file.

Writes the component description to disk in either YAML (human-readable) or FlatBuffer (compact binary) format.

Parameters
pathThe filesystem path where the description should be written.
typeThe file format to use (default: FlatBuffer).
Note
When dumping to YAML, formatting and comments from the original file are not preserved, as the description is stored internally as FlatBuffer.

◆ getLoadPath()

const std::filesystem::path & Infinity::Procedural::ProceduralComponentDescription::getLoadPath ( ) const

Gets the package path associated with this description.

The load path is the base directory containing all ProceduralComponent files, including the shared library itself (if not statically linked or scripted). This path is used for loading the component's initial data and can optionally be used to load component-specific default assets, though these may be overridden by the containing ProceduralSystem if configured to use different assets.

Returns
Const reference to the load path.

◆ isFilePCDFlatbuffer()

bool Infinity::Procedural::ProceduralComponentDescription::isFilePCDFlatbuffer ( const std::filesystem::path &  filepath)

Checks if a file is a FlatBuffer-format component description.

Examines the file to determine if it's in binary FlatBuffer format rather than YAML format.

Parameters
filepathPath to the file to check.
Returns
True if the file is a FlatBuffer PCD, false otherwise.

◆ operator=() [1/2]

ProceduralComponentDescription & Infinity::Procedural::ProceduralComponentDescription::operator= ( const ProceduralComponentDescription copy)

Copy assignment operator.

Parameters
copyThe ProceduralComponentDescription to copy from.
Returns
Reference to this description.

◆ operator=() [2/2]

ProceduralComponentDescription & Infinity::Procedural::ProceduralComponentDescription::operator= ( ProceduralComponentDescription &&  other)

Move assignment operator.

Parameters
otherThe ProceduralComponentDescription to move from.
Returns
Reference to this description.

Friends And Related Symbol Documentation

◆ Infinity::Procedural::ProceduralComponentDescriptionImpl

friend class Infinity::Procedural::ProceduralComponentDescriptionImpl
friend

◆ operator<<

INFINITY_API_PUBLIC std::ostream & operator<< ( std::ostream &  os,
const ProceduralComponentDescription desc 
)
friend

Stream insertion operator for debugging and logging.

Parameters
osOutput stream to write to.
descThe ProceduralComponentDescription to output.
Returns
Reference to the output stream.