C++ API

This section contains a documentation of the C++ classes and functions. All classes and functions in the documentation reside in the namespace grunk. To use grunk’s C++ API, you have to include the header grunk.h.

grunk supplies two modes of operation, that will be denoted as static mode and dynamic mode. Use the static mode of grunk, if you know all the types you want to use at compile time. Use the dynamic mode of grunk, if you want to use types and functions provided by plugins which are loaded at run time. In this case, grunk falls back to its -dynamic type system, see also the design principles -section of this documentation.

The static mode is the basis of grunk, implemented in grunk::core.

grunk::core

The core of grunk consists of the action function together with Feature class.

A Feature represents any kind of feature in the feature tree. Given any kind of referentially transparent function and some input features from the feature tree, the function action registeres the evaluation of the given function for the given features as input in the feature tree.

grunk::Feature<double> l(3.3).with_id("l");
grunk::Feature<double> r(2.2).with_id("r");
auto res = grunk::action(std::add, l, r);
std::cout<<res.value()<<std::endl; // evaluate the result, thus triggering the calculation

Using grunk in this way is also called static mode, because all types and functions are known at compile time.

template<typename F, typename ...Args>
inline decltype(auto) action(F const &fun, Args&&... args)

Given a function and some features in the feature tree, this function creates an Action instance representing the evaluation of the input function for the input features.

This function accepts features as arguments for the functions, as well as instances that are not wrapped in features. Internally, the latter will be wrapped in an unnamed/anonymous feature

Template Parameters:
  • F – The type of the function to be wrapped. This can be any referentially transparent function, In particular, the function must be invokable on const references.

  • Args – The types of the arguments expected by the input function

Parameters:
  • fun – The input function

  • args – The input features of the feature tree

Returns:

ResultHolder wrapping the outputs of the Action

template<typename T>
Feature<T> feature(T const &v)

feature is a factory function to construct a Feature

Template Parameters:

T – the type of the feature value, e.g. double, std::string or even a user defined type

Parameters:

v – the value of the feature

Returns:

Feature<T> a feature with the given value

template<typename T>
Feature<T> feature()

feature is a factory function to construct an empty (placeholder) Feature.

Template Parameters:

T – the type of the feature value, e.g. double, std::string or even a user defined type

Returns:

Feature<T> an empty feature

inline tf::Taskflow to_taskflow(std::vector<parametric::NodeRef> const &nodes)

converts a vector of feature nodes into a taskflow by traversing the DAG of compute nodes and building tasks for them. The function creates a TaskflowVisitor and uses it to visit each node in the input vector, starting from the given nodes and visiting their parents and children recursively. The resulting taskflow contains tasks for all compute nodes that are reachable from the input nodes, with dependencies established based on the structure of the DAG.

Parameters:

nodes – the vector of feature nodes to convert into a taskflow

Returns:

tf::Taskflow the resulting taskflow built from the input nodes

template<typename ...T>
tf::Taskflow to_taskflow(Feature<T> const&... feature)

converts a variadic list of features into a taskflow by traversing the DAG of compute nodes and building tasks for them. The function creates a TaskflowVisitor and uses it to visit each node corresponding to the input features, starting from the given nodes and visiting their parents and children recursively. The resulting taskflow contains tasks for all compute nodes that are reachable from the input nodes, with dependencies established based on the structure of the DAG.

Template Parameters:

T – the types of the input features

Parameters:

feature – the variadic list of input features to convert into a taskflow

Returns:

tf::Taskflow the resulting taskflow built from the input features

template<typename T>
struct Feature : public grunk::FeatureBase<Feature<T>, T>
#include <Feature.hpp>

The Feature class template is the main interface for users to create and manipulate features in grunk. It is a thin wrapper around parametric::param that provides some additional functionality and syntactic sugar.

Template Parameters:

T – the type of the feature value, e.g. double, std::string or even a user defined type

Public Functions

inline Feature(T const &v)

constructs a feature with the given value. The value can be a literal, a variable or the output of an action.

There are three kinds of features, disambiguated by the existence of a name or a value.

  1. A feature with a value and no name is often called a constanct, because it cannot be retrieved by name. It is not listed in the parameters block of a recipe

  2. A feature with a name and a value is often called a variable, because it can be retrieved by name and thus manipulated. It is listed in the parameters block of a recipe

  3. A feature with a name but no value is often called a placeholder, because it can be retrieved by name but cannot be evaluated. It is listed in the parameters block of a recipe and is used to mark missing values that need to be filled in by the user or by other recipes.

Parameters:

v – the value of the feature

inline explicit Feature(parametric::param<T> const &p)

constructs a feature from a parametric::param. This is used internally for cloning and other operations that manipulate the underlying DAG.

Parameters:

p – the parametric::param to construct the feature from

inline Feature()

constructs an empty feature.

template<typename Derived, typename T>
struct FeatureBase : public parametric::param<T>
#include <FeatureBase.hpp>

The FeatureBase class template is a base class for the Feature class template. It provides some common functionality for all features, such as cloning, comparison and placeholder detection. It is not meant to be used directly by users, but rather to be inherited by the Feature class template.

The class uses the Curiously Recurring Template Pattern (CRTP) to allow the base class to return the derived class type in its methods, such as with_id and clone. This allows for more convenient method chaining and cloning of features.

Template Parameters:
  • Derived – the derived class, i.e. the Feature class template that inherits from this base class template

  • T – the type of the feature value, e.g. double, std::string or even a user defined type

Public Functions

inline FeatureBase(T const &v)

constructs a feature with the given value. The value can be a literal, a variable or the output of an action.

Parameters:

v – the value of the feature

inline explicit FeatureBase(parametric::param<T> const &p)

constructs a feature from a parametric::param. This is used internally for cloning and other operations that manipulate the underlying DAG.

Parameters:

p – the parametric::param to construct the feature from

inline Derived &with_id(std::string const &id)

sets the id of the feature and returns a reference to the feature itself. This is useful for chaining method calls.

Parameters:

id – the id to set

Returns:

Derived& a reference to the feature itself

inline bool operator==(Derived const &other)

compares two features for equality. Two features are considered equal if they point to the same node in the DAG, i.e. they are the same feature in the feature tree. This is a shallow comparison that does not compare the values of the features, but rather their identity in the DAG.

Parameters:

other – the other feature to compare with

Returns:

true if the features are equal, false otherwise

inline Derived clone(std::shared_ptr<parametric::DAGNode::ClonedNodeMap> cloned_nodes = parametric::DAGNode::new_cloned_node_map()) const

