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
sol-flow-simple-c-type.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Soletta (TM) Project
3  *
4  * Copyright (C) 2015 Intel Corporation. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #pragma once
20 
21 #include "sol-flow.h"
22 #include "sol-macros.h"
23 
83  } type;
84  uint16_t port;
85  uint16_t conn_id;
86  const char *port_name; /* @brief If type is one of SOL_FLOW_SIMPLE_C_TYPE_EVENT_TYPE_PORT_* events, the port name (copy of the string given to sol_flow_simple_c_type_new_full() */
87  const struct sol_flow_node_options *options; /* @brief If type is SOL_FLOW_SIMPLE_C_TYPE_EVENT_TYPE_OPEN, the given options */
88  const struct sol_flow_packet *packet; /* @brief If type is SOL_FLOW_SIMPLE_C_TYPE_EVENT_TYPE_PORT_IN_PROCESS, the incoming packet */
90 
94 #define SOL_FLOW_SIMPLE_C_TYPE_PORT_TYPE_IN 1
95 
99 #define SOL_FLOW_SIMPLE_C_TYPE_PORT_TYPE_OUT 2
100 
107 #define SOL_FLOW_SIMPLE_C_TYPE_PORT_IN(name, type) \
108  SOL_TYPE_CHECK(const char *, name), \
109  SOL_TYPE_CHECK(const struct sol_flow_packet_type *, type), \
110  SOL_FLOW_SIMPLE_C_TYPE_PORT_TYPE_IN
111 
118 #define SOL_FLOW_SIMPLE_C_TYPE_PORT_OUT(name, type) \
119  SOL_TYPE_CHECK(const char *, name), \
120  SOL_TYPE_CHECK(const struct sol_flow_packet_type *, type), \
121  SOL_FLOW_SIMPLE_C_TYPE_PORT_TYPE_OUT
122 
160 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;
161 
174 #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)
175 
187 #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)
188 
202 uint16_t sol_flow_simple_c_type_get_port_out_index(const struct sol_flow_node_type *type, const char *port_out_name);
203 
217 uint16_t sol_flow_simple_c_type_get_port_in_index(const struct sol_flow_node_type *type, const char *port_in_name);
218 
Node is being open (instantiated)
Definition: sol-flow-simple-c-type.h:76
Node is being closed (deleted)
Definition: sol-flow-simple-c-type.h:77
The input port defined by port index and port_name name received an incoming packet.
Definition: sol-flow-simple-c-type.h:80
The output port defined by port index and port_name name is being disconnected.
Definition: sol-flow-simple-c-type.h:82
The input port defined by port index and port_name name is being connected.
Definition: sol-flow-simple-c-type.h:78
The output port defined by port index and port_name name is being connected.
Definition: sol-flow-simple-c-type.h:81
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.
Node options are a set of attributes defined by the Node Type that can change the behavior of a Node...
Definition: sol-flow.h:552
const char * port_name
Definition: sol-flow-simple-c-type.h:86
The input port defined by port index and port_name name is being disconnected.
Definition: sol-flow-simple-c-type.h:79
struct sol_flow_node sol_flow_node
A node is an entity that has input/output ports.
Definition: sol-flow.h:71
sol_flow_simple_c_type_event_type
Event type.
Definition: sol-flow-simple-c-type.h:75
These are common Soletta macros.
uint16_t options_size
Options size in bytes.
Definition: sol-flow.h:803
struct sol_flow_packet sol_flow_packet
A packet is a generic container for different kinds (types) of contents.
Definition: sol-flow-packet.h:54
#define SOL_ATTR_SENTINEL
Used to ensure that the last parameter in a function call is an explicit NULL.
Definition: sol-macros.h:197
The node type describes the capabilities and operations of a node.
Definition: sol-flow.h:796
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.
const struct sol_flow_node_options * options
Definition: sol-flow-simple-c-type.h:87
uint16_t conn_id
If type is one of SOL_FLOW_SIMPLE_C_TYPE_EVENT_TYPE_PORT_* events, the reference connection identifie...
Definition: sol-flow-simple-c-type.h:85
struct sol_flow_simple_c_type_event sol_flow_simple_c_type_event
Simple C event structure.
These routines are used for Soletta flows manipulation.
enum sol_flow_simple_c_type_event::sol_flow_simple_c_type_event_type type
const struct sol_flow_packet * packet
Definition: sol-flow-simple-c-type.h:88
uint16_t port
If type is one of SOL_FLOW_SIMPLE_C_TYPE_EVENT_TYPE_PORT_* events, the reference port index...
Definition: sol-flow-simple-c-type.h:84
Simple C event structure.
Definition: sol-flow-simple-c-type.h:69
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.