Soletta™ Framework
|
Helper to create a flow node type from a simple C function. More...
Data Structures | |
struct | sol_flow_simple_c_type_event |
Simple C event structure. More... | |
Macros | |
#define | sol_flow_simple_c_type_new(context_data_type, cb,...) sol_flow_simple_c_type_new_full(#cb, sizeof(context_data_type), sizeof(struct sol_flow_node_type), cb, ## __VA_ARGS__, NULL) |
This macro will simplify usage of sol_flow_simple_c_type_new_full() by taking only a context data type and the callback, as well as the port information. More... | |
#define | sol_flow_simple_c_type_new_nocontext(cb,...) sol_flow_simple_c_type_new_full(#cb, 0, sizeof(struct sol_flow_node_type), cb, ## __VA_ARGS__, NULL) |
This macro will simplify usage of sol_flow_simple_c_type_new_full() by taking only the callback as well as the port information. More... | |
#define | SOL_FLOW_SIMPLE_C_TYPE_PORT_IN(name, type) |
Helper macro to declare an input port. More... | |
#define | SOL_FLOW_SIMPLE_C_TYPE_PORT_OUT(name, type) |
Helper macro to declare an output port. More... | |
#define | SOL_FLOW_SIMPLE_C_TYPE_PORT_TYPE_IN 1 |
Input port identifier. More... | |
#define | SOL_FLOW_SIMPLE_C_TYPE_PORT_TYPE_OUT 2 |
Output port identifier. More... | |
Typedefs | |
typedef struct sol_flow_simple_c_type_event | sol_flow_simple_c_type_event |
Simple C event structure. More... | |
Functions | |
uint16_t | sol_flow_simple_c_type_get_port_in_index (const struct sol_flow_node_type *type, const char *port_in_name) |
Helper to retrieve the input port index from its name. More... | |
uint16_t | sol_flow_simple_c_type_get_port_out_index (const struct sol_flow_node_type *type, const char *port_out_name) |
Helper to retrieve the output port index from its name. More... | |
struct sol_flow_node_type * | sol_flow_simple_c_type_new_full (const char *name, size_t context_data_size, uint16_t options_size, int(*func)(struct sol_flow_node *node, const struct sol_flow_simple_c_type_event *ev, void *data),...) SOL_ATTR_SENTINEL |
Creates a flow node type using a simple C function. More... | |
Helper to create a flow node type from a simple C function.
Simple C Type is a helper to ease development of custom nodes where the full power of a node type is not needed. Instead, a single function is used and given to the node, the node private data and the event.
Each node will have a context (private) data of size declared to sol_flow_simple_c_type_new_full(). This is given as the last argument to the callback func as well as can be retrieved with sol_flow_node_get_private_data(). An example:
#define sol_flow_simple_c_type_new | ( | context_data_type, | |
cb, | |||
... | |||
) | sol_flow_simple_c_type_new_full(#cb, sizeof(context_data_type), sizeof(struct sol_flow_node_type), cb, ## __VA_ARGS__, NULL) |
This macro will simplify usage of sol_flow_simple_c_type_new_full() by taking only a context data type and the callback, as well as the port information.
It will transform the callback (func) into the name of the simple_c_type as well as doing the sizeof(context_data_type) to specify the data size.
#define sol_flow_simple_c_type_new_nocontext | ( | cb, | |
... | |||
) | sol_flow_simple_c_type_new_full(#cb, 0, sizeof(struct sol_flow_node_type), cb, ## __VA_ARGS__, NULL) |
This macro will simplify usage of sol_flow_simple_c_type_new_full() by taking only the callback as well as the port information.
It will transform the callback (func) into the name of the simple_c_type and use context_data_size as 0.
Referenced by startup().
#define SOL_FLOW_SIMPLE_C_TYPE_PORT_IN | ( | name, | |
type | |||
) |
Helper macro to declare an input port.
name | Port's name |
type | Data type of the packets that this port should receive |
Referenced by startup().
#define SOL_FLOW_SIMPLE_C_TYPE_PORT_OUT | ( | name, | |
type | |||
) |
Helper macro to declare an output port.
name | Port's name |
type | Data type of the packets that this port will send |
Referenced by startup().
#define SOL_FLOW_SIMPLE_C_TYPE_PORT_TYPE_IN 1 |
Input port identifier.
#define SOL_FLOW_SIMPLE_C_TYPE_PORT_TYPE_OUT 2 |
Output port identifier.
typedef struct sol_flow_simple_c_type_event sol_flow_simple_c_type_event |
Simple
C
event structure.
uint16_t sol_flow_simple_c_type_get_port_in_index | ( | const struct sol_flow_node_type * | type, |
const char * | port_in_name | ||
) |
Helper to retrieve the input port index from its name.
While the port index is defined by the declaration order given to sol_flow_simple_c_type_new_full(), sometimes it is desirable to find in the index given the string.
type | the type to search the port index given its name. |
port_in_name | the input port name to retrieve the index. |
uint16_t sol_flow_simple_c_type_get_port_out_index | ( | const struct sol_flow_node_type * | type, |
const char * | port_out_name | ||
) |
Helper to retrieve the output port index from its name.
While the port index is defined by the declaration order given to sol_flow_simple_c_type_new_full(), sometimes it is desirable to find out the index given the string.
type | the type to search the port index given its name. |
port_out_name | the output port name to retrieve the index. |
Referenced by on_timeout().
struct sol_flow_node_type* sol_flow_simple_c_type_new_full | ( | const char * | name, |
size_t | context_data_size, | ||
uint16_t | options_size, | ||
int(*)(struct sol_flow_node *node, const struct sol_flow_simple_c_type_event *ev, void *data) | func, | ||
... | |||
) |
Creates a flow node type using a simple C function.
The newly returned type should be freed calling sol_flow_node_type_del().
The ports of the given type should be specified using the NULL-terminated variable arguments, each port takes a triple name, packet_type and direction. Name is the string and direction is either SOL_FLOW_SIMPLE_C_TYPE_PORT_TYPE_IN or SOL_FLOW_SIMPLE_C_TYPE_PORT_TYPE_OUT. Consider using the macros SOL_FLOW_SIMPLE_C_TYPE_PORT_IN() and SOL_FLOW_SIMPLE_C_TYPE_PORT_OUT() to make it clear and future-proof.
name | the type name, will be used in debug. Often this is the name of the function you're using. |
context_data_size | the amount of bytes to store for each node instance. This memory can be retrieved from a node with sol_flow_node_get_private_data() and is given to func as the last argument. If zero is given, then this node shouldn't store per-instance information and data shouldn't be used. |
options_size | the amount of bytes to store options used with this type. The options struct must contain a struct sol_flow_node_options as its first member. |
func | the function to call for all events of this node such as opening (creating), closing (destroying), ports being connected or disconnected as well as incoming packets on input ports. |
Referenced by startup().