ServiceData class query for system checkstop

When managing resolutions, we'll need to know if a system checkstop has
occurred. This information can be retrieved from the isolation data, but
that object is not available to the resolutions. So storing it in the
service data as well.

Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: Icef801f09bdfa9591106c4889eea624d69f12057
diff --git a/analyzer/analyzer_main.cpp b/analyzer/analyzer_main.cpp
index 2485376..68babfe 100644
--- a/analyzer/analyzer_main.cpp
+++ b/analyzer/analyzer_main.cpp
@@ -162,7 +162,7 @@
 
         // Perform service actions based on the root cause.
         RasDataParser rasData{};
-        ServiceData servData{rootCause};
+        ServiceData servData{rootCause, isoData.queryCheckstop()};
         rasData.getResolution(rootCause)->resolve(servData);
 
         // Create and commit a PEL.
diff --git a/analyzer/create_pel.cpp b/analyzer/create_pel.cpp
index dd08051..e9835c5 100644
--- a/analyzer/create_pel.cpp
+++ b/analyzer/create_pel.cpp
@@ -40,19 +40,6 @@
 
 //------------------------------------------------------------------------------
 
-bool __isCheckstop(const libhei::IsolationData& i_isoData)
-{
-    // Look for any signature with a system checkstop attention.
-    auto list = i_isoData.getSignatureList();
-    auto itr  = std::find_if(list.begin(), list.end(), [](const auto& s) {
-        return libhei::ATTN_TYPE_CHECKSTOP == s.getAttnType();
-    });
-
-    return list.end() != itr;
-}
-
-//------------------------------------------------------------------------------
-
 void __getSrc(const libhei::Signature& i_signature, uint32_t& o_word6,
               uint32_t& o_word7, uint32_t& o_word8)
 {
@@ -291,7 +278,7 @@
 
     // In several cases, it is important to know if the reason for analysis was
     // due to a system checsktop.
-    bool isCheckstop = __isCheckstop(i_isoData);
+    bool isCheckstop = i_isoData.queryCheckstop();
 
     // Set words 6-9 of the SRC.
     __setSrc(i_servData.getRootCause(), logData);
diff --git a/analyzer/service_data.hpp b/analyzer/service_data.hpp
index 9f93bb9..66e0200 100644
--- a/analyzer/service_data.hpp
+++ b/analyzer/service_data.hpp
@@ -207,9 +207,11 @@
     /**
      * @brief Constructor from components.
      * @param The signature of the root cause attention.
+     * @param True if the signature list contained a system checkstop attention.
+     *        False, otherwise.
      */
-    explicit ServiceData(const libhei::Signature& i_rootCause) :
-        iv_rootCause(i_rootCause)
+    ServiceData(const libhei::Signature& i_rootCause, bool i_isCheckstop) :
+        iv_rootCause(i_rootCause), iv_isCheckstop(i_isCheckstop)
     {}
 
     /** @brief Destructor. */
@@ -225,6 +227,10 @@
     /** The signature of the root cause attention. */
     const libhei::Signature iv_rootCause;
 
+    /** True if the signature list contained a system checkstop attention.
+     *  False, otherwise. */
+    const bool iv_isCheckstop;
+
     /** The list of callouts that will be added to a PEL. */
     std::vector<std::shared_ptr<Callout>> iv_calloutList;
 
@@ -240,6 +246,13 @@
         return iv_rootCause;
     }
 
+    /** @return True if the signature list contained a system checkstop
+     *          attention. False, otherwise. */
+    bool queryCheckstop() const
+    {
+        return iv_isCheckstop;
+    }
+
     /** Add a callout to the list. */
     void addCallout(const std::shared_ptr<Callout>& i_callout)
     {
diff --git a/test/resolution_test.cpp b/test/resolution_test.cpp
index c2cb88c..f05997f 100644
--- a/test/resolution_test.cpp
+++ b/test/resolution_test.cpp
@@ -65,8 +65,8 @@
     // Get some ServiceData objects
     libhei::Chip chip{chip_str, 0xdeadbeef};
     libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
-    ServiceData sd1{sig};
-    ServiceData sd2{sig};
+    ServiceData sd1{sig, true};
+    ServiceData sd2{sig, false};
 
     // Resolve
     l1->resolve(sd1);
diff --git a/test/service_data_test.cpp b/test/service_data_test.cpp
index e181558..01f4556 100644
--- a/test/service_data_test.cpp
+++ b/test/service_data_test.cpp
@@ -12,7 +12,7 @@
     libhei::Signature rootCause{chip, 0xabcd, 0, 0,
                                 libhei::ATTN_TYPE_CHECKSTOP};
 
-    ServiceData sd{rootCause};
+    ServiceData sd{rootCause, true};
 
     sd.addCallout(std::make_shared<HardwareCallout>("Test location 1",
                                                     Callout::Priority::HIGH));