Reduce multiple oem_ibm entry points in pldmd

Abstract the custom method of `OEM-IBM` into the oem-ibm.hpp file
to prevent the continuous increase of custom code and reduce multiple
`OEM-IBM` entry points in pldmd.

Tested: enabled oem-ibm and built pldm successfully.

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ieddb8d12281553e70bdb1c333bd29425c9d14fb0
diff --git a/host-bmc/host_pdr_handler.cpp b/host-bmc/host_pdr_handler.cpp
index 2f65dd6..868e82d 100644
--- a/host-bmc/host_pdr_handler.cpp
+++ b/host-bmc/host_pdr_handler.cpp
@@ -90,13 +90,11 @@
     const std::string& eventsJsonsDir, pldm_entity_association_tree* entityTree,
     pldm_entity_association_tree* bmcEntityTree,
     pldm::InstanceIdDb& instanceIdDb,
-    pldm::requester::Handler<pldm::requester::Request>* handler,
-    pldm::responder::oem_platform::Handler* oemPlatformHandler) :
+    pldm::requester::Handler<pldm::requester::Request>* handler) :
     mctp_fd(mctp_fd),
     mctp_eid(mctp_eid), event(event), repo(repo),
     stateSensorHandler(eventsJsonsDir), entityTree(entityTree),
     bmcEntityTree(bmcEntityTree), instanceIdDb(instanceIdDb), handler(handler),
-    oemPlatformHandler(oemPlatformHandler),
     entityMaps(parseEntityMap(ENTITY_MAP_JSON))
 {
     mergedHostParents = false;
diff --git a/host-bmc/host_pdr_handler.hpp b/host-bmc/host_pdr_handler.hpp
index 0755a25..bc08c2d 100644
--- a/host-bmc/host_pdr_handler.hpp
+++ b/host-bmc/host_pdr_handler.hpp
@@ -95,8 +95,7 @@
         pldm_entity_association_tree* entityTree,
         pldm_entity_association_tree* bmcEntityTree,
         pldm::InstanceIdDb& instanceIdDb,
-        pldm::requester::Handler<pldm::requester::Request>* handler,
-        pldm::responder::oem_platform::Handler* oemPlatformHandler);
+        pldm::requester::Handler<pldm::requester::Request>* handler);
 
     /** @brief fetch PDRs from host firmware. See @class.
      *  @param[in] recordHandles - list of record handles pointing to host's
@@ -171,6 +170,16 @@
      */
     bool isHostUp();
 
+    /* @brief Method to set the oem platform handler in host pdr handler class
+     *
+     * @param[in] handler - oem platform handler
+     */
+    inline void
+        setOemPlatformHandler(pldm::responder::oem_platform::Handler* handler)
+    {
+        oemPlatformHandler = handler;
+    }
+
     /** @brief map that captures various terminus information **/
     TLPDRMap tlPDRInfo;
 
@@ -326,7 +335,7 @@
     std::vector<responder::pdr_utils::FruRecordDataFormat> fruRecordData;
 
     /** @OEM platform handler */
-    pldm::responder::oem_platform::Handler* oemPlatformHandler;
+    pldm::responder::oem_platform::Handler* oemPlatformHandler = nullptr;
 
     /** @brief entityID and entity name is only loaded once
      */
