Add Configuration class

Adding this class improves maintainability by increasing separation
of concern. One major improvement is the removal of reoccuring calls to
loadConfigurations. These calls took a long time. Now it's only called
once.

Tested:
QEMU/yosemite4 with probe statement set to TRUE.
```
root@yosemite4:~# journalctl | grep entity-manager
Dec 19 13:26:21 yosemite4 entity-manager[502]: Clearing previous configuration
Dec 19 13:26:25 yosemite4 entity-manager[502]: Inventory Added: Yosemite 4 Management Board
root@yosemite4:~# busctl tree xyz.openbmc_project.EntityManager
`- /xyz
  `- /xyz/openbmc_project
    |- /xyz/openbmc_project/EntityManager
    `- /xyz/openbmc_project/inventory
      `- /xyz/openbmc_project/inventory/system
        `- /xyz/openbmc_project/inventory/system/board
          `- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board
            |- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/All_Fan
            |- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P0V6_VOLT_V
            |- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P12V_VOLT_V
            |- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P1V0_VOLT_V
            |- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P1V2_VOLT_V
            |- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P1V8_VOLT_V
            |- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P2V5_VOLT_V
            |- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P3V3_RGM_VOLT_V
            |- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P3V3_VOLT_V
            |- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P3V_BAT_VOLT_V
            |- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P5V_USB_VOLT_V
            |- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_ADC_P5V_VOLT_V
            |- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/MGNT_TEMP_C
            |- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/PID_NIC_TEMP
            |- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/Stepwise_MGNT_TEMP
            |- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/Stepwise_NIC_TEMP
            |- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/Stepwise_SENTINEL_DOME_SLOT_PRESENT_PERCENTAGE
            `- /xyz/openbmc_project/inventory/system/board/Yosemite_4_Management_Board/Zone_1
```

Change-Id: I5684a03232012e14d97edcf4ea5ed1aed4d50c8d
Signed-off-by: Christopher Meis <christopher.meis@9elements.com>
diff --git a/src/entity_manager/entity_manager.cpp b/src/entity_manager/entity_manager.cpp
index 31e7ef4..ff9a5d5 100644
--- a/src/entity_manager/entity_manager.cpp
+++ b/src/entity_manager/entity_manager.cpp
@@ -86,6 +86,8 @@
         propertiesChangedCallback();
     });
     dbus_interface::tryIfaceInitialize(entityIface);
+
+    initFilters(configuration.probeInterfaces);
 }
 
 void EntityManager::postToDbus(const nlohmann::json& newConfiguration)
@@ -450,7 +452,7 @@
     loadOverlays(newConfiguration, io);
 
     boost::asio::post(io, [this]() {
-        if (!configuration::writeJsonFiles(systemConfiguration))
+        if (!writeJsonFiles(systemConfiguration))
         {
             std::cerr << "Error writing json files\n";
         }
@@ -498,16 +500,8 @@
             auto missingConfigurations = std::make_shared<nlohmann::json>();
             *missingConfigurations = systemConfiguration;
 
-            std::list<nlohmann::json> configurations;
-            if (!configuration::loadConfigurations(configurations))
-            {
-                std::cerr << "Could not load configurations\n";
-                propertiesChangedInProgress = false;
-                return;
-            }
-
             auto perfScan = std::make_shared<scan::PerformScan>(
-                *this, *missingConfigurations, configurations, io,
+                *this, *missingConfigurations, configuration.configurations, io,
                 [this, count, oldConfiguration, missingConfigurations]() {
                     // this is something that since ac has been applied to the
                     // bmc we saw, and we no longer see it
@@ -517,11 +511,9 @@
                     {
                         pruneConfiguration(powerOff, name, device);
                     }
-
                     nlohmann::json newConfiguration = systemConfiguration;
 
-                    configuration::deriveNewConfiguration(oldConfiguration,
-                                                          newConfiguration);
+                    deriveNewConfiguration(oldConfiguration, newConfiguration);
 
                     for (const auto& [_, device] : newConfiguration.items())
                     {
@@ -542,7 +534,8 @@
 
 // Check if InterfacesAdded payload contains an iface that needs probing.
 static bool iaContainsProbeInterface(
-    sdbusplus::message_t& msg, const std::set<std::string>& probeInterfaces)
+    sdbusplus::message_t& msg,
+    const std::unordered_set<std::string>& probeInterfaces)
 {
     sdbusplus::message::object_path path;
     DBusObject interfaces;
@@ -564,7 +557,8 @@
 
 // Check if InterfacesRemoved payload contains an iface that needs probing.
 static bool irContainsProbeInterface(
-    sdbusplus::message_t& msg, const std::set<std::string>& probeInterfaces)
+    sdbusplus::message_t& msg,
+    const std::unordered_set<std::string>& probeInterfaces)
 {
     sdbusplus::message::object_path path;
     std::set<std::string> interfaces;
@@ -582,15 +576,13 @@
 {
     if (em_utils::fwVersionIsSame())
     {
-        if (std::filesystem::is_regular_file(
-                configuration::currentConfiguration))
+        if (std::filesystem::is_regular_file(currentConfiguration))
         {
             // this file could just be deleted, but it's nice for debug
             std::filesystem::create_directory(tempConfigDir);
             std::filesystem::remove(lastConfiguration);
-            std::filesystem::copy(configuration::currentConfiguration,
-                                  lastConfiguration);
-            std::filesystem::remove(configuration::currentConfiguration);
+            std::filesystem::copy(currentConfiguration, lastConfiguration);
+            std::filesystem::remove(currentConfiguration);
 
             std::ifstream jsonStream(lastConfiguration);
             if (jsonStream.good())
@@ -616,7 +608,7 @@
     {
         // not an error, just logging at this level to make it in the journal
         std::cerr << "Clearing previous configuration\n";
-        std::filesystem::remove(configuration::currentConfiguration);
+        std::filesystem::remove(currentConfiguration);
     }
 }
 
@@ -644,7 +636,8 @@
 // org.freedesktop.DBus.Properties signals.  Similarly if a process exits
 // for any reason, expected or otherwise, we'll need a poke to remove
 // entities from DBus.
-void EntityManager::initFilters(const std::set<std::string>& probeInterfaces)
+void EntityManager::initFilters(
+    const std::unordered_set<std::string>& probeInterfaces)
 {
     nameOwnerChangedMatch = std::make_unique<sdbusplus::bus::match_t>(
         static_cast<sdbusplus::bus_t&>(*systemBus),
@@ -694,10 +687,6 @@
 
     nlohmann::json systemConfiguration = nlohmann::json::object();
 
-    std::set<std::string> probeInterfaces = configuration::getProbeInterfaces();
-
-    em.initFilters(probeInterfaces);
-
     boost::asio::post(io, [&]() { em.propertiesChangedCallback(); });
 
     em.handleCurrentConfigurationJson();