1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

nodes: avoid designated initializers for structs

This commit is contained in:
Steffen Vogel 2019-04-23 00:36:06 +02:00
parent b764dbfd7d
commit 932d15fdb7
21 changed files with 512 additions and 352 deletions

View file

@ -105,6 +105,11 @@ static int hook_cmp_priority(const Hook *a, const Hook *b)
return a->getPriority() - b->getPriority();
}
static int hook_is_enabled(const Hook *h)
{
return h->isEnabled() ? 0 : -1;
}
int hook_list_prepare(vlist *hs, vlist *sigs, int m, struct path *p, struct node *n)
{
assert(hs->state == STATE_INITIALIZED);
@ -122,15 +127,15 @@ int hook_list_prepare(vlist *hs, vlist *sigs, int m, struct path *p, struct node
}
skip_add:
/* Remove filters which are not enabled */
vlist_filter(hs, (dtor_cb_t) hook_is_enabled);
/* We sort the hooks according to their priority */
vlist_sort(hs, (cmp_cb_t) hook_cmp_priority);
for (size_t i = 0; i < vlist_length(hs); i++) {
Hook *h = (Hook *) vlist_at(hs, i);
if (!h->isEnabled())
continue;
try {
h->prepare(sigs);
} catch (...) {
@ -145,20 +150,17 @@ skip_add:
int hook_list_process(vlist *hs, sample *smps[], unsigned cnt)
{
unsigned ret, curent, processed = 0;
unsigned ret, current, processed = 0;
if (vlist_length(hs) == 0)
return cnt;
for (curent = 0; curent < cnt; curent++) {
sample *smp = smps[curent];
for (current = 0; current < cnt; current++) {
sample *smp = smps[current];
for (size_t i = 0; i < vlist_length(hs); i++) {
Hook *h = (Hook *) vlist_at(hs, i);
if (!h->isEnabled())
continue;
ret = h->process(smp);
switch (ret) {
case HOOK_ERROR:
@ -187,9 +189,6 @@ int hook_list_periodic(vlist *hs)
for (size_t j = 0; j < vlist_length(hs); j++) {
Hook *h = (Hook *) vlist_at(hs, j);
if (!h->isEnabled())
continue;
try {
h->periodic();
} catch (...) {
@ -205,9 +204,6 @@ int hook_list_start(vlist *hs)
for (size_t i = 0; i < vlist_length(hs); i++) {
Hook *h = (Hook *) vlist_at(hs, i);
if (!h->isEnabled())
continue;
try {
h->start();
} catch (...) {

View file

@ -392,23 +392,36 @@ int amqp_destroy(struct node *n)
return 0;
}
static struct plugin p = {
.name = "amqp",
.description = "Advanced Message Queueing Protoocl (rabbitmq-c)",
.type = PLUGIN_TYPE_NODE,
.node = {
.vectorize = 0,
.size = sizeof(struct amqp),
.destroy = amqp_destroy,
.parse = amqp_parse,
.print = amqp_print,
.start = amqp_start,
.stop = amqp_stop,
.read = amqp_read,
.write = amqp_write,
.poll_fds = amqp_poll_fds
}
};
static struct plugin p;
__attribute__((constructor(110)))
static void register_plugin() {
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "amqp";
p.description = "Advanced Message Queueing Protoocl (rabbitmq-c)";
p.type = PLUGIN_TYPE_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;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
}
__attribute__((destructor(110)))
static void deregister_plugin() {
if (plugins.state != STATE_DESTROYED)
vlist_remove_all(&plugins, &p);
}
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)

View file

@ -986,22 +986,33 @@ int comedi_poll_fds(struct node *n, int fds[])
return 0;
}
static struct plugin p = {
.name = "comedi",
.description = "Comedi-compatible DAQ/ADC cards",
.type = PLUGIN_TYPE_NODE,
.node = {
.vectorize = 0,
.size = sizeof(struct comedi),
.parse = comedi_parse,
.print = comedi_print,
.start = comedi_start,
.stop = comedi_stop,
.read = comedi_read,
.write = comedi_write,
.poll_fds = comedi_poll_fds
}
};
static struct plugin p;
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)
__attribute__((constructor(110)))
static void register_plugin() {
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "comedi";
p.description = "Comedi-compatible DAQ/ADC cards";
p.type = PLUGIN_TYPE_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;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
}
__attribute__((destructor(110)))
static void deregister_plugin() {
if (plugins.state != STATE_DESTROYED)
vlist_remove_all(&plugins, &p);
}

View file

@ -472,23 +472,34 @@ int file_poll_fds(struct node *n, int fds[])
return -1; /** @todo not supported yet */
}
static struct plugin p = {
.name = "file",
.description = "support for file log / replay node type",
.type = PLUGIN_TYPE_NODE,
.node = {
.vectorize = 1,
.size = sizeof(struct file),
.parse = file_parse,
.print = file_print,
.start = file_start,
.restart = file_restart,
.stop = file_stop,
.read = file_read,
.write = file_write,
.poll_fds = file_poll_fds
}
};
static struct plugin p;
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)
__attribute__((constructor(110)))
static void register_plugin() {
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "file";
p.description = "support for file log / replay node type";
p.type = PLUGIN_TYPE_NODE;
p.node.instances.state = STATE_DESTROYED;
p.node.vectorize = 1;
p.node.size = sizeof(struct file);
p.node.parse = file_parse;
p.node.print = file_print;
p.node.start = file_start;
p.node.restart = file_restart;
p.node.stop = file_stop;
p.node.read = file_read;
p.node.write = file_write;
p.node.poll_fds = file_poll_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
}
__attribute__((destructor(110)))
static void deregister_plugin() {
if (plugins.state != STATE_DESTROYED)
vlist_remove_all(&plugins, &p);
}

View file

@ -473,29 +473,38 @@ int iec61850_sv_poll_fds(struct node *n, int fds[])
return 1;
}
static struct plugin p = {
.name = "iec61850-9-2",
.description = "IEC 61850-9-2 (Sampled Values)",
.type = PLUGIN_TYPE_NODE,
.node = {
.vectorize = 0,
.size = sizeof(struct iec61850_sv),
.type = {
.start = iec61850_type_start,
.stop = iec61850_type_stop
},
.destroy = iec61850_sv_destroy,
.parse = iec61850_sv_parse,
.print = iec61850_sv_print,
.start = iec61850_sv_start,
.stop = iec61850_sv_stop,
.read = iec61850_sv_read,
.write = iec61850_sv_write,
.poll_fds = iec61850_sv_poll_fds
}
};
static struct plugin p;
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)
__attribute__((constructor(110)))
static void register_plugin() {
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "iec61850-9-2";
p.description = "IEC 61850-9-2 (Sampled Values)";
p.type = PLUGIN_TYPE_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;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
}
__attribute__((destructor(110)))
static void deregister_plugin() {
if (plugins.state != STATE_DESTROYED)
vlist_remove_all(&plugins, &p);
}
#endif /* CONFIG_IEC61850_SAMPLED_VALUES_SUPPORT */

View file

@ -999,26 +999,37 @@ int ib_write(struct node *n, struct sample *smps[], unsigned cnt, unsigned *rele
return sent;
}
static struct plugin p = {
.name = "infiniband",
.description = "Infiniband interface (libibverbs, librdmacm)",
.type = PLUGIN_TYPE_NODE,
.node = {
.vectorize = 0,
.size = sizeof(struct infiniband),
.pool_size = 8192,
.destroy = ib_destroy,
.parse = ib_parse,
.check = ib_check,
.print = ib_print,
.start = ib_start,
.stop = ib_stop,
.read = ib_read,
.write = ib_write,
.reverse = ib_reverse,
.memory_type = memory_ib
}
};
static struct plugin p;
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)
__attribute__((constructor(110)))
static void register_plugin() {
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "infiniband";
p.description = "Infiniband interface (libibverbs, librdmacm)";
p.type = PLUGIN_TYPE_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;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
}
__attribute__((destructor(110)))
static void deregister_plugin() {
if (plugins.state != STATE_DESTROYED)
vlist_remove_all(&plugins, &p);
}

View file

@ -198,20 +198,32 @@ char * influxdb_print(struct node *n)
return buf;
}
static struct plugin p = {
.name = "influxdb",
.description = "Write results to InfluxDB",
.type = PLUGIN_TYPE_NODE,
.node = {
.vectorize = 0,
.size = sizeof(struct influxdb),
.parse = influxdb_parse,
.print = influxdb_print,
.start = influxdb_open,
.stop = influxdb_close,
.write = influxdb_write,
}
};
static struct plugin p;
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)
__attribute__((constructor(110)))
static void register_plugin() {
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "influxdb";
p.description = "Write results to InfluxDB";
p.type = PLUGIN_TYPE_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;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
}
__attribute__((destructor(110)))
static void deregister_plugin() {
if (plugins.state != STATE_DESTROYED)
vlist_remove_all(&plugins, &p);
}

View file

@ -150,23 +150,34 @@ int loopback_poll_fds(struct node *n, int fds[])
return 1;
}
static struct plugin p = {
.name = "loopback",
.description = "Loopback to connect multiple paths",
.type = PLUGIN_TYPE_NODE,
.node = {
.vectorize = 0,
.flags = NODE_TYPE_PROVIDES_SIGNALS,
.size = sizeof(struct loopback),
.parse = loopback_parse,
.print = loopback_print,
.start = loopback_start,
.stop = loopback_stop,
.read = loopback_read,
.write = loopback_write,
.poll_fds = loopback_poll_fds
}
};
static struct plugin p;
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)
__attribute__((constructor(110)))
static void register_plugin() {
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "loopback";
p.description = "Loopback to connect multiple paths";
p.type = PLUGIN_TYPE_NODE;
p.node.instances.state = STATE_DESTROYED;
p.node.vectorize = 0;
p.node.flags = NODE_TYPE_PROVIDES_SIGNALS;
p.node.size = sizeof(struct loopback);
p.node.parse = loopback_parse;
p.node.print = loopback_print;
p.node.start = loopback_start;
p.node.stop = loopback_stop;
p.node.read = loopback_read;
p.node.write = loopback_write;
p.node.poll_fds = loopback_poll_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
}
__attribute__((destructor(110)))
static void deregister_plugin() {
if (plugins.state != STATE_DESTROYED)
vlist_remove_all(&plugins, &p);
}