clones the feature and its underlying DAG node. This is a deep copy that creates a new feature with the same value and id, but a different identity in the DAG. The cloned nodes map is used to keep track of already cloned nodes and avoid infinite recursion in case of cyclic dependencies.

Parameters:

cloned_nodes – a shared pointer to a map that keeps track of already cloned nodes. This is used internally to avoid infinite recursion when cloning features with cyclic dependencies. Users typically do not need to provide this argument, as it is handled automatically by the clone method.

Returns:

Derived a new feature that is a clone of the original feature, with the same value and id, but a different identity in the DAG.

inline bool is_placeholder() const

is_placeholder returns true if the feature is a placeholder, i.e. a root parameter that is invalid even after evaluation. This can be used to detect features that are meant to be filled in later, e.g. by a recipe call action, but have not been assigned a value yet.

Returns:

true if the feature is a placeholder, false otherwise

class ParallelExecutor
#include <ParallelExecutor.hpp>

The ParallelExecutor class is a utility for executing a set of features in parallel using Taskflow. It takes a variadic list of features as input, builds a taskflow from their corresponding DAG nodes, and runs the taskflow using a Taskflow executor. The ParallelExecutor can be constructed with a specified number of threads for the executor, and it provides methods to build the taskflow, run it, and manage its state.

Public Functions

template<typename ...T>
inline ParallelExecutor(Feature<T> const&... feature)

constructs a ParallelExecutor with the given features. The constructor takes a variadic list of features as input, extracts their corresponding DAG nodes, and initializes the internal state of the executor. The constructor also checks that all input features are non-dynamic (i.e. they do not have sol::object as their type), since parallel execution is only supported for non-dynamic features.

Template Parameters:

T – the types of the input features

Parameters:

feature – the variadic list of input features to execute in parallel

template<typename ...T>
inline ParallelExecutor(size_t num_threads, Feature<T> const&... feature)

constructs a ParallelExecutor with the given features and number of threads. The constructor takes a variadic list of features as input, extracts their corresponding DAG nodes, and initializes the internal state of the executor with the specified number of threads. The constructor also checks that all input features are non-dynamic (i.e. they do not have sol::object as their type), since parallel execution is only supported for non-dynamic features.

Template Parameters:

T – the types of the input features

Parameters:
  • num_threads – the number of threads to use for the Taskflow executor

  • feature – the variadic list of input features to execute in parallel

inline void build_taskflow()

builds the taskflow from the input features by traversing the DAG of compute nodes and building tasks for them. The function creates a TaskflowVisitor and uses it to visit each node corresponding to the input features, starting from the given nodes and visiting their parents and children recursively. The resulting taskflow contains tasks for all compute nodes that are reachable from the input nodes, with dependencies established based on the structure of the DAG.

inline tf::Taskflow const &get_taskflow() const

returns a const reference to the internal taskflow of the executor. This allows users to inspect the structure of the taskflow, e.g. for debugging or visualization purposes, without modifying it. The taskflow is built from the input features and their corresponding DAG nodes, and it contains tasks for all compute nodes that are reachable from the input nodes, with dependencies established based on the structure of the DAG.

Returns:

tf::Taskflow const& a const reference to the internal taskflow of the executor

inline void reset()

resets the internal state of the executor by clearing the taskflow. This allows users to reuse the same executor instance for different sets of features or to rebuild the taskflow from the same features after modifying their DAG structure. The nodes vector is not modified by this function, so it still contains the DAG nodes corresponding to the input features, but the taskflow is cleared and needs to be rebuilt before running again.

inline void name(std::string const &name)

sets the name of the taskflow for better readability and debugging. The name is used in the Taskflow visualization and can help users to identify the purpose of the taskflow, e.g. by giving it a descriptive name based on the input features or the context of the execution.

Parameters:

name – the name to set for the taskflow

inline std::string const &name() const

returns a const reference to the name of the taskflow. This allows users to inspect the name of the taskflow, e.g. for debugging or visualization purposes, without modifying it. The name is set by the user and can be used to identify the purpose of the taskflow, e.g. by giving it a descriptive name based on the input features or the context of the execution.

Returns:

std::string const& a const reference to the name of the taskflow

inline void run()

runs the taskflow using the Taskflow executor. The function checks if the taskflow is empty, and if so, it builds the taskflow from the input features by traversing the DAG of compute nodes and building tasks for them. Then it runs the taskflow using the executor and waits for its completion. The execution of the taskflow will evaluate all compute nodes that are reachable from the input features, with dependencies established based on the structure of the DAG.

grunk::dynamic

Just like in static mode, the usage of grunk revolves around DynamicFeatures and an overload of the action function.

The main difference is that dynamic mode depends on a valid LUA state, that is owned by a grunk::state instance. The state is used to store all registered types and functions, and to execute the LUA code that is generated by grunk.

We will call the grunk::state instance grunk and employ C++’s context aware name resolution.

A DynamicFeature wraps a grunk::object, which is the main type in grunk’s dynamic mode. A grunk::object can hold any kind of value, and can be used to represent any kind of feature in the feature tree.

grunk::state grunk;

grunk.register_function("add", std::add); // register the function "add" in the grunk state, so that it can be used in the feature tree

auto l = grunk.feature(3.3).with_id("l");
auto r = grunk.feature(2.2).with_id("r");
auto res = grunk.action("add", l, r).with_id("o");
std::cout<<res.value().as<double>()<<std::endl; // evaluate the result, thus triggering the calculation

The types and functions must be registered from plugins loaded at run time, see also the plugin section of this documentation or the corresponding section under Usage.

template<typename ...Args>
inline DynamicFeature action(function_meta const &function, Args&&... args)

Given a string identifier of a function, that has previously been registered in the static function registry as well as input features of the feature tree, this function represents the evaluation of the registered function when it gets passed the input features.

Template Parameters:

Args – The types of the arguments expected by the registered function

Parameters:
  • function – The function with metadata

  • args – The input Features

Returns:

DynamicFeature the result

class environment
#include <environment.hpp>

The environment class is a wrapper around a sol::environment, which represents a LUA environment. It provides methods to access variables stored in the environment and to evaluate LUA scripts in the environment. It also provides a method to tag features stored in the environment with their LUA variable name, which is useful for serialization.

Subclassed by grunk::Recipe

Public Functions

inline environment(sol::environment const &env)

constructs an environment from a sol::environment. This is used internally for creating environments from the state and for creating recipes from environments.

Parameters:

