Shift to boost asio library

This commit shifts vpd manager from sdbusplus event loop to
boost io_context event loop.
The shift was done to have a more flexible way to perform
async Dbus calls.
For example read/write of vpd data can be performed
asynchronously.

It also removes dependency of Manager class on the interface
class created as a part of Phosphor-Dbus-Interface repo.

Test:
- Introspect com.ibm.VPD.Manager /com/ibm/VPD/Manager to ensure
that all the methods exposed under com.ibm.VPD.Manager interface
matches to the ones documented under PDI repo.

- Make DBus call to each of the exposed api to ensure that the
funcation calls are working fine.

-To ensure bios handler call back is working.
Stop vpd-manager service.
Stop pldm service.
Start vpd-manager service
Start pldm service.
Should recieve callback.

-To ensure gpio call back
std::cout were added to callback function being trigerred on
timer expiration and the same were verified in journal.

Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
Change-Id: I00640f64de487d5244e8be2e7a3f3d63a013644e
diff --git a/vpd-manager/manager.hpp b/vpd-manager/manager.hpp
index 4992801..12fc1d4 100644
--- a/vpd-manager/manager.hpp
+++ b/vpd-manager/manager.hpp
@@ -1,19 +1,11 @@
 #pragma once
 
+#include "bios_handler.hpp"
 #include "editor_impl.hpp"
-#include "types.hpp"
+#include "gpioMonitor.hpp"
 
-#include <com/ibm/VPD/Manager/server.hpp>
 #include <map>
-#include <nlohmann/json.hpp>
-
-namespace sdbusplus
-{
-namespace bus
-{
-class bus;
-}
-} // namespace sdbusplus
+#include <sdbusplus/asio/object_server.hpp>
 
 namespace openpower
 {
@@ -22,18 +14,12 @@
 namespace manager
 {
 
-template <typename T>
-using ServerObject = T;
-
-using ManagerIface = sdbusplus::com::ibm::VPD::server::Manager;
-
 /** @class Manager
  *  @brief OpenBMC VPD Manager implementation.
  *
- *  A concrete implementation for the
- *  com.ibm.vpd.Manager
+ *  Implements methods under interface com.ibm.vpd.Manager.
  */
-class Manager : public ServerObject<ManagerIface>
+class Manager
 {
   public:
     /* Define all of the basic class operations:
@@ -54,14 +40,14 @@
         sd_bus_unref(sdBus);
     }
 
-    /** @brief Constructor to put object onto bus at a dbus path.
-     *  @param[in] bus - Bus connection.
-     *  @param[in] busName - Name to be requested on Bus
-     *  @param[in] objPath - Path to attach at.
-     *  @param[in] iFace - interface to implement
+    /** @brief Constructor.
+     *  @param[in] ioCon - IO context.
+     *  @param[in] iFace - interface to implement.
+     *  @param[in] connection - Dbus Connection.
      */
-    Manager(sdbusplus::bus_t&& bus, const char* busName, const char* objPath,
-            const char* iFace);
+    Manager(std::shared_ptr<boost::asio::io_context>& ioCon,
+            std::shared_ptr<sdbusplus::asio::dbus_interface>& iFace,
+            std::shared_ptr<sdbusplus::asio::connection>& conn);
 
     /** @brief Implementation for WriteKeyword
      *  Api to update the keyword value for a given inventory.
@@ -72,9 +58,9 @@
      *  @param[in] keyword - keyword whose value needs to be updated
      *  @param[in] value - value that needs to be updated
      */
-    void writeKeyword(const sdbusplus::message::object_path path,
-                      const std::string recordName, const std::string keyword,
-                      const Binary value);
+    void writeKeyword(const sdbusplus::message::object_path& path,
+                      const std::string& recordName, const std::string& keyword,
+                      const Binary& value);
 
     /** @brief Implementation for GetFRUsByUnexpandedLocationCode
      *  A method to get list of FRU D-BUS object paths for a given unexpanded
@@ -89,7 +75,7 @@
      *  List of all the FRUs D-Bus object paths for the given location code.
      */
     inventory::ListOfPaths
-        getFRUsByUnexpandedLocationCode(const std::string locationCode,
+        getFRUsByUnexpandedLocationCode(const std::string& locationCode,
                                         const uint16_t nodeNumber);
 
     /** @brief Implementation for GetFRUsByExpandedLocationCode
@@ -103,7 +89,7 @@
      *  List of all the FRUs D-Bus object path for the given location code.
      */
     inventory::ListOfPaths
-        getFRUsByExpandedLocationCode(const std::string locationCode);
+        getFRUsByExpandedLocationCode(const std::string& locationCode);
 
     /** @brief Implementation for GetExpandedLocationCode
      *  An API to get expanded location code corresponding to a given
@@ -115,12 +101,9 @@
      *
      *  @return locationCode[std::string] - Location code in expanded format.
      */
-    std::string getExpandedLocationCode(const std::string locationCode,
+    std::string getExpandedLocationCode(const std::string& locationCode,
                                         const uint16_t nodeNumber);
 
-    /** @brief Start processing DBus messages. */
-    void run();
-
     /** @brief Api to perform VPD recollection.
      * This api will trigger parser to perform VPD recollection for FRUs that
      * can be replaced at standby.
@@ -128,6 +111,11 @@
     void performVPDRecollection();
 
   private:
+    /**
+     * @brief An api to process some initial requirements.
+     */
+    void initManager();
+
     /** @brief process the given JSON file
      */
     void processJSON();
@@ -169,11 +157,14 @@
      */
     void checkEssentialFrus();
 
-    /** @brief Persistent sdbusplus DBus bus connection. */
-    sdbusplus::bus_t _bus;
+    // Shared pointer to asio context object.
+    std::shared_ptr<boost::asio::io_context>& ioContext;
 
-    /** @brief sdbusplus org.freedesktop.DBus.ObjectManager reference. */
-    sdbusplus::server::manager_t _manager;
+    // Shared pointer to Dbus interface class.
+    std::shared_ptr<sdbusplus::asio::dbus_interface>& interface;
+
+    // Shared pointer to bus connection.
+    std::shared_ptr<sdbusplus::asio::connection>& conn;
 
     // file to store parsed json
     nlohmann::json jsonFile;
@@ -188,6 +179,12 @@
     // map to hold FRUs which can be replaced at standby
     inventory::ReplaceableFrus replaceableFrus;
 
+    // Shared pointer to gpio monitor object.
+    std::shared_ptr<GpioMonitor> gpioMon;
+
+    // Shared pointer to instance of the BIOS handler.
+    std::shared_ptr<BiosHandler> biosHandler;
+
     // List of FRUs marked as essential in the system.
     inventory::EssentialFrus essentialFrus;