Change isolate() API to take list of chips

In order to avoid issues with the internal data structures of the
isolation code, we changed the isolate() API take a list of chips
instead of a single chip.

Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: I736d59ce1733cf6b582ece53447ef0c978846f50
diff --git a/src/chip_data/hei_chip_data.hpp b/src/chip_data/hei_chip_data.hpp
index a02987f..0e8bbc2 100644
--- a/src/chip_data/hei_chip_data.hpp
+++ b/src/chip_data/hei_chip_data.hpp
@@ -5,8 +5,4 @@
 namespace libhei
 {
 
-typedef uint32_t ChipType_t;
-
-static constexpr ChipType_t DEFAULT_CHIP_TYPE = 0;
-
 } //end namespace libhei
diff --git a/src/hei_chip.hpp b/src/hei_chip.hpp
new file mode 100644
index 0000000..394f51c
--- /dev/null
+++ b/src/hei_chip.hpp
@@ -0,0 +1,75 @@
+#pragma once
+
+#include <hei_types.hpp>
+
+namespace libhei
+{
+
+/**
+ * @brief This is a simple container for pointers to the user application chip
+ *        objects and the associated chip type.
+ */
+class Chip
+{
+  public: // Constructors, destructors, assignment, etc.
+
+    Chip() = default;
+
+    ~Chip() = default;
+
+    Chip( const Chip & ) = default;
+
+    Chip & operator=( const Chip & ) = default;
+
+    /**
+     * @brief Constructor.
+     * @param i_chip See description for iv_chip.
+     * @param i_type See description for iv_type.
+     */
+    Chip( void * i_chip, ChipType_t i_type ) :
+        iv_chip(i_chip), iv_type(i_type)
+    {}
+
+  public: // Accessors
+
+    void * getChip() const { return iv_chip; }
+
+    ChipType_t getType() const { return iv_type; }
+
+  public: // Operators
+
+    bool operator==( const Chip & r ) const
+    {
+        return (iv_chip == r.iv_chip) &&
+               (iv_type == r.iv_type);
+    }
+
+    bool operator<( const Chip & r ) const
+    {
+        return (  iv_chip <  r.iv_chip     ) ||
+               ( (iv_chip == r.iv_chip) &&
+                 (iv_type <  r.iv_type)    );
+    }
+
+  private:
+
+    /**
+     * The user application will provide pointers to user application objects
+     * that represent chips targeted for analysis. The isolator does not know
+     * anything about these objects nor how to use them. The pointers' only
+     * purpose is to eventually get passed back to the user application with
+     * information associated with each chip.
+     */
+    void * iv_chip = nullptr;
+
+    /**
+     * When doing analysis on a chip, the isolator will need to know the chip
+     * type in order to look up the correct information from the Chip Data
+     * Files.
+     */
+    ChipType_t iv_type = DEFAULT_CHIP_TYPE;
+
+}; // end class Chip
+
+} // end namespace libhei
+
diff --git a/src/hei_includes.hpp b/src/hei_includes.hpp
index ccf5ee6..c2675c0 100644
--- a/src/hei_includes.hpp
+++ b/src/hei_includes.hpp
@@ -8,10 +8,13 @@
 
 // Standard library includes
 #include <stdint.h>
+#include <vector>
 
 // External includes
 #include <hei_user_defines.hpp> // For HEI_ASSERT, HEI_INF, and HEI_ERR
 
 // Internal includes
+#include <hei_chip.hpp>
 #include <hei_return_code.hpp>
+#include <hei_types.hpp>
 
diff --git a/src/hei_isolation_data.hpp b/src/hei_isolation_data.hpp
index 66de234..0117ce5 100644
--- a/src/hei_isolation_data.hpp
+++ b/src/hei_isolation_data.hpp
@@ -1,28 +1,22 @@
 #pragma once
 
 #include <hei_includes.hpp>
