Soletta™ Framework
|
This file contains the implementation of 3 custom node types. More...
#include <errno.h>
#include <stdio.h>
#include "custom-node-types-gen.h"
#include <sol-log.h>
#include <sol-mainloop.h>
#include "custom-node-types-gen.c"
Data Structures | |
struct | reader_data |
Reader: More... | |
struct | writer_data |
Writer: More... | |
Macros | |
#define | SOL_FLOW_NODE_OPTIONS_SUB_API_CHECK(options, expected,...) |
Functions | |
static int | logic_process (struct sol_flow_node *node, void *data, uint16_t port, uint16_t conn_id, const struct sol_flow_packet *packet) |
Logic: More... | |
static void | reader_close (struct sol_flow_node *node, void *data) |
This destructor method is called when the node is finished. More... | |
static bool | reader_on_timeout (void *data) |
static int | reader_open (struct sol_flow_node *node, void *data, const struct sol_flow_node_options *options) |
this constructor method is called when the node is created. More... | |
static void | writer_close (struct sol_flow_node *node, void *data) |
static int | writer_in_process (struct sol_flow_node *node, void *data, uint16_t port, uint16_t conn_id, const struct sol_flow_packet *packet) |
static int | writer_open (struct sol_flow_node *node, void *data, const struct sol_flow_node_options *options) |
This file contains the implementation of 3 custom node types.
It does not contain the full implementation in C, rather it leverages soletta's tooling to generate boilerplate from JSON. Even this file was initially created using a tool:
To create the initial version (stub) file from JSON:
$ sol-flow-node-type-stub-gen.py \ custom-node-types.c \ custom-node-types-spec.json
To create the dependencies from JSON:
$ sol-flow-node-type-gen.py \ ${top_srcdir}/data/schemas/node-type.schema \ custom-node-types-spec.json \ custom-node-types-gen.h \ custom-node-types-gen.c
This file contains 3 custom node types:
#define SOL_FLOW_NODE_OPTIONS_SUB_API_CHECK | ( | options, | |
expected, | |||
... | |||
) |
Referenced by reader_open(), and writer_open().
|
static |
Logic:
The logic is a node type simulates business logic, it will receive some information and deliver another. Here the logic is pretty simple, we receive an integer and deliver a boolean packet as true if the integer is even or false if it is odd.
this node contains no data, it will recompute everything based on the last received packet, thus there is no node private data, open or close methods.
References sol_flow_packet_get_irange(), sol_flow_send_bool_packet(), SOL_INT_CHECK, and sol_irange::val.
|
static |
This destructor method is called when the node is finished.
When this method returns the memory pointed by 'data' is released and should stop being referenced.
References sol_timeout_del(), and reader_data::timer.
|
static |
References sol_flow_node_get_private_data(), sol_flow_send_irange_value_packet(), reader_data::timer, and reader_data::val.
Referenced by reader_open().
|
static |
this constructor method is called when the node is created.
The options are checked to see if it conforms to our api by using the 'sub_api' field.
The private data is guaranteed to be of size 'struct reader_data'.
Never send packets from this function as the node is still being created and there are no connections.
References reader_on_timeout(), SOL_FLOW_NODE_OPTIONS_SUB_API_CHECK, sol_flow_send_irange_value_packet(), sol_timeout_add(), reader_data::timer, and reader_data::val.
|
static |
References writer_data::prefix.
|
static |
References writer_data::prefix, sol_flow_packet_get_bool(), and SOL_INT_CHECK.
|
static |
References writer_data::prefix, and SOL_FLOW_NODE_OPTIONS_SUB_API_CHECK.