Move root cause signature into service data object

This allows the analysis code to access the signature from the service
data object instead of passing around two variables in all of those
functions.

Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: Ib85386759068aee26dc1e8b9e8d609daf7e63c1b
diff --git a/analyzer/analyzer_main.cpp b/analyzer/analyzer_main.cpp
index 3cc1d65..c616f7e 100644
--- a/analyzer/analyzer_main.cpp
+++ b/analyzer/analyzer_main.cpp
@@ -29,12 +29,10 @@
 
 /**
  * @brief Will create and submit a PEL using the given data.
- * @param i_rootCause A signature defining the attention root cause.
  * @param i_isoData   The data gathered during isolation (for FFDC).
  * @param i_servData  Data regarding service actions gathered during analysis.
  */
-void createPel(const libhei::Signature& i_rootCause,
-               const libhei::IsolationData& i_isoData,
+void createPel(const libhei::IsolationData& i_isoData,
                const ServiceData& i_servData);
 
 //------------------------------------------------------------------------------
@@ -144,12 +142,12 @@
 
         // TODO: Perform service actions based on the root cause. The default
         // callout if none other exist is level 2 support.
-        ServiceData servData{};
+        ServiceData servData{rootCause};
         servData.addCallout(std::make_shared<ProcedureCallout>(
             ProcedureCallout::NEXTLVL, Callout::Priority::HIGH));
 
         // Create and commit a PEL.
-        createPel(rootCause, i_isoData, servData);
+        createPel(i_isoData, servData);
     }
 
     return attnFound;
diff --git a/analyzer/create_pel.cpp b/analyzer/create_pel.cpp
index 9295dca..36badb1 100644
--- a/analyzer/create_pel.cpp
+++ b/analyzer/create_pel.cpp
@@ -273,8 +273,7 @@
 
 //------------------------------------------------------------------------------
 
-void createPel(const libhei::Signature& i_rootCause,
-               const libhei::IsolationData& i_isoData,
+void createPel(const libhei::IsolationData& i_isoData,
                const ServiceData& i_servData)
 {
     // The message registry will require additional log data to fill in keywords
@@ -292,7 +291,7 @@
     bool isCheckstop = __isCheckstop(i_isoData);
 
     // Set words 6-9 of the SRC.
-    __setSrc(i_rootCause, logData);
+    __setSrc(i_servData.getRootCause(), logData);
 
     // Add the list of callouts to the PEL.
     __addCalloutList(i_servData, userDataFiles);
diff --git a/analyzer/service_data.hpp b/analyzer/service_data.hpp
index 560fc72..ffd0804 100644
--- a/analyzer/service_data.hpp
+++ b/analyzer/service_data.hpp
@@ -1,5 +1,6 @@
 #pragma once
 
+#include <hei_main.hpp>
 #include <nlohmann/json.hpp>
 
 namespace analyzer
@@ -203,8 +204,13 @@
 class ServiceData
 {
   public:
-    /** @brief Default constructor. */
-    ServiceData() = default;
+    /**
+     * @brief Constructor from components.
+     * @param The signature of the root cause attention.
+     */
+    explicit ServiceData(const libhei::Signature& i_rootCause) :
+        iv_rootCause(i_rootCause)
+    {}
 
     /** @brief Destructor. */
     ~ServiceData() = default;
@@ -216,6 +222,9 @@
     ServiceData& operator=(const ServiceData&) = default;
 
   private:
+    /** The signature of the root cause attention. */
+    const libhei::Signature iv_rootCause;
+
     /** The list of callouts that will be added to a PEL. */
     std::vector<std::shared_ptr<Callout>> iv_calloutList;
 
@@ -225,6 +234,12 @@
     std::vector<std::shared_ptr<Guard>> iv_guardList;
 
   public:
+    /** @return The signature of the root cause attention. */
+    const libhei::Signature& getRootCause() const
+    {
+        return iv_rootCause;
+    }
+
     /** Add a callout to the list. */
     void addCallout(const std::shared_ptr<Callout>& i_callout)
     {
diff --git a/test/meson.build b/test/meson.build
index 676c518..9486773 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -15,8 +15,10 @@
 
 if gtest.found()
     foreach t : tests
-        test(t, executable(t.underscorify(), t + '.cpp', dependencies : gtest,
-             cpp_args : test_arg, include_directories : incdir))
+        test(t, executable(t.underscorify(), t + '.cpp',
+                           dependencies : [ libhei_dep, gtest ],
+                           cpp_args : test_arg,
+                           include_directories : incdir))
     endforeach
 
     test('ffdc_file_test',
diff --git a/test/service_data_test.cpp b/test/service_data_test.cpp
index 6939294..e181558 100644
--- a/test/service_data_test.cpp
+++ b/test/service_data_test.cpp
@@ -6,9 +6,13 @@
 
 using namespace analyzer;
 
-TEST(SericeData, TestSet1)
+TEST(ServiceData, TestSet1)
 {
-    ServiceData sd{};
+    libhei::Chip chip{"/proc0", 0xdeadbeef};
+    libhei::Signature rootCause{chip, 0xabcd, 0, 0,
+                                libhei::ATTN_TYPE_CHECKSTOP};
+
+    ServiceData sd{rootCause};
 
     sd.addCallout(std::make_shared<HardwareCallout>("Test location 1",
                                                     Callout::Priority::HIGH));