mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
hook: use proper data types for priority and enabled members
This commit is contained in:
parent
0593626967
commit
8fb929c4bf
2 changed files with 17 additions and 8 deletions
|
@ -64,8 +64,8 @@ protected:
|
|||
enum State state;
|
||||
|
||||
int flags;
|
||||
int priority; /**< A priority to change the order of execution within one type of hook. */
|
||||
int enabled; /**< Is this hook active? */
|
||||
unsigned priority; /**< A priority to change the order of execution within one type of hook. */
|
||||
bool enabled; /**< Is this hook active? */
|
||||
|
||||
struct vpath *path;
|
||||
struct vnode *node;
|
||||
|
@ -141,7 +141,7 @@ public:
|
|||
return Reason::OK;
|
||||
};
|
||||
|
||||
int getPriority() const
|
||||
unsigned getPriority() const
|
||||
{
|
||||
return priority;
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ public:
|
|||
virtual Hook * make(struct vpath *p, struct vnode *n) = 0;
|
||||
|
||||
virtual int getFlags() const = 0;
|
||||
virtual int getPriority() const = 0;
|
||||
virtual unsigned getPriority() const = 0;
|
||||
|
||||
virtual
|
||||
std::string
|
||||
|
@ -207,7 +207,7 @@ public:
|
|||
{ return "hook"; }
|
||||
};
|
||||
|
||||
template <typename T, const char *name, const char *desc, int flags = 0, int prio = 99>
|
||||
template <typename T, const char *name, const char *desc, int flags = 0, unsigned prio = 99>
|
||||
class HookPlugin : public HookFactory {
|
||||
|
||||
public:
|
||||
|
@ -234,7 +234,7 @@ public:
|
|||
getFlags() const
|
||||
{ return flags; }
|
||||
|
||||
virtual int
|
||||
virtual unsigned
|
||||
getPriority() const
|
||||
{ return prio; }
|
||||
};
|
||||
|
|
13
lib/hook.cpp
13
lib/hook.cpp
|
@ -86,13 +86,22 @@ void Hook::parse(json_t *json)
|
|||
|
||||
assert(state != State::STARTED);
|
||||
|
||||
int prio;
|
||||
int en;
|
||||
|
||||
ret = json_unpack_ex(json, &err, 0, "{ s?: i, s?: b }",
|
||||
"priority", &priority,
|
||||
"enabled", &enabled
|
||||
"priority", &prio,
|
||||
"enabled", &en
|
||||
);
|
||||
if (ret)
|
||||
throw ConfigError(json, err, "node-config-hook");
|
||||
|
||||
if (prio < 0)
|
||||
throw ConfigError(json, "node-config-hook", "Priority must be equal or larger than zero");
|
||||
|
||||
priority = prio;
|
||||
enabled = en;
|
||||
|
||||
config = json;
|
||||
|
||||
state = State::PARSED;
|
||||
|
|
Loading…
Add table
Reference in a new issue