diff options
Diffstat (limited to 'mmss/context.hpp')
-rw-r--r-- | mmss/context.hpp | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/mmss/context.hpp b/mmss/context.hpp index db0c283..60fa4c3 100644 --- a/mmss/context.hpp +++ b/mmss/context.hpp @@ -27,6 +27,7 @@ #pragma once #include "event.hpp" +#include "monitor.hpp" #include "queue.hpp" #include <cstdarg> @@ -39,6 +40,7 @@ namespace MMSS { class context_t : public now_t, public nocopy_t { private: timeout_queue_t<event_t> event_queue; + std::list<std::shared_ptr<monitor_t>> monitors; public: context_t() : event_queue(this) {} @@ -47,7 +49,40 @@ public: event_queue.put(std::move(data), timeout); } - void vlogf_orig(const node_t *orig, int priority, const char *format, std::va_list ap); + void attach_monitor(std::shared_ptr<monitor_t> &&monitor) { + monitors.emplace_back(std::move(monitor)); + } + + void node_log(node_t *node, int priority, const std::string &message) { + for (auto monitor : monitors) + monitor->handle_log(node, priority, message); + } + + void node_init(node_t *node, const uint8_t *node_id, size_t len) { + for (auto monitor : monitors) + monitor->handle_init(node, node_id, len); + } + + void node_neigh(node_t *node, gmrf_iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost) { + for (auto monitor : monitors) + monitor->handle_neigh(node, iface, addr, rxcost, txcost); + } + + void node_neigh_lost(node_t *node, gmrf_iface_t *iface, const gmrf_addr_t *addr) { + for (auto monitor : monitors) + monitor->handle_neigh_lost(node, iface, addr); + } + + void node_route(node_t *node, const uint8_t *node_id, size_t len, gmrf_iface_t *iface, const gmrf_addr_t *addr, int metric) { + for (auto monitor : monitors) + monitor->handle_route(node, node_id, len, iface, addr, metric); + } + + void node_route_lost(node_t *node, const uint8_t *node_id, size_t len) { + for (auto monitor : monitors) + monitor->handle_route_lost(node, node_id, len); + } + void logf(int priority, const char *format, ...); void run(int argc, char *argv[]); |