View file

@ -447,29 +447,38 @@ int mqtt_poll_fds(struct node *n, int fds[])
return 1;
}
static struct plugin p = {
.name = "mqtt",
.description = "Message Queuing Telemetry Transport (libmosquitto)",
.type = PLUGIN_TYPE_NODE,
.node = {
.vectorize = 0,
.size = sizeof(struct mqtt),
.type ={
.start = mqtt_type_start,
.stop = mqtt_type_stop
},
.destroy = mqtt_destroy,
.parse = mqtt_parse,
.check = mqtt_check,
.print = mqtt_print,
.start = mqtt_start,
.stop = mqtt_stop,
.read = mqtt_read,
.write = mqtt_write,
.reverse = mqtt_reverse,
.poll_fds = mqtt_poll_fds
}
};
static struct plugin p;
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)
__attribute__((constructor(110)))
static void register_plugin() {
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "mqtt";
p.description = "Message Queuing Telemetry Transport (libmosquitto)";
p.type = PLUGIN_TYPE_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.parse = mqtt_parse;
p.node.check = mqtt_check;
p.node.print = mqtt_print;
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;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
}
__attribute__((destructor(110)))
static void deregister_plugin() {
if (plugins.state != STATE_DESTROYED)
vlist_remove_all(&plugins, &p);
}

