21#include <unordered_map>
32#include "sparta/utils/Utils.hpp"
36#include "sparta/utils/StringManager.hpp"
40class PostRunValidationInfo;
43#ifndef TREENODE_LIFETIME_TRACE
57#define ALPHANUM_CHARS \
58 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890_"
61#define DIGIT_CHARS "0123456789"
68#define RESERVED_WORDS {"and", "del", "from", "not", \
69 "while", "as", "elif", "global", \
70 "or", "with", "assert", "else", \
71 "if", "pass", "yield", "break", \
72 "except", "import", "print", "class", \
73 "exec", "in", "raise", "continue", \
74 "finally", "is", "return", "def", \
75 "for", "lambda", "try", "__init__", \
76 "__del__", "__cinit__", "__dealloc__", \
78 "name", "author", "report", "content", \
148#define REGISTER_FOR_NOTIFICATION(func, datat, name) \
149 registerForNotification<datat, \
150 typename std::remove_reference<decltype(*this)>::type, \
151 &std::remove_reference<decltype(*this)>::type::func>(this, name);
158#define DEREGISTER_FOR_NOTIFICATION(func, datat, name) \
159 deregisterForNotification<datat, \
160 typename std::remove_reference<decltype(*this)>::type, \
161 &std::remove_reference<decltype(*this)>::type::func>(this, name);
163#define NOTIFY(func, datat, name) \
173 class VirtualGlobalTreeNode;
175 class TreeNodePrivateAttorney;
178 class ExtensionDescriptor;
180 typedef std::vector<std::unique_ptr<ExtensionDescriptor>> ExtensionDescriptorVec;
281 typedef std::map<const std::string*, std::vector<TreeNode*>>
TagsMap;
435 <<
"TREE_CONFIGURING phase, so it cannot enter TREE_LOCKDOWN";
437 lockdownParametersUtil_();
440 static const std::map<const TreeNode*, WeakPtr>& getParentlessNodes();
573 const std::string& name,
574 const std::string& group,
576 const std::string& desc,
585 const std::string& name,
586 const std::string& group,
588 const std::string& desc);
595 const std::string& group,
597 const std::string& desc);
611 const std::string& name,
612 const std::string& desc);
627 const std::string& group,
629 const std::string& desc);
639 const std::string& desc);
703 void addTags(
const std::vector<std::string>& v);
723 virtual std::string
stringize(
bool pretty=
false)
const {
725 std::stringstream ss;
744 if(tags_.size() > 0){
747 for(
auto & tag : tags_){
839 const std::vector<const std::string*>&
getTags()
const;
844 bool hasTag(
const std::string& tag)
const;
853 bool hasTag(
const std::string* interned_tag_name)
const;
930 const std::string& group,
989 template <class T, typename = typename std::enable_if<std::is_pointer<T>::value>::type>
991 const T result =
dynamic_cast<const T
>(
getParent());
992 if(result ==
nullptr){
1003 template <class T, typename = typename std::enable_if<!std::is_pointer<T>::value>::type>
1004 const T*
getParentAs(
bool must_exist=
true)
const {
1005 return getParentAs<const T*>(must_exist);
1009 template <class T, typename = typename std::enable_if<std::is_pointer<T>::value>::type>
1011 T result =
dynamic_cast<T
>(
getParent());
1012 if(result ==
nullptr){
1014 throw SpartaException(
"Could not get parent of ")
1023 template <class T, typename = typename std::enable_if<!std::is_pointer<T>::value>::type>
1025 return getParentAs<T*>(must_exist);
1125 bool ignore_builtin_group=
true,
1126 bool ignore_anonymous_nodes=
true);
1138 uint32_t orig_size = results.size();
1141 if (
dynamic_cast<T*
>(child))
1143 results.emplace_back(
static_cast<T*
>(child));
1146 return results.size() - orig_size;
1180 template <
typename T>
1225 template<
typename T>
1228 static_assert(!std::is_pointer<T>::value && !std::is_reference<T>::value,
1229 "Expected a non-pointer/non-reference T template argument");
1270 bool ignore_builtin_group=
true)
const;
1318 std::vector<TreeNode*>& results);
1422 std::vector<TreeNode*>& results,
1423 std::vector<std::vector<std::string>>& replacements)
1425 return findChildren_(pattern, results, replacements,
false );
1432 std::vector<TreeNode*>& results)
1434 return findChildren_(pattern, results,
false );
1447 std::vector<TreeNode*>& found,
1448 std::vector<std::vector<std::string>>& replacements,
1449 bool allow_private=
false);
1455 std::vector<TreeNode*>& found,
1456 bool allow_private=
false);
1462 std::vector<const TreeNode*>& found,
1463 std::vector<std::vector<std::string>>& replacements,
1464 bool allow_private=
false)
const;
1471 std::vector<const TreeNode*>& found,
1472 bool allow_private=
false)
const;
1532 bool must_exist=
true)
1534 return getChild_(name, must_exist,
false );
1539 bool must_exist=
true)
const
1541 return getChild_(name, must_exist,
false );
1573 return hasChild_(name,
false );
1604 typename =
typename std::enable_if<std::is_pointer<T>::value>::type,
1605 class ConstT =
typename ptr_to_const_obj_ptr<T>::type>
1606 const ConstT
getChildAs(
const std::string& name,
bool must_exist=
true)
const {
1607 static_assert(std::is_base_of<TreeNode, typename std::remove_pointer<T>::type>::value ==
true,
1608 "Cannot use getChildAs with a type argument that is not a subclass of " \
1609 "TreeNode. If the caller is looking for a resource, use " \
1610 "getChild(name)->getResource instead.");
1612 const ConstT result =
dynamic_cast<ConstT
>(child);
1613 if(result ==
nullptr){
1616 <<
getLocation() <<
"\" with the relative path \""
1617 << name <<
"\" that was of type: const "
1618 <<
demangle(
typeid(T*).name()) <<
". Found node of type "
1619 <<
demangle(
typeid(*child).name());
1627 template <class T, typename = typename std::enable_if<!std::is_pointer<T>::value>::type>
1628 const T*
getChildAs(
const std::string& name,
bool must_exist=
true)
const {
1629 return getChildAs<const T*>(name, must_exist);
1633 template <class T, typename = typename std::enable_if<std::is_pointer<T>::value>::type>
1634 T
getChildAs(
const std::string& name,
bool must_exist=
true) {
1635 static_assert(std::is_base_of<TreeNode, typename std::remove_pointer<T>::type>::value ==
true,
1636 "Cannot use getChildAs with a type argument that is not a subclass of " \
1637 "TreeNode. If the caller is looking for a resource, use " \
1638 "getChild(name)->getResource instead.");
1640 T result =
dynamic_cast<T
>(child);
1641 if(result ==
nullptr){
1643 throw SpartaException(
"Could not find child of \"")
1644 <<
getLocation() <<
"\" with the relative path \""
1645 << name <<
"\" that was of type: " <<
demangle(
typeid(T).name())
1646 <<
". Found node of type "<<
demangle(
typeid(*child).name());
1654 template <class T, typename = typename std::enable_if<!std::is_pointer<T>::value>::type>
1655 T*
getChildAs(
const std::string& name,
bool must_exist=
true) {
1656 return getChildAs<T*>(name, must_exist);
1672 typename =
typename std::enable_if<std::is_pointer<T>::value>::type,
1673 class ConstT =
typename ptr_to_const_obj_ptr<T>::type>
1675 static_assert(std::is_base_of<TreeNode, typename std::remove_pointer<T>::type>::value ==
true,
1676 "Cannot use getAs with a type argument that is not a subclass of " \
1678 ConstT result =
dynamic_cast<typename ptr_to_const_obj_ptr<T>::type
>(
this);
1679 if(result ==
nullptr){
1696 template <class T, typename = typename std::enable_if<!std::is_pointer<T>::value>::type>
1698 return getAs<const T*>();
1711 template <class T, typename = typename std::enable_if<std::is_pointer<T>::value>::type>
1713 static_assert(std::is_base_of<TreeNode, typename std::remove_pointer<T>::type>::value ==
true,
1714 "Cannot use getAs with a type argument that is not a subclass of " \
1716 T result =
dynamic_cast<T
>(
this);
1717 if(result ==
nullptr){
1734 template <class T, typename = typename std::enable_if<!std::is_pointer<T>::value>::type>
1757 std::vector<TreeNode*>& results,
1758 int32_t max_depth=-1);
1774 int32_t max_depth=-1)
const;
1831 bool show_builtins=false,
1832 bool names_only=false,
1833 bool hide_hidden=false,
1834 bool(*leaf_filt_fxn)(const
TreeNode*) =
nullptr) const;
1853 template <typename T>
1855 uint32_t count =
dynamic_cast<const typename std::remove_const<typename std::remove_pointer<T>::type
>::type*>(
this) !=
nullptr;
1856 for(
auto& child : children_){
1857 count += child->getRecursiveNodeCount<T>();
1891 virtual void setParameters(std::unique_ptr<ParameterSet> params) = 0;
1894 virtual void postCreate() {}
1901 std::unique_ptr<ParameterSet> extension_params);
2002 incrementPrivacyLevel_(1);
2010 is_scope_root_ =
true;
2019 return is_scope_root_;
2035 return working_clock_;
2055 return working_clock_;
2227 void lockdownParametersUtil_(){
2228 for(
auto child : children_){
2229 child->lockdownParametersUtil_();
2231 special_params_lockdown_ =
true;
2248 static void trackParentlessNode_(
TreeNode* node);
2258 static void untrackParentlessNode_(
TreeNode* node);
2272 static void trackNode_(
TreeNode* node);
2295 static void untrackNode_(
TreeNode* node)
noexcept;
2304 void informAddedChildSubtree_();
2315 void informAddedChildAncestors_(
TreeNode* des);
2323 void incrementGetChildCount_(
const std::string& name)
const;
2356 virtual void setParent_(
TreeNode* parent,
bool inherit_phase);
2364 void addChild_(
TreeNode* child,
bool inherit_phase);
2395 void getLocation_(std::stringstream& ss,
bool anticipate_parent=
false)
const;
2401 void getDisplayLocation_(std::stringstream& ss)
const;
2418 uint32_t renderSubtree_(std::stringstream& ss,
2424 bool(*leaf_filt_fxn)(
const TreeNode*))
const;
2436 getImmediateChildByIdentity_(
const std::string& name,
2437 bool must_exist=
true)
2443 getImmediateChildByIdentity_(
const std::string& name,
2444 bool must_exist=
true)
2453 void ensureNoParent_(
const char* action);
2459 OneWayBool<false> special_params_lockdown_;
2476 std::vector<std::string>& replacements);
2514 size_t name_pos)
const;
2695 bool ignore_group_collision=false);
2747 return special_params_lockdown_;
2765 typedef void (*stub_type)(
void* obj,
2775 reveals_origin(
true)
2779 object_ptr(d.object_ptr),
2780 obs_point(d.obs_point),
2781 name_ptr(d.name_ptr),
2782 stub_ptr(d.stub_ptr),
2783 reveals_origin(d.reveals_origin)
2790 object_ptr = d.object_ptr;
2791 obs_point = d.obs_point;
2792 name_ptr = d.name_ptr;
2793 stub_ptr = d.stub_ptr;
2794 reveals_origin = d.reveals_origin;
2800 object_ptr(d.object_ptr),
2801 obs_point(d.obs_point),
2802 name_ptr(d.name_ptr),
2803 stub_ptr(d.stub_ptr),
2804 reveals_origin(d.reveals_origin)
2816 template <
class DataT,
class T, void (T::*TMethod)(const
TreeNode&,
2821 const std::string& name) const
2823 return (stub_ptr == &method_stub<DataT, T, TMethod>)
2824 && (obj == object_ptr)
2825 && (&obs_pt == obs_point)
2826 && (name == *name_ptr);
2829 template <
class DataT,
class T,
void (T::*TMethod)(const DataT&)>
2830 constexpr bool equals(T* obj,
2832 const std::string& name)
const
2834 return (stub_ptr == &method_stub<DataT, T, TMethod>)
2835 && (obj == object_ptr)
2836 && (&obs_pt == obs_point)
2837 && (name == *name_ptr);
2849 return (stub_ptr == d.stub_ptr)
2850 && (object_ptr == d.object_ptr)
2851 && (obs_point == d.obs_point)
2852 && (name_ptr == d.name_ptr);
2875 return (&obs_pt == obs_point)
2885 template <
class DataT,
class T, void (T::*TMethod)(const
TreeNode&,
2890 const std::string& name)
2894 d.obs_point = &obs_pt;
2896 d.stub_ptr = &method_stub<DataT, T, TMethod>;
2900 template <
class DataT,
class T,
void (T::*TMethod)(const DataT&)>
2903 const std::string& name)
2907 d.obs_point = &obs_pt;
2909 d.stub_ptr = &method_stub<DataT, T, TMethod>;
2910 d.reveals_origin =
false;
2917 template <
typename DataT>
2919 const DataT& data)
const
2921 (*stub_ptr)(object_ptr, origin, obs_point, &data);
2924 const std::string* getNameID()
const {
2928 const TreeNode* getObservationPoint()
const {
2932 bool revealsOrigin()
const {
return reveals_origin; }
2942 template <
class DataT,
class T, void (T::*TMethod)(const
TreeNode&,
2945 static void method_stub(void* obj,
2955 T* p =
static_cast<T*
>(obj);
2956 const DataT& d = *
static_cast<const DataT*
>(data);
2957 return (p->*TMethod)(origin, *obs_pt, d);
2960 template <
class DataT,
class T,
void (T::*TMethod)(const DataT&)>
2961 static void method_stub(
void* obj,
2968 T* p =
static_cast<T*
>(obj);
2969 const DataT& d = *
static_cast<const DataT*
>(data);
2970 return (p->*TMethod)(d);
2973 template <
class DataT, void (*TMethod)(
const TreeNode&,
2976 static void method_stub(
void* obj,
2982 const DataT& d = *
static_cast<const DataT*
>(data);
2983 return (*TMethod)(origin, *obs_pt, d);
2986 template <
class DataT,
void (*TMethod)(const DataT&)>
2987 static void method_stub(
void* obj,
2995 const DataT& d = *
static_cast<const DataT*
>(data);
2996 return (*TMethod)(d);
3014 const std::string* name_ptr;
3026 bool reveals_origin =
true;
3037 const std::type_info* tinfo_;
3046 hash_code_(rhp.hash_code_)
3051 hash_code_(tinfo.hash_code())
3055 return hash_code_ == rhp.hash_code_;
3059 return hash_code_ < rhp.hash_code_;
3062 const std::type_info& operator*()
const {
3066 const std::type_info* get()
const {
3090 template <
typename DataT>
3093 const std::string* name_id) {
3106 <<
"\", \"" << *name_id
3107 <<
"\"> which it did not properly announce through canGenerateNotification";
3110 propagateNotification_(origin, data, name_id);
3131 template <
typename DataT,
typename T, void (T::*TMethod)(const
TreeNode&,
3136 const std::string& target_name) {
3137 const DelegateVector::const_iterator dend = dvec.end();
3138 DelegateVector::iterator d;
3139 for(d=dvec.begin(); d!=dend; ++d){
3140 if(d->equals<DataT, T, TMethod>(obj, *
this, target_name)){
3148 template <
typename DataT,
typename T,
void (T::*TMethod)(const DataT&)>
3151 const std::string& target_name) {
3152 const DelegateVector::const_iterator dend = dvec.end();
3153 DelegateVector::iterator d;
3154 for(d=dvec.begin(); d!=dend; ++d){
3155 if(d->equals<DataT, T, TMethod>(obj, *
this, target_name)){
3185 const std::vector<const std::string*>& name_ids,
3188 const bool allow_private);
3204 const std::vector<const std::string*>& name_ids,
3207 const bool allow_private);
3215 const std::string& name,
3218 const bool private_only)
3231 const std::string& name,
3234 const bool private_only)
3249 template <
typename DataT>
3252 const std::string* name_id) {
3253 to_invoke->invokeDelegates_(
this, data, name_id);
3269 template <
typename DataT>
3270 void invokeDelegates_(
const TreeNode* origin,
3272 const std::string* name_id) {
3273 auto itr = obs_local_.find(
typeid(DataT));
3274 if(itr != obs_local_.end()){
3276 for(delegate& d : observers) {
3278 if(d.getNameID() == name_id
3304 template <
typename DataT>
3305 void propagateNotification_(
const TreeNode* origin,
3307 const std::string* name_id) {
3309 invokeDelegates_<DataT>(origin, data, name_id);
3312 getParent()->propagateNotification_(origin, data, name_id);
3336 const std::type_info* _tinfo,
3337 const std::string* _name) :
3443 template <
typename DataT=ANY_TYPE>
3445 const std::string& name=
"") {
3446 static_assert(std::is_same<
3447 typename std::remove_cv<
3448 typename std::remove_reference<
3449 typename std::remove_pointer<DataT>::type
3454 "DataT must NOT be a const, volatile, pointer, or reference"
3455 "type. It violates at least one of these restrictions");
3458 const std::string* name_id = strmgr.internString(name);
3459 return locateNotificationSources_<DataT>(nodes, name_id);
3469 template <
typename DataT=ANY_TYPE>
3471 std::vector<TreeNode*> nodes;
3472 locateNotificationSources<DataT>(nodes, name);
3474 o << n->stringize() << std::endl;
3520 const std::string* name)
const;
3532 const std::string& name)
const;
3567 const std::string* name)
const;
3579 const std::string& name)
const;
3586 const std::vector<const std::string*>& names)
const;
3670 template <
typename DataT,
typename T,
void (T::*TMethod)(const TreeNode&, const TreeNode&, const DataT&)>
3673 registerForNotification_<DataT, T, TMethod>(obj, name, ensure_possible,
false );
3677 template <
typename DataT,
typename T,
void (T::*TMethod)(const DataT&)>
3680 registerForNotification_<DataT, T, TMethod>(obj, name, ensure_possible,
false );
3692 template <
typename DataT,
typename T,
void (T::*TMethod)(const TreeNode&, const TreeNode&, const DataT&)>
3695 deregisterForNotification_<DataT, T, TMethod>(obj, name,
false );
3699 template <
typename DataT,
typename T,
void (T::*TMethod)(const DataT&)>
3702 deregisterForNotification_<DataT, T, TMethod>(obj, name,
false );
3713 const std::string* name)
const noexcept;
3725 const std::string* name,
3726 std::vector<delegate>& dels)
noexcept;
3735 const std::string* node_id);
3746 void incrementPrivacyLevel_(uint32_t privacy_increment)
3748 privacy_level_ += privacy_increment;
3749 for (
auto n : children_)
3751 n->incrementPrivacyLevel_(privacy_increment);
3775 virtual void onAddingChild_(
TreeNode* child) {
3803 virtual void onSettingParent_(
const TreeNode* parent)
const {
3825 virtual void onAddedAsChild_() noexcept {
3840 virtual void onDescendentSubtreeAdded_(
TreeNode* des)
noexcept {
3850 virtual void onDestroyingParent_() noexcept {
3860 virtual void onDestroyingChild_(
TreeNode* child)
noexcept {
3867 virtual void onConfiguring_() {;}
3872 virtual void onBindTreeEarly_() {;}
3877 virtual void onBindTreeLate_() {;}
3907 virtual void onEnteringTeardown_() noexcept {
3924 void addChildNameMapping_(
const std::string& name,
3931 template <
typename DataT>
3932 uint32_t locateNotificationSources_(std::vector<TreeNode*>& nodes,
const std::string* name_id){
3933 uint32_t additions = 0;
3935 const std::string* dummy;
3936 if(canGenerateNotification_(
typeid(DataT), name_id, dummy)){
3937 nodes.push_back(
this);
3942 additions += child->template locateNotificationSources_<DataT>(nodes, name_id);
3972 virtual void notificationObserverAdded_(
const std::type_info& tinfo,
3973 const std::string* name_id,
3975 const delegate* del) {
4001 virtual void notificationObserverRemoved_(
const std::type_info& tinfo,
4002 const std::string* name_id,
4004 const delegate* del) {
4039 virtual bool canGenerateNotification_(
const std::type_info& tinfo,
4040 const std::string* name,
4041 const std::string*& match)
const {
4059 virtual void getPossibleNotifications_(std::vector<NotificationInfo>& infos)
const {
4073 virtual void createResource_() {
4087 virtual void validateNode_()
const {
4097 bool canSeeChild_(
const TreeNode* node)
const
4101 return (privacy_level_ == node->privacy_level_);
4103 uint32_t findChildren_(
const std::string& pattern,
4104 std::vector<TreeNode*>& results,
4105 std::vector<std::vector<std::string>>& replacements,
4106 bool allow_private);
4111 uint32_t findChildren_(
const std::string& pattern,
4112 std::vector<TreeNode*>& results,
4113 bool allow_private);
4118 template <
typename DataT,
typename T,
void (T::*TMethod)(const TreeNode&, const TreeNode&, const DataT&)>
4119 void registerForNotification_(T* obj,
const std::string& name,
bool ensure_possible=
true,
bool allow_private=
false)
4121 (void)allow_private;
4122 const std::type_info& data_type =
typeid(DataT);
4124 throw SpartaException(
"Cannot registerForNotification for data type \"")
4125 <<
demangle(
typeid(DataT).name()) <<
"\" and name=\"" << name <<
"\" on node " <<
getLocation()
4126 <<
" with callback on \"" <<
demangle(
typeid(T).name()) <<
"\""
4127 <<
"\" because this notification cannot possibly be generated by any descendant of this "
4128 <<
"node. Set ensure_possible=false to prevent this check if additional notification "
4129 <<
"source descendants are expected to be added. "
4130 <<
"It is possible the node generating the desired notification is in a private sub tree.";
4134 if(findDelegate_<DataT, T, TMethod>(observers, obj, name) != observers.end()){
4135 throw SpartaException(
"Already observing a notification for data type \"")
4136 <<
demangle(
typeid(DataT).name()) <<
"\" Name \"" << name <<
"\" on node " <<
getLocation()
4137 <<
" with callback on \"" <<
demangle(
typeid(T).name()) <<
"\""
4138 <<
"\". Cannot register";
4141 delegate d = delegate::from_method<DataT, T, TMethod>(obj, *
this, name);
4142 observers.push_back(std::move(d));
4149 template <
typename DataT,
typename T,
void (T::*TMethod)(const DataT&)>
4150 void registerForNotification_(T* obj,
const std::string& name,
bool ensure_possible=
true,
const bool allow_private=
false)
4152 (void)allow_private;
4153 const std::type_info& data_type =
typeid(DataT);
4155 throw SpartaException(
"Cannot registerForNotification for data type \"")
4156 <<
demangle(
typeid(DataT).name()) <<
"\" and name=\"" << name <<
"\" on node " <<
getLocation()
4157 <<
" with callback on \"" <<
demangle(
typeid(T).name()) <<
"\""
4158 <<
"\" because this notification cannot possibly be generated by any descendant of this "
4159 <<
"node. Set ensure_possible=false to prevent this check if additional notification "
4160 <<
"source descendants are expected to be added. "
4161 <<
"It is possible the node generating the desired notification is in a private sub tree.";
4165 if(findDelegate_<DataT, T, TMethod>(observers, obj, name) != observers.end()){
4166 throw SpartaException(
"Already observing a notification for data type \"")
4167 <<
demangle(
typeid(DataT).name()) <<
"\" Name \"" << name <<
"\" on node " <<
getLocation()
4168 <<
" with callback on \"" <<
demangle(
typeid(T).name()) <<
"\""
4169 <<
"\". Cannot register";
4172 delegate d = delegate::from_method<DataT, T, TMethod>(obj, *
this, name);
4173 observers.push_back(std::move(d));
4183 template <
typename DataT,
typename T,
void (T::*TMethod)(const TreeNode&, const TreeNode&, const DataT&)>
4184 void deregisterForNotification_(T* obj,
const std::string& name,
const bool allow_private)
4186 (void)allow_private;
4187 const std::type_info& data_type =
typeid(DataT);
4188 auto itr = obs_local_.find(data_type);
4189 if(itr == obs_local_.end()){
4190 throw SpartaException(
"Not currently observing any notification for data type \"")
4191 <<
demangle(
typeid(DataT).name()) <<
"\" Name \"" << name <<
"\" on node " <<
getLocation()
4192 <<
" with callback on \"" <<
demangle(
typeid(T).name()) <<
"\" function \"" << TMethod
4193 <<
"\". Cannot deregister";
4196 DelegateVector::iterator d = findDelegate_<DataT, T, TMethod>(observers, obj, name);
4197 if(observers.end() == d){
4198 throw SpartaException(
"Not currently observing a notification for data type \"")
4199 <<
demangle(
typeid(DataT).name()) <<
"\" Name \"" << name <<
"\" on node " <<
getLocation()
4200 <<
" . Attempted to deregister \"" <<
demangle(
typeid(T).name()) <<
"\" function \"" << TMethod
4201 <<
"\". Cannot deregister";
4210 template <
typename DataT,
typename T,
void (T::*TMethod)(const DataT&)>
4211 void deregisterForNotification_(T* obj,
const std::string& name,
const bool allow_private)
4213 (void)allow_private;
4214 const std::type_info& data_type =
typeid(DataT);
4215 auto itr = obs_local_.find(data_type);
4216 if(itr == obs_local_.end()){
4217 throw SpartaException(
"Not currently observing any notification for data type \"")
4218 <<
demangle(
typeid(DataT).name()) <<
"\" Name \"" << name <<
"\" on node " <<
getLocation()
4219 <<
" with callback on \"" <<
demangle(
typeid(T).name()) <<
"\" function \"" << TMethod
4220 <<
"\". Cannot deregister";
4223 DelegateVector::iterator d = findDelegate_<DataT, T, TMethod>(observers, obj, name);
4224 if(observers.end() == d){
4225 throw SpartaException(
"Not currently observing a notification for data type \"")
4226 <<
demangle(
typeid(DataT).name()) <<
"\" Name \"" << name <<
"\" on node " <<
getLocation()
4227 <<
" . Attempted to deregister \"" <<
demangle(
typeid(T).name()) <<
"\" function \"" << TMethod
4228 <<
"\". Cannot deregister";
4248 template <
typename T> T *getScopeRootImpl_(T *node)
const;
4253 TreeNode* getChild_(
const std::string& name,
4258 const TreeNode* getChild_(
const std::string& name,
4260 bool private_also)
const;
4266 bool hasChild_(
const std::string& name,
bool private_also)
const noexcept;
4278 const std::string* name_;
4290 const bool is_indexable_;
4296 const std::string *
const group_ptr_;
4308 std::vector<const std::string*> tags_;
4313 const std::string *
const desc_ptr_;
4327 const std::string* parent_loc_;
4344 const Clock* clock_;
4352 const Clock* working_clock_;
4358 std::unordered_map<std::string, std::unique_ptr<ExtensionsBase>> extensions_;
4359 std::unordered_map<std::string, std::unique_ptr<ParameterSet>> extension_parameters_;
4360 std::unordered_map<std::string, std::function<ExtensionsBase*()>> extension_factories_;
4361 std::set<std::string> extension_names_;
4362 ExtensionDescriptorVec extension_descs_;
4372 mutable uint32_t num_children_finds_;
4379 mutable uint32_t num_children_gets_;
4475 uint32_t privacy_level_ = 0;
4488 bool is_scope_root_ =
false;
4496 class TreeNodeStatics {
4502 std::map<const TreeNode*, WeakPtr> parentless_map_;
4516 std::map<const TreeNode*, WeakPtr> node_map_;
4518 static TreeNodeStatics *statics_;
4530 static TagsMap global_tags_map_;
4536 static uint32_t teardown_errors_;
4540 template<
class Ch,
class Tr>
4541 inline std::basic_ostream<Ch,Tr>&
Contains a number of ArchData pointers.
Basic Node framework in sparta device tree composite pattern.
Helpers for printing and populating vectors.
Object with a name which holds a Resource.
Set of macros for Sparta assertions. Caught by the framework.
#define sparta_assert(...)
Simple variadic assertion that will throw a sparta_exception if the condition fails.
Exception class for all of Sparta.
Helpers for enforcing StaticInitialization order.
Container class for any number of ArchData pointers owned externally.
Manages building a clock tree.
A representation of simulated time.
Generic container of Parameters.
virtual bool isFinalizing() const
Is this node (and thus the entire tree above it) "finalized".
virtual bool isFinalized() const
Is this node (and thus the entire tree above it) "finalized".
TreePhase getPhase() const
Gets the trees current phase.
TreePhase
Current phase of tree construction (applies to node and entire tree).
@ TREE_CONFIGURING
Setting parameters, ports, and other pre-instantiation attributes. Hierarchy cannot be modified.
@ TREE_BUILDING
Setting up tree hierarchy only (initial state)
Information describing the type of validation being done.
PhasedObject which can hold 0 or 1 Resource pointers to an associatedresource. Contains logic for set...
const T getResourceAs() const
Gets the resource contained by this node (if any) as the given type.
virtual std::string getResourceTypeRaw() const
Gets the typename of the resource that this node will eventually contain.
A class that lets you schedule events now and in the future.
Used to construct and throw a standard C++ exception. Inherits from std::exception.
Static-initialization order controller.
static StringManager & getStringManager()
Returns the StringManager singleton.
const std::string *const EMPTY
Holds interned empty strings.
std::string * internString(const std::string &s)
Stores a string in shared space within this manager unless it is already stored.
Base class used to extend TreeNode parameter sets.
Temporary delegate for notificaiton invokation until the implementation is working....
delegate & operator=(const delegate &d)
void operator()(const TreeNode &origin, const DataT &data) const
Invokes the delegate.
bool operator==(const delegate &d) const
Compares all fields in this delegate against another delegate.
bool observes(const TreeNode &obs_pt, const std::string *name) const
Compares against another delegate based on the observation point and name ignoring delegate callback ...
static delegate from_method(T *obj, const TreeNode &obs_pt, const std::string &name)
Creates delegate with given properties.
constexpr bool equals(T *obj, const TreeNode &obs_pt, const std::string &name) const
Compares against another delegate's information based on DataT, T, TMethod, observer pointer,...
Container for std::type_info.
Node in a composite tree representing a sparta Tree item.
app::Simulation * getSimulation() const
Gets the simulation (if any) associated with this tree.
virtual void broadcastRegistrationForNotificationToChildren_(const std::type_info &tinfo, const std::vector< const std::string * > &name_ids, TreeNode *obs_node, const delegate *del, const bool allow_private)
Recursively notifies children that the notification described is now (or still is) being observed at ...
static const uint32_t RENDER_SUBTREE_INDENT
Spaces to indent for each tree level in sparta::TreeNode::renderSubtree.
std::map< type_info_container, DelegateVector > NotificationObserverMap
Map of delegate vectors containing all observers.
void addExtensionParameters(const std::string &extension_name, std::unique_ptr< ParameterSet > extension_params)
Add a named parameter set to extend this tree node's metadata.
static constexpr char NODE_NAME_VIRTUAL_GLOBAL[]
Node name for the virtual glopbal node.
uint32_t findImmediateChildren_(std::regex &expr, std::vector< TreeNode * > &found, bool allow_private=false)
Variant of findImmediateChildren_ with no replacements vector.
std::weak_ptr< TreeNode > WeakPtr
Weak pointer to a TreeNode. Acquire with getWeakPtr.
static const group_idx_type GROUP_IDX_NONE
GroupIndex indicating that a node has no group index because it belongs to no group.
node_uid_type getNodeUID() const
Gets the unique ID of this node.
bool hasObserversRegisteredForNotification(const std::type_info &tinfo, const std::string *name) const noexcept
Determines if this TreeNode (not descendants) has any observers for this type of event and name.
std::weak_ptr< const TreeNode > ConstWeakPtr
Weak pointer to a const TreeNode. Acquire with getWeakPtr.
ConstT getAs() const
Retrieves this node after casting to type T.
const std::vector< const std::string * > & getTags() const
Gets the set of tags associated with this TreeNode.
std::string getLocation() const override final
bool canGenerateNotification(const std::type_info &tinfo, const std::string &name) const
Can this TreeNode generate a notification of the given type having the given name (does not require i...
const Clock * getLocalClock()
Gets the clock associated directly with this Node. This is useful for configuration and simulator deb...
static std::string getNextName(const std::string &name, size_t &pos)
Gets the next name between two '.' chars in a string starting at pos.
virtual TreeNode * getRoot()
Gets farthest ancestor of this node.
static const node_uid_type MAX_NODE_UID
Maximum value of node_uid_ before the framework throws an exception.
void validateTree_()
Iterates the finalized tree and validates each node (e.g. ensures statistics can be evaluated)
virtual uint32_t findImmediateChildren_(std::regex &expr, std::vector< const TreeNode * > &found, std::vector< std::vector< std::string > > &replacements, bool allow_private=false) const
Const-qualified variant of findImmediateChildren_.
void detachFromChildren_()
Removes a node from its children with the expectation this node will be immediately destroyed (i....
static const std::string DEBUG_DUMP_SECTION_DIVIDER
String dividing sections in a debug dump file.
uint32_t getGroup(const std::string &group, std::vector< TreeNode * > &results)
Gets all nodes in a child group.
void dumpPossibleNotifications(std::ostream &o) const noexcept
Dumps a listing of the notifications which this node can generate to the ostream o.
static constexpr char NODE_NAME_NONE[]
Node name for anonymous node.
static bool hasWildcardCharacters(const std::string &name)
Determines if a given node name has any wildcard characters which will be substituted in createSearch...
static constexpr char GROUP_NAME_BUILTIN[]
Reserved name for built-in nodes.
const std::string & getDesc() const
Gets the description of this node.
TreeNode(TreeNode *parent, const std::string &name, const std::string &group, group_idx_type group_idx, const std::string &desc, bool is_indexable)
TreeNode full constructor. Initializes node and adds it as a child of an existing tree node (if paren...
void markHidden(bool hidden=true)
Marks this TreeNode hidden for the purposes of printint out nodes. This does not make the node inacce...
TreeNode(TreeNode *parent, const std::string &name, const std::string &desc)
TreeNode constructor with no group information.
uint32_t findChildren(const std::string &pattern, std::vector< TreeNode * > &results)
Version of findChildren with no replacements vector.
static constexpr char GROUP_NAME_NONE[]
Group name indicating that a node belongs to no group.
void simulationTerminating_()
Hook to allow simulation resources to clean-up before simulation is ended.
static bool notificationCategoryMatch(const std::string *query_id, const std::string *node_id)
Checks if two notification categories match where one is an actual category.
void dumpPossibleSubtreeNotifications(std::ostream &o) const noexcept
Dumps a listing of the notifications which this node and its descendants can generate to the ostream ...
bool isIndexableByGroup() const
Returns whether this object is accessible through its parent's interfaces for getting children by gro...
const T getParentAs(bool must_exist=true) const
Retrieves a parent casted to type T* if this node has a parent.
void enterTeardown_() noexcept
Recursively enter TREE_TEARDOWN phase while alerting nodes through onEnteringTeardown_ and alterting ...
virtual void addLink(TreeNode *node, const std::string &label)
Link this tree node with another tree node.
bool canSubtreeGenerateNotifications(const std::type_info &tinfo, const std::vector< const std::string * > &names) const
Checks to see if any a subtree can generate any of several notification names which may be patterns.
const std::set< std::string > & getAllExtensionNames()
Extension names, if any. Tree node extensions are typically instantiated on-demand for best performan...
uint32_t findChildrenByTag(const std::string &tag, std::vector< TreeNode * > &results, int32_t max_depth=-1)
Finds a set of all children having the selected tag which this node or descendants of this node withi...
static const uint32_t TEARDOWN_ERROR_LIMIT
Number of teardown-phase-related messages that can be printed before the rest will be suppressed.
void addExtensionFactory(const std::string &extension_name, std::function< ExtensionsBase *()> factory)
Add an extension factory to this tree node by its type (name). This method does not actually create a...
static constexpr char LOCATION_NODE_SEPARATOR_EXPECTING
Separator character between node identifiers in a location string when the child is being attached to...
static std::vector< const std::string * > parseNotificationNameString(const std::string &csl)
Parses a comma-separated list of notification names (or patterns) separated by commas and ignoring wh...
TreeNode * getChildAt(uint32_t idx) const
Gets a child at a position in the children vector in the order in which they were added to this node.
void addAlias(const std::string &alias)
Add a single alias for this node.
uint32_t getPossibleSubtreeNotifications(std::vector< NotificationInfo > &infos) const noexcept
Gets information on the possible notifications generated by this node and all its descendants.
std::vector< TreeNode * > ChildrenVector
Vector of TreeNode children.
TreeNode(const TreeNode &)=delete
Not copy-constructable.
const TreeNode * getExpectedRoot() const
build-time equivalent to getRoot before an object is actually attached to a tree. This is a mainly a ...
void addChild(TreeNode &child)
AddChild by reference for convenience.
void broadcastDeregistrationForNotificationListStringToChildren_(const std::type_info &tinfo, const std::string &name, TreeNode *obs_node, const delegate *del, const bool private_only)
Symmetric oppostie of broadcastRegistrationForNotificationListStringToChildren_.
void broadcastRegistrationForNotificationListStringToChildren_(const std::type_info &tinfo, const std::string &name, TreeNode *obs_node, const delegate *del, const bool private_only)
Entry point to broadcastRegistrationForNotificationToChildren_ recursion. Breaks a name string.
virtual bool isAttached() const
Is this node part of a device tree with a proper RootTreeNode at the root.
bool canSubtreeGenerateNotification(const std::type_info &tinfo, const std::string &name) const
Can this TreeNode or its descendants (of any distance) generate a notification of the given type havi...
bool isBuiltin() const
Is this node in the builtins group.
static const std::vector< std::pair< const char *, std::function< void(std::string &)> > > TREE_NODE_PATTERN_SUBS
List of pattern susbtitutions when creating a search pattern from a TreeNode name containing wildcard...
void registerForNotification(T *obj, const std::string &name, bool ensure_possible=true)
Registers a callback method to listen for all notifications having the specified data type DataT and ...
void invokeDelegatesOn_(TreeNode *to_invoke, const DataT &data, const std::string *name_id)
Protected wrapper for invokeDelegates_ which allows a TreeNode to invoke delegates on another TreeNod...
TreeNode()=delete
Not default-constructable.
const ChildrenVector getChildren() const
Gets a vector of all children of this node in any group in the order in which they were added to this...
std::string renderSubtree(int32_t max_depth=-1, bool show_builtins=false, bool names_only=false, bool hide_hidden=false, bool(*leaf_filt_fxn)(const TreeNode *)=nullptr) const
Renders the subtree starting at this node as a string containing an indentation-based depth-first rep...
group_idx_type getGroupIndexMax(const std::string &group)
Gets the largest index of a node in the given group.
void verifyUniqueChildIdentifier_(const std::string &ident, bool ignore_group_collision=false)
Verifies that the given identifier is unique for all children of this node by comparing against names...
const std::string * getGroupNamePtr() const
Gets the group name string pointer (interned in StringManager singleton) of this node.
void detachFromParent_()
Removes a node from its parent with the expectation this node will be immediately destroyed (i....
const TreeNode * getChild(const std::string &name, bool must_exist=true) const
Overloaded const-qualified.
TreeNode(TreeNode &&rhp)
Move constructor.
uint32_t getLevel() const
Gets the level of this node. 0 is root.
uint32_t getChildren(std::vector< TreeNode * > &results, bool ignore_builtin_group=true, bool ignore_anonymous_nodes=true)
Gets all children of this node in the order in which they were added to this node.
sparta::TreeNode * findAncestorByName(const std::string &name)
Find ancestor by name.
void validatePostRun_(const PostRunValidationInfo &info) const
Hook to check the state of the simulator post-run and throw exceptions if something is incorrect.
std::map< const std::string *, std::vector< TreeNode * > > TagsMap
Map of strings (interned in StringManager) tags to TreeNodes.
std::multimap< std::string, TreeNode * > ChildNameMapping
Mapping of names, aliases, and groups to individual child nodes within one node. This must be in a de...
void validateGroup(const std::string &name, const std::string &group, group_idx_type idx)
Validates the given group name string and group index for this TreeNode. Does not consider context (e...
static constexpr char LOCATION_NODE_SEPARATOR_ATTACHED
Separator character between node identifiers in a location string when the child is attached to the p...
virtual void broadcastDeregistrationForNotificationToChildren_(const std::type_info &tinfo, const std::vector< const std::string * > &name_ids, TreeNode *obs_node, const delegate *del, const bool allow_private)
Recursively notifies children that the notification described has lost one particular observer (del) ...
DelegateVector::iterator findDelegate_(DelegateVector &dvec, T *obj, const std::string &target_name)
Finds a delegate associated with the given type T, object pointer, DataT, and TMethod within a Deleva...
static const std::map< const TreeNode *, WeakPtr > & getAllNodes()
Gets the vector of all TreeNodes currently known to be constructed.
void enterFinalizing_()
Recursively enter TREE_FINALIZING phase.
bool hasTag(const std::string &tag) const
Does this node have a specific tag (by name)
void validateDesc(const std::string &desc)
Validates the given description string for this TreeNode.
Scheduler * getScheduler(const bool must_exist=false)
Get the scheduler associated with this tree node's root.
const std::string * getNamePtr() const
Gets the name of this node's string pointer which isinterned in StringManager)
void addChild(TreeNode *child, bool inherit_phase=true)
Adds a TreeNode to this node as a child.
TreeNode(TreeNode *parent, const std::string &name, const std::string &group, group_idx_type group_idx, const std::string &desc)
TreeNode constructor with no is_indexable parameter [defaults to true].
bool areParametersLocked_() const
This method informs whether the tree is past the lockdown phase for all LOCKED and HIDDEN parameters....
const TreeNode * getScopeRoot() const
static bool matchesGlobLike(const std::string &pattern, const std::string &other)
Determine if a glob-like search pattern matches some other string.
virtual TreeNode * getParent()
Gets immediate parent of this node if one exists.
static std::string getPreviousName_(const std::string &name, size_t &pos)
Gets the previous name between two '.' chars in a string starting at pos.
void postPropagatingNotification_(const TreeNode *origin, const DataT &data, const std::string *name_id)
Starts a notification propagating up the tree.
uint32_t group_idx_type
Index within a group.
void enterFinalized_()
Recursively enter TREE_FINALIZED phase.
static const uint64_t CHILD_GET_THRESHOLD
Threshold for number of getChild calls after finalization before a warning message is printed about f...
const AliasVector & getAliases() const
Gets a vector of all aliases of this node.
bool hasTag(const std::string *interned_tag_name) const
Does this node have a specific tag (by string pointer interned with StringManager)....
ExtensionsBase * getExtension()
Get an extension without needing to specify any particular type string. If no extensions exist,...
std::string getDeepestMatchingPath(const std::string &path) const
Gets the deepest whole node location starting from this node that matches some part of path starting ...
void deregisterForNotification(T *obj, const std::string &name)
Removes at most one registration made with registerForNotification.
const Clock * getClock() override
Walks up parents (starting with self) until a parent with an associated local clock is found,...
bool canGenerateNotification(const std::type_info &tinfo, const std::string *name) const
Can this TreeNode generate a notification of the given type having the given name or pattern.
virtual void activateLink(const std::string &label)
Activate one of the links added with addLink.
TreeNode(TreeNode *parent, const std::string &group, group_idx_type group_idx, const std::string &desc)
TreeNode constructor for anonymous node with group information.
void finalizeTree_()
Recursively create resources based on tree configuration. enter_finalize_ should be invoked after thi...
virtual uint32_t findImmediateChildren_(std::regex &expr, std::vector< TreeNode * > &found, std::vector< std::vector< std::string > > &replacements, bool allow_private=false)
Finds immediate children with some identity (name or alias) matching a regex.
WeakPtr getWeakPtr()
Gets a weak pointer to this TreeNode. This weak pointer is guaranteed to expire when this TreeNode is...
static constexpr char LOCATION_NODE_SEPARATOR_UNATTACHED
Separator character preceding a node identifiers in a location string when that node has no parent an...
TreeNode(const std::string &name, const std::string &group, group_idx_type group_idx, const std::string &desc)
TreeNode constructor with no parent Node.
static TreeNode * getVirtualGlobalNode()
Gets the virtual global node singleton. This node can have no parent and no children....
virtual void setClock(const Clock *clk)
Assigns a clock to this node. This clock will then be accessed by any descendant which has no assigne...
std::string getDisplayLocation() const
Returns the location of this node in the device tree which might not be usable for navigating the dev...
std::pair< uint32_t, std::string > recursGetDeepestMatchingPath_(const std::string &path, size_t name_pos) const
Finds the deepest node path mathing the input path. Implements getDeepestMatchingPath.
uint32_t locateNotificationSources(std::vector< TreeNode * > &nodes, const std::string &name="")
Gets all possible notification info from NotificationSources within this node's subtree.
void getDelegatesRegisteredForNotification(const std::type_info &tinfo, const std::string *name, std::vector< delegate > &dels) noexcept
Gets the vector of delegates registered for a notification on this TreeNode.
std::vector< const std::string * > getIdentifiers() const
Gets all the identifiers for this node (excluding groups)
bool isExpired() const
Is this expired (i.e. has it been the rhp of a move constructor)
bool isDescendantOf(const TreeNode *ancestor, int32_t max_depth=-1) const
Determines if this node is a descendant of the specified ancestor node within some number of generati...
void dumpDebugContent_(std::ostream &out) const noexcept
Allows resources to write out detailed textual debugging information about the node....
void lockdownParameters()
Method to put the device tree in lockdown phase. All LOCKED and HIDDEN parameters are frozen after th...
static std::string createSearchRegexPattern(const std::string &pat)
Compute a regex pattern for a node child path containing any number of wildcard characters (not a dot...
group_idx_type getGroupIdx() const
Gets the group index of this node.
ExtensionsBase * getExtension(const std::string &extension_name)
Get an extension object by type string. Returns nullptr if not found (unrecognized).
uint32_t getRecursiveNodeCount() const
Recursively gets the count of a nodes that are a subclass of a particular type (determined by dynamic...
const ConstT getChildAs(const std::string &name, bool must_exist=true) const
Retrieves a child that is castable to T with the given dotted path.
static bool identityMatchesPattern_(const std::string &ident, std::regex &expr, std::vector< std::string > &replacements)
Performs pattern matching on a identity string.
virtual std::string stringize(bool pretty=false) const
Create a string representation of this node.
const T * getAs() const
Retrieves this node after casting to type const T.
void stringizeTags(std::stringstream &ss) const
Render tags to a string in the form: " tags:[tag0, tag1]" If there are any tags. The leading space ma...
const std::string & getName() const override
Gets the name of this node.
void enterConfig_() noexcept
Recursively enter TREE_CONFIGURING phase.
sparta::TreeNode * findAncestorByTag(const std::string &tag)
Find the first ancestor with a particular tag.
uint32_t getNumChildren() const
Gets the number of children that this node has including those in the sparta builtins group.
TreeNode * getChild(const std::string &name, bool must_exist=true)
Retrieves a child with this dotted path name.
void addTags(const std::vector< std::string > &v)
Adds each elements of a vector of tags to this node.
uint32_t getGroupSize(const std::string &group)
Gets the number of nodes in a group.
bool canGenerateNotification(const NotificationInfo &info) const
Can this TreeNode generate a notification of the given NotificationInfo.
uint32_t getChildrenOfType(std::vector< T * > &results) const
return all the children matching a particular type using dynamic cast.
void validateName(const std::string &nm)
Validates the given name string for this TreeNode. Does not consider context (e.g....
std::vector< delegate > DelegateVector
Vector of delegates representing a list of observers to notify.
bool isHidden() const
Is this TreeNode supposed to be hidden during tree printouts This value does not have to be respected...
std::string getExpectedLocation() const
build-time equivalent to getLocation before an object is actually attached to a tree....
T getAs()
Retrieves this node after casting to type const T.
static std::string formatAllNodes()
Prints the list of all TreeNodes currently known to be constructed.
TreeNode * getScopeRoot()
void removeChildForTeardown_(TreeNode *child)
"Removes" the given child by invoking onDestroyingChild_ then removing this child from the children_ ...
bool hasImmediateChild(const TreeNode *n) const noexcept
Determines if the node n is an immediate child of this node.
std::vector< std::string > AliasVector
Vector of aliases (other names for this node)
void addAliases(const AliasVector &v)
Adds each element of a vector of aliases to this node..
static const uint64_t CHILD_FIND_THRESHOLD
Threshold for number of findChildren calls after finalization before a warning message is printed abo...
void addTag(const std::string &tag)
Adds single tag to this node.
TreeNode(const std::string &name, const std::string &desc)
TreeNode constructor with no parent node or group information.
uint64_t node_uid_type
Type of unique-identifier assigned to every node.
bool canSubtreeGenerateNotification(const std::type_info &tinfo, const std::string *name) const
Can this TreeNode or its descendants (of any distance) generate a notification of the given type havi...
void bindTreeLate_()
Recursively invoke TreeNode::onBindTreeEarly_ and Resource::onBindTreeLate_ (in that order for each n...
uint32_t getChildrenIdentifiers(std::vector< std::string > &idents, bool ignore_builtin_group=true) const
Gets all child identifiers, aliases, group names, and group-aliases which can be used to refer to a c...
static bool isNodeConstructed(const TreeNode *)
Is a given node constructed?
virtual ~TreeNode()
Virtual destructor.
uint32_t findChildren(const std::string &pattern, std::vector< TreeNode * > &results, std::vector< std::vector< std::string > > &replacements)
Finds all children starting at this node with a given pattern relative to this node by matching names...
sparta::TreeNode * findAncestorByType()
Find ancestor by type.
T * getAs()
Retrieves this node after casting to type const T.
TreeNode & operator=(const TreeNode &)=delete
Not assign-constructable.
const std::string & getGroup() const
Gets the group name of this node.
bool isAnonymous() const
Is this node anonymous.
void bindTreeEarly_()
Recursively invoke TreeNode::onBindTreeEarly_ and Resource::onBindTreeEarly_ (in that order for each ...
T * findAncestorResourceByType()
Find an ancestor's resource with a certain type.
void setExpectedParent_(const TreeNode *parent)
Tracks a node as an expected parent without actually adding this node as a child. This is used almost...
uint32_t findImmediateChildren_(std::regex &expr, std::vector< const TreeNode * > &found, bool allow_private=false) const
Variant of const-qualified findImmediateChildren_ with no replacements vector.
void makeSubtreePrivate()
Make the entire subtree private.
uint32_t getPossibleNotifications(std::vector< NotificationInfo > &infos) const
Gets information on the possible notifications generated by this node (excludes children).
ConstWeakPtr getWeakPtr() const
Const variant of getWeakPtr.
void removeFromParentForTeardown_(TreeNode *parent)
Protected Wrapper for getParent()->removeChildForTeardown_ which allows subclases of TreeNode to indi...
bool locationMatchesPattern(const std::string &pattern, const TreeNode *pat_loc) const
Determines if the given pattern (which may contain wildcards) can describe this node.
std::shared_ptr< TreeNode > SharedPtr
Shared pointer to TreeNode. Acquire with WeakPtr::lock().
void dumpLocatedNotificationSources(std::ostream &o, const std::string &name="")
Retrieves the relevant NotificationSources from locateNotificationSources and prints them to the outp...
static bool identityMatchesPattern_(const std::string &ident, std::regex &expr)
Variant of identityMatchesPattern_ with no replacements vector.
bool hasChild(const std::string &name) const noexcept
Determines if a child can be found with the given dotted path.
Virtual global node for all device trees in a single simulation. This node acts a potential notificat...
Simulator which builds a sparta DeviceTree.
Macros for handling exponential backoff.
std::ostream & operator<<(std::ostream &o, const SimulationInfo &info)
ostream insertion operator for SimulationInfo
std::string demangle(const std::string &name) noexcept
Demangles a C++ symbol.
Type for indicating that ANY notification source type should be included in a search performed by loc...
Notification type/name information.
const TreeNode * origin
TreeNode from which this notification can be generated.
NotificationInfo(const NotificationInfo &rhp)
Copy constructor.
void checkValid() const
Ensures the node contains valid data.
NotificationInfo(const NotificationInfo &&rhp)
Move constructor.
const std::string * name
String interned by StringManager. Must not be nullptr.
NotificationInfo & operator=(const NotificationInfo &rhp)
Assignment operator.
const std::type_info * tinfo
Type from typeid() on notification DataT.
NotificationInfo(const TreeNode *_origin, const std::type_info *_tinfo, const std::string *_name)
Basic constructor.