blob: 44638be86ab174f7aa32d60c5c5f03b530683408 [file] [log] [blame]
Zane Shelley0b8368c2021-03-18 17:33:41 -05001#pragma once
2
3#include <analyzer/service_data.hpp>
4
5namespace analyzer
6{
7
8/** @brief An abstract class for service event resolutions. */
9class Resolution
10{
11 public:
12 /** @brief Pure virtual destructor. */
13 virtual ~Resolution() = 0;
14
15 public:
16 /**
17 * @brief Resolves the service actions required by this resolution.
18 * @param io_sd An object containing the service data collected during
19 * hardware error analysis.
20 */
21 virtual void resolve(ServiceData& io_sd) const = 0;
22};
23
24// Pure virtual destructor must be defined.
25inline Resolution::~Resolution() {}
26
27/** @brief Resolves a hardware callout service event. */
28class HardwareCalloutResolution : public Resolution
29{
30 public:
31 /**
32 * @brief Constructor from components.
33 * @param i_path The devtree path of a guardable unit relative to a
34 * chip. An empty string refers to the chip itself.
35 * @param i_priority The callout priority.
Zane Shelley2f921302021-08-09 13:23:25 -050036 * @param i_guard True, if guard is required. False, otherwise.
Zane Shelley0b8368c2021-03-18 17:33:41 -050037 */
38 HardwareCalloutResolution(const std::string& i_path,
Zane Shelleyc85716c2021-08-17 10:54:06 -050039 callout::Priority i_priority, bool i_guard) :
Zane Shelley0b8368c2021-03-18 17:33:41 -050040 iv_path(i_path),
41 iv_priority(i_priority), iv_guard(i_guard)
42 {}
43
44 private:
45 /** The devtree path of a guardable unit relative to a chip. An empty string
46 * refers to the chip itself. */
47 const std::string iv_path;
48
49 /** The callout priority. */
Zane Shelleyc85716c2021-08-17 10:54:06 -050050 const callout::Priority iv_priority;
Zane Shelley0b8368c2021-03-18 17:33:41 -050051
Zane Shelley2f921302021-08-09 13:23:25 -050052 /** True, if guard is required. False, otherwise. */
53 const bool iv_guard;
Zane Shelley0b8368c2021-03-18 17:33:41 -050054
55 public:
56 void resolve(ServiceData& io_sd) const override;
57};
58
59/** @brief Resolves a procedure callout service event. */
60class ProcedureCalloutResolution : public Resolution
61{
62 public:
63 /**
64 * @brief Constructor from components.
65 * @param i_procedure The procedure callout type.
66 * @param i_priority The callout priority.
67 */
Zane Shelleyc85716c2021-08-17 10:54:06 -050068 ProcedureCalloutResolution(const callout::Procedure& i_procedure,
69 const callout::Priority& i_priority) :
Zane Shelley0b8368c2021-03-18 17:33:41 -050070 iv_procedure(i_procedure),
71 iv_priority(i_priority)
72 {}
73
74 private:
75 /** The procedure callout type. */
Zane Shelleyc85716c2021-08-17 10:54:06 -050076 const callout::Procedure iv_procedure;
Zane Shelley0b8368c2021-03-18 17:33:41 -050077
78 /** The callout priority. */
Zane Shelleyc85716c2021-08-17 10:54:06 -050079 const callout::Priority iv_priority;
Zane Shelley0b8368c2021-03-18 17:33:41 -050080
81 public:
Zane Shelleyc85716c2021-08-17 10:54:06 -050082 void resolve(ServiceData& io_sd) const override;
Zane Shelley0b8368c2021-03-18 17:33:41 -050083};
84
85/**
Zane Shelley723fa232021-08-09 12:02:06 -050086 * @brief Contains a list of resolutions. This resolutions will be resolved the
87 * list in the order in which they were inputted into the constructor.
Zane Shelley0b8368c2021-03-18 17:33:41 -050088 */
Zane Shelley723fa232021-08-09 12:02:06 -050089class ResolutionList : public Resolution
Zane Shelley0b8368c2021-03-18 17:33:41 -050090{
91 public:
Zane Shelley723fa232021-08-09 12:02:06 -050092 /** @brief Default constructor. */
93 ResolutionList() = default;
Zane Shelley0b8368c2021-03-18 17:33:41 -050094
95 private:
Zane Shelley723fa232021-08-09 12:02:06 -050096 /** The resolution list. */
97 std::vector<std::shared_ptr<Resolution>> iv_list;
Zane Shelley0b8368c2021-03-18 17:33:41 -050098
99 public:
Zane Shelley723fa232021-08-09 12:02:06 -0500100 /**
101 * @brief Adds a new resolution to the end of the list.
102 * @param i_resolution The new resolution
103 */
104 void push(const std::shared_ptr<Resolution>& i_resolution)
105 {
106 iv_list.push_back(i_resolution);
107 }
108
109 // Overloaded from parent.
Zane Shelley0b8368c2021-03-18 17:33:41 -0500110 void resolve(ServiceData& io_sd) const override
111 {
Zane Shelley723fa232021-08-09 12:02:06 -0500112 for (const auto& e : iv_list)
113 {
114 e->resolve(io_sd);
115 }
Zane Shelley0b8368c2021-03-18 17:33:41 -0500116 }
117};
118
119} // namespace analyzer