SolarCapture C Bindings
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
ext_node.h
Go to the documentation of this file.
1 
8 #ifndef __SOLAR_CAPTURE_EXT_NODE_H__
9 #define __SOLAR_CAPTURE_EXT_NODE_H__
10 
11 
17 struct sc_node {
18  const struct sc_node_type* nd_type;
19  char* nd_name;
20  void* nd_private;
21 };
22 
23 
29 struct sc_node_link {
30  const char* name;
31 };
32 
33 
34 struct sc_packet;
35 struct sc_packet_list;
36 struct sc_attr;
37 struct sc_node_factory;
38 struct sc_pool;
39 
40 
61 typedef int (sc_node_init_fn)(struct sc_node* node,
62  const struct sc_attr* attr,
63  const struct sc_node_factory*);
64 
71  const char* nf_name;
72  const char* nf_source_file;
73  void* nf_private;
75  void* nf_reserved[8];
76 };
77 
78 
101 typedef int (sc_node_prep_fn)(struct sc_node* node,
102  const struct sc_node_link*const* links,
103  int n_links);
104 
105 
122 typedef void (sc_node_pkts_fn)(struct sc_node* node,
123  struct sc_packet_list* packet_list);
124 
125 
148 typedef int (sc_node_add_link_fn)(struct sc_node* from_node,
149  const char* link_name,
150  struct sc_node* to_node,
151  const char* to_name_opt);
152 
153 
172 typedef struct sc_node*
173  (sc_node_select_subnode_fn)(struct sc_node* node, const char* name,
174  char** new_name_out);
175 
176 #if SC_API_VER >= 1
177 
194 typedef void (sc_node_end_of_stream_fn)(struct sc_node* node);
195 #endif
196 
197 
204 struct sc_node_type {
205  const char* nt_name;
206  void* nt_private;
211 #if SC_API_VER >= 1
213 #endif
214 };
215 
216 
228 extern int sc_node_type_alloc(struct sc_node_type** nt_out,
229  const struct sc_attr* attr_opt,
230  const struct sc_node_factory* factory);
231 
232 
240 extern void sc_forward_list(struct sc_node* node,
241  const struct sc_node_link* link,
242  struct sc_packet_list* pl);
243 
251 extern void sc_forward(struct sc_node* node, const struct sc_node_link* link,
252  struct sc_packet* packet);
253 
254 
268 extern int sc_node_init_get_arg_int(int* v_out, struct sc_node* node,
269  const char* name, int v_default);
270 
287 extern int sc_node_init_get_arg_str(const char** v_out, struct sc_node* node,
288  const char* name, const char* v_default);
289 
290 
291 #if SC_API_VER >= 1
292 
305 extern int sc_node_init_get_arg_obj(struct sc_object** obj_out,
306  struct sc_node* node, const char* name,
307  enum sc_object_type obj_type);
308 #endif
309 
310 
311 #if SC_API_VER >= 1
312 
325 extern int sc_node_init_get_arg_dbl(double* v_out, struct sc_node* node,
326  const char* name, double v_default);
327 #endif
328 
329 
346 extern const struct sc_node_link*
347  sc_node_prep_get_link(struct sc_node* node, const char* link_name);
348 
362 extern const struct sc_node_link*
363  sc_node_prep_get_link_or_free(struct sc_node* node, const char* link_name);
364 
380 extern int
381  sc_node_prep_check_links(struct sc_node* node);
382 
383 #if SC_API_VER >= 1
384 
405 extern int sc_node_prep_get_pool(struct sc_pool** pool_out,
406  const struct sc_attr* attr,
407  struct sc_node* node,
408  const struct sc_node_link*const* links,
409  int n_links);
410 #endif
411 
412 #if SC_API_VER >= 1
413 
414 extern int __sc_node_set_error(struct sc_node* node, const char* file,
415  int line, const char* func, int errno_code,
416  const char* fmt, ...);
417 
418 extern int __sc_node_fwd_error(struct sc_node* node, const char* file,
419  int line, const char* func, int rc);
421 #endif
422 
433 #define sc_node_set_error(node, errno_code, ...) \
434  __sc_node_set_error((node), __FILE__, __LINE__, __func__, \
435  (errno_code), __VA_ARGS__)
436 
445 #define sc_node_fwd_error(node, rc) \
446  __sc_node_fwd_error((node), __FILE__, __LINE__, __func__, (rc))
447 
448 
449 #if SC_API_VER >= 1
450 
459 extern void sc_node_link_end_of_stream(struct sc_node* node,
460  const struct sc_node_link* link);
461 #endif
462 
463 
464 #if SC_API_VER >= 1
465 
488 extern int sc_node_export_state(struct sc_node* node, const char* type_name,
489  int type_size, void* pp_area);
490 #endif
491 
492 
493 #endif /* __SOLAR_CAPTURE_EXT_NODE_H__ */
494 
Describes a type of node.
Definition: ext_node.h:204
int( sc_node_add_link_fn)(struct sc_node *from_node, const char *link_name, struct sc_node *to_node, const char *to_name_opt)
Signature of nt_add_link_fn function.
Definition: ext_node.h:148
Attribute object.
int sc_node_init_get_arg_str(const char **v_out, struct sc_node *node, const char *name, const char *v_default)
Get an string argument.
int nf_node_api_ver
Definition: ext_node.h:70
sc_node_add_link_fn * nt_add_link_fn
Definition: ext_node.h:209
const char * nf_source_file
Definition: ext_node.h:72
sc_object_type
The type of data the sc_object contains.
Definition: object.h:16
const char * nt_name
Definition: ext_node.h:205
const char * nf_name
Definition: ext_node.h:71
const struct sc_node_type * nd_type
Definition: ext_node.h:18
const struct sc_node_link * sc_node_prep_get_link(struct sc_node *node, const char *link_name)
Find a named outgoing link.
void sc_forward_list(struct sc_node *node, const struct sc_node_link *link, struct sc_packet_list *pl)
Forward a list of packets.
void * nd_private
Definition: ext_node.h:20
void( sc_node_pkts_fn)(struct sc_node *node, struct sc_packet_list *packet_list)
Signature of nt_pkts_fn function.
Definition: ext_node.h:122
void( sc_node_end_of_stream_fn)(struct sc_node *node)
Signature of nt_end_of_stream_fn function.
Definition: ext_node.h:194
void sc_node_link_end_of_stream(struct sc_node *node, const struct sc_node_link *link)
Indicate end-of-stream on a link.
void sc_forward(struct sc_node *node, const struct sc_node_link *link, struct sc_packet *packet)
Forward a single packet.
Representation of a packet.
Definition: ext_packet.h:56
const char * name
Definition: ext_node.h:30
An opaque object. Use this to pass all types of data that are not ints, doubles or char arrays (see S...
sc_node_select_subnode_fn * nt_select_subnode_fn
Definition: ext_node.h:210
sc_node_prep_fn * nt_prep_fn
Definition: ext_node.h:207
char * nd_name
Definition: ext_node.h:19
int sc_node_export_state(struct sc_node *node, const char *type_name, int type_size, void *pp_area)
Export dynamic state to solar_capture_monitor.
int sc_node_prep_check_links(struct sc_node *node)
Check the node's links for any unused links.
Struct to hold information about how to create an instance of this node.
Definition: ext_node.h:69
void * nf_private
Definition: ext_node.h:73
A list of packets or packet buffers.
Definition: ext_packet_list.h:14
sc_node_end_of_stream_fn * nt_end_of_stream_fn
Definition: ext_node.h:212
int sc_node_init_get_arg_int(int *v_out, struct sc_node *node, const char *name, int v_default)
Get an integer argument.
sc_node_init_fn * nf_init_fn
Definition: ext_node.h:74
int sc_node_type_alloc(struct sc_node_type **nt_out, const struct sc_attr *attr_opt, const struct sc_node_factory *factory)
Allocate an sc_node_type instance.
int( sc_node_prep_fn)(struct sc_node *node, const struct sc_node_link *const *links, int n_links)
Signature of nt_prep_fn function.
Definition: ext_node.h:101
int sc_node_prep_get_pool(struct sc_pool **pool_out, const struct sc_attr *attr, struct sc_node *node, const struct sc_node_link *const *links, int n_links)
Get a packet pool that can be used to obtain empty packet buffers that can be passed to any of the gi...
int sc_node_init_get_arg_dbl(double *v_out, struct sc_node *node, const char *name, double v_default)
Get a double argument.
Description of a node.
Definition: ext_node.h:17
const struct sc_node_link * sc_node_prep_get_link_or_free(struct sc_node *node, const char *link_name)
Find a named outgoing link or return a link for freeing.
struct sc_node *( sc_node_select_subnode_fn)(struct sc_node *node, const char *name, char **new_name_out)
Signature of nt_select_subnode_fn function.
Definition: ext_node.h:173
int sc_node_init_get_arg_obj(struct sc_object **obj_out, struct sc_node *node, const char *name, enum sc_object_type obj_type)
Get an sc_object argument.
int( sc_node_init_fn)(struct sc_node *node, const struct sc_attr *attr, const struct sc_node_factory *)
Signature of function to initialise a node.
Definition: ext_node.h:61
sc_node_pkts_fn * nt_pkts_fn
Definition: ext_node.h:208
void * nt_private
Definition: ext_node.h:206