View file

@ -290,27 +290,36 @@ int nanomsg_netem_fds(struct node *n, int fds[])
return 1;
}
static struct plugin p = {
.name = "nanomsg",
.description = "scalability protocols library (libnanomsg)",
.type = PLUGIN_TYPE_NODE,
.node = {
.vectorize = 0,
.size = sizeof(struct nanomsg),
.type = {
.stop = nanomsg_type_stop
},
.parse = nanomsg_parse,
.print = nanomsg_print,
.start = nanomsg_start,
.stop = nanomsg_stop,
.read = nanomsg_read,
.write = nanomsg_write,
.reverse = nanomsg_reverse,
.poll_fds = nanomsg_poll_fds,
.netem_fds = nanomsg_netem_fds
}
};
static struct plugin p;
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)
__attribute__((constructor(110)))
static void register_plugin() {
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "nanomsg";
p.description = "scalability protocols library (libnanomsg)";
p.type = PLUGIN_TYPE_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;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
}
__attribute__((destructor(110)))
static void deregister_plugin() {
if (plugins.state != STATE_DESTROYED)
vlist_remove_all(&plugins, &p);
}

View file

@ -585,26 +585,35 @@ int ngsi_poll_fds(struct node *n, int fds[])
return 1;
}
static struct plugin p = {
.name = "ngsi",
.description = "OMA Next Generation Services Interface 10 (libcurl, libjansson)",
.type = PLUGIN_TYPE_NODE,
.node = {
.vectorize = 0, /* unlimited */
.size = sizeof(struct ngsi),
.type = {
.start = ngsi_type_start,
.stop = ngsi_type_stop
},
.parse = ngsi_parse,
.print = ngsi_print,
.start = ngsi_start,
.stop = ngsi_stop,
.read = ngsi_read,
.write = ngsi_write,
.poll_fds = ngsi_poll_fds
}
};
static struct plugin p;
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)
__attribute__((constructor(110)))
static void register_plugin() {
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "ngsi";
p.description = "OMA Next Generation Services Interface 10 (libcurl, libjansson)";
p.type = PLUGIN_TYPE_NODE;
p.node.instances.state = STATE_DESTROYED;
p.node.vectorize = 0, /* unlimited */
p.node.size = sizeof(struct ngsi);
p.node.type.start = ngsi_type_start;
p.node.type.stop = ngsi_type_stop;
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;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
}
__attribute__((destructor(110)))
static void deregister_plugin() {
if (plugins.state != STATE_DESTROYED)
vlist_remove_all(&plugins, &p);
}

