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