env – the sol::environment to construct the environment from

inline decltype(auto) operator[](std::string const &key)

returns a variable stored in the active environment

Parameters:

key – The name of the variable

Returns:

The queried variable

inline decltype(auto) operator[](std::string const &key) const

returns a variable stored in the active environment

Parameters:

key – The name of the variable

Returns:

The queried variable

template<typename T = sol::object>
inline T get(std::string const &key)

get returns a variable stored in the active environment and checks if it is valid. If the variable is not found in the environment, an exception is thrown.

Template Parameters:

T – the type to cast the variable to. If T is sol::object, no casting is performed and the variable is returned as a sol::object. Otherwise, the variable is cast to T using sol::object::as<T>().

Parameters:

key – The name of the variable

Throws:

std::runtime_error – if the variable is not found in the environment

Returns:

The queried variable, cast to T if T is not sol::object

template<typename T = sol::object>
inline T get(std::string const &key) const

get returns a variable stored in the active environment and checks if it is valid. If the variable is not found in the environment, an exception is thrown.

Template Parameters:

T – the type to cast the variable to. If T is sol::object, no casting is performed and the variable is returned as a sol::object. Otherwise, the variable is cast to T using sol::object::as<T>().

Parameters:

key – The name of the variable

Throws:

std::runtime_error – if the variable is not found in the environment

Returns:

The queried variable, cast to T if T is not sol::object

inline DynamicFeature get_feature(std::string const &key)

get_feature returns a Feature stored in the active environment

This is syntactic sugar for static_cast<DynamicFeature>(grunk[“foo”]), i.e. retrieval of the variable as a grunk::object and then casting it to DynamicFeature

Parameters:

key – The name of the Feature

Returns:

The queried feature

inline DynamicFeature get_feature(std::string const &key) const

get_feature returns a Feature stored in the active environment

This is syntactic sugar for static_cast<DynamicFeature>(grunk[“foo”]), i.e. retrieval of the variable as a grunk::object and then casting it to DynamicFeature

Parameters:

key – The name of the Feature

Returns:

The queried feature

inline void tag_features()

sets the id of every feature in the active environment to its LUA variable name. This is particularly useful for serialization

inline auto eval(std::string const &lua_script)

eval evaluates a LUA script in the active environment

Parameters:

lua_script – The lua script to be evaluated

class state
#include <state.hpp>

The state class is responsible for grunk’s dynamic scripting capabilities and LUA interface. Important: A grunk instance must outlive any dynamic feature created from it!

Use this class to register types and functions at runtime for use in a grunk recipe, instantiate dynamic features and actions and running LUA scripts.

The state holds the LUA state as well as three environments, the original environment, the decorated environment and the active environment. The active environment is where variables are created when executing dynamic scripts. When running code in the active environment, symbols are looked up either in the decorated environment (default) or the original environment.

The original environment is where registered types and functions are stored. The decorated environment has access to all symbols in the original environment, but every function and method is decorated as an action. Therefore, any code executed in the decorated environment will have dependency tracking, lazy evaluation and automatic invalidation enabled. Code run in the original environment simply uses the original undecorated symbols.

Public Functions

inline state()

Creates a grunk::state and initializes the environments. It also registers some grunk symbols which can be used in a LUA script.

template<typename T>
inline auto register_type(std::string const &name, std::optional<sol::table> table = std::nullopt)

register_type registers a type in the dynamic type system.

This type is stored as a symbol in the original environment by default. Optionally, a sol::table can be specified. If it is specified, the type will be registered inside the sol::table. Note that only symbols stored in the original environment can be decorated.

Parameters:
  • name – Name of the type

  • table – optional table as a “namespace”, where the type shall be registered.

Returns:

a usertype_proxy<T> to allow method chaining

template<typename Func>
inline void register_function(std::string const &name, Func &&fun, std::vector<Parameter> params = {}, std::optional<sol::table> table = std::nullopt)

register_function registers a function in the dynamic type system.

This function is stored as a symbol in the original environment by default. Optionally, a sol::table can be specified. It it is specified, the type will be registered inside the sol::table. Note that only symobls stored in the original environment can be decorated.

Parameters:
  • name – Name of the function

  • fun – The function to be registered. This can be a function pointer, a functor or a lambda expression

  • params – optional metadata for the function parameters

  • table – optional table as a “namespace”, where the type shall be registered.

inline environment create_env() const

create_env creates a new environment based on the original environment.

A new environment is created with the original environment as its __index metamethod, which means that any code executed in this environment will have access to all symbols in the original environment, but any new symbols created in this environment will not be visible in the original environment. This is the environment that should be used for executing user-provided LUA scripts, where you don’t want dependency tracking, lazy evaluation and automatic invalidation to be enabled.

Returns:

A new environment instance.

inline environment create_parametric_env() const

create_parametric_env creates a new parametric environment based on the decorated environment.

A parametric environment is an environment where all functions are decorated as actions, which means that any code executed in this environment will have dependency tracking, lazy evaluation and automatic invalidation enabled. This is the environment that should be used for executing grunk recipes and for creating grunk features and actions.

Returns:

A new parametric environment instance.

inline void run_module_script(std::string const &name, std::string const &script)

run_module_script executes a Lua script, storing every symbol it defines in a named module table in the original environment.

If a module with the given name already exists, the existing table is reused and the script is executed against it, so multiple scripts/files can incrementally populate the same module. The module table’s lookups fall back to the original environment, so the script can reference any other registered type, function or module.

Functions defined by the script become available both in a plain environment (as regular, uninstrumented Lua functions - see create_env) and in a parametric environment, where they are decorated into actions like any other symbol registered in the original environment (see create_parametric_env). Statements within a module function are not themselves parametric, which is what allows module functions to use non-const setters to build up objects - see the “Modules” section of the documentation.

Note

Lua syntax errors in the script are not detected at registration time. They surface the first time a function from the module is executed (e.g. via env.eval(...) or grunk.action(...)). This is intentional: the script is stored as a Feature<std::string> so that editing it invalidates every downstream compute node that calls into the module.

Parameters:
  • name – name of the module to create or populate in the original environment

  • script – the Lua source code to execute

inline void run_module_file(std::string const &name, std::string const &filename)

run_module_file loads a Lua file from disk and runs it into a module, following the same semantics as run_module_script.

Parameters:
  • name – name of the module to create or populate

  • filename – path to a Lua file

inline void clear_module(std::string const &name)

clear_module removes a module table from the original and decorated environments.

