Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions
Meta types

These routines are used to manipulate the flow meta types. More...

Data Structures

struct  sol_flow_metatype
 Struct that describes a meta type. More...
 
struct  sol_flow_metatype_context
 Meta type context. More...
 
struct  sol_flow_metatype_option_description
 Struct that describes the meta type options. More...
 
struct  sol_flow_metatype_port_description
 Struct that describes the meta type ports. More...
 

Macros

#define SOL_FLOW_METATYPE(_NAME, decl...)
 Exports a meta type. More...
 
#define SOL_FLOW_METATYPE_API_VERSION   (1)
 Defines the current version of the meta type API. More...
 

Typedefs

typedef struct sol_flow_metatype sol_flow_metatype
 Struct that describes a meta type. More...
 
typedef struct
sol_flow_metatype_context 
sol_flow_metatype_context
 Meta type context. More...
 
typedef int(* sol_flow_metatype_create_type_func )(const struct sol_flow_metatype_context *ctx, struct sol_flow_node_type **type)
 A callback used to create the meta type itself. More...
 
typedef int(* sol_flow_metatype_generate_code_func )(const struct sol_flow_metatype_context *ctx, struct sol_buffer *out)
 A callback used by sol-fbp-generator to generate the meta type C code. More...
 
typedef struct
sol_flow_metatype_option_description 
sol_flow_metatype_option_description
 Struct that describes the meta type options. More...
 
typedef int(* sol_flow_metatype_options_description_func )(struct sol_vector *opts)
 A callback used create the options description of a meta type. More...
 
typedef struct
sol_flow_metatype_port_description 
sol_flow_metatype_port_description
 Struct that describes the meta type ports. More...
 
typedef int(* sol_flow_metatype_ports_description_func )(const struct sol_flow_metatype_context *ctx, struct sol_vector *in, struct sol_vector *out)
 A callback used create the port description of a meta type. More...
 

Functions

sol_flow_metatype_generate_code_func sol_flow_metatype_get_generate_code_end_func (const struct sol_str_slice name)
 Searchs for the callback that generates the end code of a given meta type. More...
 
sol_flow_metatype_generate_code_func sol_flow_metatype_get_generate_code_start_func (const struct sol_str_slice name)
 Searchs for the callback that generates the start code of a given meta type. More...
 
sol_flow_metatype_generate_code_func sol_flow_metatype_get_generate_code_type_func (const struct sol_str_slice name)
 Searchs for the callback that generates the body code of a given meta type. More...
 
sol_flow_metatype_options_description_func sol_flow_metatype_get_options_description_func (const struct sol_str_slice name)
 Searchs for callback that describes the options of a given meta type. More...
 
const char * sol_flow_metatype_get_options_symbol (const struct sol_str_slice name)
 Searchs for the metatype options symbol. More...
 
sol_flow_metatype_ports_description_func sol_flow_metatype_get_ports_description_func (const struct sol_str_slice name)
 Searchs for callback that describes the ports of a given meta type. More...
 

Detailed Description

These routines are used to manipulate the flow meta types.

Meta type nodes are nodes that are created on-the-fly. This means that there is no json file describing what are the node ports, open/close functions, private data and etc.

One usually needs to create a meta type node for two reasons:

To use a meta type using flow, one must declare it using the DECLARE keyword, take a look in the example.

DECLARE=The-Name-Of-The-Node-Type:The-Name-Of-My-Meta-Type:Arguments-to-my-meta-type

The first part of the declare statement is responsible for identifying what will be the node type in the flow code, the second part is the name of the meta type that is going to be created and the last part are the arguments for the meta type.

As a concrete example, the code below creates a composed meta type.

DECLARE=MyComposedNode:composed-new:KEY(string)|VALUE(int)
_(constant/string:value="My Key") OUT -> KEY Composed(MyComposedNode) OUT -> _(console)
_(constant/int:value=20) OUT -> VALUE Composed

The example above, uses the Soletta's composed-new meta type. This meta type is responsible for grouping various packet types and output them as one single packet with all the input values.

Macro Definition Documentation

#define SOL_FLOW_METATYPE (   _NAME,
  decl... 
)
Value:
const struct sol_flow_metatype SOL_FLOW_METATYPE_ ## _NAME = { \
decl \
}
Struct that describes a meta type.
Definition: sol-flow-metatype.h:309
uint16_t api_version
The API version.
Definition: sol-flow-metatype.h:311
#define SOL_FLOW_METATYPE_API_VERSION
Defines the current version of the meta type API.
Definition: sol-flow-metatype.h:293
#define SOL_SET_API_VERSION(expression)
This macro will cope with SOL_NO_API_VERSION and allows easy declaration of api_version fields...
Definition: sol-mainloop.h:660

Exports a meta type.

This macro should be used to declare a meta type, making it visible to Soletta.

Parameters
_NAMEThe meta type name. This name will be appended to the sol_flow_metatype variable name.
declThe meta type declarations.

Example:

.name = "My Meta"
.options_symbol = "my_meta_options"
.create_type = create_function,
.generate_type_start = type_start_function,
.generate_type_body = body_function,
.generate_type_end = type_end_function,
.ports_description = ports_description_function);
#define SOL_FLOW_METATYPE_API_VERSION   (1)

Defines the current version of the meta type API.

Typedef Documentation

