40 lines
1.1 KiB
C
40 lines
1.1 KiB
C
#ifndef cmsg_node_h
|
|
#define cmsg_node_h
|
|
|
|
typedef struct node_t_ {
|
|
refcount_t refcount;
|
|
struct node_class_t_ *node_class;
|
|
hashtable_t names;
|
|
} node_t;
|
|
|
|
typedef node_t *(*node_constructor_fn_t)(struct node_class_t_ *nc, sexp_t *args);
|
|
typedef void (*node_destructor_fn_t)(node_t *n);
|
|
typedef void (*node_message_handler_fn_t)(node_t *n, sexp_t *m);
|
|
|
|
typedef struct node_class_t_ {
|
|
char const *name;
|
|
node_constructor_fn_t construct;
|
|
node_destructor_fn_t destroy;
|
|
node_message_handler_fn_t handle_message;
|
|
} node_class_t;
|
|
|
|
extern void init_node(void);
|
|
|
|
extern void basic_node_destroy(node_t *n);
|
|
|
|
extern void register_node_class(node_class_t *nc);
|
|
extern node_class_t *lookup_node_class(cmsg_bytes_t name);
|
|
|
|
extern node_t *new_node(node_class_t *nc, sexp_t *args);
|
|
extern void node_destructor(node_t *n);
|
|
|
|
extern node_t *lookup_node(cmsg_bytes_t name);
|
|
extern int bind_node(cmsg_bytes_t name, node_t *n);
|
|
extern int unbind_node(cmsg_bytes_t name);
|
|
extern void unbind_all_names_for_node(node_t *n);
|
|
|
|
extern int post_node(cmsg_bytes_t node, cmsg_bytes_t name, sexp_t *body);
|
|
extern int send_node(cmsg_bytes_t node, sexp_t *message);
|
|
|
|
#endif
|