entity-manager: create class EMDBusInterface

class EMDBusInterface is created to remove global var 'inventory'.

The one instance of this class is a member of class EntityManager and
has the same lifetime. Since the EntityManager class instance is created
at the start of the main function, the 'inventory' member should always
be in scope from the perspective of the rest of the code, as before.

The class was created with a small amount of changes.
It does not aim to be a good abstraction for entity-manager's dbus
interface, the primary goal is to get rid of the global variable and
avoid passing it through a bunch of functions.

Tested: On Tyan S8030

```
Jul 01 09:59:26 s8030-bmc-30303035c0c1 entity-manager[4204]: Inventory Added: Supermicro PWS 920P SQ 0
Jul 01 09:59:26 s8030-bmc-30303035c0c1 entity-manager[4204]: Inventory Added: Supermicro PWS 920P SQ 1
Jul 01 09:59:26 s8030-bmc-30303035c0c1 entity-manager[4204]: Inventory Added: chassis
Jul 01 09:59:26 s8030-bmc-30303035c0c1 entity-manager[4204]: Inventory Added: MBX 1.57 Chassis
```

busctl tree output as before

Change-Id: I5f682311358836f88fe861d778210cf38efe08fa
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/src/entity_manager/dbus_interface.cpp b/src/entity_manager/dbus_interface.cpp
index ff8094e..1efa0c3 100644
--- a/src/entity_manager/dbus_interface.cpp
+++ b/src/entity_manager/dbus_interface.cpp
@@ -22,13 +22,6 @@
 const std::regex illegalDbusPathRegex("[^A-Za-z0-9_.]");
 const std::regex illegalDbusMemberRegex("[^A-Za-z0-9_]");
 
-// NOLINTBEGIN(cppcoreguidelines-avoid-non-const-global-variables)
-// store reference to all interfaces so we can destroy them later
-boost::container::flat_map<
-    std::string, std::vector<std::weak_ptr<sdbusplus::asio::dbus_interface>>>
-    inventory;
-// NOLINTEND(cppcoreguidelines-avoid-non-const-global-variables)
-
 void tryIfaceInitialize(std::shared_ptr<sdbusplus::asio::dbus_interface>& iface)
 {
     try
@@ -44,9 +37,10 @@
     }
 }
 
-std::shared_ptr<sdbusplus::asio::dbus_interface> createInterface(
-    sdbusplus::asio::object_server& objServer, const std::string& path,
-    const std::string& interface, const std::string& parent, bool checkNull)
+std::shared_ptr<sdbusplus::asio::dbus_interface>
+    EMDBusInterface::createInterface(
+        sdbusplus::asio::object_server& objServer, const std::string& path,
+        const std::string& interface, const std::string& parent, bool checkNull)
 {
     // on first add we have no reason to check for null before add, as there
     // won't be any. For dynamically added interfaces, we check for null so that
@@ -244,7 +238,7 @@
     tryIfaceInitialize(iface);
 }
 
-void createAddObjectMethod(
+void EMDBusInterface::createAddObjectMethod(
     boost::asio::io_context& io, const std::string& jsonPointerPath,
     const std::string& path, nlohmann::json& systemConfiguration,
     sdbusplus::asio::object_server& objServer, const std::string& board)
@@ -256,9 +250,9 @@
         "AddObject",
         [&systemConfiguration, &objServer,
          jsonPointerPath{std::string(jsonPointerPath)}, path{std::string(path)},
-         board,
-         &io](const boost::container::flat_map<std::string, JsonVariantType>&
-                  data) {
+         board, &io,
+         this](const boost::container::flat_map<std::string, JsonVariantType>&
+                   data) {
             nlohmann::json::json_pointer ptr(jsonPointerPath);
             nlohmann::json& base = systemConfiguration[ptr];
             auto findExposes = base.find("Exposes");
@@ -374,7 +368,7 @@
 }
 
 std::vector<std::weak_ptr<sdbusplus::asio::dbus_interface>>&
-    getDeviceInterfaces(const nlohmann::json& device)
+    EMDBusInterface::getDeviceInterfaces(const nlohmann::json& device)
 {
     return inventory[device["Name"].get<std::string>()];
 }