Use this to force a clean reload of a module, e.g. clear_module(name) followed by run_module_script(name, new_script), rather than relying on run_module_script’s incremental-augmentation behavior.

Parameters:

name – name of the module to remove

inline Recipe create_recipe() const

create_recipe creates a new recipe based on the decorated environment.

A recipe is created with a parametric environment, which means that any code executed in this recipe will have dependency tracking, lazy evaluation and automatic invalidation enabled. This is the environment that should be used for executing grunk recipes and for creating grunk features and actions.

Returns:

A new recipe instance.

inline void write(std::string const &filename, Recipe const &recipe)

write writes a recipe to a file. The recipe is serialized using the to_string method of the recipe, which returns a LUA script that can be executed to recreate the recipe.

Parameters:
  • filename – The name of the file to write the recipe to

  • recipe – The recipe to be written to the file

inline Recipe read(std::string const &filename)

read reads a recipe from a file.

Parameters:

filename – The name of the file to read the recipe from

Returns:

A new recipe instance

inline sol::table get_type(std::string const &keys_nested) const

get_type returns a type based on a nested string of keys. The key is assumed to be seperated using either dots (.) or colons (:). get_type(“foo.bar.baz”) would look up original_env[“foo”][“bar”][“baz”].

Parameters:

keys_nested – A string of nested keys

Returns:

A sol::table representing the type

inline function_meta get_function(std::string const &keys_nested) const

get_function returns a function based on a nested string of keys. The key is assumed to be seperated using either dots (.) or colons (:). get_function(“foo.bar:baz”) would lookup original_env[“foo”][“bar”][“baz”].

Parameters:

keys_nested – A string of nested keys

Returns:

A sol::protected_function

inline DynamicFeature feature() const

feature Creates a new dynamic feature without an initial value. This can be used as a placeholder for a value that will be set later, e.g. when creating a recipe with some features that are not yet known.

Returns:

a DynamicFeature instance

template<typename T>
inline DynamicFeature feature(T const &value) const

feature Creates a new dynamic feature wrapping a value

Parameters:

value – The value to be wrapped

Returns:

a DynamicFeature instance

template<typename T>
inline grunk::object create_object(T const &value) const

object Creates a grunk::object from a value. This is useful for wrapping values in a grunk::object without creating a DynamicFeature, e.g. when passing arguments to an action that are not features themselves.

Parameters:

value – The value to be wrapped

Returns:

a grunk::object instance

inline DynamicFeature feature(grunk::object const &value) const

feature Creates a new dynamic feature wrapping an existing grunk::object

Parameters:

value – The grunk::object

Returns:

a DynamicFeature instance

template<typename ...Args>
inline DynamicFeature feature(std::string const &type_name, Args&&... args) const

feature Creates a new dynamic feature by invoking the registered constructor/new-method with the provided constructor arguments

Parameters:
  • type_name – The name of the type

  • args – The constructor arguments

Returns:

a DynamicFeature instance

inline DynamicFeature feature(std::string const &type_name, default_construct_t default_construct)

feature Creates a new dynamic feature by invoking the default constructor of the type, if it exists.

This function uses a tag-dispatch method to avoid ambiguity with the templated grunk::feature method that constructs a DynamicFeature wrapping a string.

Use it like this: auto x = grunk.feature(“foo”, grunk::default_construct);

Parameters:
  • type_name – The name of the type

  • default_construct – The default_construct tag.

Returns:

A DynamicFeature instance

template<typename ...Args>
inline DynamicFeature feature(sol::table usertype, Args&&... args) const

feature Creates a new dynamic feature by invoking the registered constructor/new-method with the provided constructor arguments

Parameters:
  • usertype – A sol::table representing the type

  • args – The constructor arguments

Returns:

a DynamicFeature instance

Returns:

template<typename ...Args>
inline DynamicFeature action(std::string const &function, Args&&... args) const

action Creates an action representing the function evaluation given the passed arguments. This will internally register this computation in the underlying dependency graph.

If one of the arguments is not yet a Feature instance, an anonymous Feature (i.e. a constant) will be created on the fly.

Parameters:
  • function – The name of the function to be evaluated

  • args – The arguments passed to the function.

Returns:

a DynamicFeature instance representing the calculation result

template<typename ...Args>
inline DynamicFeature action(function_meta const &function, Args&&... args) const

action Creates an action representing the function evaluation given the passed arguments. This will internally register this computation in the underlying dependency graph.

If one of the arguments is not yet a Feature instance, an anonymous Feature (i.e. a constant) will be created on the fly.

Parameters:
  • function – The function to be evaluated

  • args – The arguments passed to the function.

Returns:

a DynamicFeature instance representing the calculation result

inline grunk::object deserialize(std::string const &v)

deserializes a string back to a grunk::object

This assumes thtat the object has been previously serialized with grunk::serialize

grunk::recipe

This section documents all functions and classes of grunk::recipe. This library allows to write parametric recipes as a mix of yaml and LUA code.

class Recipe : public grunk::environment
#include <Recipe.hpp>

Represents a recipe in grunk.

A Recipe is a specialized environment that can contain parameters, and sub-recipes. Recipes can be serialized to YAML, deep-cloned, populated from YAML files or strings.

Public Functions

Recipe(Recipe const &other)

copy constructor

Parameters:

other – the copied-from object

Recipe &operator=(Recipe const &other)

copy assignment operator

Parameters:

other – the copied-from object

Recipe(Recipe&&)

move constructor

Parameters:

other – the moved-from object

Recipe &operator=(Recipe &&other)

move assignment operator

Parameters:

other – the moved-from object

std::string to_string() const

Serialize the recipe to a YAML string.

This produces a YAML representation of the recipe suitable for persisting to disk or displaying to the user.

Returns:

std::string YAML-formatted representation of the recipe.

Recipe clone() const

Deep-clone this recipe.

The clone will contain copies of all parameters and sub-recipes so the result is independent from the original.

Returns:

Recipe A deep copy of this recipe.

void populate_from_file(std::string const &filename)

Populate this recipe from a YAML file.

The file at filename is parsed as YAML and used to set parameters and sub-recipes of this instance.

Parameters:

filename – Path to the YAML file to read.

void populate_from_string(std::string const &yml)

Populate this recipe from a YAML string.

Parameters:

yml – A YAML document as a string.

void insert_recipe(std::string const &name, Recipe &&recipe)

Insert a sub-recipe into this recipe.

The provided recipe will be moved into the internal collection under the given name.

Parameters:
  • name – Key under which to store the sub-recipe.

  • recipe – Recipe object to move into this recipe.

