Move current implementation into separate namespace
We will be moving ietf-hardware implementation from cla-sysrepo to
velia. Veliad daemon will manage not only the "system health" (the
current implementation) but it will also (in later commits) implement
ietf-hardware (RFC8348) [1] (report HW sensors readout to Sysrepo).
This commit prepares the directory structure (i.e., it moves the current
code into a namespace velia::health.
We will be adding new namespace velia::ietf_hardware throughout the next
few commits which will implement the support for ietf-hardware YANG
model.
[1] https://tools.ietf.org/html/rfc8348#appendix-A
Change-Id: I315c2575c5d50036d27cb0a11f5571ce9d615fe5
diff --git a/src/health/outputs/SlotWrapper.h b/src/health/outputs/SlotWrapper.h
new file mode 100644
index 0000000..1a76e17
--- /dev/null
+++ b/src/health/outputs/SlotWrapper.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2020 CESNET, https://photonics.cesnet.cz/
+ *
+ * Written by Tomáš Pecka <tomas.pecka@fit.cvut.cz>
+ *
+*/
+#pragma once
+
+namespace velia::health {
+
+class LedOutputCallback;
+
+namespace boost::signals2 {
+
+/**
+ * Wraps a slot in a copyable class. Ensures that destructor of the Slot is called only once.
+ */
+template <typename Ret, typename... Args>
+class SlotWrapper {
+public:
+ explicit SlotWrapper(std::shared_ptr<LedOutputCallback> callback)
+ : m_callback(callback)
+ {
+ }
+
+ Ret operator()(Args... args)
+ {
+ (*m_callback)(args...);
+ }
+
+private:
+ std::shared_ptr<LedOutputCallback> m_callback;
+};
+
+}
+
+}