host-bmc: Implement Connector interface

Adding support to host Connector dbus interface.  Based on the PDRs
received from remote PLDM terminus, PLDM hosts the dbus interface based
on the entity type.  The Connector 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/Connector.interface.yaml

Change-Id: Iefad8287e4cb2221b14f28219473285b89098975
Signed-off-by: Archana Kakani <archana.kakani@ibm.com>
diff --git a/host-bmc/dbus/connector.hpp b/host-bmc/dbus/connector.hpp
new file mode 100644
index 0000000..cb0128e
--- /dev/null
+++ b/host-bmc/dbus/connector.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/Connector/server.hpp>
+
+#include <string>
+
+namespace pldm
+{
+namespace dbus
+{
+using ItemConnector = sdbusplus::server::object_t<
+    sdbusplus::xyz::openbmc_project::Inventory::Item::server::Connector>;
+
+class Connector : public ItemConnector
+{
+  public:
+    Connector() = delete;
+    ~Connector() = default;
+    Connector(const Connector&) = delete;
+    Connector& operator=(const Connector&) = delete;
+    Connector(Connector&&) = delete;
+    Connector& operator=(Connector&&) = delete;
+
+    Connector(sdbusplus::bus_t& bus, const std::string& objPath) :
+        ItemConnector(bus, objPath.c_str()), path(objPath)
+    {}
+
+  private:
+    std::string path;
+};
+
+} // namespace dbus
+} // namespace pldm
diff --git a/host-bmc/dbus/custom_dbus.cpp b/host-bmc/dbus/custom_dbus.cpp
index f4581d8..54dd076 100644
--- a/host-bmc/dbus/custom_dbus.cpp
+++ b/host-bmc/dbus/custom_dbus.cpp
@@ -147,6 +147,16 @@
     }
 }
 
+void CustomDBus::implementConnecterInterface(const std::string& path)
+{
+    if (!connector.contains(path))
+    {
+        connector.emplace(
+            path, std::make_unique<Connector>(
+                      pldm::utils::DBusHandler::getBus(), path.c_str()));
+    }
+}
+
 void CustomDBus::implementChassisInterface(const std::string& path)
 {
     if (!chassis.contains(path))
diff --git a/host-bmc/dbus/custom_dbus.hpp b/host-bmc/dbus/custom_dbus.hpp
index 281f928..2d4ac6b 100644
--- a/host-bmc/dbus/custom_dbus.hpp
+++ b/host-bmc/dbus/custom_dbus.hpp
@@ -5,6 +5,7 @@
 #include "cable.hpp"
 #include "chassis.hpp"
 #include "common/utils.hpp"
+#include "connector.hpp"
 #include "cpu_core.hpp"
 #include "fan.hpp"
 #include "motherboard.hpp"
@@ -159,6 +160,13 @@
      */
     void implementPowerSupplyInterface(const std::string& path);
 
+    /** @brief Implement Connector Interface
+     *
+     *  @param[in] path - The object path
+     *
+     */
+    void implementConnecterInterface(const std::string& path);
+
     /** @brief Implement Asset Interface
      *
      *  @param[in] path - The object path
@@ -187,6 +195,7 @@
     std::unordered_map<ObjectPath, std::unique_ptr<Cable>> cable;
     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;
 };
 
 } // namespace dbus
diff --git a/host-bmc/host_pdr_handler.cpp b/host-bmc/host_pdr_handler.cpp
index 524c55b..cf2652f 100644
--- a/host-bmc/host_pdr_handler.cpp
+++ b/host-bmc/host_pdr_handler.cpp
@@ -1168,6 +1168,10 @@
                 CustomDBus::getCustomDBus().implementPCIeSlotInterface(
                     entity.first);
                 break;
+            case PLDM_ENTITY_CONNECTOR:
+                CustomDBus::getCustomDBus().implementConnecterInterface(
+                    entity.first);
+                break;
             case PLDM_ENTITY_CARD:
                 CustomDBus::getCustomDBus().implementPCIeDeviceInterface(
                     entity.first);