pid: add helper methods for thermal controller types
Add helper methods for thermal controller types, such as checking if a
string is a supported thermal type and which type that string
corresponds to.
Change-Id: I3c782f5825e7726f264dd186df583bde0a0dc861
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/pid/thermalcontroller.cpp b/pid/thermalcontroller.cpp
index ff2c7bc..d794525 100644
--- a/pid/thermalcontroller.cpp
+++ b/pid/thermalcontroller.cpp
@@ -20,6 +20,20 @@
#include "util.hpp"
#include "zone.hpp"
+#include <algorithm>
+
+ThermalType getThermalType(const std::string& typeString)
+{
+ /* Currently it only supports the two types. */
+ return (typeString == "temp") ? ThermalType::absolute : ThermalType::margin;
+}
+
+bool isThermalType(const std::string& typeString)
+{
+ static const std::vector<std::string> thermalTypes = {"temp", "margin"};
+ return std::count(thermalTypes.begin(), thermalTypes.end(), typeString);
+}
+
std::unique_ptr<PIDController> ThermalController::createThermalPid(
ZoneInterface* owner, const std::string& id,
const std::vector<std::string>& inputs, double setpoint,