blob: f979c52f19dc92d3dbcb87ff3cd52b0b7ce8e859 [file] [log] [blame]
Christopher Meis26fbbd52025-03-26 14:55:06 +01001#pragma once
2
3#include "perform_scan.hpp"
4
5#include <boost/container/flat_map.hpp>
6
7#include <memory>
8#include <string>
9#include <vector>
10
11namespace probe
12{
13struct CmpStr
14{
15 bool operator()(const char* a, const char* b) const
16 {
17 return std::strcmp(a, b) < 0;
18 }
19};
20
21// underscore T for collison with dbus c api
22enum class probe_type_codes
23{
24 FALSE_T,
25 TRUE_T,
26 AND,
27 OR,
28 FOUND,
29 MATCH_ONE
30};
31
32using FoundProbeTypeT = std::optional<boost::container::flat_map<
33 const char*, probe_type_codes, CmpStr>::const_iterator>;
34
35FoundProbeTypeT findProbeType(const std::string& probe);
36
37// this class finds the needed dbus fields and on destruction runs the probe
38struct PerformProbe : std::enable_shared_from_this<PerformProbe>
39{
40 PerformProbe(nlohmann::json& recordRef,
41 const std::vector<std::string>& probeCommand,
42 std::string probeName,
43 std::shared_ptr<scan::PerformScan>& scanPtr);
44 virtual ~PerformProbe();
45
46 nlohmann::json& recordRef;
47 std::vector<std::string> _probeCommand;
48 std::string probeName;
49 std::shared_ptr<scan::PerformScan> scan;
50};
51
52} // namespace probe