View file

@ -303,23 +303,34 @@ int opal_write(struct node *n, struct pool *pool, unsigned cnt)
return 1;
}
static struct plugin p = {
.name = "opal",
.description = "run as OPAL Asynchronous Process (libOpalAsyncApi)",
.type = PLUGIN_TYPE_NODE,
.node = {
.vectoroize = 1,
.size = sizeof(struct opal),
.type.start = opal_type_start,
.type.stop = opal_type_stop,
.parse = opal_parse,
.print = opal_print,
.start = opal_start,
.stop = opal_stop,
.read = opal_read,
.write = opal_write
}
};
static struct plugin p;
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)
__attribute__((constructor(110)))
static void register_plugin() {
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "opal";
p.description = "run as OPAL Asynchronous Process (libOpalAsyncApi)";
p.type = PLUGIN_TYPE_NODE;
p.node.instances.state = STATE_DESTROYED;
p.node.vectoroize = 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.stop = opal_stop;
p.node.read = opal_read;
p.node.write = opal_write;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
}
__attribute__((destructor(110)))
static void deregister_plugin() {
if (plugins.state != STATE_DESTROYED)
vlist_remove_all(&plugins, &p);
}

View file

@ -607,14 +607,17 @@ int rtp_netem_fds(struct node *n, int fds[])
__attribute__((constructor(110)))
static void register_plugin() {
p.name = "rtp";
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "rtp";
#ifdef WITH_NETEM
p.description = "real-time transport protocol (libre, libnl3 netem support)";
p.description = "real-time transport protocol (libre, libnl3 netem support)";
#else
p.description = "real-time transport protocol (libre)";
p.description = "real-time transport protocol (libre)";
#endif
p.type = PLUGIN_TYPE_NODE;
p.node.instances.state = STATE_DESTROYED;
p.type = PLUGIN_TYPE_NODE;
p.node.instances.state = STATE_DESTROYED;
p.node.vectorize = 0;
p.node.size = sizeof(struct rtp);
p.node.type.start = rtp_type_start;

View file

@ -195,21 +195,33 @@ char * shmem_print(struct node *n)
return buf;
}
static struct plugin p = {
.name = "shmem",
.description = "POSIX shared memory interface with external processes",
.type = PLUGIN_TYPE_NODE,
.node = {
.vectorize = 0,
.size = sizeof(struct shmem),
.parse = shmem_parse,
.print = shmem_print,
.start = shmem_start,
.stop = shmem_stop,
.read = shmem_read,
.write = shmem_write
}
};
static struct plugin p;
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)
__attribute__((constructor(110)))
static void register_plugin() {
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "shmem";
p.description = "POSIX shared memory interface with external processes";
p.type = PLUGIN_TYPE_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;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
}
__attribute__((destructor(110)))
static void deregister_plugin() {
if (plugins.state != STATE_DESTROYED)
vlist_remove_all(&plugins, &p);
}