void insert_module_script(std::string const &name, std::string const &script)

Insert a module script into this recipe.

The script is stored as a Feature<std::string> so that it participates in the recipe’s deep-clone semantics, and installs a callable Lua proxy under name in this recipe’s environment. Calling a function through that proxy (e.g. name.foo(...) from a steps: script) creates a ModuleAction that depends on the stored script feature: editing the script’s value invalidates and recomputes every call made into this module.

Parameters:
  • name – name under which the module is accessible from steps:

  • script – a Lua script as a string, defining the functions of the module

void tag()

Tag this recipe.

This iterates over all keys in the recipes environment and sets the corresponding feature ids to be equal to the keys. This is a convenience method to name all features in a recipe before writing it to YAML.

Feature<Recipe> const &get_recipe(std::string const &key) const

Retrieve a const-reference to a stored sub-recipe feature.

Throws or asserts if the key does not exist (behavior follows the underlying implementation of the class).

Parameters:

key – Key of the sub-recipe to retrieve.

Returns:

Feature<Recipe> const& Reference to the stored feature.

Feature<Recipe> &get_recipe(std::string const &key)

Retrieve a mutable reference to a stored sub-recipe feature.

Parameters:

key – Key of the sub-recipe to retrieve.

Returns:

Feature<Recipe>& Mutable reference to the stored feature.

Public Members

std::unordered_map<std::string, SubRecipe> recipes

Map of sub-recipes stored by name.

std::unordered_map<std::string, Feature<std::string>> module_scripts

Map of module scripts stored by name.

struct SubRecipe
#include <Recipe.hpp>

Container describing a sub-recipe entry.

A SubRecipe bundles the stored recipe feature together with the Lua state used for its bindings and a human-readable name.

Public Functions

RecipeCaller operator()() const

returns a proxy object that can be used to evaluate the subrecipe as a function

Public Members

std::string name

The key name of the sub-recipe in the parent recipe.

Feature<Recipe> recipe

The recipe feature (parameter wrapper) stored for this entry.

lua_State *lua_state

Pointer to the Lua state used by this sub-recipe (may be null).

grunk::plugin

To Do: Not implemented yet .. This section documents all functions and classes of grunk’s plugin system. This .. includes the PluginRegistry that manages all registered plugins, the plugin .. interface IPlugin, that plugin authors must use as base class when writing plugins, .. and the StdPlugin, that registers standard C++ types and functions.

Advanced

This section contains documentation for the most important internal classes and functions. This section of the documentation is targeted for developers who want to modify grunk. As a user of grunk, you should not need to worry about any of these.

template<typename>
bool is_feature_v = false

is_feature_v returns false if the input type is not a Feature template realization

Template Parameters:

typename – any ol’ type

template<typename T>
bool is_feature_v<Feature<T>> = true

is_feature_v returns true, if the input template argument is a Feature template realization

Template Parameters:

T – the element type of the Feature

template<typename F, typename ...Args>
Feature<std::invoke_result_t<F, Args const&...>> action(F const &fun, Feature<Args> const&... args)

Given a function and some features in the feature tree, this function creates an Action instance representing the evaluation of the input function for the input features.

This function accepts features as arguments for the functions, as well as instances that are not wrapped in features. Internally, the latter will be wrapped in an unnamed/anonymous feature

Template Parameters:
  • F – The type of the function to be wrapped. This can be any referentially transparent function, In particular, the function must be invokable on const references.

  • Args – The types of the arguments expected by the input function

Parameters:
  • fun – The input function

  • args – The input features of the feature tree

Returns:

ResultHolder wrapping the outputs of the Action

template<typename T>
auto to_feature(T const &arg)

to_feature is a helper function to convert an input to a feature. If the input is already a feature, it is returned as is. Otherwise, it is wrapped in an unnamed/anonymous feature.

Template Parameters:

T – the type of the input value

Parameters:

arg – the input value

Returns:

auto a feature representing the input value

template<typename F, typename ...Args>
class Action : public parametric::ComputeNode<Action<F, Args...>, parametric::Results<std::invoke_result_t<F, Args const&...>>, parametric::Arguments<Args...>>
#include <ActionStatic.hpp>

The Action class template is a compute node in the feature tree that wraps a referentially transparent function and its arguments. It evaluates the function for the given arguments and caches the output as features. The function can return either a single value, a tuple of values or void. The Action class template inherits from parametric::ComputeNode and implements the eval method to perform the evaluation and caching of the outputs.

Template Parameters:
  • F – The type of the wrapped function, e.g. a lambda, a function pointer or a std::function

  • Args – The types of the arguments expected by the wrapped function, e.g. double, std::string or even user defined types

Public Types

using ReturnType = std::invoke_result_t<F, Args const&...>

The return type of the wrapped function.

Public Functions

inline void eval() const final override

evaluates the function and caches the output.

Public Static Attributes

static size_t nresults = std::tuple_size_v<parametric::Results<ReturnType>>

The number of outputs of the wrapped function. This is 0 for void functions, 1 for functions that return a single value and n for functions that return a tuple of n values.

struct ActionFactory
#include <ActionStatic.hpp>

The ActionFactory struct is an internal factory for creating Action instances.

It is a proxy class used in the free factory functions action. Factory functions are needed, because Actions should always be wrapped in a parametric::compute_node_ptr and the private constructor of ALgorithm makes sure that there is no misuse. The factory function parametric::new_node does not work with the templated constructors of the Action class, so we need new factory functions.

The proxy factory is needed, because the factory functions action must be templated, and templated friend functions are a pain in the ass. This way we have a non-templated friend struct with templated member functions.

Public Static Functions

template<typename F, typename ...Args>
static inline ResultHolder<Action<F, Args...>> new_action(F const &fun, Feature<Args> const&... args)

construct a new Action instance.

Template Parameters:
  • F – The type of the wrapped function

  • Args – The types of the arguments expected by the wrapped function

Parameters:
  • fun – The function to be wrapped in an Action instance

  • args – The arguments wrapped in Features to be passed to the function on evaluation

Returns:

ResultHolder wrapping the outputs of the Action

template<typename Flow>
class TaskflowVisitor
#include <ParallelExecutor.hpp>

The TaskflowVisitor class template is a visitor for traversing the DAG of compute nodes in a feature tree and building a taskflow from it. It is used internally by the to_taskflow function to convert a vector of feature nodes into a taskflow. The visitor uses a depth-first traversal of the DAG, starting from the given nodes and visiting their parents and children recursively. It keeps track of visited nodes and created tasks to avoid redundant work and to establish the correct dependencies between tasks.

