Flyweight improvements to various classes

The copy constructor is no longer a requirement for Flyweight objects.
Also, minor improvement to < and == operators.

Change-Id: I7bdbea6eb6ab253d3a895da93a625dadc0893533
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
diff --git a/src/isolator/hei_isolation_node.hpp b/src/isolator/hei_isolation_node.hpp
index 782ac7f..4cf44dd 100644
--- a/src/isolator/hei_isolation_node.hpp
+++ b/src/isolator/hei_isolation_node.hpp
@@ -48,24 +48,10 @@
     ~IsolationNode() = default;
 
   private:
-    // This is needed to allow the flyweights to use the copy constructor, but
-    // not allow it to be used in general.
-    friend class Flyweight<IsolationNode>;
+    /** @brief Copy constructor. */
+    IsolationNode(const IsolationNode&) = delete;
 
-    /**
-     * @brief Copy constructor.
-     *
-     * Needed by Flyweight class, but should not be allowed in general.
-     */
-    IsolationNode(const IsolationNode&) = default;
-
-    /**
-     * @brief Explicitly disables assignment operator.
-     *
-     * This is redundant since the compilier will implicitly delete this because
-     * of the constant instance variables, but helps communicate it is not
-     * allowed.
-     */
+    /** @brief Assignment operator. */
     IsolationNode& operator=(const IsolationNode&) = delete;
 
   private: // Instance variables
diff --git a/src/isolator/hei_isolator.cpp b/src/isolator/hei_isolator.cpp
index db5668e..e4266b0 100644
--- a/src/isolator/hei_isolator.cpp
+++ b/src/isolator/hei_isolator.cpp
@@ -37,15 +37,15 @@
 
     // Remove all of the IsolationNode objects stored in the flyweights. This
     // must be done before removing the HardwareRegister objects
-    Flyweight<IsolationNode>::getSingleton().clear();
+    Flyweight<const IsolationNode>::getSingleton().clear();
 
     // Must flush the hardware register cache before deleting any
     // HardwareRegister objects.
     HardwareRegister::flushAll();
 
     // Remove all of the HardwareRegister objects stored in the flyweights.
-    Flyweight<ScomRegister>::getSingleton().clear();
-    Flyweight<IdScomRegister>::getSingleton().clear();
+    Flyweight<const ScomRegister>::getSingleton().clear();
+    Flyweight<const IdScomRegister>::getSingleton().clear();
 }
 
 void Isolator::isolate(const std::vector<Chip>& i_chipList,
diff --git a/src/register/hei_hardware_register.hpp b/src/register/hei_hardware_register.hpp
index ae7480e..0f5ac61 100644
--- a/src/register/hei_hardware_register.hpp
+++ b/src/register/hei_hardware_register.hpp
@@ -100,22 +100,45 @@
     /** @brief Equals operator. */
     bool operator==(const HardwareRegister& i_r) const
     {
-        // Comparing register type and address should be sufficient.
-        return (getAddress() == i_r.getAddress()) &&
+        // In general, comparing the ID and instance should be enough. However,
+        // no error will be thrown when adding the register to the flyweights
+        // and any other field differs. Therfore all fields will be used and
+        // invalid duplicates will be found when adding the register pointers
+        // to the IsolationChip objects.
+        return (getAddress() == i_r.getAddress()) && (getId() == i_r.getId()) &&
+               (getInstance() == i_r.getInstance()) &&
                (getType() == i_r.getType());
     }
 
     /** @brief Less than operator. */
     bool operator<(const HardwareRegister& i_r) const
     {
-        // Comparing register type and address should be sufficient.
+        // In general, comparing the ID and instance should be enough. However,
+        // no error will be thrown when adding the register to the flyweights
+        // and any other field differs. Therfore all fields will be used and
+        // invalid duplicates will be found when adding the register pointers
+        // to the IsolationChip objects.
         if (getAddress() < i_r.getAddress())
         {
             return true;
         }
         else if (getAddress() == i_r.getAddress())
         {
-            return (getType() < i_r.getType());
+            if (getId() < i_r.getId())
+            {
+                return true;
+            }
+            else if (getId() == i_r.getId())
+            {
+                if (getInstance() < i_r.getInstance())
+                {
+                    return true;
+                }
+                else if (getInstance() == i_r.getInstance())
+                {
+                    return (getType() < i_r.getType());
+                }
+            }
         }
 
         return false;
diff --git a/src/register/hei_scom_register.hpp b/src/register/hei_scom_register.hpp
index 47a6852..040bd4f 100644
--- a/src/register/hei_scom_register.hpp
+++ b/src/register/hei_scom_register.hpp
@@ -33,24 +33,10 @@
     ~ScomRegister() = default;
 
   private:
-    // This is needed to allow the flyweights to use the copy constructor, but
-    // not allow it to be used in general.
-    friend class Flyweight<ScomRegister>;
+    /** @brief Copy constructor. */
+    ScomRegister(const ScomRegister&) = delete;
 
-    /**
-     * @brief Copy constructor.
-     *
-     * Needed by Flyweight class, but should not be allowed in general.
-     */
-    ScomRegister(const ScomRegister&) = default;
-
-    /**
-     * @brief Explicitly disables assignment operator.
-     *
-     * This is redundant since the compilier will implicitly delete this because
-     * of the constant instance variables, but helps communicate it is not
-     * allowed.
-     */
+    /** @brief Assignment operator. */
     ScomRegister& operator=(const ScomRegister&) = delete;
 
   public: // Accessor functions
@@ -112,24 +98,10 @@
     ~IdScomRegister() = default;
 
   private:
-    // This is needed to allow the flyweights to use the copy constructor, but
-    // not allow it to be used in general.
-    friend class Flyweight<IdScomRegister>;
+    /** @brief Copy constructor. */
+    IdScomRegister(const IdScomRegister&) = delete;
 
-    /**
-     * @brief Copy constructor.
-     *
-     * Needed by Flyweight class, but should not be allowed in general.
-     */
-    IdScomRegister(const IdScomRegister&) = default;
-
-    /**
-     * @brief Explicitly disables assignment operator.
-     *
-     * This is redundant since the compilier will implicitly delete this because
-     * of the constant instance variables, but helps communicate it is not
-     * allowed.
-     */
+    /** @brief Assignment operator. */
     IdScomRegister& operator=(const IdScomRegister&) = delete;
 
   public: // Accessor functions