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

hook: add Hook::isReadOnly()

This commit is contained in:
Steffen Vogel 2021-06-18 21:00:10 -04:00
parent c49ee5b21c
commit d9859fe20c
10 changed files with 20 additions and 13 deletions

View file

@ -45,10 +45,12 @@ class Hook {
public:
enum class Flags {
BUILTIN = (1 << 0), /**< Should we add this hook by default to every path?. */
PATH = (1 << 1), /**< This hook type is used by paths. */
NODE_READ = (1 << 2), /**< This hook type is used by nodes. */
NODE_WRITE = (1 << 3) /**< This hook type is used by nodes. */
BUILTIN = (1 << 0), /**< Should we add this hook by default to every path?. */
READ_ONLY = (1 << 1), /**< The does not modify the sample contents */
PATH = (1 << 8), /**< This hook type is used by paths. */
NODE_READ = (1 << 9), /**< This hook type is used by nodes. */
NODE_WRITE = (1 << 10) /**< This hook type is used by nodes. */
};
enum class Reason {
@ -164,6 +166,11 @@ public:
{
return enabled;
}
bool isReadOnly() const
{
return flags & HookFlags::READ_ONLY;
}
};
class LimitHook : public Hook {

View file

@ -69,7 +69,7 @@ Hook::Reason DecimateHook::process(sample *smp)
/* Register hook */
static char n[] = "decimate";
static char d[] = "Downsamping by integer factor";
static HookPlugin<DecimateHook, n, d, (int) Hook::Flags::NODE_READ | (int) Hook::Flags::NODE_WRITE | (int) Hook::Flags::PATH> p;
static HookPlugin<DecimateHook, n, d, (int) Hook::Flags::READ_ONLY | (int) Hook::Flags::NODE_READ | (int) Hook::Flags::NODE_WRITE | (int) Hook::Flags::PATH> p;
} /* namespace node */
} /* namespace villas */

View file

@ -98,7 +98,7 @@ public:
/* Register hook */
static char n[] = "drop";
static char d[] = "Drop messages with reordered sequence numbers";
static HookPlugin<DropHook, n, d, (int) Hook::Flags::BUILTIN | (int) Hook::Flags::NODE_READ, 3> p;
static HookPlugin<DropHook, n, d, (int) Hook::Flags::READ_ONLY | (int) Hook::Flags::BUILTIN | (int) Hook::Flags::NODE_READ, 3> p;
} /* namespace node */
} /* namespace villas */

View file

@ -50,7 +50,7 @@ public:
/* Register hook */
static char n[] = "dump";
static char d[] = "Dump data to stdout";
static HookPlugin<DumpHook, n, d, (int) Hook::Flags::NODE_READ | (int) Hook::Flags::NODE_WRITE | (int) Hook::Flags::PATH, 1> p;
static HookPlugin<DumpHook, n, d, (int) Hook::Flags::READ_ONLY | (int) Hook::Flags::NODE_READ | (int) Hook::Flags::NODE_WRITE | (int) Hook::Flags::PATH, 1> p;
} /* namespace node */
} /* namespace villas */

View file

@ -200,7 +200,7 @@ public:
/* Register hook */
static char n[] = "gate";
static char d[] = "Skip samples only if an enable signal is under a specified threshold";
static HookPlugin<GateHook, n, d, (int) Hook::Flags::NODE_READ | (int) Hook::Flags::PATH> p;
static HookPlugin<GateHook, n, d, (int) Hook::Flags::READ_ONLY | (int) Hook::Flags::NODE_READ | (int) Hook::Flags::PATH> p;
} /* namespace node */
} /* namespace villas */

View file

@ -114,7 +114,7 @@ public:
/* Register hook */
static char n[] = "jitter_calc";
static char d[] = "Calc jitter, mean and variance of GPS vs NTP TS";
static HookPlugin<JitterCalcHook, n, d, (int) Hook::Flags::NODE_READ | (int) Hook::Flags::PATH, 0> p;
static HookPlugin<JitterCalcHook, n, d, (int) Hook::Flags::READ_ONLY | (int) Hook::Flags::NODE_READ | (int) Hook::Flags::PATH, 0> p;
} /* namespace node */
} /* namespace villas */

View file

@ -98,7 +98,7 @@ Hook::Reason LimitRateHook::process(sample *smp)
/* Register hook */
static char n[] = "limit_rate";
static char d[] = "Limit sending rate";
static HookPlugin<LimitRateHook, n, d, (int) Hook::Flags::NODE_READ | (int) Hook::Flags::NODE_WRITE | (int) Hook::Flags::PATH> p;
static HookPlugin<LimitRateHook, n, d, (int) Hook::Flags::READ_ONLY | (int) Hook::Flags::NODE_READ | (int) Hook::Flags::NODE_WRITE | (int) Hook::Flags::PATH> p;
} /* namespace node */
} /* namespace villas */

View file

@ -138,7 +138,7 @@ public:
/* Register hook */
static char n[] = "print";
static char d[] = "Print the message to stdout";
static HookPlugin<PrintHook, n, d, (int) Hook::Flags::NODE_READ | (int) Hook::Flags::NODE_WRITE | (int) Hook::Flags::PATH> p;
static HookPlugin<PrintHook, n, d, (int) Hook::Flags::READ_ONLY | (int) Hook::Flags::NODE_READ | (int) Hook::Flags::NODE_WRITE | (int) Hook::Flags::PATH> p;
} /* namespace node */
} /* namespace villas */

View file

@ -143,7 +143,7 @@ public:
/* Register hook */
static char n[] = "skip_first";
static char d[] = "Skip the first samples";
static HookPlugin<SkipFirstHook, n, d, (int) Hook::Flags::NODE_READ | (int) Hook::Flags::NODE_WRITE | (int) Hook::Flags::PATH> p;
static HookPlugin<SkipFirstHook, n, d, (int) Hook::Flags::READ_ONLY | (int) Hook::Flags::NODE_READ | (int) Hook::Flags::NODE_WRITE | (int) Hook::Flags::PATH> p;
} /* namespace node */
} /* namespace villas */

View file

@ -279,7 +279,7 @@ Hook::Reason StatsReadHook::process(sample *smp)
/* Register hook */
static char n[] = "stats";
static char d[] = "Collect statistics for the current node";
static HookPlugin<StatsHook, n, d, (int) Hook::Flags::NODE_READ> p;
static HookPlugin<StatsHook, n, d, (int) Hook::Flags::READ_ONLY | (int) Hook::Flags::NODE_READ> p;
} /* namespace node */
} /* namespace villas */