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

made vtable pointer private (renamed from node::vt to node::_vt)

This commit is contained in:
Steffen Vogel 2015-10-12 18:47:52 +02:00
parent 4dc0db5163
commit 405af5d0e2
6 changed files with 24 additions and 26 deletions

View file

@ -27,14 +27,14 @@
#include "list.h"
/* Helper macros for virtual node type */
#define node_type(n) ((n)->vt->type)
#define node_print(n) ((n)->vt->print(n))
#define node_type(n) ((n)->_vt->type)
#define node_print(n) ((n)->_vt->print(n))
#define node_read(n, p, ps, f, c) ((n)->vt->read(n, p, ps, f, c))
#define node_write(n, p, ps, f, c) ((n)->vt->write(n, p, ps, f, c))
#define node_read(n, p, ps, f, c) ((n)->_vt->read(n, p, ps, f, c))
#define node_write(n, p, ps, f, c) ((n)->_vt->write(n, p, ps, f, c))
#define node_read_single(n, m) ((n)->vt->read(n, m, 1, 0, 1))
#define node_write_single(n, m) ((n)->vt->write(n, m, 1, 0, 1))
#define node_read_single(n, m) ((n)->_vt->read(n, m, 1, 0, 1))
#define node_write_single(n, m) ((n)->_vt->write(n, m, 1, 0, 1))
#define REGISTER_NODE_TYPE(type, name, fnc) \
@ -49,9 +49,7 @@ __attribute__((constructor)) void __register_node_ ## fnc () { \
extern struct list node_types;
/** C++ like vtable construct for node_types
* @todo Add comments
*/
/** C++ like vtable construct for node_types */
struct node_type {
/** The unique name of this node. This must be allways the first member! */
char *name;
@ -166,7 +164,7 @@ struct node
int combine; /**< Number of messages to send / recv at once (scatter / gather) */
int affinity; /**< CPU Affinity of this node */
struct node_type *vt; /**< C++ like virtual function call table */
struct node_type *_vt; /**< C++ like virtual function call table */
union {
struct socket *socket;
@ -174,7 +172,7 @@ struct node
struct gtfpga *gtfpga;
struct file *file;
struct ngsi *ngsi;
}; /** Virtual data (used by vtable functions) */
}; /** Virtual data (used by struct node::_vt functions) */
config_setting_t *cfg; /**< A pointer to the libconfig object which instantiated this node */
};

View file

@ -150,11 +150,11 @@ int config_parse_path(config_setting_t *cfg,
if (enabled) {
p->in->refcnt++;
p->in->vt->refcnt++;
p->in->_vt->refcnt++;
list_foreach(struct node *node, &p->destinations) {
node->refcnt++;
node->vt->refcnt++;
node->_vt->refcnt++;
}
list_push(paths, p);
@ -173,9 +173,9 @@ int config_parse_path(config_setting_t *cfg,
/* Increment reference counters */
r->in->refcnt++;
r->in->vt->refcnt++;
r->in->_vt->refcnt++;
r->out->refcnt++;
r->out->vt->refcnt++;
r->out->_vt->refcnt++;
if (cfg_hook)
config_parse_hooklist(cfg_hook, &r->hooks);
@ -265,11 +265,11 @@ int config_parse_node(config_setting_t *cfg, struct list *nodes, struct settings
if (!config_setting_lookup_int(cfg, "affinity", &n->combine))
n->affinity = set->affinity;
n->vt = list_lookup(&node_types, type);
if (!n->vt)
n->_vt = list_lookup(&node_types, type);
if (!n->_vt)
cerror(cfg, "Invalid type for node '%s'", n->name);
ret = n->vt->parse(cfg, n);
ret = n->_vt->parse(cfg, n);
if (!ret)
list_push(nodes, n);

View file

@ -66,11 +66,11 @@ int node_start(struct node *n)
}
char *buf = node_print(n);
debug(1, "Starting node '%s' of type '%s' (%s)", n->name, n->vt->name, buf);
debug(1, "Starting node '%s' of type '%s' (%s)", n->name, n->_vt->name, buf);
free(buf);
{ INDENT
return n->vt->open(n);
return n->_vt->open(n);
}
}
@ -80,7 +80,7 @@ int node_stop(struct node *n)
info("Stopping node '%s'", n->name);
{ INDENT
ret = n->vt->close(n);
ret = n->_vt->close(n);
}
return ret;
@ -88,7 +88,7 @@ int node_stop(struct node *n)
void node_reverse(struct node *n)
{
switch (n->vt->type) {
switch (n->_vt->type) {
#ifdef ENABLE_SOCKET
case BSD_SOCKET:
SWAP(n->socket->remote, n->socket->local);
@ -108,7 +108,7 @@ struct node * node_create()
void node_destroy(struct node *n)
{
switch (n->vt->type) {
switch (n->_vt->type) {
#ifdef ENABLE_NGSI
case NGSI:
json_decref(n->ngsi->context);

View file

@ -102,7 +102,7 @@ int main(int argc, char *argv[])
node_reverse(node);
node->refcnt++;
node->vt->refcnt++;
node->_vt->refcnt++;
node_init(argc-optind, argv+optind, &set);
node_start(node);

View file

@ -102,7 +102,7 @@ int main(int argc, char *argv[])
node_reverse(node);
node->refcnt++;
node->vt->refcnt++;
node->_vt->refcnt++;
info("Initialize node types");
node_init(argc-optind, argv+optind, &set);

View file

@ -97,7 +97,7 @@ int main(int argc, char *argv[])
error("There's no node with the name '%s'", argv[3]);
node->refcnt++;
node->vt->refcnt++;
node->_vt->refcnt++;
node_init(argc-3, argv+3, &settings);
node_start(node);