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/isolator/hei_isolation_node.hpp b/src/isolator/hei_isolation_node.hpp
index 4fc5927..26424cc 100644
--- a/src/isolator/hei_isolation_node.hpp
+++ b/src/isolator/hei_isolation_node.hpp
@@ -39,6 +39,12 @@
*/
class IsolationNode
{
+ public: // Aliases
+ using Ptr = std::shared_ptr<IsolationNode>;
+ using ConstPtr = std::shared_ptr<const IsolationNode>;
+
+ using Key = std::pair<NodeId_t, Instance_t>;
+
public: // Constructors, destructor, assignment
/**
* @brief Constructor from components.
@@ -52,7 +58,6 @@
/** @brief Destructor. */
~IsolationNode() = default;
- private:
/** @brief Copy constructor. */
IsolationNode(const IsolationNode&) = delete;
@@ -76,14 +81,13 @@
* HardwareRegister objects and virtual operator registers (all children
* of the Register class).
*/
- std::map<AttentionType_t, const RegisterPtr> iv_rules;
+ std::map<AttentionType_t, const Register::ConstPtr> iv_rules;
/**
* Each bit (key) in this map indicates that an attention was driven from
* another register (value).
*/
- std::map<BitPosition_t, const std::shared_ptr<const IsolationNode>>
- iv_children;
+ std::map<BitPosition_t, const ConstPtr> iv_children;
public: // Member functions
/**
@@ -113,7 +117,7 @@
* @param The target attention type.
* @param The rule for this attention type.
*/
- void addRule(AttentionType_t i_attnType, RegisterPtr i_rule);
+ void addRule(AttentionType_t i_attnType, Register::ConstPtr i_rule);
/**
* @brief Adds a child node to analyze for the given bit position in this
@@ -125,8 +129,7 @@
* @param The target bit on this node.
* @param The child node to analyze for the given bit.
*/
- void addChild(BitPosition_t i_bit,
- std::shared_ptr<const IsolationNode> i_child);
+ void addChild(BitPosition_t i_bit, ConstPtr i_child);
/** @return The node ID. */
NodeId_t getId() const
@@ -140,6 +143,12 @@
return iv_instance;
}
+ /** @return The node/instance key. */
+ Key getKey() const
+ {
+ return {iv_id, iv_instance};
+ }
+
private: // Isolation stack and supporting functions.
/** When analyze() is called at the tree root, all recursive calls to
* analyze() will target the same chip and attention type. So we only need
@@ -153,7 +162,7 @@
* this node can be popped off the top of the stack. Once all the recursive
* calls have returned back to the root node the stack should be empty.
*/
- static std::vector<std::shared_ptr<const IsolationNode>> cv_isolationStack;
+ static std::vector<ConstPtr> cv_isolationStack;
/**
* @brief Pushes this node to the top of the stack. Will assert that this
@@ -168,7 +177,4 @@
}
};
-/** Pointer management for IsolationNode objects. */
-using IsolationNodePtr = std::shared_ptr<const IsolationNode>;
-
} // end namespace libhei