View file

@ -300,23 +300,35 @@ int signal_generator_poll_fds(struct node *n, int fds[])
return 1;
}
static struct plugin p = {
.name = "signal",
.description = "Signal generator",
.type = PLUGIN_TYPE_NODE,
.node = {
.vectorize = 1,
.flags = NODE_TYPE_PROVIDES_SIGNALS,
.size = sizeof(struct signal_generator),
.parse = signal_generator_parse,
.prepare = signal_generator_prepare,
.print = signal_generator_print,
.start = signal_generator_start,
.stop = signal_generator_stop,
.read = signal_generator_read,
.poll_fds = signal_generator_poll_fds
}
};
static struct plugin p;
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)
__attribute__((constructor(110)))
static void register_plugin() {
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "signal";
p.description = "Signal generator";
p.type = PLUGIN_TYPE_NODE;
p.node.instances.state = STATE_DESTROYED;
p.node.vectorize = 1;
p.node.flags = NODE_TYPE_PROVIDES_SIGNALS;
p.node.size = sizeof(struct signal_generator);
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;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
}
__attribute__((destructor(110)))
static void deregister_plugin() {
if (plugins.state != STATE_DESTROYED)
vlist_remove_all(&plugins, &p);
}

View file

@ -559,6 +559,9 @@ int socket_fds(struct node *n, int fds[])
__attribute__((constructor(110)))
static void register_plugin() {
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "socket";
#ifdef WITH_NETEM
p.description = "BSD network sockets for Ethernet / IP / UDP (libnl3, netem support)";
@ -566,6 +569,7 @@ static void register_plugin() {
p.description = "BSD network sockets for Ethernet / IP / UDP";
#endif
p.type = PLUGIN_TYPE_NODE;
p.node.instances.state = STATE_DESTROYED;
p.node.vectorize = 0;
p.node.size = sizeof(struct socket);
p.node.type.start = socket_type_start;

View file

@ -20,10 +20,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
/** @addtogroup hooks Hook functions
* @{
*/
#include <string.h>
#include <villas/nodes/stats.hpp>
@ -257,22 +253,25 @@ static struct plugin p;
__attribute__((constructor(110)))
static void register_plugin() {
p.name = "stats";
p.description = "Send statistics to another node";
p.type = PLUGIN_TYPE_NODE;
p.node.instances.state = STATE_DESTROYED;
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "stats";
p.description = "Send statistics to another node";
p.type = PLUGIN_TYPE_NODE;
p.node.instances.state = STATE_DESTROYED;
p.node.vectorize = 1;
p.node.flags = 0;
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.destroy = stats_node_destroy;
p.node.print = stats_node_print;
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.node.poll_fds = stats_node_poll_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
@ -283,5 +282,3 @@ static void deregister_plugin() {
if (plugins.state != STATE_DESTROYED)
vlist_remove_all(&plugins, &p);
}
/** @} */

View file

@ -435,16 +435,19 @@ int test_rtt_poll_fds(struct node *n, int fds[])
__attribute__((constructor(110)))
static void register_plugin() {
p.name = "test_rtt";
p.description = "Test round-trip time with loopback";
p.type = PLUGIN_TYPE_NODE;
p.node.instances.state = STATE_DESTROYED;
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "test_rtt";
p.description = "Test round-trip time with loopback";
p.type = PLUGIN_TYPE_NODE;
p.node.instances.state = STATE_DESTROYED;
p.node.vectorize = 0;
p.node.flags = NODE_TYPE_PROVIDES_SIGNALS;
p.node.size = sizeof(struct test_rtt);
p.node.parse = test_rtt_parse;
p.node.prepare = test_rtt_prepare;
p.node.destroy = test_rtt_destroy;
p.node.prepare = test_rtt_prepare;
p.node.destroy = test_rtt_destroy;
p.node.print = test_rtt_print;
p.node.start = test_rtt_start;
p.node.stop = test_rtt_stop;

View file

@ -634,26 +634,35 @@ int uldaq_read(struct node *n, struct sample *smps[], unsigned cnt, unsigned *re
return cnt;
}
static struct plugin p = {
.name = "uldaq",
.description = "Measurement Computing DAQ devices like UL201 (libuldaq)",
.type = PLUGIN_TYPE_NODE,
.node = {
.vectorize = 0,
.flags = 0,
.size = sizeof(struct uldaq),
.type = {
.start = uldaq_type_start
},
.init = uldaq_init,
.destroy = uldaq_destroy,
.parse = uldaq_parse,
.print = uldaq_print,
.start = uldaq_start,
.stop = uldaq_stop,
.read = uldaq_read
}
};
static struct plugin p;
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)
__attribute__((constructor(110)))
static void register_plugin() {
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "uldaq";
p.description = "Measurement Computing DAQ devices like UL201 (libuldaq)";
p.type = PLUGIN_TYPE_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;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
}
__attribute__((destructor(110)))
static void deregister_plugin() {
if (plugins.state != STATE_DESTROYED)
vlist_remove_all(&plugins, &p);
}

View file

@ -610,12 +610,12 @@ int websocket_poll_fds(struct node *n, int fds[])
}
__attribute__((constructor(110))) static void UNIQUE(__ctor)() {
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "websocket";
p.description = "Send and receive samples of a WebSocket connection (libwebsockets)";
p.type = PLUGIN_TYPE_NODE;
p.name = "websocket";
p.description = "Send and receive samples of a WebSocket connection (libwebsockets)";
p.type = PLUGIN_TYPE_NODE;
p.node.vectorize = 0; /* unlimited */
p.node.size = sizeof(struct websocket);
p.node.instances.state = STATE_DESTROYED;
@ -630,7 +630,6 @@ __attribute__((constructor(110))) static void UNIQUE(__ctor)() {
p.node.poll_fds = websocket_poll_fds;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
}

View file

@ -564,29 +564,38 @@ int zeromq_netem_fds(struct node *n, int fds[])
return 1;
}
static struct plugin p = {
.name = "zeromq",
.description = "ZeroMQ Distributed Messaging (libzmq)",
.type = PLUGIN_TYPE_NODE,
.node = {
.vectorize = 0,
.size = sizeof(struct zeromq),
.type = {
.start = zeromq_type_start,
.stop = zeromq_type_stop,
},
.destroy = zeromq_destroy,
.parse = zeromq_parse,
.print = zeromq_print,
.start = zeromq_start,
.stop = zeromq_stop,
.read = zeromq_read,
.write = zeromq_write,
.reverse = zeromq_reverse,
.poll_fds = zeromq_poll_fds,
.netem_fds = zeromq_netem_fds,
}
};
static struct plugin p;
REGISTER_PLUGIN(&p)
LIST_INIT_STATIC(&p.node.instances)
__attribute__((constructor(110)))
static void register_plugin() {
if (plugins.state == STATE_DESTROYED)
vlist_init(&plugins);
p.name = "zeromq";
p.description = "ZeroMQ Distributed Messaging (libzmq)";
p.type = PLUGIN_TYPE_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.destroy = zeromq_destroy;
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;
vlist_init(&p.node.instances);
vlist_push(&plugins, &p);
}
__attribute__((destructor(110)))
static void deregister_plugin() {
if (plugins.state != STATE_DESTROYED)
vlist_remove_all(&plugins, &p);
}