Instantiate objects in the correct namespace

Add an hwmon -> dbus namespace map for sensor objects.

For example, the OpenBMC DBus specification mandates that
temperature sensors be instantiated in the temperature
namespace.  Prior to this patch they were simply instantiated
in the temp namespace ( the hwmon sensor type ).

Change-Id: I29c1982cc6b60e818cbc52458009aa6765c1111f
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/mainloop.cpp b/mainloop.cpp
index 7e579a8..b2ae7ff 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -37,27 +37,33 @@
     std::make_tuple(
         hwmon::type::ctemp,
         ValueInterface::Unit::DegreesC,
-        -3),
+        -3,
+        "temperature"),
     std::make_tuple(
         hwmon::type::cfan,
         ValueInterface::Unit::RPMS,
-        0),
+        0,
+        "fan_tach"),
     std::make_tuple(
         hwmon::type::cvolt,
         ValueInterface::Unit::Volts,
-        -3),
+        -3,
+        "voltage"),
     std::make_tuple(
         hwmon::type::ccurr,
         ValueInterface::Unit::Amperes,
-        -3),
+        -3,
+        "current"),
     std::make_tuple(
         hwmon::type::cenergy,
         ValueInterface::Unit::Joules,
-        -6),
+        -6,
+        "energy"),
     std::make_tuple(
         hwmon::type::cpower,
         ValueInterface::Unit::Watts,
-        -6),
+        -6,
+        "power"),
 };
 
 auto getHwmonType(decltype(typeAttrMap)::const_reference attrs)
@@ -75,6 +81,11 @@
     return std::get<2>(attrs);
 }
 
+auto getNamespace(decltype(typeAttrMap)::const_reference attrs)
+{
+    return std::get<3>(attrs);
+}
+
 using AttributeIterator = decltype(*typeAttrMap.begin());
 using Attributes
     = std::remove_cv<std::remove_reference<AttributeIterator>::type>::type;
@@ -170,9 +181,15 @@
             continue;
         }
 
+        Attributes attrs;
+        if (!getAttributes(i.first.first, attrs))
+        {
+            continue;
+        }
+
         std::string objectPath{_root};
         objectPath.append("/");
-        objectPath.append(i.first.first);
+        objectPath.append(getNamespace(attrs));
         objectPath.append("/");
         objectPath.append(label);