Set guard policy based on analysis type

Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: I38d0a84c3f890635b102efd8315a5c180a451047
diff --git a/analyzer/analyzer_main.cpp b/analyzer/analyzer_main.cpp
index 3be26bc..55726bd 100644
--- a/analyzer/analyzer_main.cpp
+++ b/analyzer/analyzer_main.cpp
@@ -149,7 +149,7 @@
         }
 
         // Start building the service data.
-        ServiceData servData{rootCause, isoData.queryCheckstop()};
+        ServiceData servData{rootCause, i_type};
 
         // Apply any service actions, if needed. Note that there are no
         // resolutions for manual analysis.
diff --git a/analyzer/service_data.hpp b/analyzer/service_data.hpp
index 1ce991e..0f9cac5 100644
--- a/analyzer/service_data.hpp
+++ b/analyzer/service_data.hpp
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <analyzer/analyzer_main.hpp>
 #include <analyzer/callout.hpp>
 #include <hei_main.hpp>
 #include <nlohmann/json.hpp>
@@ -17,11 +18,12 @@
     /**
      * @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.
+     * @param The type of analysis to perform.
      */
-    ServiceData(const libhei::Signature& i_rootCause, bool i_isCheckstop) :
-        iv_rootCause(i_rootCause), iv_isCheckstop(i_isCheckstop)
+    ServiceData(const libhei::Signature& i_rootCause,
+                AnalysisType i_analysisType) :
+        iv_rootCause(i_rootCause),
+        iv_analysisType(i_analysisType)
     {}
 
     /** @brief Destructor. */
@@ -37,9 +39,8 @@
     /** 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 type of analysis to perform. */
+    const AnalysisType iv_analysisType;
 
     /** The list of callouts that will be added to a PEL. */
     nlohmann::json iv_calloutList = nlohmann::json::array();
@@ -55,23 +56,25 @@
         return iv_rootCause;
     }
 
-    /** @return True if the signature list contained a system checkstop
-     *          attention. False, otherwise. */
-    bool queryCheckstop() const
+    /** @return The type of analysis to perform. */
+    AnalysisType getAnalysisType() const
     {
-        return iv_isCheckstop;
+        return iv_analysisType;
     }
 
     /** @return Returns the guard type based on current analysis policies. */
     callout::GuardType queryGuardPolicy() const
     {
-        // TODO: Manual execution of the analyzer (i.e. from the command line),
-        //       will eventually require the ability to not guard. This is
-        //       useful when we simply want to check for attentions in the
-        //       hardware with no service action.
+        if (AnalysisType::SYSTEM_CHECKSTOP == iv_analysisType)
+        {
+            return callout::GuardType::UNRECOVERABLE;
+        }
+        else if (AnalysisType::TERMINATE_IMMEDIATE == iv_analysisType)
+        {
+            return callout::GuardType::PREDICTIVE;
+        }
 
-        return queryCheckstop() ? callout::GuardType::UNRECOVERABLE
-                                : callout::GuardType::PREDICTIVE;
+        return callout::GuardType::NONE;
     }
 
     /**
diff --git a/test/resolution_test.cpp b/test/resolution_test.cpp
index 7738a27..4063bcb 100644
--- a/test/resolution_test.cpp
+++ b/test/resolution_test.cpp
@@ -1,5 +1,6 @@
 #include <stdio.h>
 
+#include <analyzer/analyzer_main.hpp>
 #include <analyzer/resolution.hpp>
 #include <util/trace.hpp>
 
@@ -297,8 +298,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, true};
-    ServiceData sd2{sig, false};
+    ServiceData sd1{sig, AnalysisType::SYSTEM_CHECKSTOP};
+    ServiceData sd2{sig, AnalysisType::TERMINATE_IMMEDIATE};
 
     // Resolve
     l1->resolve(sd1);
@@ -356,7 +357,7 @@
 
     libhei::Chip chip{chip_str, 0xdeadbeef};
     libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
-    ServiceData sd{sig, true};
+    ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP};
 
     c1->resolve(sd);
 
@@ -403,7 +404,7 @@
 
     libhei::Chip chip{chip_str, 0xdeadbeef};
     libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
-    ServiceData sd{sig, true};
+    ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP};
 
     nlohmann::json j{};
     std::string s{};
@@ -483,7 +484,7 @@
 
     libhei::Chip chip{chip_str, 0xdeadbeef};
     libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
-    ServiceData sd{sig, true};
+    ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP};
 
     nlohmann::json j{};
     std::string s{};
@@ -555,7 +556,7 @@
 
     libhei::Chip chip{chip_str, 0xdeadbeef};
     libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
-    ServiceData sd{sig, true};
+    ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP};
 
     c1->resolve(sd);
 
@@ -593,7 +594,7 @@
 
     libhei::Chip chip{chip_str, 0xdeadbeef};
     libhei::Signature sig{chip, 0xabcd, 0, 0, libhei::ATTN_TYPE_CHECKSTOP};
-    ServiceData sd{sig, true};
+    ServiceData sd{sig, AnalysisType::SYSTEM_CHECKSTOP};
 
     c1->resolve(sd);