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-metatype.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-str-slice.h"
23 #include "sol-buffer.h"
24 #include "sol-vector.h"
25 #include <stdbool.h>
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
87 typedef struct sol_flow_metatype_context {
101  int (*read_file)(
102  const struct sol_flow_metatype_context *ctx,
103  const char *name, struct sol_buffer *buf);
104 
118  int (*store_type)(
119  const struct sol_flow_metatype_context *ctx,
120  struct sol_flow_node_type *type);
122 
134  char *name;
135  char *type;
137  int idx;
139 
151  char *name;
152  char *data_type;
154 
164 typedef int (*sol_flow_metatype_create_type_func)(const struct sol_flow_metatype_context *ctx, struct sol_flow_node_type **type);
165 
192 typedef int (*sol_flow_metatype_generate_code_func)(const struct sol_flow_metatype_context *ctx, struct sol_buffer *out);
193 
210 typedef int (*sol_flow_metatype_ports_description_func)(const struct sol_flow_metatype_context *ctx, struct sol_vector *in, struct sol_vector *out);
211 
231 
241 
251 
260 
270 
280 
288 const char *sol_flow_metatype_get_options_symbol(const struct sol_str_slice name);
289 
293 #define SOL_FLOW_METATYPE_API_VERSION (1)
294 
309 typedef struct sol_flow_metatype {
310 #ifndef SOL_NO_API_VERSION
311  uint16_t api_version;
312 #endif
313 
314  const char *name;
315  const char *options_symbol;
324 
325 #ifdef SOL_FLOW_METATYPE_MODULE_EXTERNAL
326 
345 #define SOL_FLOW_METATYPE(_NAME, decl ...) \
346  SOL_API const struct sol_flow_metatype *SOL_FLOW_METATYPE = \
347  &((const struct sol_flow_metatype) { \
348  SOL_SET_API_VERSION(.api_version = SOL_FLOW_METATYPE_API_VERSION, ) \
349  decl \
350  })
351 #else
352 
371 #define SOL_FLOW_METATYPE(_NAME, decl ...) \
372  const struct sol_flow_metatype SOL_FLOW_METATYPE_ ## _NAME = { \
373  SOL_SET_API_VERSION(.api_version = SOL_FLOW_METATYPE_API_VERSION, ) \
374  decl \
375  }
376 #endif
377 
382 #ifdef __cplusplus
383 }
384 #endif
char * data_type
The option type (int, float, blob and etc).
Definition: sol-flow-metatype.h:152
sol_flow_metatype_generate_code_func generate_type_body
A callback used to generate the meta type code.
Definition: sol-flow-metatype.h:319
struct sol_flow_metatype_option_description sol_flow_metatype_option_description
Struct that describes the meta type options.
struct sol_str_slice contents
Parameters for the metatype that is being created.
Definition: sol-flow-metatype.h:89
int array_size
If the port is an array this field should be > 0.
Definition: sol-flow-metatype.h:136
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.
sol_flow_metatype_generate_code_func generate_type_end
A callback used to generate the meta type end code.
Definition: sol-flow-metatype.h:320
Struct that describes the meta type ports.
Definition: sol-flow-metatype.h:133
sol_flow_metatype_generate_code_func generate_type_start
A callback used to generate the meta type start code.
Definition: sol-flow-metatype.h:318
Struct that describes a meta type.
Definition: sol-flow-metatype.h:309
struct sol_str_slice name
The node name that is being created.
Definition: sol-flow-metatype.h:88
struct sol_flow_metatype_context sol_flow_metatype_context
Meta type context.
uint16_t api_version
The API version.
Definition: sol-flow-metatype.h:311
int(* read_file)(const struct sol_flow_metatype_context *ctx, const char *name, struct sol_buffer *buf)
Opens a file for the meta type.
Definition: sol-flow-metatype.h:101
Struct that describes the meta type options.
Definition: sol-flow-metatype.h:150
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.
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.
struct sol_flow_metatype_port_description sol_flow_metatype_port_description
Struct that describes the meta type ports.
sol_flow_metatype_create_type_func create_type
A callback used the create the meta type.
Definition: sol-flow-metatype.h:317
const char * sol_flow_metatype_get_options_symbol(const struct sol_str_slice name)
Searchs for the metatype options symbol.
String slice type.
Definition: sol-str-slice.h:84
These are routines that Soletta provides for its buffer implementation.
The node type describes the capabilities and operations of a node.
Definition: sol-flow.h:796
char * name
The port name.
Definition: sol-flow-metatype.h:134
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.
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.
Definition: sol-flow-metatype.h:192
const char * options_symbol
The options symbol.
Definition: sol-flow-metatype.h:315
char * name
The option name.
Definition: sol-flow-metatype.h:151
int(* sol_flow_metatype_options_description_func)(struct sol_vector *opts)
A callback used create the options description of a meta type.
Definition: sol-flow-metatype.h:230
struct sol_flow_metatype sol_flow_metatype
Struct that describes a meta type.
sol_flow_metatype_ports_description_func ports_description
A callback used to fetch the meta type port description.
Definition: sol-flow-metatype.h:321
char * type
The port type (int, float, blob and etc).
Definition: sol-flow-metatype.h:135
These are routines that Soletta provides for its string slice implementation.
const char * name
The name of the meta type.
Definition: sol-flow-metatype.h:314
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.
Definition: sol-flow-metatype.h:164
int idx
The port index.
Definition: sol-flow-metatype.h:137
Meta type context.
Definition: sol-flow-metatype.h:87
int(* store_type)(const struct sol_flow_metatype_context *ctx, struct sol_flow_node_type *type)
Stores the meta type in the Soletta infrastructure.
Definition: sol-flow-metatype.h:118
These routines are used for Soletta flows manipulation.
Soletta vector is an array that grows dynamically.
Definition: sol-vector.h:58
These are routines that Soletta provides for its vector implementation.
A sol_buffer is a dynamic array, that can be resized if needed.
Definition: sol-buffer.h:130
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.
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.
Definition: sol-flow-metatype.h:210
sol_flow_metatype_options_description_func options_description
A callback used to fetch the meta type options description.
Definition: sol-flow-metatype.h:322