diff --git a/common b/common index 6fb725374..574f4467c 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 6fb725374693af9cc8ac831bd12b3b504c391ca8 +Subproject commit 574f4467cccc72a4fc71b078b6b28f3f9eb7b28c diff --git a/include/villas/node_type.h b/include/villas/node_type.h index ce8cce8a7..71e64fd4c 100644 --- a/include/villas/node_type.h +++ b/include/villas/node_type.h @@ -50,14 +50,17 @@ enum class NodeFlags { /** C++ like vtable construct for node_types */ struct vnode_type { - unsigned vectorize; /**< Maximal vector length supported by this node type. Zero is unlimited. */ + const char *name; + const char *description; + + unsigned vectorize; /**< Maximal vector length supported by this node type. Zero is unlimited. */ int flags; - enum State state; /**< State of this node-type. */ + enum State state; /**< State of this node-type. */ struct vlist instances; /**< A list of all existing nodes of this type. */ - size_t size; /**< Size of private data bock. @see node::_vd */ + size_t size; /**< Size of private data bock. @see node::_vd */ size_t pool_size; struct { @@ -259,6 +262,10 @@ int node_type_stop(struct vnode_type *vt); /** Return a printable representation of the node-type. */ const char * node_type_name(struct vnode_type *vt); -struct vnode_type * node_type_lookup(const char *name); +struct vnode_type * node_type_lookup(const std::string &name); + +using NodeTypeList = std::list; + +extern NodeTypeList *node_types; /** @} */ diff --git a/include/villas/nodes/amqp.hpp b/include/villas/nodes/amqp.hpp index 801fba4b5..191c2c091 100644 --- a/include/villas/nodes/amqp.hpp +++ b/include/villas/nodes/amqp.hpp @@ -31,10 +31,12 @@ #include -#include #include #include +/* Forward declarations */ +struct vnode; + struct amqp_ssl_info { int verify_peer; int verify_hostname; diff --git a/include/villas/nodes/comedi.hpp b/include/villas/nodes/comedi.hpp index 48bb764ef..c0af5a473 100644 --- a/include/villas/nodes/comedi.hpp +++ b/include/villas/nodes/comedi.hpp @@ -31,10 +31,12 @@ #include -#include #include #include +/* Forward declarations */ +struct vnode; + // whether to use read() or mmap() kernel interface #define COMEDI_USE_READ (1) //#define COMEDI_USE_READ (0) diff --git a/include/villas/nodes/ethercat.hpp b/include/villas/nodes/ethercat.hpp index 05f8b32b8..25ceb5769 100644 --- a/include/villas/nodes/ethercat.hpp +++ b/include/villas/nodes/ethercat.hpp @@ -33,7 +33,6 @@ #include -#include #include #include #include @@ -41,6 +40,9 @@ #include #include +/* Forward declarations */ +struct vnode; + /* Include hard-coded Ethercat Bus configuration */ #include diff --git a/include/villas/nodes/example.hpp b/include/villas/nodes/example.hpp index ff96d3c2f..7878cb037 100644 --- a/include/villas/nodes/example.hpp +++ b/include/villas/nodes/example.hpp @@ -30,10 +30,12 @@ #pragma once #include -#include #include #include +/* Forward declarations */ +struct vnode; + struct example { /* Settings */ int setting1; diff --git a/include/villas/nodes/file.hpp b/include/villas/nodes/file.hpp index 9577ea47e..a37fd42c9 100644 --- a/include/villas/nodes/file.hpp +++ b/include/villas/nodes/file.hpp @@ -32,9 +32,11 @@ #include #include -#include #include +/* Forward declarations */ +struct vnode; + #define FILE_MAX_PATHLEN 512 struct file { diff --git a/include/villas/nodes/fpga.hpp b/include/villas/nodes/fpga.hpp index 2326234f8..d3df4c988 100644 --- a/include/villas/nodes/fpga.hpp +++ b/include/villas/nodes/fpga.hpp @@ -30,7 +30,6 @@ #pragma once #include -#include #include #include @@ -38,6 +37,9 @@ #include #include +/* Forward declarations */ +struct vnode; + using namespace villas; #define FPGA_DMA_VLNV diff --git a/include/villas/nodes/iec61850.hpp b/include/villas/nodes/iec61850.hpp index a5c52ced8..705b45cea 100644 --- a/include/villas/nodes/iec61850.hpp +++ b/include/villas/nodes/iec61850.hpp @@ -41,10 +41,12 @@ #include #include -#include #include #include +/* Forward declarations */ +struct vnode; + enum class IEC61850Type { /* According to IEC 61850-7-2 */ BOOLEAN, diff --git a/include/villas/nodes/iec61850_sv.hpp b/include/villas/nodes/iec61850_sv.hpp index ec026cc18..33edcbbfa 100644 --- a/include/villas/nodes/iec61850_sv.hpp +++ b/include/villas/nodes/iec61850_sv.hpp @@ -36,10 +36,12 @@ #include #include -#include #include #include +/* Forward declarations */ +struct vnode; + struct iec61850_sv { char *interface; int app_id; diff --git a/include/villas/nodes/infiniband.hpp b/include/villas/nodes/infiniband.hpp index 49eefe92e..90a11395a 100644 --- a/include/villas/nodes/infiniband.hpp +++ b/include/villas/nodes/infiniband.hpp @@ -29,12 +29,14 @@ #pragma once -#include #include #include #include #include +/* Forward declarations */ +struct vnode; + /* Constants */ #define META_SIZE 24 #define GRH_SIZE 40 diff --git a/include/villas/nodes/kafka.hpp b/include/villas/nodes/kafka.hpp index 696a0c29d..44ee8f5d9 100644 --- a/include/villas/nodes/kafka.hpp +++ b/include/villas/nodes/kafka.hpp @@ -31,11 +31,12 @@ #include -#include #include #include #include +/* Forward declarations */ +struct vnode; struct kafka { struct queue_signalled queue; diff --git a/include/villas/nodes/mqtt.hpp b/include/villas/nodes/mqtt.hpp index 12bca2123..f223bc801 100644 --- a/include/villas/nodes/mqtt.hpp +++ b/include/villas/nodes/mqtt.hpp @@ -29,12 +29,12 @@ #pragma once -#include #include #include #include /* Forward declarations */ +struct vnode; struct mosquitto; struct mqtt { diff --git a/include/villas/nodes/nanomsg.hpp b/include/villas/nodes/nanomsg.hpp index 4fb4d54db..66815542d 100644 --- a/include/villas/nodes/nanomsg.hpp +++ b/include/villas/nodes/nanomsg.hpp @@ -29,10 +29,12 @@ #pragma once -#include #include #include +/* Forward declarations */ +struct vnode; + /** The maximum length of a packet which contains stuct msg. */ #define NANOMSG_MAX_PACKET_LEN 1500 diff --git a/include/villas/nodes/ngsi.hpp b/include/villas/nodes/ngsi.hpp index 7c00a633b..d8e00a706 100644 --- a/include/villas/nodes/ngsi.hpp +++ b/include/villas/nodes/ngsi.hpp @@ -39,7 +39,6 @@ #include #include -#include #include /* Forward declarations */ diff --git a/include/villas/nodes/opal.hpp b/include/villas/nodes/opal.hpp index 3bd84333e..b3cc838e8 100644 --- a/include/villas/nodes/opal.hpp +++ b/include/villas/nodes/opal.hpp @@ -31,9 +31,11 @@ #include -#include #include +/* Forward declarations */ +struct vnode; + extern "C" { #include } diff --git a/include/villas/nodes/rtp.hpp b/include/villas/nodes/rtp.hpp index e86a4b222..976b68033 100644 --- a/include/villas/nodes/rtp.hpp +++ b/include/villas/nodes/rtp.hpp @@ -34,7 +34,6 @@ #include -#include #include #include #include @@ -43,6 +42,9 @@ #include #include +/* Forward declarations */ +struct vnode; + extern "C" { #include #include diff --git a/include/villas/nodes/shmem.hpp b/include/villas/nodes/shmem.hpp index be66ac501..3175f0332 100644 --- a/include/villas/nodes/shmem.hpp +++ b/include/villas/nodes/shmem.hpp @@ -29,13 +29,15 @@ #pragma once -#include #include #include #include #include #include +/* Forward declarations */ +struct vnode; + /** Node-type for shared memory communication. * @see node_type */ diff --git a/include/villas/nodes/socket.hpp b/include/villas/nodes/socket.hpp index 8d0990e94..c3a1dd5b9 100644 --- a/include/villas/nodes/socket.hpp +++ b/include/villas/nodes/socket.hpp @@ -30,10 +30,12 @@ #pragma once #include -#include #include #include +/* Forward declarations */ +struct vnode; + /** The maximum length of a packet which contains stuct msg. */ #define SOCKET_INITIAL_BUFFER_LEN (64*1024) diff --git a/include/villas/nodes/stats.hpp b/include/villas/nodes/stats.hpp index e9c845c65..00d6b2264 100644 --- a/include/villas/nodes/stats.hpp +++ b/include/villas/nodes/stats.hpp @@ -31,11 +31,13 @@ #include -#include #include #include #include +/* Forward declarations */ +struct vnode; + struct stats_node_signal { struct vnode *node; char *node_str; diff --git a/include/villas/nodes/temper.hpp b/include/villas/nodes/temper.hpp index e7e293b85..1a9187c83 100644 --- a/include/villas/nodes/temper.hpp +++ b/include/villas/nodes/temper.hpp @@ -30,12 +30,14 @@ #pragma once #include -#include #include #include #include #include +/* Forward declarations */ +struct vnode; + class TEMPerDevice : public villas::usb::Device { protected: diff --git a/include/villas/nodes/websocket.hpp b/include/villas/nodes/websocket.hpp index be0a24b2e..82e35486d 100644 --- a/include/villas/nodes/websocket.hpp +++ b/include/villas/nodes/websocket.hpp @@ -29,7 +29,6 @@ #pragma once -#include #include #include #include @@ -37,6 +36,9 @@ #include #include +/* Forward declarations */ +struct vnode; + #define DEFAULT_WEBSOCKET_QUEUE_LENGTH (DEFAULT_QUEUE_LENGTH * 64) #define DEFAULT_WEBSOCKET_SAMPLE_LENGTH DEFAULT_SAMPLE_LENGTH diff --git a/include/villas/plugin.h b/include/villas/plugin.h deleted file mode 100644 index 94e1170fe..000000000 --- a/include/villas/plugin.h +++ /dev/null @@ -1,56 +0,0 @@ -/** Loadable / plugin support. - * - * @file - * @author Steffen Vogel - * @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC - * @license GNU General Public License (version 3) - * - * VILLASnode - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - *********************************************************************************/ - -#pragma once - -#include -#include -#include - -extern struct vlist plugins; - -enum PluginType { - NODE -}; - -struct plugin { - const char *name; - const char *description; - - enum PluginType type; - - union { - struct vnode_type node; - }; -}; - -/** Return a pointer to the plugin structure */ -#define plugin(vt) ((struct plugin *) ((char *) (vt) - offsetof(struct plugin, node))) - -#define plugin_name(vt) plugin(vt)->name -#define plugin_description(vt) plugin(vt)->description - -void plugin_dump(enum PluginType type); - -/** Find registered and loaded plugin with given name and type. */ -struct plugin * plugin_lookup(enum PluginType type, const char *name); diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 2ca79fb28..58d0500c8 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -60,7 +60,6 @@ set(LIB_SRC path_destination.cpp path_source.cpp path.cpp - plugin.cpp pool.cpp queue_signalled.cpp queue.cpp diff --git a/lib/api/requests/capabiltities.cpp b/lib/api/requests/capabiltities.cpp index 8538dca49..0901032ef 100644 --- a/lib/api/requests/capabiltities.cpp +++ b/lib/api/requests/capabiltities.cpp @@ -21,7 +21,6 @@ *********************************************************************************/ #include -#include #include #include #include @@ -75,17 +74,8 @@ public: json_array_append_new(json_nodes, json_name); } #else - for (size_t i = 0; i < vlist_length(&plugins); i++) { - struct plugin *p = (struct plugin *) vlist_at(&plugins, i); - - json_t *json_name; - switch(p->type) { - case PluginType::NODE: - json_name = json_string(p->name); - json_array_append_new(json_nodes, json_name); - break; - } - } + for (auto *vt : *node_types) + json_array_append_new(json_nodes, json_string(vt->name)); #endif auto *json_capabilities = json_pack("{ s: o, s: o, s: o, s: o }", diff --git a/lib/api/requests/node_action.cpp b/lib/api/requests/node_action.cpp index 04a187d71..30741eee7 100644 --- a/lib/api/requests/node_action.cpp +++ b/lib/api/requests/node_action.cpp @@ -22,7 +22,6 @@ #include -#include #include #include #include diff --git a/lib/api/requests/path_action.cpp b/lib/api/requests/path_action.cpp index 48db2a795..92f42d07a 100644 --- a/lib/api/requests/path_action.cpp +++ b/lib/api/requests/path_action.cpp @@ -22,7 +22,6 @@ #include -#include #include #include #include diff --git a/lib/hooks/dft.cpp b/lib/hooks/dft.cpp index 3881fe346..a8bc9fa08 100644 --- a/lib/hooks/dft.cpp +++ b/lib/hooks/dft.cpp @@ -34,7 +34,6 @@ #include #include #include -#include namespace villas { namespace node { diff --git a/lib/hooks/print.cpp b/lib/hooks/print.cpp index 4df798764..c72cf402a 100644 --- a/lib/hooks/print.cpp +++ b/lib/hooks/print.cpp @@ -32,7 +32,6 @@ #include #include #include -#include namespace villas { namespace node { diff --git a/lib/node_type.cpp b/lib/node_type.cpp index ce92dbc59..d29fd5063 100644 --- a/lib/node_type.cpp +++ b/lib/node_type.cpp @@ -27,10 +27,12 @@ #include #include #include -#include using namespace villas; +/** Global list of all known plugins */ +std::list *node_types = nullptr; + int node_type_start(struct vnode_type *vt, villas::node::SuperNode *sn) { int ret; @@ -39,7 +41,7 @@ int node_type_start(struct vnode_type *vt, villas::node::SuperNode *sn) return 0; auto logger = logging.get(fmt::format("node:{}", node_type_name(vt))); - logger->info("Initializing node type which is used by {} nodes", vlist_length(&vt->instances)); + logger->info("Initializing node type which is used by {} nodes", vt->instances.size()); ret = vt->type.start ? vt->type.start(sn) : 0; if (ret == 0) @@ -67,16 +69,15 @@ int node_type_stop(struct vnode_type *vt) const char * node_type_name(struct vnode_type *vt) { - return plugin_name(vt); + return vt->name; } -struct vnode_type * node_type_lookup(const char *name) +struct vnode_type * node_type_lookup(const std::string &name) { - struct plugin *p; + for (auto *vt : *node_types) { + if (name == vt->name) + return vt; + } - p = plugin_lookup(PluginType::NODE, name); - if (!p) - return nullptr; - - return &p->node; + return nullptr; } diff --git a/lib/nodes/amqp.cpp b/lib/nodes/amqp.cpp index edfe4f7f0..96b5fe808 100644 --- a/lib/nodes/amqp.cpp +++ b/lib/nodes/amqp.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include @@ -388,33 +388,28 @@ int amqp_destroy(struct vnode *n) return 0; } -static struct plugin p; +static struct vnode_type p; __attribute__((constructor(110))) static void register_plugin() { - p.name = "amqp"; - p.description = "Advanced Message Queueing Protoocl (rabbitmq-c)"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.size = sizeof(struct amqp); - p.node.destroy = amqp_destroy; - p.node.parse = amqp_parse; - p.node.print = amqp_print; - p.node.start = amqp_start; - p.node.stop = amqp_stop; - p.node.read = amqp_read; - p.node.write = amqp_write; - p.node.poll_fds = amqp_poll_fds; + p.name = "amqp"; + p.description = "Advanced Message Queueing Protoocl (rabbitmq-c)"; + p.vectorize = 0; + p.size = sizeof(struct amqp); + p.destroy = amqp_destroy; + p.parse = amqp_parse; + p.print = amqp_print; + p.start = amqp_start; + p.stop = amqp_stop; + p.read = amqp_read; + p.write = amqp_write; + p.poll_fds = amqp_poll_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } + diff --git a/lib/nodes/can.cpp b/lib/nodes/can.cpp index 96099ab86..37a9f5c7d 100644 --- a/lib/nodes/can.cpp +++ b/lib/nodes/can.cpp @@ -34,17 +34,16 @@ #include #include +#include #include #include #include -#include #include -#include #include /* Forward declarations */ -static struct plugin p; +static struct vnode_type p; using namespace villas; using namespace villas::node; @@ -525,30 +524,24 @@ int can_poll_fds(struct vnode *n, int fds[]) __attribute__((constructor(110))) static void register_plugin() { - p.name = "can"; - p.description = "Receive CAN messages using the socketCAN driver"; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.size = sizeof(struct can); - p.node.init = can_init; - p.node.destroy = can_destroy; - p.node.prepare = can_prepare; - p.node.parse = can_parse; - p.node.print = can_print; - p.node.check = can_check; - p.node.start = can_start; - p.node.stop = can_stop; - p.node.read = can_read; - p.node.write = can_write; - p.node.poll_fds = can_poll_fds; + p.name = "can"; + p.description = "Receive CAN messages using the socketCAN driver"; + p.vectorize = 0; + p.size = sizeof(struct can); + p.init = can_init; + p.destroy = can_destroy; + p.prepare = can_prepare; + p.parse = can_parse; + p.print = can_print; + p.check = can_check; + p.start = can_start; + p.stop = can_stop; + p.read = can_read; + p.write = can_write; + p.poll_fds = can_poll_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - if (plugins.state != State::DESTROYED) - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/comedi.cpp b/lib/nodes/comedi.cpp index a8a689a18..6cdcd0236 100644 --- a/lib/nodes/comedi.cpp +++ b/lib/nodes/comedi.cpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include #include #include @@ -974,30 +974,24 @@ int comedi_poll_fds(struct vnode *n, int fds[]) return 0; } -static struct plugin p; +static struct vnode_type p; __attribute__((constructor(110))) static void register_plugin() { - p.name = "comedi"; - p.description = "Comedi-compatible DAQ/ADC cards"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.size = sizeof(struct comedi); - p.node.parse = comedi_parse; - p.node.print = comedi_print; - p.node.start = comedi_start; - p.node.stop = comedi_stop; - p.node.read = comedi_read; - p.node.write = comedi_write; - p.node.poll_fds = comedi_poll_fds; + p.name = "comedi"; + p.description = "Comedi-compatible DAQ/ADC cards"; + p.vectorize = 0; + p.size = sizeof(struct comedi); + p.parse = comedi_parse; + p.print = comedi_print; + p.start = comedi_start; + p.stop = comedi_stop; + p.read = comedi_read; + p.write = comedi_write; + p.poll_fds = comedi_poll_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/ethercat.cpp b/lib/nodes/ethercat.cpp index aa3144232..3eac93c7f 100644 --- a/lib/nodes/ethercat.cpp +++ b/lib/nodes/ethercat.cpp @@ -26,15 +26,15 @@ #include #include -#include #include +#include #include using namespace villas; using namespace villas::node; /* Forward declartions */ -static struct plugin p; +static struct vnode_type p; /* Constants */ #define NSEC_PER_SEC (1000000000) @@ -440,32 +440,27 @@ int ethercat_poll_fds(struct vnode *n, int *fds) __attribute__((constructor(110))) static void register_plugin() { - p.name = "ethercat"; - p.description = "Send and receive samples of an ethercat connection"; - p.type = PluginType::NODE; - p.node.vectorize = 1; /* we only process a single sample per call */ - p.node.size = sizeof(struct ethercat); - p.node.type.start = ethercat_type_start; - p.node.type.stop = ethercat_type_stop; - p.node.parse = ethercat_parse; - p.node.print = ethercat_print; - p.node.check = ethercat_check; - p.node.init = ethercat_init; - p.node.destroy = ethercat_destroy; - p.node.prepare = ethercat_prepare; - p.node.start = ethercat_start; - p.node.stop = ethercat_stop; - p.node.read = ethercat_read; - p.node.write = ethercat_write; - p.node.poll_fds = ethercat_poll_fds; + p.name = "ethercat"; + p.description = "Send and receive samples of an ethercat connection"; + p.vectorize = 1; /* we only process a single sample per call */ + p.size = sizeof(struct ethercat); + p.type.start = ethercat_type_start; + p.type.stop = ethercat_type_stop; + p.parse = ethercat_parse; + p.print = ethercat_print; + p.check = ethercat_check; + p.init = ethercat_init; + p.destroy = ethercat_destroy; + p.prepare = ethercat_prepare; + p.start = ethercat_start; + p.stop = ethercat_stop; + p.read = ethercat_read; + p.write = ethercat_write; + p.poll_fds = ethercat_poll_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} - -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + if (!node_types) + node_types = new NodeTypeList(); + + node_types->push_back(&p); } diff --git a/lib/nodes/example.cpp b/lib/nodes/example.cpp index 9fbe112b4..b738457ce 100644 --- a/lib/nodes/example.cpp +++ b/lib/nodes/example.cpp @@ -20,16 +20,16 @@ * along with this program. If not, see . *********************************************************************************/ +#include #include #include #include -#include #include #include #include /* Forward declartions */ -static struct plugin p; +static struct vnode_type p; using namespace villas; using namespace villas::node; @@ -235,34 +235,28 @@ __attribute__((constructor(110))) static void register_plugin() { p.name = "example"; p.description = "An example for staring new node-type implementations"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.size = sizeof(struct example); - p.node.type.start = example_type_start; - p.node.type.stop = example_type_stop; - p.node.init = example_init; - p.node.destroy = example_destroy; - p.node.prepare = example_prepare; - p.node.parse = example_parse; - p.node.print = example_print; - p.node.check = example_check; - p.node.start = example_start; - p.node.stop = example_stop; - p.node.pause = example_pause; - p.node.resume = example_resume; - p.node.read = example_read; - p.node.write = example_write; - p.node.reverse = example_reverse; - p.node.poll_fds = example_poll_fds; - p.node.netem_fds = example_netem_fds; + p.vectorize = 0; + p.size = sizeof(struct example); + p.type.start = example_type_start; + p.type.stop = example_type_stop; + p.init = example_init; + p.destroy = example_destroy; + p.prepare = example_prepare; + p.parse = example_parse; + p.print = example_print; + p.check = example_check; + p.start = example_start; + p.stop = example_stop; + p.pause = example_pause; + p.resume = example_resume; + p.read = example_read; + p.write = example_write; + p.reverse = example_reverse; + p.poll_fds = example_poll_fds; + p.netem_fds = example_netem_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/exec.cpp b/lib/nodes/exec.cpp index 45ab01fae..9ec7c602d 100644 --- a/lib/nodes/exec.cpp +++ b/lib/nodes/exec.cpp @@ -22,10 +22,10 @@ #include -#include -#include #include +#include #include +#include #include using namespace villas; @@ -244,32 +244,26 @@ int exec_poll_fds(struct vnode *n, int fds[]) return 1; } -static struct plugin p; +static struct vnode_type p; __attribute__((constructor(110))) static void register_plugin() { - p.name = "exec"; - p.description = "run subprocesses with stdin/stdout communication"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.size = sizeof(struct exec); - p.node.parse = exec_parse; - p.node.print = exec_print; - p.node.prepare = exec_prepare; - p.node.init = exec_init; - p.node.destroy = exec_destroy; - p.node.stop = exec_stop; - p.node.read = exec_read; - p.node.write = exec_write; - p.node.poll_fds = exec_poll_fds; + p.name = "exec"; + p.description = "run subprocesses with stdin/stdout communication"; + p.vectorize = 0; + p.size = sizeof(struct exec); + p.parse = exec_parse; + p.print = exec_print; + p.prepare = exec_prepare; + p.init = exec_init; + p.destroy = exec_destroy; + p.stop = exec_stop; + p.read = exec_read; + p.write = exec_write; + p.poll_fds = exec_poll_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/file.cpp b/lib/nodes/file.cpp index 37d36987c..239719f7b 100644 --- a/lib/nodes/file.cpp +++ b/lib/nodes/file.cpp @@ -27,11 +27,11 @@ #include #include +#include #include #include #include #include -#include #include #include @@ -475,32 +475,26 @@ int file_destroy(struct vnode *n) return 0; } -static struct plugin p; +static struct vnode_type p; __attribute__((constructor(110))) static void register_plugin() { - p.name = "file"; - p.description = "support for file log / replay node type"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 1; - p.node.size = sizeof(struct file); - p.node.init = file_init; - p.node.destroy = file_destroy; - p.node.parse = file_parse; - p.node.print = file_print; - p.node.start = file_start; - p.node.stop = file_stop; - p.node.read = file_read; - p.node.write = file_write; - p.node.poll_fds = file_poll_fds; + p.name = "file"; + p.description = "support for file log / replay node type"; + p.vectorize = 1; + p.size = sizeof(struct file); + p.init = file_init; + p.destroy = file_destroy; + p.parse = file_parse; + p.print = file_print; + p.start = file_start; + p.stop = file_stop; + p.read = file_read; + p.write = file_write; + p.poll_fds = file_poll_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/fpga.cpp b/lib/nodes/fpga.cpp index f716c2c68..e90ae60dd 100644 --- a/lib/nodes/fpga.cpp +++ b/lib/nodes/fpga.cpp @@ -27,12 +27,12 @@ #include #include +#include #include #include #include #include #include -#include #include #include @@ -40,7 +40,7 @@ #include /* Forward declartions */ -static struct plugin p; +static struct vnode_type p; using namespace villas; using namespace villas::node; @@ -328,33 +328,27 @@ int fpga_poll_fds(struct vnode *n, int fds[]) __attribute__((constructor(110))) static void register_plugin() { - p.name = "fpga"; - p.description = "Communicate with VILLASfpga Xilinx FPGA boards"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 1; - p.node.size = sizeof(struct fpga); - p.node.type.start = fpga_type_start; - p.node.type.stop = fpga_type_stop; - p.node.init = fpga_init; - p.node.destroy = fpga_destroy; - p.node.prepare = fpga_prepare; - p.node.parse = fpga_parse; - p.node.print = fpga_print; - p.node.check = fpga_check; - p.node.start = fpga_start; - p.node.stop = fpga_stop; - p.node.read = fpga_read; - p.node.write = fpga_write; - p.node.poll_fds = fpga_poll_fds; + p.name = "fpga"; + p.description = "Communicate with VILLASfpga Xilinx FPGA boards"; + p.vectorize = 1; + p.size = sizeof(struct fpga); + p.start = fpga_type_start; + p.stop = fpga_type_stop; + p.init = fpga_init; + p.destroy = fpga_destroy; + p.prepare = fpga_prepare; + p.parse = fpga_parse; + p.print = fpga_print; + p.check = fpga_check; + p.start = fpga_start; + p.stop = fpga_stop; + p.read = fpga_read; + p.write = fpga_write; + p.poll_fds = fpga_poll_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); + if (!node_types) + node_types = new NodeTypeList(); + + node_types->push_back(&p); } -__attribute__((destructor(110))) -static void deregister_plugin() { - if (plugins.state != State::DESTROYED) - vlist_remove_all(&plugins, &p); -} diff --git a/lib/nodes/iec61850.cpp b/lib/nodes/iec61850.cpp index ac2c2d4ac..c287526c4 100644 --- a/lib/nodes/iec61850.cpp +++ b/lib/nodes/iec61850.cpp @@ -24,9 +24,10 @@ #include #include +#include #include -#include #include +#include #include #define CONFIG_SV_DEFAULT_APPID 0x4000 diff --git a/lib/nodes/iec61850_sv.cpp b/lib/nodes/iec61850_sv.cpp index e16a88179..b79b648f1 100644 --- a/lib/nodes/iec61850_sv.cpp +++ b/lib/nodes/iec61850_sv.cpp @@ -27,7 +27,6 @@ #include #include -#include #define CONFIG_SV_DEFAULT_APPID 0x4000 #define CONFIG_SV_DEFAULT_DST_ADDRESS CONFIG_GOOSE_DEFAULT_DST_ADDRESS @@ -476,35 +475,29 @@ int iec61850_sv_poll_fds(struct vnode *n, int fds[]) return 1; } -static struct plugin p; +static struct vnode_type p; __attribute__((constructor(110))) static void register_plugin() { - p.name = "iec61850-9-2"; - p.description = "IEC 61850-9-2 (Sampled Values)"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.size = sizeof(struct iec61850_sv); - p.node.type.start = iec61850_type_start; - p.node.type.stop = iec61850_type_stop; - p.node.destroy = iec61850_sv_destroy; - p.node.parse = iec61850_sv_parse; - p.node.print = iec61850_sv_print; - p.node.start = iec61850_sv_start; - p.node.stop = iec61850_sv_stop; - p.node.read = iec61850_sv_read; - p.node.write = iec61850_sv_write; - p.node.poll_fds = iec61850_sv_poll_fds; + p.name = "iec61850-9-2"; + p.description = "IEC 61850-9-2 (Sampled Values)"; + p.vectorize = 0; + p.size = sizeof(struct iec61850_sv); + p.start = iec61850_type_start; + p.stop = iec61850_type_stop; + p.destroy = iec61850_sv_destroy; + p.parse = iec61850_sv_parse; + p.print = iec61850_sv_print; + p.start = iec61850_sv_start; + p.stop = iec61850_sv_stop; + p.read = iec61850_sv_read; + p.write = iec61850_sv_write; + p.poll_fds = iec61850_sv_poll_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } #endif /* CONFIG_IEC61850_SAMPLED_VALUES_SUPPORT */ diff --git a/lib/nodes/infiniband.cpp b/lib/nodes/infiniband.cpp index ecc451ccb..6cbe60ee2 100644 --- a/lib/nodes/infiniband.cpp +++ b/lib/nodes/infiniband.cpp @@ -26,8 +26,8 @@ #include #include +#include #include -#include #include #include #include @@ -1000,34 +1000,28 @@ int ib_write(struct vnode *n, struct sample * const smps[], unsigned cnt) return sent; } -static struct plugin p; +static struct vnode_type p; __attribute__((constructor(110))) static void register_plugin() { - p.name = "infiniband"; - p.description = "Infiniband interface (libibverbs, librdmacm)"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.size = sizeof(struct infiniband); - p.node.pool_size = 8192; - p.node.destroy = ib_destroy; - p.node.parse = ib_parse; - p.node.check = ib_check; - p.node.print = ib_print; - p.node.start = ib_start; - p.node.stop = ib_stop; - p.node.read = ib_read; - p.node.write = ib_write; - p.node.reverse = ib_reverse; - p.node.memory_type = memory_ib; + p.name = "infiniband"; + p.description = "Infiniband interface (libibverbs, librdmacm)"; + p.vectorize = 0; + p.size = sizeof(struct infiniband); + p.pool_size = 8192; + p.destroy = ib_destroy; + p.parse = ib_parse; + p.check = ib_check; + p.print = ib_print; + p.start = ib_start; + p.stop = ib_stop; + p.read = ib_read; + p.write = ib_write; + p.reverse = ib_reverse; + p.memory_type = memory_ib; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/influxdb.cpp b/lib/nodes/influxdb.cpp index 1d7f5fad2..8f6f4cfbc 100644 --- a/lib/nodes/influxdb.cpp +++ b/lib/nodes/influxdb.cpp @@ -26,12 +26,13 @@ #include #include -#include -#include #include +#include #include +#include #include #include +#include #include using namespace villas; @@ -214,28 +215,22 @@ char * influxdb_print(struct vnode *n) return buf; } -static struct plugin p; +static struct vnode_type p; __attribute__((constructor(110))) static void register_plugin() { - p.name = "influxdb"; - p.description = "Write results to InfluxDB"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.size = sizeof(struct influxdb); - p.node.parse = influxdb_parse; - p.node.print = influxdb_print; - p.node.start = influxdb_open; - p.node.stop = influxdb_close; - p.node.write = influxdb_write; + p.name = "influxdb"; + p.description = "Write results to InfluxDB"; + p.vectorize = 0; + p.size = sizeof(struct influxdb); + p.parse = influxdb_parse; + p.print = influxdb_print; + p.start = influxdb_open; + p.stop = influxdb_close; + p.write = influxdb_write; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/kafka.cpp b/lib/nodes/kafka.cpp index 8f0deff82..4a8755964 100644 --- a/lib/nodes/kafka.cpp +++ b/lib/nodes/kafka.cpp @@ -24,8 +24,8 @@ #include #include +#include #include -#include #include #include @@ -576,38 +576,33 @@ int kafka_poll_fds(struct vnode *n, int fds[]) return 1; } -static struct plugin p; +static struct vnode_type p; __attribute__((constructor(110))) static void register_plugin() { p.name = "kafka"; p.description = "Kafka event message streaming (rdkafka)"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.size = sizeof(struct kafka); - p.node.type.start = kafka_type_start; - p.node.type.stop = kafka_type_stop; - p.node.destroy = kafka_destroy; - p.node.prepare = kafka_prepare; - p.node.parse = kafka_parse; - p.node.prepare = kafka_prepare; - p.node.print = kafka_print; - p.node.init = kafka_init; - p.node.destroy = kafka_destroy; - p.node.start = kafka_start; - p.node.stop = kafka_stop; - p.node.read = kafka_read; - p.node.write = kafka_write; - p.node.reverse = kafka_reverse; - p.node.poll_fds = kafka_poll_fds; + p.instances.state = State::DESTROYED; + p.vectorize = 0; + p.size = sizeof(struct kafka); + p.start = kafka_type_start; + p.stop = kafka_type_stop; + p.destroy = kafka_destroy; + p.prepare = kafka_prepare; + p.parse = kafka_parse; + p.prepare = kafka_prepare; + p.print = kafka_print; + p.init = kafka_init; + p.destroy = kafka_destroy; + p.start = kafka_start; + p.stop = kafka_stop; + p.read = kafka_read; + p.write = kafka_write; + p.reverse = kafka_reverse; + p.poll_fds = kafka_poll_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/loopback.cpp b/lib/nodes/loopback.cpp index 3d53c0e17..8fb4ccce3 100644 --- a/lib/nodes/loopback.cpp +++ b/lib/nodes/loopback.cpp @@ -22,18 +22,18 @@ #include -#include -#include #include +#include #include #include #include +#include using namespace villas; using namespace villas::node; using namespace villas::utils; -static struct plugin p; +static struct vnode_type p; int loopback_init(struct vnode *n) { @@ -143,28 +143,22 @@ int loopback_poll_fds(struct vnode *n, int fds[]) __attribute__((constructor(110))) static void register_plugin() { - p.name = "loopback"; - p.description = "Loopback to connect multiple paths"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.flags = 0; - p.node.size = sizeof(struct loopback); - p.node.parse = loopback_parse; - p.node.print = loopback_print; - p.node.prepare = loopback_prepare; - p.node.init = loopback_init; - p.node.destroy = loopback_destroy; - p.node.read = loopback_read; - p.node.write = loopback_write; - p.node.poll_fds = loopback_poll_fds; + p.name = "loopback"; + p.description = "Loopback to connect multiple paths"; + p.vectorize = 0; + p.flags = 0; + p.size = sizeof(struct loopback); + p.parse = loopback_parse; + p.print = loopback_print; + p.prepare = loopback_prepare; + p.init = loopback_init; + p.destroy = loopback_destroy; + p.read = loopback_read; + p.write = loopback_write; + p.poll_fds = loopback_poll_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/loopback_internal.cpp b/lib/nodes/loopback_internal.cpp index a4a526fc4..d70c62207 100644 --- a/lib/nodes/loopback_internal.cpp +++ b/lib/nodes/loopback_internal.cpp @@ -22,18 +22,16 @@ #include -#include -#include #include +#include #include #include #include using namespace villas; using namespace villas::node; -using namespace villas::utils; -static struct plugin p; +static struct vnode_type p; int loopback_internal_init(struct vnode *n) { @@ -108,7 +106,7 @@ struct vnode * loopback_internal_create(struct vnode *orig) if (!n) throw MemoryAllocationError(); - ret = node_init(n, &p.node); + ret = node_init(n, &p); if (ret) return nullptr; @@ -123,26 +121,20 @@ struct vnode * loopback_internal_create(struct vnode *orig) __attribute__((constructor(110))) static void register_plugin() { - p.name = "loopback_internal"; - p.description = "internal loopback to connect multiple paths"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.flags = (int) NodeFlags::PROVIDES_SIGNALS | (int) NodeFlags::INTERNAL; - p.node.size = sizeof(struct loopback_internal); - p.node.prepare = loopback_internal_prepare; - p.node.init = loopback_internal_init; - p.node.destroy = loopback_internal_destroy; - p.node.read = loopback_internal_read; - p.node.write = loopback_internal_write; - p.node.poll_fds = loopback_internal_poll_fds; + p.name = "loopback_internal"; + p.description = "internal loopback to connect multiple paths"; + p.vectorize = 0; + p.flags = (int) NodeFlags::PROVIDES_SIGNALS | (int) NodeFlags::INTERNAL; + p.size = sizeof(struct loopback_internal); + p.prepare = loopback_internal_prepare; + p.init = loopback_internal_init; + p.destroy = loopback_internal_destroy; + p.read = loopback_internal_read; + p.write = loopback_internal_write; + p.poll_fds = loopback_internal_poll_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/mqtt.cpp b/lib/nodes/mqtt.cpp index a4dd9bece..32a85f291 100644 --- a/lib/nodes/mqtt.cpp +++ b/lib/nodes/mqtt.cpp @@ -23,8 +23,8 @@ #include #include +#include #include -#include #include #include @@ -559,39 +559,33 @@ int mqtt_poll_fds(struct vnode *n, int fds[]) return 1; } -static struct plugin p; +static struct vnode_type p; __attribute__((constructor(110))) static void register_plugin() { - p.name = "mqtt"; - p.description = "Message Queuing Telemetry Transport (libmosquitto)"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.size = sizeof(struct mqtt); - p.node.type.start = mqtt_type_start; - p.node.type.stop = mqtt_type_stop; - p.node.destroy = mqtt_destroy; - p.node.prepare = mqtt_prepare; - p.node.parse = mqtt_parse; - p.node.check = mqtt_check; - p.node.prepare = mqtt_prepare; - p.node.print = mqtt_print; - p.node.init = mqtt_init; - p.node.destroy = mqtt_destroy; - p.node.start = mqtt_start; - p.node.stop = mqtt_stop; - p.node.read = mqtt_read; - p.node.write = mqtt_write; - p.node.reverse = mqtt_reverse; - p.node.poll_fds = mqtt_poll_fds; + p.name = "mqtt"; + p.description = "Message Queuing Telemetry Transport (libmosquitto)"; + p.vectorize = 0; + p.size = sizeof(struct mqtt); + p.type.start = mqtt_type_start; + p.type.stop = mqtt_type_stop; + p.destroy = mqtt_destroy; + p.prepare = mqtt_prepare; + p.parse = mqtt_parse; + p.check = mqtt_check; + p.prepare = mqtt_prepare; + p.print = mqtt_print; + p.init = mqtt_init; + p.destroy = mqtt_destroy; + p.start = mqtt_start; + p.stop = mqtt_stop; + p.read = mqtt_read; + p.write = mqtt_write; + p.reverse = mqtt_reverse; + p.poll_fds = mqtt_poll_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/nanomsg.cpp b/lib/nodes/nanomsg.cpp index 6ab68f5d0..1ee088b3d 100644 --- a/lib/nodes/nanomsg.cpp +++ b/lib/nodes/nanomsg.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include @@ -284,33 +284,27 @@ int nanomsg_netem_fds(struct vnode *n, int fds[]) return 1; } -static struct plugin p; +static struct vnode_type p; __attribute__((constructor(110))) static void register_plugin() { - p.name = "nanomsg"; - p.description = "scalability protocols library (libnanomsg)"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.size = sizeof(struct nanomsg); - p.node.type.stop = nanomsg_type_stop; - p.node.parse = nanomsg_parse; - p.node.print = nanomsg_print; - p.node.start = nanomsg_start; - p.node.stop = nanomsg_stop; - p.node.read = nanomsg_read; - p.node.write = nanomsg_write; - p.node.reverse = nanomsg_reverse; - p.node.poll_fds = nanomsg_poll_fds; - p.node.netem_fds = nanomsg_netem_fds; + p.name = "nanomsg"; + p.description = "scalability protocols library (libnanomsg)"; + p.vectorize = 0; + p.size = sizeof(struct nanomsg); + p.type.stop = nanomsg_type_stop; + p.parse = nanomsg_parse; + p.print = nanomsg_print; + p.start = nanomsg_start; + p.stop = nanomsg_stop; + p.read = nanomsg_read; + p.write = nanomsg_write; + p.reverse = nanomsg_reverse; + p.poll_fds = nanomsg_poll_fds; + p.netem_fds = nanomsg_netem_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/ngsi.cpp b/lib/nodes/ngsi.cpp index ca7d79393..a366d3947 100644 --- a/lib/nodes/ngsi.cpp +++ b/lib/nodes/ngsi.cpp @@ -31,12 +31,12 @@ #include #include +#include #include #include #include #include #include -#include #include using namespace villas; @@ -846,39 +846,33 @@ int ngsi_reverse(struct vnode *n) } -static struct plugin p; +static struct vnode_type p; __attribute__((constructor(110))) static void register_plugin() { p.name = "ngsi"; p.description = "OMA Next Generation Services Interface 10 (libcurl, libjansson)"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; #ifdef NGSI_VECTORS - p.node.vectorize = 0, /* unlimited */ + p.vectorize = 0, /* unlimited */ #else - p.node.vectorize = 1, + p.vectorize = 1, #endif - p.node.size = sizeof(struct ngsi); - p.node.type.start = ngsi_type_start; - p.node.type.stop = ngsi_type_stop; - p.node.init = ngsi_init; - p.node.destroy = ngsi_destroy; - p.node.parse = ngsi_parse; - p.node.print = ngsi_print; - p.node.start = ngsi_start; - p.node.stop = ngsi_stop; - p.node.read = ngsi_read; - p.node.write = ngsi_write; - p.node.poll_fds = ngsi_poll_fds; - p.node.reverse = ngsi_reverse; + p.size = sizeof(struct ngsi); + p.type.start = ngsi_type_start; + p.type.stop = ngsi_type_stop; + p.init = ngsi_init; + p.destroy = ngsi_destroy; + p.parse = ngsi_parse; + p.print = ngsi_print; + p.start = ngsi_start; + p.stop = ngsi_stop; + p.read = ngsi_read; + p.write = ngsi_write; + p.poll_fds = ngsi_poll_fds; + p.reverse = ngsi_reverse; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/opal.cpp b/lib/nodes/opal.cpp index 2412313f8..69638a40a 100644 --- a/lib/nodes/opal.cpp +++ b/lib/nodes/opal.cpp @@ -30,9 +30,9 @@ #include #include +#include #include #include -#include #include extern "C" { @@ -351,30 +351,24 @@ int opal_write(struct vnode *n, struct sample * const smps[], unsigned cnt) return 1; } -static struct plugin p; +static struct vnode_type p; __attribute__((constructor(110))) static void register_plugin() { - p.name = "opal"; - p.description = "run as OPAL Asynchronous Process (libOpalAsyncApi)"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 1; - p.node.size = sizeof(struct opal); - p.node.type.start = opal_type_start; - p.node.type.stop = opal_type_stop; - p.node.parse = opal_parse; - p.node.print = opal_print; - p.node.start = opal_start; - p.node.read = opal_read; - p.node.write = opal_write; + p.name = "opal"; + p.description = "run as OPAL Asynchronous Process (libOpalAsyncApi)"; + p.vectorize = 1; + p.size = sizeof(struct opal); + p.start = opal_type_start; + p.stop = opal_type_stop; + p.parse = opal_parse; + p.print = opal_print; + p.start = opal_start; + p.read = opal_read; + p.write = opal_write; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/rtp.cpp b/lib/nodes/rtp.cpp index 038566d48..8542e8b36 100644 --- a/lib/nodes/rtp.cpp +++ b/lib/nodes/rtp.cpp @@ -39,7 +39,7 @@ extern "C" { #undef ALIGN_MASK } -#include +#include #include #include #include @@ -57,7 +57,7 @@ using namespace villas::utils; using namespace villas::node; using namespace villas::kernel; -static struct plugin p; +static struct vnode_type p; static int rtp_aimd(struct vnode *n, double loss_frac) { @@ -471,8 +471,7 @@ int rtp_type_start(villas::node::SuperNode *sn) #ifdef WITH_NETEM /* Gather list of used network interfaces */ - for (size_t i = 0; i < vlist_length(&p.node.instances); i++) { - struct vnode *n = (struct vnode *) vlist_at(&p.node.instances, i); + for (auto *n : p.instances) { struct rtp *r = (struct rtp *) n->_vd; Interface *j = Interface::getEgress(&r->out.saddr_rtp.u.sa, sn); @@ -589,30 +588,24 @@ static void register_plugin() { #else p.description = "real-time transport protocol (libre)"; #endif - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.size = sizeof(struct rtp); - p.node.type.start = rtp_type_start; - p.node.type.stop = rtp_type_stop; - p.node.init = rtp_init; - p.node.destroy = rtp_destroy; - p.node.parse = rtp_parse; - p.node.print = rtp_print; - p.node.start = rtp_start; - p.node.stop = rtp_stop; - p.node.read = rtp_read; - p.node.write = rtp_write; - p.node.reverse = rtp_reverse; - p.node.poll_fds = rtp_poll_fds; - p.node.netem_fds = rtp_netem_fds; + p.vectorize = 0; + p.size = sizeof(struct rtp); + p.type.start = rtp_type_start; + p.type.stop = rtp_type_stop; + p.init = rtp_init; + p.destroy = rtp_destroy; + p.parse = rtp_parse; + p.print = rtp_print; + p.start = rtp_start; + p.stop = rtp_stop; + p.read = rtp_read; + p.write = rtp_write; + p.reverse = rtp_reverse; + p.poll_fds = rtp_poll_fds; + p.netem_fds = rtp_netem_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/shmem.cpp b/lib/nodes/shmem.cpp index 307954de8..dd0b75f61 100644 --- a/lib/nodes/shmem.cpp +++ b/lib/nodes/shmem.cpp @@ -32,8 +32,8 @@ #include #include #include +#include #include -#include #include #include @@ -202,29 +202,23 @@ char * shmem_print(struct vnode *n) return buf; } -static struct plugin p; +static struct vnode_type p; __attribute__((constructor(110))) static void register_plugin() { - p.name = "shmem"; - p.description = "POSIX shared memory interface with external processes"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.size = sizeof(struct shmem); - p.node.parse = shmem_parse; - p.node.print = shmem_print; - p.node.start = shmem_start; - p.node.stop = shmem_stop; - p.node.read = shmem_read; - p.node.write = shmem_write; + p.name = "shmem"; + p.description = "POSIX shared memory interface with external processes"; + p.vectorize = 0; + p.size = sizeof(struct shmem); + p.parse = shmem_parse; + p.print = shmem_print; + p.start = shmem_start; + p.stop = shmem_stop; + p.read = shmem_read; + p.write = shmem_write; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/signal_generator.cpp b/lib/nodes/signal_generator.cpp index 8693b3c1e..0743565ef 100644 --- a/lib/nodes/signal_generator.cpp +++ b/lib/nodes/signal_generator.cpp @@ -25,10 +25,10 @@ #include #include -#include -#include #include +#include #include +#include using namespace villas; using namespace villas::node; @@ -444,33 +444,27 @@ int signal_generator_poll_fds(struct vnode *n, int fds[]) return 0; } -static struct plugin p; +static struct vnode_type p; __attribute__((constructor(110))) static void register_plugin() { - p.name = "signal"; - p.description = "Signal generator"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 1; - p.node.flags = (int) NodeFlags::PROVIDES_SIGNALS; - p.node.size = sizeof(struct signal_generator); - p.node.init = signal_generator_init; - p.node.destroy = signal_generator_destroy; - p.node.parse = signal_generator_parse; - p.node.prepare = signal_generator_prepare; - p.node.print = signal_generator_print; - p.node.start = signal_generator_start; - p.node.stop = signal_generator_stop; - p.node.read = signal_generator_read; - p.node.poll_fds = signal_generator_poll_fds; + p.name = "signal"; + p.description = "Signal generator"; + p.vectorize = 1; + p.flags = (int) NodeFlags::PROVIDES_SIGNALS; + p.size = sizeof(struct signal_generator); + p.init = signal_generator_init; + p.destroy = signal_generator_destroy; + p.parse = signal_generator_parse; + p.prepare = signal_generator_prepare; + p.print = signal_generator_print; + p.start = signal_generator_start; + p.stop = signal_generator_stop; + p.read = signal_generator_read; + p.poll_fds = signal_generator_poll_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/socket.cpp b/lib/nodes/socket.cpp index 0a472f04c..f9f181517 100644 --- a/lib/nodes/socket.cpp +++ b/lib/nodes/socket.cpp @@ -26,11 +26,11 @@ #include #include +#include #include #include #include #include -#include #include #include @@ -44,7 +44,7 @@ #endif /* WITH_NETEM */ /* Forward declartions */ -static struct plugin p; +static struct vnode_type p; using namespace villas; using namespace villas::utils; @@ -55,8 +55,7 @@ int socket_type_start(villas::node::SuperNode *sn) { #ifdef WITH_NETEM /* Gather list of used network interfaces */ - for (size_t i = 0; i < vlist_length(&p.node.instances); i++) { - struct vnode *n = (struct vnode *) vlist_at(&p.node.instances, i); + for (auto *n : p.instances) { struct socket *s = (struct socket *) n->_vd; if (s->layer == SocketLayer::UNIX) @@ -555,28 +554,22 @@ static void register_plugin() { #else p.description = "BSD network sockets for Ethernet / IP / UDP"; #endif - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.size = sizeof(struct socket); - p.node.type.start = socket_type_start; - p.node.reverse = socket_reverse; - p.node.parse = socket_parse; - p.node.print = socket_print; - p.node.check = socket_check; - p.node.start = socket_start; - p.node.stop = socket_stop; - p.node.read = socket_read; - p.node.write = socket_write; - p.node.poll_fds = socket_fds; - p.node.netem_fds = socket_fds; + p.vectorize = 0; + p.size = sizeof(struct socket); + p.type.start = socket_type_start; + p.reverse = socket_reverse; + p.parse = socket_parse; + p.print = socket_print; + p.check = socket_check; + p.start = socket_start; + p.stop = socket_stop; + p.read = socket_read; + p.write = socket_write; + p.poll_fds = socket_fds; + p.netem_fds = socket_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/stats.cpp b/lib/nodes/stats.cpp index 9004521d0..fd7a7ed7c 100644 --- a/lib/nodes/stats.cpp +++ b/lib/nodes/stats.cpp @@ -22,19 +22,19 @@ #include +#include #include #include -#include #include #include #include -#include +#include using namespace villas; using namespace villas::node; using namespace villas::utils; -static struct vlist *nodes; /** The global list of nodes */ +static NodeList nodes; /** The global list of nodes */ int stats_node_signal_destroy(struct stats_node_signal *s) { @@ -126,7 +126,7 @@ int stats_node_start(struct vnode *n) for (size_t i = 0; i < vlist_length(&s->signals); i++) { struct stats_node_signal *stats_sig = (struct stats_node_signal *) vlist_at(&s->signals, i); - stats_sig->node = vlist_lookup_name(nodes, stats_sig->node_str); + stats_sig->node = nodes.lookup(stats_sig->node_str); if (!stats_sig->node) throw ConfigError(n->config, "node-config-node-stats-node", "Invalid reference node {}", stats_sig->node_str); } @@ -253,34 +253,28 @@ int stats_node_poll_fds(struct vnode *n, int fds[]) return 0; } -static struct plugin p; +static struct vnode_type p; __attribute__((constructor(110))) static void register_plugin() { - p.name = "stats"; - p.description = "Send statistics to another node"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 1; - p.node.flags = (int) NodeFlags::PROVIDES_SIGNALS; - p.node.size = sizeof(struct stats_node); - p.node.type.start = stats_node_type_start; - p.node.parse = stats_node_parse; - p.node.init = stats_node_init; - p.node.destroy = stats_node_destroy; - p.node.print = stats_node_print; - p.node.prepare = stats_node_prepare; - p.node.start = stats_node_start; - p.node.stop = stats_node_stop; - p.node.read = stats_node_read; - p.node.poll_fds = stats_node_poll_fds; + p.name = "stats"; + p.description = "Send statistics to another node"; + p.vectorize = 1; + p.flags = (int) NodeFlags::PROVIDES_SIGNALS; + p.size = sizeof(struct stats_node); + p.type.start = stats_node_type_start; + p.parse = stats_node_parse; + p.init = stats_node_init; + p.destroy = stats_node_destroy; + p.print = stats_node_print; + p.prepare = stats_node_prepare; + p.start = stats_node_start; + p.stop = stats_node_stop; + p.read = stats_node_read; + p.poll_fds = stats_node_poll_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/temper.cpp b/lib/nodes/temper.cpp index f5013ab47..b4177331c 100644 --- a/lib/nodes/temper.cpp +++ b/lib/nodes/temper.cpp @@ -30,9 +30,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include -#include #include using namespace villas; @@ -46,7 +46,7 @@ static std::list devices; static struct libusb_context *context; /* Forward declartions */ -static struct plugin p; +static struct vnode_type p; TEMPerDevice::TEMPerDevice(struct libusb_device *dev) : @@ -414,30 +414,24 @@ int temper_read(struct vnode *n, struct sample * const smps[], unsigned cnt) __attribute__((constructor(110))) static void register_plugin() { - p.name = "temper"; - p.description = "An temper for staring new node-type implementations"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 1; - p.node.flags = (int) NodeFlags::PROVIDES_SIGNALS; - p.node.size = sizeof(struct temper); - p.node.type.start = temper_type_start; - p.node.type.stop = temper_type_stop; - p.node.init = temper_init; - p.node.destroy = temper_destroy; - p.node.prepare = temper_prepare; - p.node.parse = temper_parse; - p.node.print = temper_print; - p.node.start = temper_start; - p.node.stop = temper_stop; - p.node.read = temper_read; + p.name = "temper"; + p.description = "An temper for staring new node-type implementations"; + p.vectorize = 1; + p.flags = (int) NodeFlags::PROVIDES_SIGNALS; + p.size = sizeof(struct temper); + p.type.start = temper_type_start; + p.type.stop = temper_type_stop; + p.init = temper_init; + p.destroy = temper_destroy; + p.prepare = temper_prepare; + p.parse = temper_parse; + p.print = temper_print; + p.start = temper_start; + p.stop = temper_stop; + p.read = temper_read; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/test_rtt.cpp b/lib/nodes/test_rtt.cpp index c8c8848db..d9e21e34d 100644 --- a/lib/nodes/test_rtt.cpp +++ b/lib/nodes/test_rtt.cpp @@ -27,18 +27,19 @@ #include #include -#include #include +#include +#include #include -#include #include +#include #include using namespace villas; using namespace villas::node; using namespace villas::utils; -static struct plugin p; +static struct vnode_type p; static int test_rtt_case_start(struct vnode *n, int id) { @@ -428,29 +429,23 @@ int test_rtt_poll_fds(struct vnode *n, int fds[]) __attribute__((constructor(110))) static void register_plugin() { - p.name = "test_rtt"; - p.description = "Test round-trip time with loopback"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.flags = (int) NodeFlags::PROVIDES_SIGNALS; - p.node.size = sizeof(struct test_rtt); - p.node.parse = test_rtt_parse; - p.node.prepare = test_rtt_prepare; - p.node.init = test_rtt_init; - p.node.destroy = test_rtt_destroy; - p.node.print = test_rtt_print; - p.node.start = test_rtt_start; - p.node.stop = test_rtt_stop; - p.node.read = test_rtt_read; - p.node.write = test_rtt_write; + p.name = "test_rtt"; + p.description = "Test round-trip time with loopback"; + p.vectorize = 0; + p.flags = (int) NodeFlags::PROVIDES_SIGNALS; + p.size = sizeof(struct test_rtt); + p.parse = test_rtt_parse; + p.prepare = test_rtt_prepare; + p.init = test_rtt_init; + p.destroy = test_rtt_destroy; + p.print = test_rtt_print; + p.start = test_rtt_start; + p.stop = test_rtt_stop; + p.read = test_rtt_read; + p.write = test_rtt_write; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/uldaq.cpp b/lib/nodes/uldaq.cpp index 13d447d2c..1ae2d8f8b 100644 --- a/lib/nodes/uldaq.cpp +++ b/lib/nodes/uldaq.cpp @@ -24,12 +24,12 @@ #include -#include -#include #include +#include #include #include #include +#include using namespace villas; using namespace villas::node; @@ -625,32 +625,26 @@ int uldaq_read(struct vnode *n, struct sample * const smps[], unsigned cnt) return cnt; } -static struct plugin p; +static struct vnode_type p; __attribute__((constructor(110))) static void register_plugin() { - p.name = "uldaq"; - p.description = "Measurement Computing DAQ devices like UL201 (libuldaq)"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.flags = 0; - p.node.size = sizeof(struct uldaq); - p.node.type.start = uldaq_type_start; - p.node.init = uldaq_init; - p.node.destroy = uldaq_destroy; - p.node.parse = uldaq_parse; - p.node.print = uldaq_print; - p.node.start = uldaq_start; - p.node.stop = uldaq_stop; - p.node.read = uldaq_read; + p.name = "uldaq"; + p.description = "Measurement Computing DAQ devices like UL201 (libuldaq)"; + p.vectorize = 0; + p.flags = 0; + p.size = sizeof(struct uldaq); + p.type.start = uldaq_type_start; + p.init = uldaq_init; + p.destroy = uldaq_destroy; + p.parse = uldaq_parse; + p.print = uldaq_print; + p.start = uldaq_start; + p.stop = uldaq_stop; + p.read = uldaq_read; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/websocket.cpp b/lib/nodes/websocket.cpp index 4968abfaa..c6ac229cd 100644 --- a/lib/nodes/websocket.cpp +++ b/lib/nodes/websocket.cpp @@ -30,7 +30,7 @@ #include #include -#include +#include #include #include @@ -47,7 +47,7 @@ static villas::node::Web *web; static villas::Logger logger = logging.get("websocket"); /* Forward declarations */ -static struct plugin p; +static struct vnode_type p; static char * websocket_connection_name(struct websocket_connection *c) { @@ -211,7 +211,7 @@ int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, voi format = (char *) "villas.web"; /* Search for node whose name matches the URI. */ - c->node = vlist_lookup_name(&p.node.instances, node); + c->node = p.instances.lookup(node); if (!c->node) { websocket_connection_close(c, wsi, LWS_CLOSE_STATUS_POLICY_VIOLATION, "Unknown node"); logger->warn("Failed to find node: {}", node); @@ -601,27 +601,22 @@ int websocket_poll_fds(struct vnode *n, int fds[]) } __attribute__((constructor(110))) static void UNIQUE(__ctor)() { - p.name = "websocket"; - p.description = "Send and receive samples of a WebSocket connection (libwebsockets)"; - p.type = PluginType::NODE; - p.node.vectorize = 0; /* unlimited */ - p.node.size = sizeof(struct websocket); - p.node.instances.state = State::DESTROYED; - p.node.type.start = websocket_type_start; - p.node.destroy = websocket_destroy; - p.node.parse = websocket_parse; - p.node.print = websocket_print; - p.node.start = websocket_start; - p.node.stop = websocket_stop; - p.node.read = websocket_read; - p.node.write = websocket_write; - p.node.poll_fds = websocket_poll_fds; + p.name = "websocket"; + p.description = "Send and receive samples of a WebSocket connection (libwebsockets)"; + p.vectorize = 0; + p.size = sizeof(struct websocket); + p.type.start = websocket_type_start; + p.destroy = websocket_destroy; + p.parse = websocket_parse; + p.print = websocket_print; + p.start = websocket_start; + p.stop = websocket_stop; + p.read = websocket_read; + p.write = websocket_write; + p.poll_fds = websocket_poll_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) static void UNIQUE(__dtor)() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/nodes/zeromq.cpp b/lib/nodes/zeromq.cpp index 6dde1bc64..71dd7a916 100644 --- a/lib/nodes/zeromq.cpp +++ b/lib/nodes/zeromq.cpp @@ -27,12 +27,11 @@ #include #endif -#include #include +#include #include #include #include -#include #include using namespace villas; @@ -636,37 +635,31 @@ int zeromq_netem_fds(struct vnode *n, int fds[]) return 1; } -static struct plugin p; +static struct vnode_type p; __attribute__((constructor(110))) static void register_plugin() { - p.name = "zeromq"; - p.description = "ZeroMQ Distributed Messaging (libzmq)"; - p.type = PluginType::NODE; - p.node.instances.state = State::DESTROYED; - p.node.vectorize = 0; - p.node.size = sizeof(struct zeromq); - p.node.type.start = zeromq_type_start; - p.node.type.stop = zeromq_type_stop; - p.node.init = zeromq_init; - p.node.destroy = zeromq_destroy; - p.node.check = zeromq_check; - p.node.parse = zeromq_parse; - p.node.print = zeromq_print; - p.node.start = zeromq_start; - p.node.stop = zeromq_stop; - p.node.read = zeromq_read; - p.node.write = zeromq_write; - p.node.reverse = zeromq_reverse; - p.node.poll_fds = zeromq_poll_fds; - p.node.netem_fds = zeromq_netem_fds; + p.name = "zeromq"; + p.description = "ZeroMQ Distributed Messaging (libzmq)"; + p.vectorize = 0; + p.size = sizeof(struct zeromq); + p.type.start = zeromq_type_start; + p.type.stop = zeromq_type_stop; + p.init = zeromq_init; + p.destroy = zeromq_destroy; + p.check = zeromq_check; + p.parse = zeromq_parse; + p.print = zeromq_print; + p.start = zeromq_start; + p.stop = zeromq_stop; + p.read = zeromq_read; + p.write = zeromq_write; + p.reverse = zeromq_reverse; + p.poll_fds = zeromq_poll_fds; + p.netem_fds = zeromq_netem_fds; - int ret = vlist_init(&p.node.instances); - if (!ret) - vlist_init_and_push(&plugins, &p); -} + if (!node_types) + node_types = new NodeTypeList(); -__attribute__((destructor(110))) -static void deregister_plugin() { - vlist_remove_all(&plugins, &p); + node_types->push_back(&p); } diff --git a/lib/plugin.cpp b/lib/plugin.cpp deleted file mode 100644 index f2b9b5a4f..000000000 --- a/lib/plugin.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/** Loadable / plugin support. - * - * @author Steffen Vogel - * @copyright 2014-2020, Institute for Automation of Complex Power Systems, EONERC - * @license GNU General Public License (version 3) - * - * VILLASnode - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - *********************************************************************************/ - -#include -#include - -#include - -/** Global list of all known plugins */ -struct vlist plugins; - -LIST_INIT_STATIC(&plugins) - -struct plugin * plugin_lookup(enum PluginType type, const char *name) -{ - for (size_t i = 0; i < vlist_length(&plugins); i++) { - struct plugin *p = (struct plugin *) vlist_at(&plugins, i); - - if (p->type == type && strcmp(p->name, name) == 0) - return p; - } - - return nullptr; -} - -void plugin_dump(enum PluginType type) -{ - for (size_t i = 0; i < vlist_length(&plugins); i++) { - struct plugin *p = (struct plugin *) vlist_at(&plugins, i); - - if (p->type == type) - printf(" - %-13s: %s\n", p->name, p->description); - } -} diff --git a/src/villas-convert.cpp b/src/villas-convert.cpp index 9515bb4e9..e11334794 100644 --- a/src/villas-convert.cpp +++ b/src/villas-convert.cpp @@ -32,8 +32,9 @@ #include #include #include -#include #include +#include +#include using namespace villas; diff --git a/src/villas-hook.cpp b/src/villas-hook.cpp index a376d1bfb..4311d52c5 100644 --- a/src/villas-hook.cpp +++ b/src/villas-hook.cpp @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include diff --git a/src/villas-node.cpp b/src/villas-node.cpp index 376f0bdd6..07259426e 100644 --- a/src/villas-node.cpp +++ b/src/villas-node.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -44,7 +45,6 @@ #include #include #include -#include #include #include @@ -102,26 +102,27 @@ protected: << " See in the RT-LAB User Guide for more information." << std::endl << std::endl #endif /* WITH_NODE_OPAL */ - << "Supported node-types:" << std::endl; - plugin_dump(PluginType::NODE); + << "Supported node-types:" << std::endl; + for (auto *vt : *node_types) + std::cout << " - " << std::left << std::setw(18) << node_type_name(vt) << vt->description << std::endl; std::cout << std::endl; std::cout << "Supported IO formats:" << std::endl; for (Plugin *p : Registry::lookup()) - std::cout << " - " << p->getName() << ": " << p->getDescription() << std::endl; + std::cout << " - " << std::left << std::setw(18) << p->getName() << p->getDescription() << std::endl; std::cout << std::endl; #ifdef WITH_HOOKS std::cout << "Supported hooks:" << std::endl; for (Plugin *p : Registry::lookup()) - std::cout << " - " << p->getName() << ": " << p->getDescription() << std::endl; + std::cout << " - " << std::left << std::setw(18) << p->getName() << p->getDescription() << std::endl; std::cout << std::endl; #endif /* WITH_HOOKS */ #ifdef WITH_API std::cout << "Supported API commands:" << std::endl; for (Plugin *p : Registry::lookup()) - std::cout << " - " << p->getName() << ": " << p->getDescription() << std::endl; + std::cout << " - " << std::left << std::setw(18) << p->getName() << p->getDescription() << std::endl; std::cout << std::endl; #endif /* WITH_API */ diff --git a/src/villas-signal.cpp b/src/villas-signal.cpp index f729c153a..b698d9f1b 100644 --- a/src/villas-signal.cpp +++ b/src/villas-signal.cpp @@ -40,7 +40,6 @@ #include #include #include -#include #include using namespace villas; diff --git a/tests/unit/format.cpp b/tests/unit/format.cpp index f4529c9b1..d50b001aa 100644 --- a/tests/unit/format.cpp +++ b/tests/unit/format.cpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include