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.cpp b/vpd-manager/manager.cpp
index cf20b0a..23e6290 100644
--- a/vpd-manager/manager.cpp
+++ b/vpd-manager/manager.cpp
@@ -2,10 +2,8 @@
 
 #include "manager.hpp"
 
-#include "bios_handler.hpp"
 #include "common_utility.hpp"
 #include "editor_impl.hpp"
-#include "gpioMonitor.hpp"
 #include "ibm_vpd_utils.hpp"
 #include "ipz_parser.hpp"
 #include "parser_factory.hpp"
@@ -15,7 +13,6 @@
 #include <filesystem>
 #include <phosphor-logging/elog-errors.hpp>
 
-using namespace openpower::vpd::manager;
 using namespace openpower::vpd::constants;
 using namespace openpower::vpd::inventory;
 using namespace openpower::vpd::manager::editor;
@@ -33,16 +30,49 @@
 {
 namespace manager
 {
-Manager::Manager(sdbusplus::bus_t&& bus, const char* busName,
-                 const char* objPath, const char* /*iFace*/) :
-    ServerObject<ManagerIface>(bus, objPath),
-    _bus(std::move(bus)), _manager(_bus, objPath)
+Manager::Manager(std::shared_ptr<boost::asio::io_context>& ioCon,
+                 std::shared_ptr<sdbusplus::asio::dbus_interface>& iFace,
+                 std::shared_ptr<sdbusplus::asio::connection>& conn) :
+    ioContext(ioCon),
+    interface(iFace), conn(conn)
 {
-    _bus.request_name(busName);
+    interface->register_method(
+        "WriteKeyword",
+        [this](const sdbusplus::message::object_path& path,
+               const std::string& recordName, const std::string& keyword,
+               const Binary& value) {
+            this->writeKeyword(path, recordName, keyword, value);
+        });
+
+    interface->register_method(
+        "GetFRUsByUnexpandedLocationCode",
+        [this](const std::string& locationCode,
+               const uint16_t nodeNumber) -> inventory::ListOfPaths {
+            return this->getFRUsByUnexpandedLocationCode(locationCode,
+                                                         nodeNumber);
+        });
+
+    interface->register_method(
+        "GetFRUsByExpandedLocationCode",
+        [this](const std::string& locationCode) -> inventory::ListOfPaths {
+            return this->getFRUsByExpandedLocationCode(locationCode);
+        });
+
+    interface->register_method(
+        "GetExpandedLocationCode",
+        [this](const std::string& locationCode,
+               const uint16_t nodeNumber) -> std::string {
+            return this->getExpandedLocationCode(locationCode, nodeNumber);
+        });
+
+    interface->register_method("PerformVPDRecollection",
+                               [this]() { this->performVPDRecollection(); });
+
     sd_bus_default(&sdBus);
+    initManager();
 }
 
-void Manager::run()
+void Manager::initManager()
 {
     try
     {
@@ -52,14 +82,10 @@
         listenAssetTag();
 
         // Create an instance of the BIOS handler
-        BiosHandler biosHandler{_bus, *this};
+        biosHandler = std::make_shared<BiosHandler>(conn, *this);
 
-        auto event = sdeventplus::Event::get_default();
-        GpioMonitor gpioMon1(jsonFile, event);
-
-        _bus.attach_event(event.get(), SD_EVENT_PRIORITY_IMPORTANT);
-        cout << "VPD manager event loop started\n";
-        event.loop();
+        // instantiate gpioMonitor class
+        gpioMon = std::make_shared<GpioMonitor>(jsonFile, ioContext);
     }
     catch (const std::exception& e)
     {
@@ -169,7 +195,7 @@
 {
     static std::shared_ptr<sdbusplus::bus::match_t> hostState =
         std::make_shared<sdbusplus::bus::match_t>(
-            _bus,
+            *conn,
             sdbusplus::bus::match::rules::propertiesChanged(
                 "/xyz/openbmc_project/state/host0",
                 "xyz.openbmc_project.State.Host"),
@@ -239,7 +265,7 @@
 {
     static std::shared_ptr<sdbusplus::bus::match_t> assetMatcher =
         std::make_shared<sdbusplus::bus::match_t>(
-            _bus,
+            *conn,
             sdbusplus::bus::match::rules::propertiesChanged(
                 "/xyz/openbmc_project/inventory/system",
                 "xyz.openbmc_project.Inventory.Decorator.AssetTag"),
@@ -342,9 +368,9 @@
     }
 }
 
-void Manager::writeKeyword(const sdbusplus::message::object_path path,
-                           const std::string recordName,
-                           const std::string keyword, const Binary value)
+void Manager::writeKeyword(const sdbusplus::message::object_path& path,
+                           const std::string& recordName,
+                           const std::string& keyword, const Binary& value)
 {
     try
     {
@@ -410,7 +436,7 @@
 }
 
 ListOfPaths
-    Manager::getFRUsByUnexpandedLocationCode(const LocationCode locationCode,
+    Manager::getFRUsByUnexpandedLocationCode(const LocationCode& locationCode,
                                              const NodeNumber nodeNumber)
 {
     ReaderImpl read;
@@ -418,13 +444,13 @@
 }
 
 ListOfPaths
-    Manager::getFRUsByExpandedLocationCode(const LocationCode locationCode)
+    Manager::getFRUsByExpandedLocationCode(const LocationCode& locationCode)
 {
     ReaderImpl read;
     return read.getFRUsByExpandedLocationCode(locationCode, fruLocationCode);
 }
 
-LocationCode Manager::getExpandedLocationCode(const LocationCode locationCode,
+LocationCode Manager::getExpandedLocationCode(const LocationCode& locationCode,
                                               const NodeNumber nodeNumber)
 {
     ReaderImpl read;