1 #pragma once 2 3 #include <analyzer/service_data.hpp> 4 5 namespace analyzer 6 { 7 8 /** @brief An abstract class for service event resolutions. */ 9 class 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. 25 inline Resolution::~Resolution() {} 26 27 /** @brief Resolves a hardware callout service event. */ 28 class 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. 36 * @param i_guard True, if guard is required. False, otherwise. 37 */ 38 HardwareCalloutResolution(const std::string& i_path, 39 callout::Priority i_priority, bool i_guard) : 40 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. */ 50 const callout::Priority iv_priority; 51 52 /** True, if guard is required. False, otherwise. */ 53 const bool iv_guard; 54 55 public: 56 void resolve(ServiceData& io_sd) const override; 57 }; 58 59 /** @brief Resolves a clock callout service event. */ 60 class ClockCalloutResolution : public Resolution 61 { 62 public: 63 /** 64 * @brief Constructor from components. 65 * @param i_clockType The clock type. 66 * @param i_priority The callout priority. 67 * @param i_guard The guard type for this callout. 68 */ 69 ClockCalloutResolution(const callout::ClockType& i_clockType, 70 const callout::Priority& i_priority, bool i_guard) : 71 iv_clockType(i_clockType), 72 iv_priority(i_priority), iv_guard(i_guard) 73 {} 74 75 private: 76 /** The clock type. */ 77 const callout::ClockType iv_clockType; 78 79 /** The callout priority. */ 80 const callout::Priority iv_priority; 81 82 /** True, if guard is required. False, otherwise. */ 83 const bool iv_guard; 84 85 public: 86 void resolve(ServiceData& io_sd) const override; 87 }; 88 89 /** @brief Resolves a procedure callout service event. */ 90 class ProcedureCalloutResolution : public Resolution 91 { 92 public: 93 /** 94 * @brief Constructor from components. 95 * @param i_procedure The procedure callout type. 96 * @param i_priority The callout priority. 97 */ 98 ProcedureCalloutResolution(const callout::Procedure& i_procedure, 99 const callout::Priority& i_priority) : 100 iv_procedure(i_procedure), 101 iv_priority(i_priority) 102 {} 103 104 private: 105 /** The procedure callout type. */ 106 const callout::Procedure iv_procedure; 107 108 /** The callout priority. */ 109 const callout::Priority iv_priority; 110 111 public: 112 void resolve(ServiceData& io_sd) const override; 113 }; 114 115 /** 116 * @brief Contains a list of resolutions. This resolutions will be resolved the 117 * list in the order in which they were inputted into the constructor. 118 */ 119 class ResolutionList : public Resolution 120 { 121 public: 122 /** @brief Default constructor. */ 123 ResolutionList() = default; 124 125 private: 126 /** The resolution list. */ 127 std::vector<std::shared_ptr<Resolution>> iv_list; 128 129 public: 130 /** 131 * @brief Adds a new resolution to the end of the list. 132 * @param i_resolution The new resolution 133 */ 134 void push(const std::shared_ptr<Resolution>& i_resolution) 135 { 136 iv_list.push_back(i_resolution); 137 } 138 139 // Overloaded from parent. 140 void resolve(ServiceData& io_sd) const override 141 { 142 for (const auto& e : iv_list) 143 { 144 e->resolve(io_sd); 145 } 146 } 147 }; 148 149 } // namespace analyzer 150