Created ServiceData class for hardware analysis
This class will contain data for any service actions required during
analysis of the hardware errors.
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: I93f2c8113881510fff960f7428ee519e8a584938
diff --git a/analyzer/service_data.hpp b/analyzer/service_data.hpp
index 9c5e6fd..eff85d8 100644
--- a/analyzer/service_data.hpp
+++ b/analyzer/service_data.hpp
@@ -148,4 +148,50 @@
}
};
+/**
+ * @brief Data regarding required service actions based on the hardware error
+ * analysis.
+ */
+class ServiceData
+{
+ public:
+ /** @brief Default constructor. */
+ ServiceData() = default;
+
+ /** @brief Destructor. */
+ ~ServiceData() = default;
+
+ /** @brief Copy constructor. */
+ ServiceData(const ServiceData&) = default;
+
+ /** @brief Assignment operator. */
+ ServiceData& operator=(const ServiceData&) = default;
+
+ private:
+ /** The list of callouts that will be added to a PEL. */
+ std::vector<std::shared_ptr<Callout>> iv_calloutList;
+
+ public:
+ /** Add a callout to the callout list. */
+ void addCallout(const std::shared_ptr<Callout>& i_callout)
+ {
+ iv_calloutList.push_back(i_callout);
+ }
+
+ /**
+ * @brief Iterates the callout list and returns the json attached to each
+ * callout in the list.
+ * @param o_json The returned json data.
+ */
+ void getCalloutList(nlohmann::json& o_json) const
+ {
+ o_json.clear(); // Ensure we are starting with a clean list.
+
+ for (const auto& c : iv_calloutList)
+ {
+ c->getJson(o_json);
+ }
+ }
+};
+
} // namespace analyzer
diff --git a/test/service_data_test.cpp b/test/service_data_test.cpp
index 4f8505e..6939294 100644
--- a/test/service_data_test.cpp
+++ b/test/service_data_test.cpp
@@ -8,15 +8,17 @@
TEST(SericeData, TestSet1)
{
- HardwareCallout c1{"Test location 1", Callout::Priority::HIGH};
- HardwareCallout c2{"Test location 2", Callout::Priority::MED_A};
- ProcedureCallout c3{ProcedureCallout::NEXTLVL, Callout::Priority::LOW};
+ ServiceData sd{};
+
+ sd.addCallout(std::make_shared<HardwareCallout>("Test location 1",
+ Callout::Priority::HIGH));
+ sd.addCallout(std::make_shared<HardwareCallout>("Test location 2",
+ Callout::Priority::MED_A));
+ sd.addCallout(std::make_shared<ProcedureCallout>(ProcedureCallout::NEXTLVL,
+ Callout::Priority::LOW));
nlohmann::json j{};
-
- c1.getJson(j);
- c2.getJson(j);
- c3.getJson(j);
+ sd.getCalloutList(j);
// Create a RAW string containing what we should expect in the JSON output.
std::string s = R"([