HardwareRegister operators for polymorphic comparison

Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
Change-Id: Ieff84b08203c8f317958abc121c9a053e33d415e
diff --git a/src/isolator/hei_isolator.cpp b/src/isolator/hei_isolator.cpp
index 404a367..becd1b1 100644
--- a/src/isolator/hei_isolator.cpp
+++ b/src/isolator/hei_isolator.cpp
@@ -1,8 +1,12 @@
 
 #include <isolator/hei_isolator.hpp>
-#include <register/hei_scom_register.hpp>
+#include <register/hei_hardware_register.hpp>
 #include <util/hei_flyweight.hpp>
 
+// BEGIN temporary code
+#include <register/hei_scom_register.hpp>
+// END temporary code
+
 namespace libhei
 {
 
diff --git a/src/register/hei_hardware_register.hpp b/src/register/hei_hardware_register.hpp
index a0ce387..ead7b16 100755
--- a/src/register/hei_hardware_register.hpp
+++ b/src/register/hei_hardware_register.hpp
@@ -99,6 +99,40 @@
     /** @return The size (in bytes) of this register. */
     virtual size_t getSize() const = 0;
 
+  public: // Operators
+
+    /** @brief Equals operator. */
+    bool operator==( const HardwareRegister & i_r ) const
+    {
+        // Comparing register type, chip type, and address should be sufficient.
+        return ( getRegisterType() == i_r.getRegisterType() ) &&
+               ( getChipType()     == i_r.getChipType()     ) &&
+               ( getAddress()      == i_r.getAddress()      );
+    }
+
+    /** @brief Less than operator. */
+    bool operator<( const HardwareRegister & i_r ) const
+    {
+        // Comparing register type, chip type, and address should be sufficient.
+        if ( getRegisterType() < i_r.getRegisterType() )
+        {
+            return true;
+        }
+        else if ( getRegisterType() == i_r.getRegisterType() )
+        {
+            if ( getChipType() < i_r.getChipType() )
+            {
+                return true;
+            }
+            else if ( getChipType() == i_r.getChipType() )
+            {
+                return ( getAddress() < i_r.getAddress() );
+            }
+        }
+
+        return false;
+    }
+
   public:
 
     /** Function overloaded from parent Register class. */
diff --git a/src/register/hei_scom_register.hpp b/src/register/hei_scom_register.hpp
index bebfb26..04fd124 100644
--- a/src/register/hei_scom_register.hpp
+++ b/src/register/hei_scom_register.hpp
@@ -71,25 +71,6 @@
     /** Function overloaded from parent HardwareRegister class. */
     size_t getSize() const { return 8; }
 
-  public: // Operators
-
-    /** @brief Equals operator. */
-    bool operator==( const ScomRegister & i_r ) const
-    {
-        // Comparing address and chip type should be sufficient.
-        return ( getAddress()  == i_r.getAddress()  ) &&
-               ( getChipType() == i_r.getChipType() );
-    }
-
-    /** @brief Less than operator. */
-    bool operator<( const ScomRegister & i_r ) const
-    {
-        // Comparing address and chip type should be sufficient.
-        return (   getAddress()  <  i_r.getAddress()       ) ||
-               ( ( getAddress()  == i_r.getAddress()  ) &&
-                 ( getChipType() <  i_r.getChipType() )    );
-    }
-
   private: // Instance variables
 
     /** This register's address. */
@@ -169,25 +150,6 @@
     /** Function overloaded from parent HardwareRegister class. */
     size_t getSize() const { return 8; } // See note in class documentation.
 
-  public: // Operators
-
-    /** @brief Equals operator. */
-    bool operator==( const IdScomRegister & i_r ) const
-    {
-        // Comparing address and chip type should be sufficient.
-        return ( getAddress()  == i_r.getAddress()  ) &&
-               ( getChipType() == i_r.getChipType() );
-    }
-
-    /** @brief Less than operator. */
-    bool operator<( const IdScomRegister & i_r ) const
-    {
-        // Comparing address and chip type should be sufficient.
-        return (   getAddress()  <  i_r.getAddress()       ) ||
-               ( ( getAddress()  == i_r.getAddress()  ) &&
-                 ( getChipType() <  i_r.getChipType() )    );
-    }
-
   private: // Instance variables
 
     /** This register's address. */