The Sparta Modeling Framework
Loading...
Searching...
No Matches
GlobalTreeNode.hpp
Go to the documentation of this file.
1// <GlobalTreeNode> -*- C++ -*-
2
12#pragma once
13
15
16namespace sparta
17{
32 class GlobalTreeNode final : public TreeNode
33 {
34 public:
35
39 static constexpr char GLOBAL_NODE_NAME[] = "_SPARTA_global_node_";
40
45 TreeNode(GLOBAL_NODE_NAME, GROUP_NAME_BUILTIN, GROUP_IDX_NONE, "Global space of device tree")
46 { }
47
51 virtual ~GlobalTreeNode() {};
52
53 // Returns true. Tree root is always considered "attached"
54 virtual bool isAttached() const override final {
55 return true;
56 }
57
58 // Returns 0. Tree global node will never have a parent
59 virtual TreeNode* getParent() override final { return nullptr; }
60
61 // Returns 0. Tree global node will never have a parent
62 virtual const TreeNode* getParent() const override final { return nullptr; }
63
64 // Override from TreeNode
65 // Virtual global node cannot generate any notifications!
66 virtual bool canGenerateNotification_(const std::type_info&,
67 const std::string*,
68 const std::string*&) const override final {
69 return false;
70 }
71
79 virtual std::string stringize(bool pretty=false) const override {
80 (void) pretty;
81 std::stringstream ss;
82 ss << "<" << getName() << ">";
83 return ss.str();
84 }
85
86 protected:
87
88 // No effect on root
89 virtual void createResource_() override {};
90
96 virtual void setParent_(TreeNode* parent, bool) override {
97 SpartaException ex("This GlobalTreeNode \"");
98 ex << "\" cannot be a child of any other node. Someone attempted "
99 "to add it as a child of " << parent->getLocation();
100 throw ex;
101 }
102 };
103
104} // namespace sparta
Basic Node framework in sparta device tree composite pattern.
TreeNode which represents some "global" namespace of the device tree, containing only RootTreeNodes,...
virtual bool canGenerateNotification_(const std::type_info &, const std::string *, const std::string *&) const override final
Implements TreeNode::canGenerateNotification. Node subclasses which will post notifications must impl...
virtual void setParent_(TreeNode *parent, bool) override
Disallow assining a parent to this node.
virtual void createResource_() override
Create any resources from this finalized device tree.
static constexpr char GLOBAL_NODE_NAME[]
Reserved name for this GlobalTreeNode.
virtual bool isAttached() const override final
Is this node part of a device tree with a proper RootTreeNode at the root.
virtual ~GlobalTreeNode()
Destructor.
virtual std::string stringize(bool pretty=false) const override
Render description of this TreeNode as a string.
virtual TreeNode * getParent() override final
Gets immediate parent of this node if one exists.
Used to construct and throw a standard C++ exception. Inherits from std::exception.
Node in a composite tree representing a sparta Tree item.
Definition TreeNode.hpp:205
static const group_idx_type GROUP_IDX_NONE
GroupIndex indicating that a node has no group index because it belongs to no group.
Definition TreeNode.hpp:303
std::string getLocation() const override final
static constexpr char GROUP_NAME_BUILTIN[]
Reserved name for built-in nodes.
Definition TreeNode.hpp:370
const std::string & getName() const override
Gets the name of this node.
Macros for handling exponential backoff.