Meta type context.

This is used when the meta type is being created or its code is being generated. It contains useful information like the the node name, the parameters for the meta type and some helper functions.

typedef int(* sol_flow_metatype_create_type_func)(const struct sol_flow_metatype_context *ctx, struct sol_flow_node_type **type)

A callback used to create the meta type itself.

This function is used to create a meta type, this means that this function must setup the node properties, ports and etc.

Parameters
ctxThe meta type context.
typeThe meta type node that shall be used by Soletta.
Returns
0 on success, negative value on failure.
typedef int(* sol_flow_metatype_generate_code_func)(const struct sol_flow_metatype_context *ctx, struct sol_buffer *out)

A callback used by sol-fbp-generator to generate the meta type C code.

This function is called by sol-fbp-generator in order generate the meta type code to be compiled. The code generation is divded in three steps:

  • Start type generation
    Where the common code for the meta type is generated this include - common open/close/port process functions
  • Type generation
    Port definitions, node type definition
  • End type generation
    Clean up code and etc.

The code generation functions are set using the struct sol_flow_metatype during the meta type definition.

Note
The meta type must provide all callbacks in order generate its code, if the meta type does not provide the callbacks it will be impossible to use the meta type node in sol-fbp-generator.
Parameters
ctxThe meta type context.
outA buffer where the meta type should append its code.
Returns
0 on success, negative value on failure.
See Also
struct sol_flow_metatype
struct sol_flow_metatype_context

Struct that describes the meta type options.

This struct is used by the sol_fbp_generator in order to check if the node options are correct. The sol-fbp-generator will call sol_flow_metatype_options_description_func() callback in order to obtain an array of options description.

See Also
sol_flow_metatype_options_description_func()
sol_flow_metatype_get_options_description_func()
typedef int(* sol_flow_metatype_options_description_func)(struct sol_vector *opts)

A callback used create the options description of a meta type.

One must add sol_flow_metatype_option_description elements in the given vector.

Parameters
optsWhere the options descriptions should be inserted.
Returns
0 on success, negative value on failure.
Note
sol-fbp-generator will free the opts elements when it is not necessary anymore, this means that it will call free() on the name and type variables.
the given vector is not initialized.
See Also
struct sol_flow_metatype_context
struct sol_flow_metatype
struct sol_flow_metatype_options_description

Struct that describes the meta type ports.

This struct is used by the sol_fbp_generator in order to check if the node connections are valid. The sol-fbp-generator will call sol_flow_metatype_ports_description_func() callback in order to obtain an array of input and output ports description.

See Also
sol_flow_metatype_ports_description_func()
sol_flow_metatype_get_ports_description_func()
typedef int(* sol_flow_metatype_ports_description_func)(const struct sol_flow_metatype_context *ctx, struct sol_vector *in, struct sol_vector *out)

A callback used create the port description of a meta type.

Parameters
ctxThe meta type context.
inWhere the input port descriptions should be inserted.
outWhere the output port descriptions should be inserted.
Returns
0 on success, negative value on failure.
Note
sol-fbp-generator will free the in and out elements when it is not necessary anymore, this means that it will call free() on the name and type variables.
See Also
struct sol_flow_metatype_context
struct sol_flow_metatype
struct sol_flow_metatype_port_description

Function Documentation

sol_flow_metatype_generate_code_func sol_flow_metatype_get_generate_code_end_func ( const struct sol_str_slice  name)

Searchs for the callback that generates the end code of a given meta type.

Parameters
nameThe meta type name
Returns
A valid pointer to a sol_flow_metatype_generate_code_func() or NULL if not found.
See Also
sol_flow_metatype_generate_code_func
sol_flow_metatype_generate_code_func sol_flow_metatype_get_generate_code_start_func ( const struct sol_str_slice  name)

Searchs for the callback that generates the start code of a given meta type.

Parameters
nameThe meta type name.
Returns
A valid pointer to a sol_flow_metatype_generate_code_func() or NULL if not found.
See Also
sol_flow_metatype_generate_code_func
sol_flow_metatype_generate_code_func sol_flow_metatype_get_generate_code_type_func ( const struct sol_str_slice  name)

Searchs for the callback that generates the body code of a given meta type.

Parameters
nameThe meta type name.
Returns
A valid pointer to a sol_flow_metatype_generate_code_func() or NULL if not found.
See Also
sol_flow_metatype_generate_code_func
sol_flow_metatype_options_description_func sol_flow_metatype_get_options_description_func ( const struct sol_str_slice  name)

Searchs for callback that describes the options of a given meta type.

Parameters
nameThe meta type name.
Returns
A valid pointer to a sol_flow_metatype_options_description_func() or NULL if not found.
See Also
sol_flow_metatype_options_description_func
const char* sol_flow_metatype_get_options_symbol ( const struct sol_str_slice  name)

Searchs for the metatype options symbol.

Parameters
nameThe meta type name.
Returns
The options symbol string or NULL if not found.
sol_flow_metatype_ports_description_func sol_flow_metatype_get_ports_description_func ( const struct sol_str_slice  name)

Searchs for callback that describes the ports of a given meta type.

Parameters
nameThe meta type name.
Returns
A valid pointer to a sol_flow_metatype_ports_description_func() or NULL if not found.
See Also
sol_flow_metatype_ports_description_func