Move objects out of global scope
With multiple callbacks, there is the chance that
multiple async scans can happen at the same time. This
can make it so that the result isn't always what is
expected. Move DBUS_PROBE_OBJECTS and PASSED_PROBES into
the object so that this doesn't happen. This required
moving the declaration into the header to avoid a forward
declaration.
Also add guard back into findDbusObjects so that an
individual scan doesn't populate the objects multiple times.
Tested: HSBP $index was correct index, all sensor still
available. Startup time was reduced.
Change-Id: Icfe9cc573d71b506c1cd8ae1b5816b5999e66025
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/include/EntityManager.hpp b/include/EntityManager.hpp
index 4d5de34..ae12014 100644
--- a/include/EntityManager.hpp
+++ b/include/EntityManager.hpp
@@ -16,12 +16,39 @@
#pragma once
+#include "Utils.hpp"
+
#include <systemd/sd-journal.h>
+#include <boost/container/flat_map.hpp>
#include <iostream>
+#include <list>
#include <nlohmann/json.hpp>
#include <string>
+using DBusProbeObjectT = boost::container::flat_map<
+ std::string,
+ std::vector<boost::container::flat_map<std::string, BasicVariantType>>>;
+
+struct PerformScan : std::enable_shared_from_this<PerformScan>
+{
+
+ PerformScan(nlohmann::json& systemConfiguration,
+ nlohmann::json& missingConfigurations,
+ std::list<nlohmann::json>& configurations,
+ std::function<void(const DBusProbeObjectT&)>&& callback);
+ void run(void);
+ virtual ~PerformScan();
+ nlohmann::json& _systemConfiguration;
+ nlohmann::json& _missingConfigurations;
+ std::list<nlohmann::json> _configurations;
+ std::function<void(const DBusProbeObjectT&)> _callback;
+ bool _passed = false;
+ bool powerWasOn = isPowerOn();
+ DBusProbeObjectT dbusProbeObjects;
+ std::vector<std::string> passedProbes;
+};
+
inline void logDeviceAdded(const nlohmann::json& record)
{