-#include <chip_data/hei_chip_data.hpp>
 
 namespace libhei
 {
 
 /**
- * @brief Contain a list of all active hardware errors on a chip, the contents
- *        of any registers associated with the active errors, and any other data
- *        that can be useful for debug.
+ * @brief The main isolate() API is given a list of chips to analyze. This class
+ *        will contain a list of all active hardware errors found on those
+ *        chips, the contents of any registers associated with the active
+ *        errors, and any other data that can be useful for debug.
  */
 class IsolationData
 {
   public:
 
-    /**
-     * @brief Default constructor.
-     * @param i_chip     See iv_chip.
-     * @param i_chipType See iv_chipType.
-     */
-    IsolationData( void * i_chip, ChipType_t i_chipType ) :
-        iv_chip(i_chip), iv_chipType(i_chipType)
-    {}
+    /** @brief Default constructor. */
+    IsolationData() = default;
 
     /** @brief Destructor. */
     ~IsolationData() = default;
@@ -33,33 +27,11 @@
     /** @brief Assignment operator. */
     IsolationData & operator=( const IsolationData & ) = default;
 
-    /** @return The target chip pointer. */
-    void * getChip() const { return iv_chip; }
-
-    /** @return The target chip type. */
-    ChipType_t getChipType() const { return iv_chipType; }
-
     /** @brief Flushes the data to ensure a clean slate for next isolation. */
     void clear() {}
 
   private:
 
-    /**
-     * This is simply a pointer to a user application object that represents
-     * the target chip. The isolator does not know anything about this object
-     * nor how to use it. This parameter's only purpose is to eventually get
-     * passed back to the user application in a hardware access operation, which
-     * will be defined by the user application.
-     */
-    void * const iv_chip;
-
-    /**
-     * Each Chip Data File contains a unique chip type identifier. The user
-     * application will need to input this value so that the isolator will know
-     * which set of the isolation objects to reference.
-     */
-    const ChipType_t iv_chipType;
-
     // TODO: add error signature list and register dump.
 
 }; // end class IsolationData
diff --git a/src/hei_main.hpp b/src/hei_main.hpp
index 241b625..b0e5210 100644
--- a/src/hei_main.hpp
+++ b/src/hei_main.hpp
@@ -6,7 +6,7 @@
  *
  *  - Call initialize() for each necessary Chip Data File.
  *
- *  - Call isolate() for each chip that needs error isolation.
+ *  - Call isolate() for all chips that need error isolation.
  *
  *  - Once isolation is no longer needed, call uninitialize() to free up
  *    resources used for isolation.
@@ -80,23 +80,27 @@
 }
 
 /**
- * @brief Isolates all active hardware errors found on the given chip.
+ * @brief Isolates all active hardware errors found on the given list of chips.
  *
  * This functions requires initialize() to be called with the Chip Data File
- * corresponding to the given chip type.
+ * corresponding to the given chip types.
  *
- * @param o_isoData  This parameter will contain a reference to the target chip
- *                   and its chip type. The rest of the data in the object will
- *                   be flushed and then repopulated with a list of all active
- *                   hardware errors on this chip, the contents of any
- *                   registers associated with the active errors, and any
- *                   other data that can be useful for debug.
+ * @param i_chipList The list of all chips that need to be analyzed. Generally,
+ *                   this would include all processor and memory chips in the
+ *                   system.
+ *
+ * @param o_isoData  Initially, all data in the object will be flushed and then
+ *                   repopulated with a list of all active hardware errors found
+ *                   on the given list of chips, the contents of any registers
+ *                   associated with the active errors, and any other data that
+ *                   can be useful for debug.
  *
  * @return RC_SUCCESS or RC_CHIP_DATA_MISSING
  */
-inline ReturnCode isolate( IsolationData & o_isoData )
+inline ReturnCode isolate( const std::vector<Chip> & i_chipList,
+                           IsolationData & o_isoData )
 {
-    return Isolator::getSingleton().isolate( o_isoData );
+    return Isolator::getSingleton().isolate( i_chipList, o_isoData );
 }
 
 } // end namespace libhei
