host-bmc: Implement Panel interface

Adding support to host Panel dbus interface.  Based on the PDRs received
from remote PLDM terminus, PLDM hosts the dbus interface based on the
entity type.  The Panel interface is defined at [1].

Tested:
   Functional test passed

[1]: https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/Inventory/Item/Panel.interface.yaml

Change-Id: I9e98baa8a0559a6cc38e8557349f4e2369ba6058
Signed-off-by: Archana Kakani <archana.kakani@ibm.com>
diff --git a/host-bmc/dbus/custom_dbus.cpp b/host-bmc/dbus/custom_dbus.cpp
index 7a7e168..14d1541 100644
--- a/host-bmc/dbus/custom_dbus.cpp
+++ b/host-bmc/dbus/custom_dbus.cpp
@@ -223,5 +223,15 @@
     }
 }
 
+void CustomDBus::implementPanelInterface(const std::string& path)
+{
+    if (!panel.contains(path))
+    {
+        panel.emplace(path,
+                      std::make_unique<Panel>(
+                          pldm::utils::DBusHandler::getBus(), path.c_str()));
+    }
+}
+
 } // namespace dbus
 } // namespace pldm
diff --git a/host-bmc/dbus/custom_dbus.hpp b/host-bmc/dbus/custom_dbus.hpp
index e099712..d543e1f 100644
--- a/host-bmc/dbus/custom_dbus.hpp
+++ b/host-bmc/dbus/custom_dbus.hpp
@@ -11,6 +11,7 @@
 #include "fan.hpp"
 #include "inventory_item.hpp"
 #include "motherboard.hpp"
+#include "panel.hpp"
 #include "pcie_device.hpp"
 #include "pcie_slot.hpp"
 #include "power_supply.hpp"
@@ -197,6 +198,13 @@
      */
     void updateItemPresentStatus(const std::string& path, bool isPresent);
 
+    /** @brief Implement Panel Interface
+     *
+     *  @param[in] path - The object path
+     *
+     */
+    void implementPanelInterface(const std::string& path);
+
   private:
     std::unordered_map<ObjectPath, std::unique_ptr<Asset>> asset;
     std::unordered_map<ObjectPath, std::unique_ptr<Availability>>
@@ -215,6 +223,7 @@
     std::unordered_map<ObjectPath, std::unique_ptr<Motherboard>> motherboard;
     std::unordered_map<ObjectPath, std::unique_ptr<Fan>> fan;
     std::unordered_map<ObjectPath, std::unique_ptr<Connector>> connector;
+    std::unordered_map<ObjectPath, std::unique_ptr<Panel>> panel;
 };
 
 } // namespace dbus
diff --git a/host-bmc/dbus/panel.hpp b/host-bmc/dbus/panel.hpp
new file mode 100644
index 0000000..2f91250
--- /dev/null
+++ b/host-bmc/dbus/panel.hpp
@@ -0,0 +1,36 @@
+#pragma once
+
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server.hpp>
+#include <sdbusplus/server/object.hpp>
+#include <xyz/openbmc_project/Inventory/Item/Panel/server.hpp>
+
+#include <string>
+
+namespace pldm
+{
+namespace dbus
+{
+using ItemPanel = sdbusplus::server::object_t<
+    sdbusplus::xyz::openbmc_project::Inventory::Item::server::Panel>;
+
+class Panel : public ItemPanel
+{
+  public:
+    Panel() = delete;
+    ~Panel() = default;
+    Panel(const Panel&) = delete;
+    Panel& operator=(const Panel&) = delete;
+    Panel(Panel&&) = delete;
+    Panel& operator=(Panel&&) = delete;
+
+    Panel(sdbusplus::bus_t& bus, const std::string& objPath) :
+        ItemPanel(bus, objPath.c_str()), path(objPath)
+    {}
+
+  private:
+    std::string path;
+};
+
+} // namespace dbus
+} // namespace pldm
diff --git a/host-bmc/host_pdr_handler.cpp b/host-bmc/host_pdr_handler.cpp
index e83495c..4278025 100644
--- a/host-bmc/host_pdr_handler.cpp
+++ b/host-bmc/host_pdr_handler.cpp
@@ -1171,6 +1171,10 @@
                 CustomDBus::getCustomDBus().implementPowerSupplyInterface(
                     entity.first);
                 break;
+            case PLDM_ENTITY_CHASSIS_FRONT_PANEL_BOARD:
+                CustomDBus::getCustomDBus().implementPanelInterface(
+                    entity.first);
+                break;
             case PLDM_ENTITY_SLOT:
                 CustomDBus::getCustomDBus().implementPCIeSlotInterface(
                     entity.first);