blob: 0f9cac535e6b3c20278f88cc4509e64e6ff8c0c7 [file] [log] [blame]
Zane Shelleyf685afd2021-02-15 15:39:44 -06001#pragma once
2
Zane Shelley82be3ab2021-12-07 10:36:08 -06003#include <analyzer/analyzer_main.hpp>
Zane Shelleyc85716c2021-08-17 10:54:06 -05004#include <analyzer/callout.hpp>
Zane Shelley8af9e462021-03-11 10:44:28 -06005#include <hei_main.hpp>
Zane Shelleyf685afd2021-02-15 15:39:44 -06006#include <nlohmann/json.hpp>
7
8namespace analyzer
9{
10
Zane Shelley64791cf2021-02-15 17:02:37 -060011/**
12 * @brief Data regarding required service actions based on the hardware error
13 * analysis.
14 */
15class ServiceData
16{
17 public:
Zane Shelley8af9e462021-03-11 10:44:28 -060018 /**
19 * @brief Constructor from components.
20 * @param The signature of the root cause attention.
Zane Shelley82be3ab2021-12-07 10:36:08 -060021 * @param The type of analysis to perform.
Zane Shelley8af9e462021-03-11 10:44:28 -060022 */
Zane Shelley82be3ab2021-12-07 10:36:08 -060023 ServiceData(const libhei::Signature& i_rootCause,
24 AnalysisType i_analysisType) :
25 iv_rootCause(i_rootCause),
26 iv_analysisType(i_analysisType)
Zane Shelley8af9e462021-03-11 10:44:28 -060027 {}
Zane Shelley64791cf2021-02-15 17:02:37 -060028
29 /** @brief Destructor. */
30 ~ServiceData() = default;
31
32 /** @brief Copy constructor. */
33 ServiceData(const ServiceData&) = default;
34
35 /** @brief Assignment operator. */
36 ServiceData& operator=(const ServiceData&) = default;
37
38 private:
Zane Shelley8af9e462021-03-11 10:44:28 -060039 /** The signature of the root cause attention. */
40 const libhei::Signature iv_rootCause;
41
Zane Shelley82be3ab2021-12-07 10:36:08 -060042 /** The type of analysis to perform. */
43 const AnalysisType iv_analysisType;
Zane Shelleyca496192021-08-09 12:05:52 -050044
Zane Shelley64791cf2021-02-15 17:02:37 -060045 /** The list of callouts that will be added to a PEL. */
Zane Shelleyc85716c2021-08-17 10:54:06 -050046 nlohmann::json iv_calloutList = nlohmann::json::array();
Zane Shelley64791cf2021-02-15 17:02:37 -060047
Zane Shelley2d114322021-08-25 17:06:12 -050048 /** FFDC for callouts that would otherwise not be available in the
49 * callout list (unit paths, bus types, etc.). */
50 nlohmann::json iv_calloutFFDC = nlohmann::json::array();
51
Zane Shelley64791cf2021-02-15 17:02:37 -060052 public:
Zane Shelley8af9e462021-03-11 10:44:28 -060053 /** @return The signature of the root cause attention. */
54 const libhei::Signature& getRootCause() const
55 {
56 return iv_rootCause;
57 }
58
Zane Shelley82be3ab2021-12-07 10:36:08 -060059 /** @return The type of analysis to perform. */
60 AnalysisType getAnalysisType() const
Zane Shelleyca496192021-08-09 12:05:52 -050061 {
Zane Shelley82be3ab2021-12-07 10:36:08 -060062 return iv_analysisType;
Zane Shelleyca496192021-08-09 12:05:52 -050063 }
64
Zane Shelleybf3326f2021-11-12 13:41:39 -060065 /** @return Returns the guard type based on current analysis policies. */
66 callout::GuardType queryGuardPolicy() const
67 {
Zane Shelley82be3ab2021-12-07 10:36:08 -060068 if (AnalysisType::SYSTEM_CHECKSTOP == iv_analysisType)
69 {
70 return callout::GuardType::UNRECOVERABLE;
71 }
72 else if (AnalysisType::TERMINATE_IMMEDIATE == iv_analysisType)
73 {
74 return callout::GuardType::PREDICTIVE;
75 }
Zane Shelleybf3326f2021-11-12 13:41:39 -060076
Zane Shelley82be3ab2021-12-07 10:36:08 -060077 return callout::GuardType::NONE;
Zane Shelleybf3326f2021-11-12 13:41:39 -060078 }
79
Zane Shelleyc85716c2021-08-17 10:54:06 -050080 /**
81 * @brief Add callout information to the callout list.
82 * @param The JSON object for this callout.
83 */
Zane Shelley979e2872021-09-20 22:46:06 -050084 void addCallout(const nlohmann::json& i_callout);
Zane Shelley64791cf2021-02-15 17:02:37 -060085
Zane Shelley95135822021-08-23 09:00:05 -050086 /**
Zane Shelley2d114322021-08-25 17:06:12 -050087 * @brief Add FFDC for a callout that would otherwise not be available in
88 * the callout list (unit paths, bus types, etc.).
89 * @param The JSON object for this callout.
90 */
91 void addCalloutFFDC(const nlohmann::json& i_ffdc)
92 {
93 iv_calloutFFDC.push_back(i_ffdc);
94 }
95
Zane Shelleyc85716c2021-08-17 10:54:06 -050096 /** @brief Accessor to iv_calloutList. */
97 const nlohmann::json& getCalloutList() const
Zane Shelley64791cf2021-02-15 17:02:37 -060098 {
Zane Shelleyc85716c2021-08-17 10:54:06 -050099 return iv_calloutList;
Zane Shelley64791cf2021-02-15 17:02:37 -0600100 }
Zane Shelley5f6e3de2021-02-23 13:57:37 -0600101
Zane Shelley2d114322021-08-25 17:06:12 -0500102 /** @brief Accessor to iv_calloutFFDC. */
103 const nlohmann::json& getCalloutFFDC() const
104 {
105 return iv_calloutFFDC;
106 }
Zane Shelley64791cf2021-02-15 17:02:37 -0600107};
108
Zane Shelleyf685afd2021-02-15 15:39:44 -0600109} // namespace analyzer