split Factory class
In the next few patches we are going to split veliad into velia and
velia-hardware. However, the current veliad uses a Factory class which
has two functions, one for velia(-health) and one for velia-hardware.
It is only logical to split this Factory class into two, one for the
health and one for the hardware part.
There is no point in the velia-hardware to depend on stuff from
velia-health and vice versa.
Change-Id: If935c21b5da98cf56713479635d6ae6266c680a7
diff --git a/src/Factory.h b/src/Factory.h
deleted file mode 100644
index 521bc4f..0000000
--- a/src/Factory.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#pragma once
-#include <memory>
-#include "health/State.h"
-#include "health/outputs/SlotWrapper.h"
-
-namespace velia::ietf_hardware {
-class IETFHardware;
-}
-
-namespace velia::ietf_hardware {
-std::shared_ptr<ietf_hardware::IETFHardware> create(const std::string& applianceName);
-}
-
-namespace velia::health {
-boost::signals2::SlotWrapper<void, health::State> createOutput(const std::string& applianceName);
-}
diff --git a/src/health/Factory.cpp b/src/health/Factory.cpp
new file mode 100644
index 0000000..607a985
--- /dev/null
+++ b/src/health/Factory.cpp
@@ -0,0 +1,18 @@
+#include "Factory.h"
+#include "health/outputs/LedSysfsDriver.h"
+#include "health/outputs/SlotWrapper.h"
+#include "health/outputs/callables.h"
+
+namespace velia::health {
+boost::signals2::SlotWrapper<void, health::State> createOutput(const std::string& applianceName)
+{
+ if (applianceName == "czechlight-clearfog") {
+ return boost::signals2::SlotWrapper<void, State>(std::make_shared<LedOutputCallback>(
+ std::make_shared<LedSysfsDriver>("/sys/class/leds/status:red/"),
+ std::make_shared<LedSysfsDriver>("/sys/class/leds/status:green/"),
+ std::make_shared<LedSysfsDriver>("/sys/class/leds/status:blue/")));
+ } else {
+ throw std::runtime_error("Unknown appliance '" + applianceName + "'");
+ }
+}
+}
diff --git a/src/health/Factory.h b/src/health/Factory.h
new file mode 100644
index 0000000..c4207a2
--- /dev/null
+++ b/src/health/Factory.h
@@ -0,0 +1,8 @@
+#pragma once
+#include <memory>
+#include "health/State.h"
+#include "health/outputs/SlotWrapper.h"
+
+namespace velia::health {
+boost::signals2::SlotWrapper<void, health::State> createOutput(const std::string& applianceName);
+}
diff --git a/src/Factory.cpp b/src/ietf-hardware/Factory.cpp
similarity index 79%
rename from src/Factory.cpp
rename to src/ietf-hardware/Factory.cpp
index 408e06d..c214c85 100644
--- a/src/Factory.cpp
+++ b/src/ietf-hardware/Factory.cpp
@@ -1,7 +1,4 @@
#include "Factory.h"
-#include "health/outputs/LedSysfsDriver.h"
-#include "health/outputs/SlotWrapper.h"
-#include "health/outputs/callables.h"
#include "ietf-hardware/IETFHardware.h"
#include "ietf-hardware/sysfs/EMMC.h"
#include "ietf-hardware/sysfs/HWMon.h"
@@ -41,17 +38,3 @@
}
}
-
-namespace velia::health {
-boost::signals2::SlotWrapper<void, health::State> createOutput(const std::string& applianceName)
-{
- if (applianceName == "czechlight-clearfog") {
- return boost::signals2::SlotWrapper<void, State>(std::make_shared<LedOutputCallback>(
- std::make_shared<LedSysfsDriver>("/sys/class/leds/status:red/"),
- std::make_shared<LedSysfsDriver>("/sys/class/leds/status:green/"),
- std::make_shared<LedSysfsDriver>("/sys/class/leds/status:blue/")));
- } else {
- throw std::runtime_error("Unknown appliance '" + applianceName + "'");
- }
-}
-}
diff --git a/src/ietf-hardware/Factory.h b/src/ietf-hardware/Factory.h
new file mode 100644
index 0000000..fcd83f5
--- /dev/null
+++ b/src/ietf-hardware/Factory.h
@@ -0,0 +1,10 @@
+#pragma once
+#include <memory>
+
+namespace velia::ietf_hardware {
+class IETFHardware;
+}
+
+namespace velia::ietf_hardware {
+std::shared_ptr<ietf_hardware::IETFHardware> create(const std::string& applianceName);
+}
diff --git a/src/main.cpp b/src/main.cpp
index cc8f0e6..33316e5 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -4,11 +4,12 @@
#include <spdlog/sinks/ansicolor_sink.h>
#include <spdlog/spdlog.h>
#include <sysrepo-cpp/Session.hpp>
-#include "Factory.h"
#include "VELIA_VERSION.h"
+#include "health/Factory.h"
#include "health/inputs/DbusSystemdInput.h"
#include "health/manager/StateManager.h"
#include "health/outputs/callables.h"
+#include "ietf-hardware/Factory.h"
#include "ietf-hardware/sysrepo/Sysrepo.h"
#include "main.h"
#include "utils/exceptions.h"