Template Parameters:

Flow – the type of the taskflow to build, either tf::Taskflow or tf::Subflow

Public Functions

inline TaskflowVisitor(Flow &flow)

constructs a TaskflowVisitor with the given taskflow to build. The taskflow can be either a tf::Taskflow or a tf::Subflow, depending on the context of the traversal. The visitor will add tasks to this taskflow and establish dependencies between them based on the structure of the DAG.

Parameters:

flow – the taskflow to build

inline void visit(parametric::DAGNode const &n, size_t depth)

visits a DAG node and builds the corresponding task in the taskflow. The visitor checks if the node has already been visited to avoid redundant work. If the node is a compute node (i.e. it is at an even depth in the DAG), it creates a task for it if it does not already exist, and establishes dependencies between the task of the node and the tasks of its parents and children. The visitor assumes that each compute node has at most one parent, which is the compute node that computes it. The visitor also gives the tasks names based on the ids of the nodes for better readability.

Parameters:
  • n – the DAG node to visit

  • depth – the depth of the node in the DAG, used to determine if it is a compute node or a feature node

template<typename C>
class ResultHolder
#include <ResultHolder.hpp>

The ResultHolder class template is a proxy for holding the result of a grunk::Action instance. The results can be either a tuple of features, a feature or a shared_ptr<DAGNode> for void functions.

Template Parameters:

C – A template realization of grunk::Action, i.e. a specific compute node in the feature tree

Public Functions

template<int i = 0>
inline decltype(auto) output() const

returns the i-th output

Template Parameters:

i – index of the queried output

Returns:

decltype(auto) the i-th output feature

inline size_t size() const

returns the number of outputs

Returns:

constexpr size_t the number of outputs

inline decltype(auto) compute_node() const

returns the compute node of this action

inline void eval() const

evaluates the compute node.

inline auto make_dynamic_action(function_meta const &func)

make_dynamic_action is a helper function to create a lambda function that can be registered in the grunk state as a DynamicFunction. The returned lambda takes variadic arguments, converts them to DynamicFeatures and calls the action factory to create a DynamicAction.

Parameters:

func – the function_meta of the function to be wrapped in the lambda

Returns:

auto a lambda function that can be registered as a DynamicFunction in the grunk state

template<typename F>
sol::object create_function_meta(sol::state_view lua, std::string const &name, std::vector<Parameter> const &params, F &&func)

Creates a function_meta instance from a function and its metadata.

template<typename F>
sol::object create_function_meta(sol::state_view lua, std::string const &name, F &&func)

Creates a function_meta instance from a function and its name, without parameter metadata.

inline void trim(std::string &s)

Trims leading and trailing whitespace from a string. This function is used to clean up the serialized strings of compute nodes and parameters before storing them in the Serializer. It removes any whitespace characters (space, tab, newline, carriage return, form feed, vertical tab) from the beginning and end of the input string.

Parameters:

s – The string to be trimmed. The function modifies the input string in place.

inline sol::object lookup_nested(sol::table const &table, std::string const &str)

Accesses a nested element in a sol::table by traversing keys separated by dots (.) or colons (:).

This function splits the string str at each dot (.) or colon (:), then uses each part as a key for accessing nested tables in table. If any key is invalid or does not exist, an exception is thrown.

Note

This function assumes the table contains only sol::table elements at each nested level except for the final key. If any key is invalid or does not exist, an exception is thrown.

Parameters:
  • table – The sol::table to be traversed.

  • str – The string representing the path of nested keys, separated by dots (.) or colons (:).

Returns:

sol::object The nested object in the table at the specified path.

class ActionDynamic : public parametric::ComputeNode<ActionDynamic>
#include <ActionDynamic.hpp>

template specialization of Algoithm for DynamicFunctions

Given a function and a set of DynamicFeature instances as inputs, a DynamicAction represents the calculation of the function from the arguments wrapped in the input DynamicFeature instances.

The class has a private constructor, as it should always be created using the factory function grunk::action.

If the wrapped function returns an std::tuple, each element of this tuple is interpreted as an output of the function and each element can be retrieved individually as a feature.

Public Functions

inline void connect_inputs(std::vector<DynamicFeature> const &args)

connect the inputs to the compute node represented by this action

Parameters:

args – the input features

template<typename ...Args>
inline void connect_inputs(Feature<Args> const&... args)

connect the inputs to the compute node represented by this action

Template Parameters:

Args – the types of the inputs features

Parameters:

args – the input features

inline DynamicFeature initialize_results() const

initializes an empty feature for the output of this action

inline void connect_results(DynamicFeature const &res)

connects this compute node with the inputs and outputs

inline void eval() const override

This function evaluates the wrapped function and caches the output.

inline std::string serialize() const final override

serialize a DynamicAction to string

Returns:

std::string the serialized DynamicAction

template<>
class ResultHolder<ActionDynamic>
#include <ActionDynamic.hpp>

Specialization of the ResultHolder class template for DynamicActions. It is a proxy for holding the result of a ::grunk::DynamicAction instance. The results is an std::vector of DynamicFeatures. In addition to storing the result, it stores a const reference to the compute_node so that void functions can be evaluated as well.

Public Functions

inline ResultHolder(result_type const &res, std::shared_ptr<parametric::DAGNode> const &c)

construct a new ResultHolder instance connecting an output dynamic feature to a compute node

Parameters:
  • res – the output dynamic feature

  • c – the compute node

inline decltype(auto) output() const

returns the i-th output

Returns:

decltype(auto) the -ith output DynamicFeature

inline std::shared_ptr<parametric::DAGNode> const &compute_node() const

returns a const reference to the DynamicAction

Returns:

DynamicAction const& the DynamicAction instance

inline void eval() const

evaluates the DynamicAction

inline decltype(auto) output() const

returns the i-th output

Template Parameters:

i – index of the queried output

Returns:

decltype(auto) the i-th output feature

inline size_t size() const

returns the number of outputs

Returns:

constexpr size_t the number of outputs

inline decltype(auto) compute_node() const

returns the compute node of this action

inline void eval() const

evaluates the compute node.

struct DynamicActionFactory
#include <ActionDynamic.hpp>

The ActionFactory struct is an internal factory for creating Action instances.

It is a proxy class used in the free factory functions action. Factory functions are needed, because Actions should always be wrapped in a parametric::compute_node_ptr and the private constructor of Action makes sure that there is no misuse. The factory function parametric::new_node does not work with the templated constructors of the Action class, so we need new factory functions.

