Node annotation
The Amino::Node
annotation, AMINO_ANNOTATE("Amino::Node")
, is required for a node to be instantiated in a Bifrost graph. Without this annotation, the function will be ignored by cpp2json
, and no node definition will be created for the function.
The AMINO_ANNOTATE("Amino::Node")
statement is placed at the end of the function's prototype statement, before its ending semicolon (";").
For example:
void concatenate_strings(const Amino::String& first, const Amino::String& second, Amino::String& concatenated)
AMINO_ANNOTATE("Amino::Node");
Passing the Amino::Node
annotation to AMINO_ANNOTATE
will generate a node definition that has the C++ function name as the node name. The full name of the function, including its namespace, is used as the node name.
For example, if your function belongs to your MyUtils
namespace, the full name of the function, MyUtils::concatenate_strings
, will be used as the node name, and the node instantiated in the Bifrost graph will have the name MyUtils::concatenate_strings
.
Ports are defined by the function's declared parameters. Parameters that are passed either by value or by const reference define input ports, and parameters that are passed by reference define output ports.
For example, the annotation above will generate a node with two input ports, first
and second
, that take Amino::String
as inputs, and one output port, concatenated
, that returns an Amino::String
.
Functions can return an enum or a C++ built in type. If a function returns a value, this value will be passed to an output port named output
. You can set the output port's name to something more representative using the outName
Amino::Node
token.
For example:
bool concatenate_strings(const Amino::String& first, const Amino::String& second, Amino::String& concatenated)
AMINO_ANNOTATE("Amino::Node outName=status");
This will pass the return value of the function to an output port called status
.
See Port annotation for more information on annotating ports.