Function to setup fan inventory object map

The getObjectMap() function constructs the object map needed by
inventory manager for the object path, interface, and properties of a
fan.

Change-Id: I8cce5cd611d3a0f7a2079b81f280b261aee486e2
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/fan_enclosure.cpp b/fan_enclosure.cpp
index b02d6e1..5461b08 100644
--- a/fan_enclosure.cpp
+++ b/fan_enclosure.cpp
@@ -9,6 +9,25 @@
 namespace presence
 {
 
+FanEnclosure::ObjectMap FanEnclosure::getObjectMap()
+{
+    ObjectMap invObj;
+    InterfaceMap invIntf;
+    PropertyMap invProp;
+    auto presPred = [](auto const& s) {return s->isPresent();};
+    // Determine if all sensors show fan is not present
+    auto isPresent = std::any_of(sensors.begin(),
+                                 sensors.end(),
+                                 presPred);
+    invProp.emplace("Present", isPresent);
+    invProp.emplace("PrettyName", fanDesc);
+    invIntf.emplace("xyz.openbmc_project.Inventory.Item", std::move(invProp));
+    Object fanInvPath = invPath;
+    invObj.emplace(std::move(fanInvPath), std::move(invIntf));
+
+    return invObj;
+}
+
 void FanEnclosure::addInventory()
 {
     //TODO Add this fan to inventory
@@ -16,15 +35,9 @@
 
 void FanEnclosure::updInventory()
 {
-    auto presPred = [](auto const& s) {return s->isPresent();};
-    // Determine if all sensors show fan is not present
-    auto isPresent = std::any_of(FanEnclosure::sensors.begin(),
-                                 FanEnclosure::sensors.end(),
-                                 presPred);
-    if (!isPresent)
-    {
-        //TODO Update inventory for this fan
-    }
+    //Get inventory object for this fan
+    ObjectMap invObj = getObjectMap();
+    //TODO Update inventory for this fan
 }
 
 void FanEnclosure::addSensor(
diff --git a/fan_enclosure.hpp b/fan_enclosure.hpp
index 5c6a040..3876cea 100644
--- a/fan_enclosure.hpp
+++ b/fan_enclosure.hpp
@@ -14,6 +14,17 @@
 
 class FanEnclosure
 {
+    using Property = std::string;
+    using Value = sdbusplus::message::variant<bool, int64_t, std::string>;
+    // Association between property and its value
+    using PropertyMap = std::map<Property, Value>;
+    using Interface = std::string;
+    // Association between interface and the dbus property
+    using InterfaceMap = std::map<Interface, PropertyMap>;
+    using Object = sdbusplus::message::object_path;
+    // Association between object and the interface
+    using ObjectMap = std::map<Object, InterfaceMap>;
+
     public:
         FanEnclosure() = delete;
         FanEnclosure(const FanEnclosure&) = delete;
@@ -43,6 +54,7 @@
         std::vector<std::unique_ptr<Sensor>> sensors;
 
         void addInventory();
+        ObjectMap getObjectMap();
 
 };