The proxy factory is needed, because the factory functions action must be templated, and templated friend functions are a pain in the ass. This way we have a non-templated friend struct with templated member functions.

Public Static Functions

static inline ResultHolder<ActionDynamic> new_action(function_meta const &fun, std::vector<DynamicFeature> const &args)

Returns a new DynamicActionPtr given a DynamicFunction and an vector of DynamicFeatures.

Parameters:
  • fun – The reflect::DynamicFunction to be wrapped

  • args – The input features

Returns:

ResultHolder<DynamicAction> The returned ResultHolder wrapping the outputs

template<typename ...Args>
static inline ResultHolder<ActionDynamic> new_action(function_meta const &fun, Feature<Args> const&... args)

Returns a new DynamicActionPtr given a DynamicFunction and an vector of DynamicFeatures.

Parameters:
  • fun – The reflect::DynamicFunction to be wrapped

  • args – The input features

Returns:

ResultHolder<DynamicAction> The returned ResultHolder wrapping the outputs

struct Parameter
#include <function_meta.hpp>

Represents a parameter for a dynamic function.

Public Members

std::optional<std::string> name = {std::nullopt}

the name of the function parameter

bool is_const_reference = {false}

wether the parameter is passed by const reference. Only meaningful for C++ types.

class function_meta
#include <function_meta.hpp>

Represents metadata for a dynamic function.

Public Functions

inline function_meta(std::string const &name_, std::optional<std::vector<Parameter>> const &params_, sol::function const &func_)

construct a function_meta isntance

Parameters:
  • name_ – The name of the function

  • params_ – The parameters of the function

  • func_ – The Lua function

inline std::string const &get_name() const

getter for the name of the function

inline std::optional<std::vector<Parameter>> const &get_params() const

getter for the parameters of the function

inline sol::protected_function const &get_function() const

getter for the wrapped Lua function

template<typename ...Args>
inline sol::protected_function_result call(Args&&... args) const

call the function

Template Parameters:

Args – the arguments passed as parameters

inline decltype(auto) operator()(sol::variadic_args va) const

call the function

Parameters:

va – the arguments passed as parameters

inline decltype(auto) lua_state() const

a getter for the underlying lua state of the wrapped Lua function

class io_error : public std::exception
#include <io_error.hpp>

An exception representing errors with grunk’s file I/O system.

Public Functions

inline io_error(std::string const &msg)

Construct a new io error object from an error message.

Parameters:

msg –

inline const char *what() const noexcept override

print the error message with the prefix “grunk IO error”

Returns:

const char* the error message

inline std::string get_message() const

Get the error message without the prefix “grunk IO error”.

Returns:

std::string the error message

class Serializer
#include <Serializer.hpp>

The Serializer class is responsible for converting a feature DAG into a YAML string representation. It traverses the DAG in a depth-first manner, visiting each node and serializing it according to its type (parameter or compute node). The resulting YAML string can be used to save recipes to file or to display them in a human-readable format.

Public Types

using Visited = std::unordered_map<parametric::DAGNode const*, bool>

A typedef for an unordered map of boolean flags for every node. This is used to keep track of the nodes that have already been visited.

Public Functions

Serializer() = default

Construct a new Serializer object.

inline std::map<std::string, std::string> const &get_parameters() const

Get the parameters of the serialized feature tree. This is a map from parameter names to their serialized values. The parameters are the root nodes of the feature tree that have no parents and are not compute nodes. They are listed in the “parameters” block of the YAML representation of the recipe.

Returns:

std::map<std::string, std::string> const& A map from parameter names to their serialized values.

inline std::vector<std::string> get_steps() const

Get the steps of the serialized feature tree. This is a vector of strings, where each string is a serialized compute node in the feature tree. The steps are the compute nodes of the feature tree that are not root nodes and are not placeholders. They are listed in the “steps” block of the YAML representation of the recipe.

Returns:

std::vector<std::string> A vector of strings, where each string is a serialized compute node in the feature tree.

inline std::string get_string(bool with_root_nodes = false) const

Get the string representation of the serialized feature tree. This is a single string that contains the serialized compute nodes in the feature tree, separated by newlines. The string can be used as the value of the “steps” block in the YAML representation of the recipe. If with_root_nodes is true, the string also includes the root nodes of the feature tree as parameter assignments at the beginning of the string.

Parameters:

with_root_nodes – If true, include the root nodes of the feature tree as parameter assignments at the beginning of the string.

Returns:

std::string A string representation of the serialized feature tree.

template<typename Arg>
inline void parse(Feature<Arg> const &f)

Parses a feature and its underlying DAG into the Serializer. This function takes a feature as input and traverses its DAG in a depth-first manner, visiting each node and serializing it according to its type (parameter or compute node). The resulting serialized nodes are stored in the “parameters” and “steps” members of the Serializer, which can be accessed using the corresponding getter functions.

Template Parameters:

Arg – The type of the feature value, e.g. double, std::string or even a user defined type.

Parameters:

f – The feature to be parsed into the Serializer.

class ToStringVisitor
#include <Serializer.hpp>

The ToStringVisitor class is a visitor for traversing the DAG of a feature and serializing its nodes into a YAML string representation. It is used internally by the Serializer class to convert a feature DAG into a YAML string. The visitor uses a depth-first traversal of the DAG, starting from the given node and visiting its children recursively. It keeps track of visited nodes to avoid redundant work and to ensure that each node is serialized only once.

Public Functions

inline ToStringVisitor(Serializer &tree, parametric::DAGNode const &start_node)

Construct a new ToStringVisitor object.

inline void visit(parametric::DAGNode const &n, size_t depth)

visit a node and serialize to yaml.

Here it is assumed, that every other node is a ComputeNode. These compute nodes will be stored on an intermediate stack, so that unstacking it will result in a topological orderd list of serialized compute nodes, which will be written into the “steps” block of the yaml node.

Parameter nodes will directly be added to the “parameters” block, if they are independent root nodes

Parameters:
  • n – The current node to be visited

  • depth – The current depth of the DFS traversal

class ModuleAction : public parametric::ComputeNode<ModuleAction>
#include <ModuleAction.hpp>

A compute node representing the invocation of a single function defined in a grunk module script that belongs to a Recipe.

A ModuleAction depends on the Feature<std::string> holding the module’s Lua source, in addition to its regular input features. Whenever the script feature’s value changes, the module is recompiled the next time this action is evaluated, so calling a module function behaves like any other feature-dependent computation: editing Recipe::module_scripts invalidates and recomputes every ModuleAction that was built from a call into that module.

