PerformProbe: Invoke PerformScan::updateSystemConfiguration() directly
Drop the lambda we previously required.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I4cfa0a8a026226a6a4d77191045da43c5b4a30a7
diff --git a/include/EntityManager.hpp b/include/EntityManager.hpp
index 781d3a1..f443874 100644
--- a/include/EntityManager.hpp
+++ b/include/EntityManager.hpp
@@ -89,17 +89,15 @@
// this class finds the needed dbus fields and on destruction runs the probe
struct PerformProbe : std::enable_shared_from_this<PerformProbe>
{
- PerformProbe(
- const std::vector<std::string>& probeCommand,
- std::shared_ptr<PerformScan>& scanPtr,
- std::function<void(FoundDevices&, const MapperGetSubTreeResponse&)>&&
- callback);
+ PerformProbe(nlohmann::json& recordRef,
+ const std::vector<std::string>& probeCommand,
+ std::string probeName, std::shared_ptr<PerformScan>& scanPtr);
virtual ~PerformProbe();
+ nlohmann::json& recordRef;
std::vector<std::string> _probeCommand;
+ std::string probeName;
std::shared_ptr<PerformScan> scan;
- std::function<void(FoundDevices&, const MapperGetSubTreeResponse&)>
- _callback;
};
inline void logDeviceAdded(const nlohmann::json& record)
diff --git a/src/PerformProbe.cpp b/src/PerformProbe.cpp
index d120b3c..7c5a2b2 100644
--- a/src/PerformProbe.cpp
+++ b/src/PerformProbe.cpp
@@ -19,6 +19,7 @@
#include <boost/algorithm/string/replace.hpp>
#include <regex>
+#include <utility>
constexpr const bool debug = false;
@@ -218,19 +219,19 @@
return ret;
}
-PerformProbe::PerformProbe(
- const std::vector<std::string>& probeCommand,
- std::shared_ptr<PerformScan>& scanPtr,
- std::function<void(FoundDevices&, const MapperGetSubTreeResponse&)>&&
- callback) :
- _probeCommand(probeCommand),
- scan(scanPtr), _callback(std::move(callback))
+PerformProbe::PerformProbe(nlohmann::json& recordRef,
+ const std::vector<std::string>& probeCommand,
+ std::string probeName,
+ std::shared_ptr<PerformScan>& scanPtr) :
+ recordRef(recordRef),
+ _probeCommand(probeCommand), probeName(std::move(probeName)), scan(scanPtr)
{}
PerformProbe::~PerformProbe()
{
FoundDevices foundDevs;
if (probe(_probeCommand, scan, foundDevs))
{
- _callback(foundDevs, scan->dbusProbeObjects);
+ scan->updateSystemConfiguration(recordRef, probeName, foundDevs,
+ scan->dbusProbeObjects);
}
}
diff --git a/src/PerformScan.cpp b/src/PerformScan.cpp
index 47b96f8..c81557f 100644
--- a/src/PerformScan.cpp
+++ b/src/PerformScan.cpp
@@ -625,13 +625,7 @@
// destroyed too early
auto thisRef = shared_from_this();
auto probePointer = std::make_shared<PerformProbe>(
- probeCommand, thisRef,
- [thisRef, recordRef,
- probeName](FoundDevices& foundDevices,
- const MapperGetSubTreeResponse& dbusSubtree) {
- thisRef->updateSystemConfiguration(recordRef, probeName,
- foundDevices, dbusSubtree);
- });
+ recordRef, probeCommand, probeName, thisRef);
// parse out dbus probes by discarding other probe types, store in a
// map