Parameter passing conventions
There are some rules that need to be followed when passing parameters of Amino and Bifrost types into and out of your functions.
When the function is instantiated into a node in a Bifrost graph, the input parameters will be instantiated to input ports, the output parameters will be instantiated to output ports, and input/output parameters will be instantiated to one input port and one output port.
Type of parameter | How it is passed to the function | Its order in the parameter list | Special annotation needed |
---|---|---|---|
Input/Output parameter | Passed by non-const reference | Must come before the outputs in the parameter list | Requires the Amino::InOut annotation |
Output parameter | Passed by non-const reference | Always comes last in the parameter list | No special annotation is required |
Output parameter | Return value of the function The return value can only be a C++ built-in type or an enum |
Not in the parameter list | Optional The port will be named output by default. You can change its name using the Amino::Node outName token. |
Input parameters always appear before output parameters in the parameter list. They do not require special annotation, but they are passed in different ways depending on their type and how the passed data will be used.
Type | How the data will be used | How it is passed |
---|---|---|
Amino::String , Amino::Any |
The data will be copied or moved | Passed by value |
Amino::String , Amino::Any |
The data will only be read, but not modified, copied, or moved | Passed by const reference |
Classes | The data will be mutated, or it will be copied to another class or another container | Passed by value using Amino::MutablePtr |
Classes | The data will be moved, or it will be copied to another class or another container, but it will not be mutated in any other way | Passed by value using Amino::Ptr |
Classes | The data will only be read, and it will not be modified, copied, or moved | Passed by const reference |
C++ built-in types | In all cases | Passed by value |
enums | In all cases | Passed by value |
All other types | In all cases | Passed by const reference |
If a class will be mutated and passed to the node's output, then the class should be passed as an Input/Output parameter using an Amino::MutablePtr
.
See the section on port annotation for details. See sdk/examples/AminoConcepts in your installation for an example that demonstrates the nodes and ports passing conventions.