1 #pragma once
2 
3 #include <analyzer/analyzer_main.hpp>
4 #include <analyzer/callout.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 The type of analysis to perform.
22      */
23     ServiceData(const libhei::Signature& i_rootCause,
24                 AnalysisType i_analysisType) :
25         iv_rootCause(i_rootCause),
26         iv_analysisType(i_analysisType)
27     {}
28 
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:
39     /** The signature of the root cause attention. */
40     const libhei::Signature iv_rootCause;
41 
42     /** The type of analysis to perform. */
43     const AnalysisType iv_analysisType;
44 
45     /** The list of callouts that will be added to a PEL. */
46     nlohmann::json iv_calloutList = nlohmann::json::array();
47 
48     /** 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 
52   public:
53     /** @return The signature of the root cause attention. */
54     const libhei::Signature& getRootCause() const
55     {
56         return iv_rootCause;
57     }
58 
59     /** @return The type of analysis to perform. */
60     AnalysisType getAnalysisType() const
61     {
62         return iv_analysisType;
63     }
64 
65     /** @return Returns the guard type based on current analysis policies. */
66     callout::GuardType queryGuardPolicy() const
67     {
68         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         }
76 
77         return callout::GuardType::NONE;
78     }
79 
80     /**
81      * @brief Add callout information to the callout list.
82      * @param The JSON object for this callout.
83      */
84     void addCallout(const nlohmann::json& i_callout);
85 
86     /**
87      * @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 
96     /** @brief Accessor to iv_calloutList. */
97     const nlohmann::json& getCalloutList() const
98     {
99         return iv_calloutList;
100     }
101 
102     /** @brief Accessor to iv_calloutFFDC. */
103     const nlohmann::json& getCalloutFFDC() const
104     {
105         return iv_calloutFFDC;
106     }
107 };
108 
109 } // namespace analyzer
110