mainloop cleanup: moved getAttrs to hwmon namespace
Moved the code that maps a sensor type to its dbus and
hwmon components from mainloop to the hwmon namespace.
Change-Id: I7963951c9484c02d17a3eb415906859609e0efd3
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/hwmon.cpp b/hwmon.cpp
new file mode 100644
index 0000000..4eb47ae
--- /dev/null
+++ b/hwmon.cpp
@@ -0,0 +1,26 @@
+#include "hwmon.hpp"
+
+namespace hwmon {
+
+bool getAttributes(const std::string& type, Attributes& attributes)
+{
+ // *INDENT-OFF*
+ auto a = std::find_if(
+ typeAttrMap.begin(),
+ typeAttrMap.end(),
+ [&](const auto & e)
+ {
+ return type == getHwmonType(e);
+ });
+ // *INDENT-ON*
+
+ if (a == typeAttrMap.end())
+ {
+ return false;
+ }
+
+ attributes = *a;
+ return true;
+}
+
+} // namespace hwmon