Cleaned smart pointer aliases and node/reg/inst keys
Scoped the aliases within the classes requiring them. Made separate
aliases for pointers and constant pointers. Created node/register
key aliases.
Change-Id: Iaed5ed7955d781c77e5c294351851c1523c6e28e
Signed-off-by: Zane Shelley <zshelle@us.ibm.com>
diff --git a/src/register/hei_hardware_register.hpp b/src/register/hei_hardware_register.hpp
index f69e8a7..358cc8f 100644
--- a/src/register/hei_hardware_register.hpp
+++ b/src/register/hei_hardware_register.hpp
@@ -36,6 +36,12 @@
*/
class HardwareRegister : public Register
{
+ public: // Aliases
+ using Ptr = std::shared_ptr<HardwareRegister>;
+ using ConstPtr = std::shared_ptr<const HardwareRegister>;
+
+ using Key = std::pair<RegisterId_t, Instance_t>;
+
public:
/** @brief Pure virtual destructor. */
virtual ~HardwareRegister() = 0;
@@ -79,6 +85,12 @@
return iv_instance;
}
+ /** @return The register/instance key. */
+ Key getKey() const
+ {
+ return {iv_id, iv_instance};
+ }
+
/** @return True if given flag is enabled, false if disabled. */
bool queryAttrFlag(RegisterAttributeFlags_t i_flag) const
{
@@ -102,12 +114,12 @@
{
// 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
+ // and any other field differs. Therefore, 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());
+ (getType() == i_r.getType()) && (iv_flags == i_r.iv_flags);
}
/** @brief Less than operator. */
@@ -115,7 +127,7 @@
{
// 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
+ // and any other field differs. Therefore, 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())
@@ -136,7 +148,14 @@
}
else if (getInstance() == i_r.getInstance())
{
- return (getType() < i_r.getType());
+ if (getType() < i_r.getType())
+ {
+ return true;
+ }
+ else if (getType() == i_r.getType())
+ {
+ return (iv_flags < i_r.iv_flags);
+ }
}
}
}
@@ -293,7 +312,4 @@
}
};
-/** Pointer management for hardware registers. */
-using HardwareRegisterPtr = std::shared_ptr<const HardwareRegister>;
-
} // end namespace libhei
diff --git a/src/register/hei_register.hpp b/src/register/hei_register.hpp
index 7cc28eb..e0473aa 100644
--- a/src/register/hei_register.hpp
+++ b/src/register/hei_register.hpp
@@ -26,6 +26,10 @@
*/
class Register
{
+ public: // Aliases
+ using Ptr = std::shared_ptr<Register>;
+ using ConstPtr = std::shared_ptr<const Register>;
+
public:
/** @brief Pure virtual destructor. */
virtual ~Register() = 0;
@@ -44,7 +48,4 @@
// Pure virtual destructor must be defined.
inline Register::~Register() {}
-/** Pointer management for Register objects. */
-using RegisterPtr = std::shared_ptr<const Register>;
-
} // end namespace libhei