The body of a module function itself is not parametric: statements inside it run as plain, uninstrumented Lua against concrete values. This is what allows non-const setters to be used safely to build up objects, see the “Modules” section of the documentation.

Public Functions

inline void connect_inputs(Feature<std::string> const &script, std::vector<DynamicFeature> const &args)

connect the inputs to this compute node

Parameters:
  • script – the module’s source code, as a Feature<std::string>

  • args – the arguments passed to the function call

inline DynamicFeature initialize_results() const

initializes an empty feature for the output of this action

inline void connect_results(DynamicFeature const &res)

connects this compute node with the inputs and outputs

void eval() const override

(Re-)compiles the module if the script has changed since the last evaluation and calls the requested function with the current argument values.

std::string serialize() const final override

serialize a ModuleAction to string

template<>
class ResultHolder<ModuleAction>
#include <ModuleAction.hpp>

Specialization of the ResultHolder class template for ModuleActions, analogous to the specialization for ActionDynamic.

Public Functions

inline decltype(auto) output() const

returns the i-th output

Template Parameters:

i – index of the queried output

Returns:

decltype(auto) the i-th output feature

inline size_t size() const

returns the number of outputs

Returns:

constexpr size_t the number of outputs

inline decltype(auto) compute_node() const

returns the compute node of this action

inline void eval() const

evaluates the compute node.

class RecipeAction : public parametric::ComputeNode<RecipeAction>
#include <RecipeAction.hpp>

An action node that operates on a Recipe.

RecipeAction is a compute node used by the recipe execution subsystem. It provides facilities to connect a recipe and dynamic input features, initialize and connect result features, and to evaluate the action. The node can also serialize itself to a string representation.

Public Functions

RecipeAction(std::string const &name)

Construct a RecipeAction.

Parameters:

name – Human-readable name for this action. Used for identification and serialization.

void connect_inputs(Feature<Recipe> const &recipe, std::unordered_map<std::string, DynamicFeature> const &input_map)

Connect inputs required by the action.

connect_inputs binds the provided recipe feature and a mapping of named dynamic features to this action’s expected inputs.

Parameters:
  • recipe – The recipe feature to connect as the primary input.

  • input_map – A map of feature name -> DynamicFeature to bind as additional inputs.

Feature<Recipe> initialize_results() const

Prepare and return a Feature<Recipe> to hold results.

initialize_results allocates or configures a result feature suitable for storing the outputs produced by this action.

Returns:

A Feature<Recipe> that will hold the action results.

void connect_results(Feature<Recipe> const &res)

Connect the result feature to this action.

Parameters:

res – The result feature to attach to this action node.

void eval() const override

Evaluate the action.

This method performs the action’s computation. It overrides the ComputeNode::eval() contract.

std::string serialize() const final override

Serialize the action to a string.

Returns:

A string containing the serialized representation.

class RecipeCaller
#include <RecipeCaller.hpp>

Helper class used to call/execute a Recipe from Lua or C++.

RecipeCaller collects input DynamicFeatures (via a Proxy), optionally assigns an id, and lazily creates the RecipeAction that performs the execution. Once an output has been requested the caller becomes locked and further input assignments are prohibited.

Public Functions

RecipeCaller(std::string const &name, Feature<Recipe> const &recipe, lua_State *lua)

Create a RecipeCaller bound to a recipe and a Lua state.

Parameters:
  • name – A human-readable name for the caller/action.

  • recipe – The source recipe feature to execute.

  • lua – Pointer to the Lua state used for value conversions.

Proxy operator[](std::string const &key)

Access a proxy for a named input key.

Example usage from Lua: caller[“input_name”] = some_value

Parameters:

key – Name of the input to access.

Returns:

A Proxy object bound to the provided key.

bool locked() const

Whether the caller is locked (no further input assignments).

The caller is locked once an output has been requested; after that input assignment via Proxy::operator= will throw.

DynamicFeature get(std::string const &key)

Retrieve a previously assigned input by key.

Parameters:

key – The input name.

Returns:

The DynamicFeature assigned to the key.

RecipeCaller &with_id(std::string const &value)

Fluent setter for the optional id field.

Parameters:

value – Identifier string to associate with the call.

Returns:

Reference to *this for chaining.

void set_id(std::string const &value)

Set the id for this caller.

Parameters:

value – Identifier value.

struct Proxy
#include <RecipeCaller.hpp>

Proxy object used by operator[] to assign inputs.

The Proxy stores the key and a reference back to the owning RecipeCaller. Assigning various types to the proxy will convert or wrap them into a DynamicFeature and insert them into the caller’s input map. Assignment is disallowed once the caller is locked.

Public Functions

template<typename T>
inline void operator=(T &&other)

Assign a value to the proxied input key.

The template overload accepts either an existing DynamicFeature, a sol::object, or any other type that can be converted into a Lua object; it will be wrapped into a DynamicFeature and stored. Throws if the caller is locked.

operator DynamicFeature()

Convert the proxy to a DynamicFeature.

This operator triggers conversion/lookup of the stored input feature and is used when retrieving the assigned value.

DynamicFeature to_feature()

Explicitly convert the proxied value to a feature.

Returns:

The DynamicFeature associated with this proxy’s key.

Public Members

std::string key

The key associated with the subrecipe to be called.

RecipeCaller &rc

The RecipeCaller instance that will be constructed by this proxy.

class RecipeGetValAction : public parametric::ComputeNode<RecipeGetValAction>
#include <RecipeGetValAction.hpp>

An action to retrieve the value of a called subrecipe. This class is handled internally.

Public Functions

RecipeGetValAction(std::string const &name)

Construct a get-value action for recipes.

Parameters:

name – Human-readable name for the action.

void connect_inputs(Feature<Recipe> const &recipe, std::string const &key)

Connect the source recipe and the key to extract.

Parameters:
  • recipe – The source recipe feature.

  • key – The name of the feature/argument to read from the recipe.

DynamicFeature initialize_results() const

Prepare a DynamicFeature to hold the extracted value.

Returns:

A DynamicFeature that will receive the value.

void connect_results(DynamicFeature const &res)

Attach an externally provided result DynamicFeature.

Parameters:

res – The DynamicFeature to write the extracted value into.

void eval() const override

Evaluate the action and extract the requested value.

std::string serialize() const final override

Serialize the action to a string representation.

Returns:

A serialized string describing the action.