11#include "sparta/log/MessageSource.hpp"
38 "Global pseudo-TreeNode capturing propagating messages from ANY TreeNode in the simulator")
40 untrackParentlessNode_(
this);
72 bool must_exist=
true) override final {
73 for(
auto& n : statics_->parentless_map_){
75 if(child_wptr.expired() ==
true){
78 std::shared_ptr<sparta::TreeNode> child = child_wptr.lock();
79 sparta_assert(child !=
nullptr,
"No null nodes (groups) should ever be added to the parentless_nodes list");
80 std::vector<const std::string*> idents = child->getIdentifiers();
81 for(
const std::string* ident_id : idents){
82 if(*ident_id == name){
88 if(
false == must_exist){
101 bool must_exist=
true) const override final {
102 for(
auto& n : statics_->parentless_map_){
104 if(child_wptr.expired() ==
true){
107 std::shared_ptr<sparta::TreeNode> child = child_wptr.lock();
108 sparta_assert(child !=
nullptr,
"No null nodes (groups) should ever be added to the parentless_nodes list");
109 std::vector<const std::string*> idents = child->getIdentifiers();
110 for(
const std::string* ident_id : idents){
111 if(*ident_id == name){
117 if(
false == must_exist){
131 std::vector<TreeNode*>& found,
132 std::vector<std::vector<std::string>>& replacements,
133 bool allow_private)
override final {
134 uint32_t num_found = 0;
135 for(
auto& n : statics_->parentless_map_){
137 if(child_wptr.expired() ==
true){
140 std::shared_ptr<TreeNode> child = child_wptr.lock();
141 std::vector<std::string> replaced;
143 if(child !=
nullptr){
144 if (allow_private || canSeeChild_(child.get()))
147 found.push_back(child.get());
148 replacements.push_back(replaced);
158 std::vector<const TreeNode*>& found,
159 std::vector<std::vector<std::string>>& replacements,
160 bool allow_private)
const override final {
161 uint32_t num_found = 0;
162 for(
auto& n : statics_->parentless_map_){
164 if(child_wptr.expired() ==
true){
167 std::shared_ptr<TreeNode> child = child_wptr.lock();
168 std::vector<std::string> replaced;
170 if(child !=
nullptr){
171 if (allow_private || canSeeChild_(child.get()))
174 found.push_back(child.get());
175 replacements.push_back(replaced);
187 virtual void onAddingChild_(
TreeNode*)
override final {
195 virtual void broadcastRegistrationForNotificationToChildren_(
const std::type_info& tinfo,
196 const std::vector<const std::string*>& name_ids,
199 const bool private_only)
override final {
201 for(
auto& n : statics_->parentless_map_){
203 if(child.expired() ==
false){
204 child.lock()->broadcastRegistrationForNotificationToChildren_(tinfo, name_ids, obs_node, del, private_only);
211 virtual void broadcastDeregistrationForNotificationToChildren_(
const std::type_info& tinfo,
212 const std::vector<const std::string*>& name_ids,
215 const bool private_only)
override final {
217 for(
auto& n : statics_->parentless_map_){
219 if(child.expired() ==
false){
220 child.lock()->broadcastDeregistrationForNotificationToChildren_(tinfo, name_ids, obs_node, del, private_only);
227 virtual bool canGenerateNotification_(
const std::type_info&,
229 const std::string*&)
const override final {
#define sparta_assert(...)
Simple variadic assertion that will throw a sparta_exception if the condition fails.
Basic Node framework in sparta device tree composite pattern.
void setPhase_(TreePhase phase)
Sets the current phase.
@ TREE_TEARDOWN
Simulation is complete. Tree and all resources are now allowed to be deleted (phase does not imply th...
Used to construct and throw a standard C++ exception. Inherits from std::exception.
Node in a composite tree representing a sparta Tree item.
static constexpr char NODE_NAME_VIRTUAL_GLOBAL[]
Node name for the virtual glopbal node.
std::weak_ptr< TreeNode > WeakPtr
Weak pointer to a TreeNode. Acquire with getWeakPtr.
std::string getLocation() const override final
TreeNode()=delete
Not default-constructable.
static bool identityMatchesPattern_(const std::string &ident, std::regex &expr, std::vector< std::string > &replacements)
Performs pattern matching on a identity string.
Virtual global node for all device trees in a single simulation. This node acts a potential notificat...
static VirtualGlobalTreeNode * getInstance()
Gets the virtual global node singleton. This is the same object as TreeNode::getVirtualGlobalNode but...
virtual const TreeNode * getImmediateChildByIdentity_(const std::string &name, bool must_exist=true) const override final
virtual uint32_t findImmediateChildren_(std::regex &expr, std::vector< const TreeNode * > &found, std::vector< std::vector< std::string > > &replacements, bool allow_private) const override final
Const-qualified variant of findImmediateChildren_.
VirtualGlobalTreeNode()
Constructor.
virtual bool isAttached() const override final
Is this node part of a device tree with a proper RootTreeNode at the root.
virtual uint32_t findImmediateChildren_(std::regex &expr, std::vector< TreeNode * > &found, std::vector< std::vector< std::string > > &replacements, bool allow_private) override final
Finds immediate children with some identity (name or alias) matching a regex.
virtual TreeNode * getImmediateChildByIdentity_(const std::string &name, bool must_exist=true) override final
Attempts to get a single child by its unique local identity (name or alias)
virtual TreeNode * getParent() override final
Gets immediate parent of this node if one exists.
~VirtualGlobalTreeNode()
Destructor.
Macros for handling exponential backoff.