pid: zone split out builders
To enable unit-testing, split the builders into their own
object files.
Tested: Ran on quanta-q71l board and it behaved as expected.
Change-Id: I92168ec9ae4946d12328e9c0b94a36bb89d0f718
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/main.cpp b/main.cpp
index a5758fe..fa94dd6 100644
--- a/main.cpp
+++ b/main.cpp
@@ -22,6 +22,7 @@
#include <memory>
#include <mutex> /* not yet used. */
#include <thread>
+#include <unordered_map>
#include <vector>
#include <sdbusplus/bus.hpp>
@@ -34,6 +35,8 @@
/* Controllers & Sensors. */
#include "interfaces.hpp"
+#include "pid/builder.hpp"
+#include "pid/builderconfig.hpp"
#include "pid/zone.hpp"
#include "sensors/builder.hpp"
#include "sensors/builderconfig.hpp"
@@ -86,7 +89,7 @@
auto ModeControlBus = sdbusplus::bus::new_default();
SensorManager mgmr;
- std::map<int64_t, std::shared_ptr<PIDZone>> zones;
+ std::unordered_map<int64_t, std::unique_ptr<PIDZone>> zones;
// Create a manager for the ModeBus because we own it.
static constexpr auto modeRoot = "/xyz/openbmc_project/settings/fanctrl";
@@ -167,7 +170,7 @@
for (auto& i : zones)
{
std::cerr << "pushing zone" << std::endl;
- zoneThreads.push_back(std::thread(PIDControlThread, i.second));
+ zoneThreads.push_back(std::thread(PIDControlThread, i.second.get()));
}
l.join();