diff --git a/src/hei_types.hpp b/src/hei_types.hpp
new file mode 100644
index 0000000..4402bde
--- /dev/null
+++ b/src/hei_types.hpp
@@ -0,0 +1,29 @@
+/**
+ * @file hei_types.hpp
+ *
+ * This file contains simple types/enums used throughout all of the isolator
+ * code.
+ */
+
+#pragma once
+
+#include <stdint.h>
+
+namespace libhei
+{
+
+/**
+ * Each Chip Data File will contain a 32-bit number representing the type of
+ * chip characterized by the file. That value must also be provide by the user
+ * application for each chip used in isolation so the isolator will know which
+ * Chip Data File to reference.
+ */
+typedef uint32_t ChipType_t;
+
+/**
+ * This is used for error checking. If a chip type contains this value, it is
+ * not a valid chip type.
+ */
+static constexpr ChipType_t DEFAULT_CHIP_TYPE = 0;
+
+} // end namespace libhei
diff --git a/src/isolator/hei_isolator.cpp b/src/isolator/hei_isolator.cpp
index 64cfe3e..cbb6652 100644
--- a/src/isolator/hei_isolator.cpp
+++ b/src/isolator/hei_isolator.cpp
@@ -24,7 +24,8 @@
     // END temporary code
 }
 
-ReturnCode Isolator::isolate( IsolationData & o_isoData ) const
+ReturnCode Isolator::isolate( const std::vector<Chip> & i_chipList,
+                              IsolationData & o_isoData ) const
 {
     ReturnCode rc;
 
@@ -32,8 +33,11 @@
     o_isoData.clear();
 
     // BEGIN temporary code
-    HEI_INF( "Isolator::isolate(%p,%u)", o_isoData.getChip(),
-             o_isoData.getChipType() );
+    for ( auto const & chip : i_chipList )
+    {
+        HEI_INF( "Isolator::isolate(%p,%u)", chip.getChip(),
+                 chip.getType() );
+    }
     // END temporary code
 
     return rc;
diff --git a/src/isolator/hei_isolator.hpp b/src/isolator/hei_isolator.hpp
index 4687b4f..1cc29b7 100644
--- a/src/isolator/hei_isolator.hpp
+++ b/src/isolator/hei_isolator.hpp
@@ -2,7 +2,6 @@
 
 #include <hei_includes.hpp>
 #include <hei_isolation_data.hpp>
-#include <chip_data/hei_chip_data.hpp>
 
 namespace libhei
 {
@@ -15,8 +14,8 @@
  *  - Create a singleton instance of an Isolator object via getSingleton().
  *  - Use initialize() to input each necessary Chip Data File provided by the
  *    user application.
- *  - Call isolate() each time you want to find all active errors being
- *    reported by a chip.
+ *  - Call isolate() to find all active errors being reported by the given list
+ *    of chips.
  *  - Once isolation is no longer needed, use uninitialize() to free up
  *    internal resources.
  *
@@ -69,7 +68,8 @@
     void uninitialize();
 
     /** @brief See API wrapper description in hei_main.hpp. */
-    ReturnCode isolate( IsolationData & o_isoData ) const;
+    ReturnCode isolate( const std::vector<Chip> & i_chipList,
+                        IsolationData & o_isoData ) const;
 
   private:
 
diff --git a/test/simulator/hei_sim_main.cpp b/test/simulator/hei_sim_main.cpp
index b3291aa..46de629 100644
--- a/test/simulator/hei_sim_main.cpp
+++ b/test/simulator/hei_sim_main.cpp
@@ -2,18 +2,24 @@
 
 int main()
 {
+    using namespace libhei;
+
     void * buffer = nullptr;
     size_t sz_buffer = 0;
 
-    libhei::initialize( buffer, sz_buffer );
+    initialize( buffer, sz_buffer );
 
-    void * chip = nullptr;
-    libhei::ChipType_t chipType = 0;
-    libhei::IsolationData isoData { chip, chipType };
+    Chip c1, c2;
 
-    libhei::isolate( isoData );
+    std::vector<Chip> chipList;
+    chipList.push_back(c1);
+    chipList.push_back(c2);
 
-    libhei::uninitialize();
+    IsolationData isoData;
+
+    isolate( chipList, isoData );
+
+    uninitialize();
 
     return 0;
 }