diff --git a/lib/cfg.c b/lib/cfg.c index a556cb4db..6d4eafae5 100644 --- a/lib/cfg.c +++ b/lib/cfg.c @@ -52,14 +52,22 @@ int cfg_init_post(struct cfg *cfg) info("Initialize web sub-system"); web_init(&cfg->web, &cfg->api); + info("Initialize node types"); + list_foreach(struct node *n, &cfg->nodes) { INDENT + config_setting_t *cfg_root = config_root_setting(&cfg->cfg); + + node_type_init(n->_vt, cfg->cli.argc, cfg->cli.argv, cfg_root); + } + return 0; } int cfg_deinit(struct cfg *cfg) { info("De-initializing node types"); - list_foreach(struct node_type *vt, &node_types) { INDENT - node_deinit(vt); + list_foreach(struct plugin *p, &plugins) { INDENT + if (p->type == PLUGIN_TYPE_NODE) + node_type_deinit(&p->node); } info("De-initializing web interface"); @@ -201,19 +209,20 @@ int cfg_parse(struct cfg *cfg, const char *uri) for (int i = 0; i < config_setting_length(cfg_nodes); i++) { config_setting_t *cfg_node = config_setting_get_elem(cfg_nodes, i); - - struct node_type *vt; + + struct plugin *p; const char *type; /* Required settings */ if (!config_setting_lookup_string(cfg_node, "type", &type)) cerror(cfg_node, "Missing node type"); - vt = list_lookup(&node_types, type); - if (!vt) + + p = plugin_lookup(PLUGIN_TYPE_NODE, type); + if (!p) cerror(cfg_node, "Invalid node type: %s", type); - struct node *n = node_create(vt); + struct node *n = node_create(&p->node); ret = node_parse(n, cfg_node); if (ret) diff --git a/lib/node.c b/lib/node.c index dc5661bb6..f4fd8f9fd 100644 --- a/lib/node.c +++ b/lib/node.c @@ -13,9 +13,7 @@ #include "cfg.h" #include "utils.h" #include "config.h" - -/** List of registered node-types */ -struct list node_types = LIST_INIT(); +#include "plugin.h" int node_read(struct node *n, struct sample *smps[], unsigned cnt) { @@ -262,7 +260,7 @@ int node_parse_list(struct list *list, config_setting_t *cfg, struct list *all) int node_parse(struct node *n, config_setting_t *cfg) { - struct node_type *vt; + struct plugin *p; const char *type, *name; int ret; @@ -271,9 +269,11 @@ int node_parse(struct node *n, config_setting_t *cfg) if (!config_setting_lookup_string(cfg, "type", &type)) cerror(cfg, "Missing node type"); - vt = list_lookup(&node_types, type); - if (!vt) - cerror(cfg, "Invalid type for node '%s'", config_setting_name(cfg)); + p = plugin_lookup(PLUGIN_TYPE_NODE, type); + assert(&p->node == n->_vt); + + if (!config_setting_lookup_int(cfg, "vectorize", &n->vectorize)) + n->vectorize = 1; n->name = name; n->cfg = cfg; diff --git a/src/node.c b/src/node.c index 888a16c49..c73069b7e 100644 --- a/src/node.c +++ b/src/node.c @@ -127,13 +127,6 @@ int main(int argc, char *argv[]) cfg_init_post(&cfg); - info("Initialize node types"); - list_foreach(struct node_type *vt, &node_types) { INDENT - int refs = list_length(&vt->instances); - if (refs > 0) - node_init(vt, argc, argv, config_root_setting(&cfg.cfg)); - } - info("Starting nodes"); list_foreach(struct node *n, &cfg.nodes) { INDENT int refs = list_count(&cfg.paths, (cmp_cb_t) path_uses_node, n); diff --git a/src/pipe.c b/src/pipe.c index 22211ae89..a92005c77 100644 --- a/src/pipe.c +++ b/src/pipe.c @@ -24,7 +24,6 @@ #include "config.h" -static struct list nodes; /**< List of all nodes */ static struct cfg cfg; /**< The global configuration */ struct dir { @@ -223,7 +222,7 @@ int main(int argc, char *argv[]) memory_init(); /* Initialize node */ - node = list_lookup(&nodes, argv[2]); + node = list_lookup(&cfg.nodes, argv[2]); if (!node) error("Node '%s' does not exist!", argv[2]);