xref: /openbmc/entity-manager/src/entity_manager/perform_probe.hpp (revision 60618a73e852a6671fce0e879e7eac532313ccdb)
1 #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 
11 namespace probe
12 {
13 struct CmpStr
14 {
operator ()probe::CmpStr15     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
22 enum class probe_type_codes
23 {
24     FALSE_T,
25     TRUE_T,
26     AND,
27     OR,
28     FOUND,
29     MATCH_ONE
30 };
31 
32 using FoundProbeTypeT = std::optional<probe_type_codes>;
33 
34 FoundProbeTypeT findProbeType(const std::string& probe);
35 
36 // this class finds the needed dbus fields and on destruction runs the probe
37 struct PerformProbe : std::enable_shared_from_this<PerformProbe>
38 {
39     PerformProbe(nlohmann::json& recordRef,
40                  const std::vector<std::string>& probeCommand,
41                  std::string probeName,
42                  std::shared_ptr<scan::PerformScan>& scanPtr);
43     virtual ~PerformProbe();
44 
45     nlohmann::json& recordRef;
46     std::vector<std::string> _probeCommand;
47     std::string probeName;
48     std::shared_ptr<scan::PerformScan> scan;
49 };
50 
51 } // namespace probe
52