diff --git a/include/villas/hook.hpp b/include/villas/hook.hpp index 6b60ebf27..59f688e5c 100644 --- a/include/villas/hook.hpp +++ b/include/villas/hook.hpp @@ -169,7 +169,7 @@ public: bool isReadOnly() const { - return flags & HookFlags::READ_ONLY; + return flags & (int) Flags::READ_ONLY; } }; diff --git a/include/villas/hook_list.hpp b/include/villas/hook_list.hpp index 89a718238..178d04773 100644 --- a/include/villas/hook_list.hpp +++ b/include/villas/hook_list.hpp @@ -76,3 +76,5 @@ void hook_list_stop(struct vlist *hs); struct vlist * hook_list_get_signals(struct vlist *hs); json_t * hook_list_to_json(struct vlist *hs); + +bool hook_list_is_read_only(struct vlist *hs); diff --git a/include/villas/node_direction.h b/include/villas/node_direction.h index 109b96081..303a1938a 100644 --- a/include/villas/node_direction.h +++ b/include/villas/node_direction.h @@ -53,8 +53,10 @@ struct vnode_direction { */ struct vpath *path; - int enabled; - int builtin; /**< This node should use built-in hooks by default. */ + bool enabled; /**< This node direction is enabled. */ + bool builtin_hooks; /**< This node direction should use built-in hooks by default. */ + bool read_only_hooks; /**< The hooks of this node direction do not alter samples while processing them. */ + unsigned vectorize; /**< Number of messages to send / recv at once (scatter / gather) */ struct vlist hooks; /**< List of read / write hooks (struct hook). */ diff --git a/lib/hook_list.cpp b/lib/hook_list.cpp index db6824982..93dfe4604 100644 --- a/lib/hook_list.cpp +++ b/lib/hook_list.cpp @@ -105,25 +105,24 @@ void hook_list_prepare(struct vlist *hs, vlist *sigs, int m, struct vpath *p, st { assert(hs->state == State::INITIALIZED); - if (!m) - goto skip_add; - /* Add internal hooks if they are not already in the list */ - for (auto f : plugin::Registry::lookup()) { - if ((f->getFlags() & m) == m) { - auto h = f->make(p, n); + if (m) { + for (auto f : plugin::Registry::lookup()) { + if ((f->getFlags() & m) == m) { + auto h = f->make(p, n); - vlist_push(hs, h); + vlist_push(hs, h); + } } } -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); + /* Prepare signal list by passing is through all hooks */ for (size_t i = 0; i < vlist_length(hs); i++) { Hook *h = (Hook *) vlist_at(hs, i); @@ -222,3 +221,16 @@ json_t * hook_list_to_json(struct vlist *hs) return json_hooks; } + +bool hook_list_is_read_only(struct vlist *hs) +{ + bool ret = true; + + for (size_t i = 0; i < vlist_length(hs); i++) { + Hook *h = (Hook *) vlist_at_safe(hs, i); + + ret &= h->isReadOnly(); + } + + return ret; +}