1 #pragma once 2 3 #include <analyzer/callout.hpp> 4 #include <analyzer/guard.hpp> 5 #include <hei_main.hpp> 6 #include <nlohmann/json.hpp> 7 8 namespace analyzer 9 { 10 11 /** 12 * @brief Data regarding required service actions based on the hardware error 13 * analysis. 14 */ 15 class ServiceData 16 { 17 public: 18 /** 19 * @brief Constructor from components. 20 * @param The signature of the root cause attention. 21 * @param True if the signature list contained a system checkstop attention. 22 * False, otherwise. 23 */ 24 ServiceData(const libhei::Signature& i_rootCause, bool i_isCheckstop) : 25 iv_rootCause(i_rootCause), iv_isCheckstop(i_isCheckstop) 26 {} 27 28 /** @brief Destructor. */ 29 ~ServiceData() = default; 30 31 /** @brief Copy constructor. */ 32 ServiceData(const ServiceData&) = default; 33 34 /** @brief Assignment operator. */ 35 ServiceData& operator=(const ServiceData&) = default; 36 37 private: 38 /** The signature of the root cause attention. */ 39 const libhei::Signature iv_rootCause; 40 41 /** True if the signature list contained a system checkstop attention. 42 * False, otherwise. */ 43 const bool iv_isCheckstop; 44 45 /** The list of callouts that will be added to a PEL. */ 46 nlohmann::json iv_calloutList = nlohmann::json::array(); 47 48 /** The list of hardware guard requests. Some information will be added to 49 * the PEL, but the actual guard record will be created after submitting 50 * the PEL. */ 51 std::vector<Guard> iv_guardList; 52 53 public: 54 /** @return The signature of the root cause attention. */ 55 const libhei::Signature& getRootCause() const 56 { 57 return iv_rootCause; 58 } 59 60 /** @return True if the signature list contained a system checkstop 61 * attention. False, otherwise. */ 62 bool queryCheckstop() const 63 { 64 return iv_isCheckstop; 65 } 66 67 /** 68 * @brief Add callout information to the callout list. 69 * @param The JSON object for this callout. 70 */ 71 void addCallout(const nlohmann::json& i_callout) 72 { 73 iv_calloutList.push_back(i_callout); 74 } 75 76 /** 77 * @brief Add a guard request to the guard list. 78 * @param i_path Entity path for the target part. 79 * @param i_guard True, if the part should be guarded. False, otherwise. 80 */ 81 void addGuard(const std::string& i_path, bool i_guard) 82 { 83 Guard::Type guardType = Guard::Type::NONE; 84 if (i_guard) 85 { 86 // The guard type is dependent on the presence of a system checkstop 87 // attention. 88 guardType = 89 queryCheckstop() ? Guard::Type::FATAL : Guard::Type::NON_FATAL; 90 } 91 92 iv_guardList.emplace_back(i_path, guardType); 93 } 94 95 /** @brief Accessor to iv_calloutList. */ 96 const nlohmann::json& getCalloutList() const 97 { 98 return iv_calloutList; 99 } 100 101 /** @brief Accessor to iv_guardList. */ 102 const std::vector<Guard>& getGuardList() const 103 { 104 return iv_guardList; 105 } 106 }; 107 108 } // namespace analyzer 109