diff --git a/libpldmresponder/base.hpp b/libpldmresponder/base.hpp
index 7ccac27..ad41299 100644
--- a/libpldmresponder/base.hpp
+++ b/libpldmresponder/base.hpp
@@ -20,10 +20,7 @@
 class Handler : public CmdHandler
 {
   public:
-    Handler(sdeventplus::Event& event,
-            pldm::responder::oem_platform::Handler* oemPlatformHandler) :
-        event(event),
-        oemPlatformHandler(oemPlatformHandler)
+    Handler(sdeventplus::Event& event) : event(event)
     {
         handlers.emplace(
             PLDM_GET_PLDM_TYPES,
@@ -87,6 +84,16 @@
      */
     Response getTID(const pldm_msg* request, size_t payloadLength);
 
+    /* @brief Method to set the oem platform handler in base handler class
+     *
+     * @param[in] handler - oem platform handler
+     */
+    inline void
+        setOemPlatformHandler(pldm::responder::oem_platform::Handler* handler)
+    {
+        oemPlatformHandler = handler;
+    }
+
   private:
     /** @brief reference of main event loop of pldmd, primarily used to schedule
      *  work
@@ -94,7 +101,7 @@
     sdeventplus::Event& event;
 
     /** @brief OEM platform handler */
-    pldm::responder::oem_platform::Handler* oemPlatformHandler;
+    pldm::responder::oem_platform::Handler* oemPlatformHandler = nullptr;
 
     /** @brief sdeventplus event source */
     std::unique_ptr<sdeventplus::source::Defer> survEvent;
diff --git a/libpldmresponder/fru.hpp b/libpldmresponder/fru.hpp
index 40a1517..a0757e6 100644
--- a/libpldmresponder/fru.hpp
+++ b/libpldmresponder/fru.hpp
@@ -66,11 +66,9 @@
     FruImpl(const std::string& configPath,
             const std::filesystem::path& fruMasterJsonPath, pldm_pdr* pdrRepo,
             pldm_entity_association_tree* entityTree,
-            pldm_entity_association_tree* bmcEntityTree,
-            pldm::responder::oem_fru::Handler* oemFruHandler) :
+            pldm_entity_association_tree* bmcEntityTree) :
         parser(configPath, fruMasterJsonPath),
-        pdrRepo(pdrRepo), entityTree(entityTree), bmcEntityTree(bmcEntityTree),
-        oemFruHandler(oemFruHandler)
+        pdrRepo(pdrRepo), entityTree(entityTree), bmcEntityTree(bmcEntityTree)
     {}
 
     /** @brief Total length of the FRU table in bytes, this includes the pad
@@ -201,6 +199,15 @@
      */
     int setFRUTable(const std::vector<uint8_t>& fruData);
 
+    /* @brief Method to set the oem platform handler in fru handler class
+     *
+     * @param[in] handler - oem fru handler
+     */
+    inline void setOemFruHandler(pldm::responder::oem_fru::Handler* handler)
+    {
+        oemFruHandler = handler;
+    }
+
   private:
     uint16_t nextRSI()
     {
@@ -224,7 +231,7 @@
     pldm_pdr* pdrRepo;
     pldm_entity_association_tree* entityTree;
     pldm_entity_association_tree* bmcEntityTree;
-    pldm::responder::oem_fru::Handler* oemFruHandler;
+    pldm::responder::oem_fru::Handler* oemFruHandler = nullptr;
     dbus::ObjectValueTree objects;
 
     std::map<dbus::ObjectPath, pldm_entity_node*> objToEntityNode{};
@@ -255,10 +262,8 @@
     Handler(const std::string& configPath,
             const std::filesystem::path& fruMasterJsonPath, pldm_pdr* pdrRepo,
             pldm_entity_association_tree* entityTree,
-            pldm_entity_association_tree* bmcEntityTree,
-            pldm::responder::oem_fru::Handler* oemFruHandler) :
-        impl(configPath, fruMasterJsonPath, pdrRepo, entityTree, bmcEntityTree,
-             oemFruHandler)
+            pldm_entity_association_tree* bmcEntityTree) :
+        impl(configPath, fruMasterJsonPath, pdrRepo, entityTree, bmcEntityTree)
     {
         handlers.emplace(
             PLDM_GET_FRU_RECORD_TABLE_METADATA,
@@ -340,6 +345,15 @@
      */
     Response setFRURecordTable(const pldm_msg* request, size_t payloadLength);
 
+    /* @brief Method to set the oem platform handler in fru handler class
+     *
+     * @param[in] handler - oem fru handler
+     */
+    void setOemFruHandler(pldm::responder::oem_fru::Handler* handler)
+    {
+        impl.setOemFruHandler(handler);
+    }
+
     using Table = std::vector<uint8_t>;
 
   private:
diff --git a/libpldmresponder/platform.hpp b/libpldmresponder/platform.hpp
index 89eca61..b045d84 100644
--- a/libpldmresponder/platform.hpp
+++ b/libpldmresponder/platform.hpp
@@ -54,7 +54,6 @@
             pldm_pdr* repo, HostPDRHandler* hostPDRHandler,
             pldm::state_sensor::DbusToPLDMEvent* dbusToPLDMEventHandler,
             fru::Handler* fruHandler,
-            pldm::responder::oem_platform::Handler* oemPlatformHandler,
             pldm::responder::platform_config::Handler* platformConfigHandler,
             pldm::requester::Handler<pldm::requester::Request>* handler,
             sdeventplus::Event& event, bool buildPDRLazily = false,
@@ -63,10 +62,9 @@
         instanceIdDb(instanceIdDb), pdrRepo(repo),
         hostPDRHandler(hostPDRHandler),
         dbusToPLDMEventHandler(dbusToPLDMEventHandler), fruHandler(fruHandler),
-        dBusIntf(dBusIntf), oemPlatformHandler(oemPlatformHandler),
-        platformConfigHandler(platformConfigHandler), handler(handler),
-        event(event), pdrJsonDir(pdrJsonDir), pdrCreated(false),
-        pdrJsonsDir({pdrJsonDir})
+        dBusIntf(dBusIntf), platformConfigHandler(platformConfigHandler),
+        handler(handler), event(event), pdrJsonDir(pdrJsonDir),
+        pdrCreated(false), pdrJsonsDir({pdrJsonDir})
     {
         if (!buildPDRLazily)
         {
@@ -211,6 +209,16 @@
      */
     EventMap eventHandlers;
 
+    /* @brief Method to set the oem platform handler in platform handler class
+     *
+     * @param[in] handler - oem platform handler
+     */
+    inline void
+        setOemPlatformHandler(pldm::responder::oem_platform::Handler* handler)
+    {
+        oemPlatformHandler = handler;
+    }
+
     /** @brief Handler for GetPDR
      *
      *  @param[in] request - Request message payload
@@ -500,7 +508,7 @@
     pldm::state_sensor::DbusToPLDMEvent* dbusToPLDMEventHandler;
     fru::Handler* fruHandler;
     const pldm::utils::DBusHandler* dBusIntf;
-    pldm::responder::oem_platform::Handler* oemPlatformHandler;
+    pldm::responder::oem_platform::Handler* oemPlatformHandler = nullptr;
     pldm::responder::platform_config::Handler* platformConfigHandler;
     pldm::requester::Handler<pldm::requester::Request>* handler;
     sdeventplus::Event& event;
diff --git a/libpldmresponder/test/libpldmresponder_base_test.cpp b/libpldmresponder/test/libpldmresponder_base_test.cpp
index b1ca89d..0387209 100644
--- a/libpldmresponder/test/libpldmresponder_base_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_base_test.cpp
@@ -28,7 +28,7 @@
     auto request = reinterpret_cast<pldm_msg*>(requestPayload.data());
     // payload length will be 0 in this case
     size_t requestPayloadLength = 0;
-    base::Handler handler(event, nullptr);
+    base::Handler handler(event);
     auto response = handler.getPLDMTypes(request, requestPayloadLength);
     // Need to support OEM type.
     auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
@@ -45,7 +45,7 @@
         requestPayload{};
     auto request = reinterpret_cast<pldm_msg*>(requestPayload.data());
     size_t requestPayloadLength = requestPayload.size() - sizeof(pldm_msg_hdr);
-    base::Handler handler(event, nullptr);
+    base::Handler handler(event);
     auto response = handler.getPLDMCommands(request, requestPayloadLength);
     auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
     uint8_t* payload_ptr = responsePtr->payload;
@@ -62,7 +62,7 @@
 
     request->payload[0] = 0xFF;
     size_t requestPayloadLength = requestPayload.size() - sizeof(pldm_msg_hdr);
-    base::Handler handler(event, nullptr);
+    base::Handler handler(event);
     auto response = handler.getPLDMCommands(request, requestPayloadLength);
     auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
     uint8_t* payload_ptr = responsePtr->payload;
@@ -87,7 +87,7 @@
 
     ASSERT_EQ(0, rc);
 
-    base::Handler handler(event, nullptr);
+    base::Handler handler(event);
     auto response = handler.getPLDMVersion(request, requestPayloadLength);
     auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
 
@@ -118,7 +118,7 @@
 
     ASSERT_EQ(0, rc);
 
-    base::Handler handler(event, nullptr);
+    base::Handler handler(event);
     auto response = handler.getPLDMVersion(request, requestPayloadLength - 1);
     auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
 
@@ -143,7 +143,8 @@
     auto request = reinterpret_cast<pldm_msg*>(requestPayload.data());
     size_t requestPayloadLength = 0;
 
-    base::Handler handler(event, nullptr);
+    base::Handler handler(event);
+    handler.setOemPlatformHandler(nullptr);
     auto response = handler.getTID(request, requestPayloadLength);
 
     auto responsePtr = reinterpret_cast<pldm_msg*>(response.data());
diff --git a/libpldmresponder/test/libpldmresponder_fru_test.cpp b/libpldmresponder/test/libpldmresponder_fru_test.cpp
index 2d7b7ec..d654fca 100644
--- a/libpldmresponder/test/libpldmresponder_fru_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_fru_test.cpp
@@ -117,7 +117,7 @@
 
     pldm::responder::FruImpl mockedFruHandler(
         FRU_JSONS_DIR, "./fru_jsons/fru_master/fru_master.json", pdrRepo.get(),
-        entityTree.get(), bmcEntityTree.get(), nullptr);
+        entityTree.get(), bmcEntityTree.get());
 
     pldm_entity systemEntity{0x2d01, 1, 0};
     pldm_entity chassisEntity{0x2d, 1, 1};
@@ -170,7 +170,7 @@
     InterfaceMap iface = {{"xyz.openbmc_project.Inventory.Item.Chassis", {}}};
     pldm::responder::FruImpl mockedFruHandler(
         FRU_JSONS_DIR, "./fru_jsons/fru_master/fru_master.json", pdrRepo.get(),
-        entityTree.get(), bmcEntityTree.get(), nullptr);
+        entityTree.get(), bmcEntityTree.get());
 
     // Good path
     auto entityPtr = mockedFruHandler.getEntityByObjectPath(iface);
diff --git a/libpldmresponder/test/libpldmresponder_pdr_effecter_test.cpp b/libpldmresponder/test/libpldmresponder_pdr_effecter_test.cpp
index ce34434..6ef74b7 100644
--- a/libpldmresponder/test/libpldmresponder_pdr_effecter_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_pdr_effecter_test.cpp
@@ -32,7 +32,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_effecter/good",
                     inPDRRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_STATE_EFFECTER_PDR);
 
@@ -133,7 +133,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_effecter/good",
                     inPDRRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_NUMERIC_EFFECTER_PDR);
 
@@ -181,7 +181,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_effecter/good",
                     inPDRRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_STATE_EFFECTER_PDR);
 
@@ -204,7 +204,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_effecter/good",
                     inPDRRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     uint16_t entityType = 33;
     uint16_t entityInstance = 0;
     uint16_t containerId = 0;
diff --git a/libpldmresponder/test/libpldmresponder_pdr_sensor_test.cpp b/libpldmresponder/test/libpldmresponder_pdr_sensor_test.cpp
index 92da066..ae1ed3a 100644
--- a/libpldmresponder/test/libpldmresponder_pdr_sensor_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_pdr_sensor_test.cpp
@@ -36,7 +36,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_sensor/good",
                     inPDRRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     handler.getPDR(req, requestPayloadLength);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_STATE_SENSOR_PDR);
@@ -88,7 +88,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_sensor/good",
                     inPDRRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     handler.getPDR(req, requestPayloadLength);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_STATE_SENSOR_PDR);
diff --git a/libpldmresponder/test/libpldmresponder_platform_test.cpp b/libpldmresponder/test/libpldmresponder_platform_test.cpp
index 35da05a..63e26e2 100644
--- a/libpldmresponder/test/libpldmresponder_platform_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_platform_test.cpp
@@ -43,7 +43,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_effecter/good",
                     pdrRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     Repo repo(pdrRepo);
     ASSERT_EQ(repo.empty(), false);
     auto response = handler.getPDR(req, requestPayloadLength);
@@ -82,7 +82,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_effecter/good",
                     pdrRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     Repo repo(pdrRepo);
     ASSERT_EQ(repo.empty(), false);
     auto response = handler.getPDR(req, requestPayloadLength);
@@ -115,7 +115,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_effecter/good",
                     pdrRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     Repo repo(pdrRepo);
     ASSERT_EQ(repo.empty(), false);
     auto response = handler.getPDR(req, requestPayloadLength);
@@ -146,7 +146,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_effecter/good",
                     pdrRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     Repo repo(pdrRepo);
     ASSERT_EQ(repo.empty(), false);
     auto response = handler.getPDR(req, requestPayloadLength);
@@ -179,7 +179,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_effecter/good",
                     pdrRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     Repo repo(pdrRepo);
     ASSERT_EQ(repo.empty(), false);
     auto response = handler.getPDR(req, requestPayloadLength);
@@ -240,7 +240,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_effecter/good",
                     inPDRRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     handler.getPDR(req, requestPayloadLength);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_STATE_EFFECTER_PDR);
@@ -288,7 +288,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_effecter/good",
                     inPDRRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     handler.getPDR(req, requestPayloadLength);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_STATE_EFFECTER_PDR);
@@ -335,7 +335,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_effecter/good",
                     inPDRRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, numericEffecterPDRs, PLDM_NUMERIC_EFFECTER_PDR);
 
@@ -379,7 +379,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_effecter/good",
                     inPDRRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, numericEffecterPDRs, PLDM_NUMERIC_EFFECTER_PDR);
 
@@ -416,7 +416,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_effecter/good",
                     inPDRRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, numericEffecterPDRs, PLDM_NUMERIC_EFFECTER_PDR);
 
@@ -493,7 +493,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_effecter/good",
                     inPDRRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, numericEffecterPDRs, PLDM_NUMERIC_EFFECTER_PDR);
 
@@ -750,7 +750,7 @@
     MockdBusHandler mockedUtils;
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "", inPDRRepo, nullptr, nullptr,
-                    nullptr, nullptr, nullptr, nullptr, event);
+                    nullptr, nullptr, nullptr, event);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_TERMINUS_LOCATOR_PDR);
 
@@ -796,7 +796,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_sensor/good",
                     inPDRRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_STATE_SENSOR_PDR);
     pdr_utils::PdrEntry e;
@@ -846,7 +846,7 @@
     auto event = sdeventplus::Event::get_default();
     Handler handler(&mockedUtils, 0, nullptr, "./pdr_jsons/state_sensor/good",
                     inPDRRepo, nullptr, nullptr, nullptr, nullptr, nullptr,
-                    nullptr, event);
+                    event);
     Repo inRepo(inPDRRepo);
     getRepoByType(inRepo, outRepo, PLDM_STATE_SENSOR_PDR);
     pdr_utils::PdrEntry e;
diff --git a/pldmd/oem_ibm.hpp b/pldmd/oem_ibm.hpp
new file mode 100644
index 0000000..82f3699
--- /dev/null
+++ b/pldmd/oem_ibm.hpp
@@ -0,0 +1,182 @@
+#pragma once
+
+#include "libpldm/pdr.h"
+
+#include "../oem/ibm/libpldmresponder/file_io.hpp"
+#include "../oem/ibm/libpldmresponder/fru_oem_ibm.hpp"
+#include "../oem/ibm/libpldmresponder/oem_ibm_handler.hpp"
+#include "common/utils.hpp"
+#include "dbus_impl_requester.hpp"
+#include "host-bmc/dbus_to_event_handler.hpp"
+#include "invoker.hpp"
+#include "libpldmresponder/fru.hpp"
+#include "requester/request.hpp"
+
+namespace pldm
+{
+namespace oem_ibm
+{
+
+using namespace pldm::state_sensor;
+using namespace pldm::dbus_api;
+
+/**
+ * @class OemIBM
+ *
+ * @brief class for creating all the OEM IBM handlers
+ *
+ *  Only in case of OEM_IBM this class object will be instantiated
+ */
+class OemIBM
+{
+  public:
+    OemIBM() = delete;
+    OemIBM(const Pdr&) = delete;
+    OemIBM& operator=(const OemIBM&) = delete;
+    OemIBM(OemIBM&&) = delete;
+    OemIBM& operator=(OemIBM&&) = delete;
+
+  public:
+    /** Constructs OemIBM object
+     *
+     * @param[in] dBusIntf - D-Bus handler
+     * @param[in] mctp_fd - fd of MCTP communications socket
+     * @param[in] mctp_eid - MCTP EID of remote host firmware
+     * @param[in] repo - pointer to BMC's primary PDR repo
+     * @param[in] instanceIdDb - pointer to an InstanceIdDb object
+     * @param[in] event - sd_event handler
+     * @param[in] invoker - invoker handler
+     * @param[in] hostPDRHandler - hostPDRHandler handler
+     * @param[in] platformHandler - platformHandler handler
+     * @param[in] fruHandler - fruHandler handler
+     * @param[in] baseHandler - baseHandler handler
+     * @param[in] reqHandler - reqHandler handler
+     */
+    explicit OemIBM(
+        const pldm::utils::DBusHandler* dBusIntf, int mctp_fd, uint8_t mctp_eid,
+        pldm_pdr* repo, pldm::InstanceIdDb& instanceIdDb,
+        sdeventplus::Event& event, Invoker& invoker,
+        HostPDRHandler* hostPDRHandler, platform::Handler* platformHandler,
+        fru::Handler* fruHandler, base::Handler* baseHandler,
+        pldm::requester::Handler<pldm::requester::Request>* reqHandler) :
+        dBusIntf(dBusIntf),
+        mctp_fd(mctp_fd), mctp_eid(mctp_eid), repo(repo),
+        instanceIdDb(instanceIdDb), event(event), invoker(invoker),
+        reqHandler(reqHandler)
+    {
+        createOemFruHandler();
+        fruHandler->setOemFruHandler(oemFruHandler.get());
+
+        createOemIbmFruHandler();
+        oemIbmFruHandler->setIBMFruHandler(fruHandler);
+
+        createCodeUpdate();
+        createOemPlatformHandler();
+        codeUpdate->setOemPlatformHandler(oemPlatformHandler.get());
+        hostPDRHandler->setOemPlatformHandler(oemPlatformHandler.get());
+        platformHandler->setOemPlatformHandler(oemPlatformHandler.get());
+        baseHandler->setOemPlatformHandler(oemPlatformHandler.get());
+
+        createOemIbmPlatformHandler();
+        oemIbmPlatformHandler->setPlatformHandler(platformHandler);
+
+        registerHandler();
+    }
+
+  private:
+    /** @brief Method for creating codeUpdate handler */
+    void createCodeUpdate()
+    {
+        codeUpdate = std::make_unique<pldm::responder::CodeUpdate>(dBusIntf);
+        codeUpdate->clearDirPath(LID_STAGING_DIR);
+    }
+
+    /** @brief Method for creating oemPlatformHandler
+     *
+     *  This method also assigns the oemPlatformHandler to the below
+     *  different handlers.
+     */
+    void createOemPlatformHandler()
+    {
+        oemPlatformHandler = std::make_unique<oem_ibm_platform::Handler>(
+            dBusIntf, codeUpdate.get(), mctp_fd, mctp_eid, instanceIdDb, event,
+            reqHandler);
+    }
+
+    /** @brief Method for creating oemIbmPlatformHandler */
+    void createOemIbmPlatformHandler()
+    {
+        oemIbmPlatformHandler =
+            dynamic_cast<pldm::responder::oem_ibm_platform::Handler*>(
+                oemPlatformHandler.get());
+    }
+
+    /** @brief Method for creating oemFruHandler */
+    void createOemFruHandler()
+    {
+        oemFruHandler = std::make_unique<oem_ibm_fru::Handler>(repo);
+    }
+
+    /** @brief Method for creating oemIbmFruHandler */
+    void createOemIbmFruHandler()
+    {
+        oemIbmFruHandler = dynamic_cast<pldm::responder::oem_ibm_fru::Handler*>(
+            oemFruHandler.get());
+    }
+
+    /** @brief Method for registering PLDM OEM handler */
+    void registerHandler()
+    {
+        invoker.registerHandler(
+            PLDM_OEM, std::make_unique<pldm::responder::oem_ibm::Handler>(
+                          oemPlatformHandler.get(), mctp_fd, mctp_eid,
+                          &instanceIdDb, reqHandler));
+    }
+
+  private:
+    /** @brief D-Bus handler */
+    const pldm::utils::DBusHandler* dBusIntf;
+
+    /** @brief fd of MCTP communications socket */
+    int mctp_fd;
+
+    /** @brief MCTP EID of remote host firmware */
+    uint8_t mctp_eid;
+
+    /** @brief pointer to BMC's primary PDR repo */
+    pldm_pdr* repo;
+
+    /** @brief reference to an Instance ID database object, used to obtain PLDM
+     * instance IDs
+     */
+    pldm::InstanceIdDb& instanceIdDb;
+
+    /** @brief reference of main event loop of pldmd, primarily used to schedule
+     *  work
+     */
+    sdeventplus::Event& event;
+
+    /** @brief Object to the invoker class*/
+    Invoker& invoker;
+
+    /** @brief pointer to the requester class*/
+    requester::Handler<requester::Request>* reqHandler;
+
+    /** @brief pointer to the oem_ibm_handler class*/
+    std::unique_ptr<oem_platform::Handler> oemPlatformHandler{};
+
+    /** @brief pointer to the oem_ibm_fru class*/
+    std::unique_ptr<oem_fru::Handler> oemFruHandler{};
+
+    /** @brief pointer to the CodeUpdate class*/
+    std::unique_ptr<pldm::responder::CodeUpdate> codeUpdate{};
+
+    /** @brief oem IBM Platform handler*/
+    pldm::responder::oem_ibm_platform::Handler* oemIbmPlatformHandler = nullptr;
+
+    /** @brief oem IBM Fru handler*/
+    pldm::responder::oem_ibm_fru::Handler* oemIbmFruHandler = nullptr;
+};
+
+} // namespace oem_ibm
+} // namespace pldm
diff --git a/pldmd/pldmd.cpp b/pldmd/pldmd.cpp
index 1030c8e..102458f 100644
--- a/pldmd/pldmd.cpp
+++ b/pldmd/pldmd.cpp
@@ -60,9 +60,7 @@
 #endif
 
 #ifdef OEM_IBM
-#include "libpldmresponder/file_io.hpp"
-#include "libpldmresponder/fru_oem_ibm.hpp"
-#include "libpldmresponder/oem_ibm_handler.hpp"
+#include "oem_ibm.hpp"
 #endif
 
 constexpr uint8_t MCTP_MSG_TYPE_PLDM = 1;
@@ -232,31 +230,16 @@
         hostEffecterParser;
     std::unique_ptr<DbusToPLDMEvent> dbusToPLDMEventHandler;
     DBusHandler dbusHandler;
-    std::unique_ptr<oem_platform::Handler> oemPlatformHandler{};
     std::unique_ptr<platform_config::Handler> platformConfigHandler{};
     platformConfigHandler = std::make_unique<platform_config::Handler>();
-    std::unique_ptr<oem_fru::Handler> oemFruHandler{};
 
-#ifdef OEM_IBM
-    std::unique_ptr<pldm::responder::CodeUpdate> codeUpdate =
-        std::make_unique<pldm::responder::CodeUpdate>(&dbusHandler);
-    codeUpdate->clearDirPath(LID_STAGING_DIR);
-    oemPlatformHandler = std::make_unique<oem_ibm_platform::Handler>(
-        &dbusHandler, codeUpdate.get(), pldmTransport.getEventSource(), hostEID,
-        instanceIdDb, event, &reqHandler);
-    codeUpdate->setOemPlatformHandler(oemPlatformHandler.get());
-    oemFruHandler = std::make_unique<oem_ibm_fru::Handler>(pdrRepo.get());
-    invoker.registerHandler(PLDM_OEM, std::make_unique<oem_ibm::Handler>(
-                                          oemPlatformHandler.get(),
-                                          pldmTransport.getEventSource(),
-                                          hostEID, &instanceIdDb, &reqHandler));
-#endif
     if (hostEID)
     {
         hostPDRHandler = std::make_shared<HostPDRHandler>(
             pldmTransport.getEventSource(), hostEID, event, pdrRepo.get(),
             EVENTS_JSONS_DIR, entityTree.get(), bmcEntityTree.get(),
-            instanceIdDb, &reqHandler, oemPlatformHandler.get());
+            instanceIdDb, &reqHandler);
+
         // HostFirmware interface needs access to hostPDR to know if host
         // is running
         dbusImplHost.setHostPdrObj(hostPDRHandler);
@@ -268,13 +251,10 @@
         dbusToPLDMEventHandler = std::make_unique<DbusToPLDMEvent>(
             pldmTransport.getEventSource(), hostEID, instanceIdDb, &reqHandler);
     }
-    auto biosHandler = std::make_unique<bios::Handler>(
-        pldmTransport.getEventSource(), hostEID, &instanceIdDb, &reqHandler,
-        platformConfigHandler.get(), requestPLDMServiceName);
 
     auto fruHandler = std::make_unique<fru::Handler>(
         FRU_JSONS_DIR, FRU_MASTER_JSON, pdrRepo.get(), entityTree.get(),
-        bmcEntityTree.get(), oemFruHandler.get());
+        bmcEntityTree.get());
 
     // FRU table is built lazily when a FRU command or Get PDR command is
     // handled. To enable building FRU table, the FRU handler is passed to the
@@ -282,25 +262,27 @@
     auto platformHandler = std::make_unique<platform::Handler>(
         &dbusHandler, hostEID, &instanceIdDb, PDR_JSONS_DIR, pdrRepo.get(),
         hostPDRHandler.get(), dbusToPLDMEventHandler.get(), fruHandler.get(),
-        oemPlatformHandler.get(), platformConfigHandler.get(), &reqHandler,
-        event, true);
-#ifdef OEM_IBM
-    pldm::responder::oem_ibm_platform::Handler* oemIbmPlatformHandler =
-        dynamic_cast<pldm::responder::oem_ibm_platform::Handler*>(
-            oemPlatformHandler.get());
-    oemIbmPlatformHandler->setPlatformHandler(platformHandler.get());
+        platformConfigHandler.get(), &reqHandler, event, true);
 
-    pldm::responder::oem_ibm_fru::Handler* oemIbmFruHandler =
-        dynamic_cast<pldm::responder::oem_ibm_fru::Handler*>(
-            oemFruHandler.get());
-    oemIbmFruHandler->setIBMFruHandler(fruHandler.get());
+    auto biosHandler = std::make_unique<bios::Handler>(
+        pldmTransport.getEventSource(), hostEID, &instanceIdDb, &reqHandler,
+        platformConfigHandler.get(), requestPLDMServiceName);
+
+    auto baseHandler = std::make_unique<base::Handler>(event);
+
+#ifdef OEM_IBM
+    pldm::oem_ibm::OemIBM oemIBM(&dbusHandler, pldmTransport.getEventSource(),
+                                 hostEID, pdrRepo.get(), instanceIdDb, event,
+                                 invoker, hostPDRHandler.get(),
+                                 platformHandler.get(), fruHandler.get(),
+                                 baseHandler.get(), &reqHandler);
 #endif
 
     invoker.registerHandler(PLDM_BIOS, std::move(biosHandler));
     invoker.registerHandler(PLDM_PLATFORM, std::move(platformHandler));
-    invoker.registerHandler(PLDM_BASE, std::make_unique<base::Handler>(
-                                           event, oemPlatformHandler.get()));
     invoker.registerHandler(PLDM_FRU, std::move(fruHandler));
+    invoker.registerHandler(PLDM_BASE, std::move(baseHandler));
+
     dbus_api::Pdr dbusImplPdr(bus, "/xyz/openbmc_project/pldm", pdrRepo.get());
     sdbusplus::xyz::openbmc_project::PLDM::server::Event dbusImplEvent(
         bus, "/xyz/openbmc_project/pldm");