Soletta™ Framework
|
Flow-builder is a helper component that creates nodes and connections specs with a friendly API. More...
Typedefs | |
typedef struct sol_flow_builder | sol_flow_builder |
Builder's handle. More... | |
Functions | |
int | sol_flow_builder_add_node (struct sol_flow_builder *builder, const char *name, const struct sol_flow_node_type *type, const struct sol_flow_node_options *option) |
Add a node to the nodes spec of the resulting flow. More... | |
int | sol_flow_builder_add_node_by_type (struct sol_flow_builder *builder, const char *name, const char *type_name, const char *const *options_strv) |
Add a node (via its type's name) to the nodes spec of the resulting flow. More... | |
int | sol_flow_builder_connect (struct sol_flow_builder *builder, const char *src_name, const char *src_port_name, int src_port_idx, const char *dst_name, const char *dst_port_name, int dst_port_idx) |
Add a connection (via port names) to the conn spec of the resulting flow. More... | |
int | sol_flow_builder_connect_by_index (struct sol_flow_builder *builder, const char *src_name, uint16_t src_port_index, const char *dst_name, uint16_t dst_port_index) |
Add a connection to the conn spec of the resulting flow. More... | |
int | sol_flow_builder_del (struct sol_flow_builder *builder) |
Destroy a sol_flow_builder instance. More... | |
int | sol_flow_builder_export_option (struct sol_flow_builder *builder, const char *node_name, const char *option_name, const char *exported_name) |
Exports an given option of a node using exported_name as identifier. More... | |
int | sol_flow_builder_export_port_in (struct sol_flow_builder *builder, const char *node_name, const char *port_name, int port_idx, const char *exported_name) |
Exports an input port of a node using exported_name as identifier. More... | |
int | sol_flow_builder_export_port_out (struct sol_flow_builder *builder, const char *node_name, const char *port_name, int port_idx, const char *exported_name) |
Exports an output port of a node using exported_name as identifier. More... | |
struct sol_flow_node_type * | sol_flow_builder_get_node_type (struct sol_flow_builder *builder) |
Returns the node type generated by the builder. More... | |
struct sol_flow_builder * | sol_flow_builder_new (void) |
Creates a new instance of a sol_flow_builder. More... | |
void | sol_flow_builder_set_resolver (struct sol_flow_builder *builder, const struct sol_flow_resolver *resolver) |
Set the Resolver to be used by the builder's resulting flow. More... | |
int | sol_flow_builder_set_type_description (struct sol_flow_builder *builder, const char *name, const char *category, const char *description, const char *author, const char *url, const char *license, const char *version) |
Set the type description to be used by the builder. More... | |
Flow-builder is a helper component that creates nodes and connections specs with a friendly API.
Instead of declaring a node spec structure and an ordered connection spec structure directly, using node and port indexes, builder can be used to add nodes and connections in a programmatic way, using nodes and ports names.
This approach should led to a code easier to read and maintain, but it would consume a bit more memory and processing when compared with the static version.
Builder's handle.
int sol_flow_builder_add_node | ( | struct sol_flow_builder * | builder, |
const char * | name, | ||
const struct sol_flow_node_type * | type, | ||
const struct sol_flow_node_options * | option | ||
) |
Add a node to the nodes spec of the resulting flow.
NULL
and must be unique within a flow.builder | The Builder |
name | Node name |
type | Node type |
option | Node options |
0
on success, error code (always negative) otherwiseReferenced by startup().
int sol_flow_builder_add_node_by_type | ( | struct sol_flow_builder * | builder, |
const char * | name, | ||
const char * | type_name, | ||
const char *const * | options_strv | ||
) |
Add a node (via its type's name) to the nodes spec of the resulting flow.
Resolver will be used to get the node type and options base on the type's name provided.
NULL
and must be unique within a flow.builder | The Builder |
name | Node name |
type_name | Name of the node type |
options_strv | Node options in a string "list" format |
0
on success, error code (always negative) otherwiseReferenced by startup().
int sol_flow_builder_connect | ( | struct sol_flow_builder * | builder, |
const char * | src_name, | ||
const char * | src_port_name, | ||
int | src_port_idx, | ||
const char * | dst_name, | ||
const char * | dst_port_name, | ||
int | dst_port_idx | ||
) |
Add a connection (via port names) to the conn spec of the resulting flow.
Port names must be as declared in the description structure of the node types. If no description was declared, sol_flow_builder_connect_by_index() should be used instead of this function.
builder | The Builder |
src_name | Name of the source node |
src_port_name | Port's name in the source node |
src_port_idx | Port's index in the source node |
dst_name | Name of the destination node |
dst_port_name | Port's name in the destination node |
dst_port_idx | Port's index in the destination node |
0
on success, error code (always negative) otherwiseReferenced by startup().
int sol_flow_builder_connect_by_index | ( | struct sol_flow_builder * | builder, |
const char * | src_name, | ||
uint16_t | src_port_index, | ||
const char * | dst_name, | ||
uint16_t | dst_port_index | ||
) |
Add a connection to the conn spec of the resulting flow.
builder | The Builder |
src_name | Name of the source node |
src_port_index | Port's index in the source node |
dst_name | Name of the destination node |
dst_port_index | Port's index in the destination node |
0
on success, error code (always negative) otherwiseint sol_flow_builder_del | ( | struct sol_flow_builder * | builder | ) |
Destroy a sol_flow_builder instance.
builder | Builder to be destroyed |
0
on success, error code (always negative) otherwise Referenced by shutdown(), and startup().
int sol_flow_builder_export_option | ( | struct sol_flow_builder * | builder, |
const char * | node_name, | ||
const char * | option_name, | ||
const char * | exported_name | ||
) |
Exports an given option of a node using exported_name
as identifier.
builder | The Builder |
node_name | Node's name |
option_name | Option's name |
exported_name | Name used to identify the exported option |
0
on success, error code (always negative) otherwise int sol_flow_builder_export_port_in | ( | struct sol_flow_builder * | builder, |
const char * | node_name, | ||
const char * | port_name, | ||
int | port_idx, | ||
const char * | exported_name | ||
) |
Exports an input port of a node using exported_name as identifier.
builder | The Builder |
node_name | Node's name |
port_name | Port's name |
port_idx | Port's index |
exported_name | Name used to identify the exported port |
0
on success, error code (always negative) otherwiseint sol_flow_builder_export_port_out | ( | struct sol_flow_builder * | builder, |
const char * | node_name, | ||
const char * | port_name, | ||
int | port_idx, | ||
const char * | exported_name | ||
) |
Exports an output port of a node using exported_name as identifier.
builder | The Builder |
node_name | Node's name |
port_name | Port's name |
port_idx | Port's index |
exported_name | Name used to identify the exported port |
0
on success, error code (always negative) otherwisestruct sol_flow_node_type* sol_flow_builder_get_node_type | ( | struct sol_flow_builder * | builder | ) |
Returns the node type generated by the builder.
It should be used to create nodes with sol_flow_node_new(). After the type is created, no more nodes or connections can be added.
This node type must be deleted using sol_flow_node_type_del().
builder | The Builder |
NULL
otherwise Referenced by startup().
struct sol_flow_builder* sol_flow_builder_new | ( | void | ) |
Creates a new instance of a sol_flow_builder.
It should be deleted with sol_flow_builder_del() only after the flow stops running.
NULL
on error. Referenced by startup().
void sol_flow_builder_set_resolver | ( | struct sol_flow_builder * | builder, |
const struct sol_flow_resolver * | resolver | ||
) |
Set the Resolver to be used by the builder's resulting flow.
builder | The Builder |
resolver | Resolver to be used |
NULL
to resolver will set the default resolver. int sol_flow_builder_set_type_description | ( | struct sol_flow_builder * | builder, |
const char * | name, | ||
const char * | category, | ||
const char * | description, | ||
const char * | author, | ||
const char * | url, | ||
const char * | license, | ||
const char * | version | ||
) |
Set the type description to be used by the builder.
Input/output ports and options descriptions are automatically set. The strings passed as arguments will be copied.
builder | The Builder |
name | Node type name |
category | Node type category |
description | Node type description |
author | Author's name |
url | Node type url |
license | License text |
version | Node type version |
0
on success, error code (always negative) otherwise