Go to the documentation of this file.
16 #ifndef SURGSIM_DATASTRUCTURES_TREENODE_H
17 #define SURGSIM_DATASTRUCTURES_TREENODE_H
27 namespace DataStructures
47 void setData(std::shared_ptr<TreeData> data);
50 std::shared_ptr<TreeData>
getData()
const;
58 std::shared_ptr<TreeNode>
getChild(
size_t index)
const;
100 void addChild(
const std::shared_ptr<TreeNode>& node);
104 void addChild(
const std::shared_ptr<TreeNode>&& node);
109 void setChild(
size_t index,
const std::shared_ptr<TreeNode>& node);
124 #endif // SURGSIM_DATASTRUCTURES_TREENODE_H
std::shared_ptr< TreeData > getData() const
Definition: TreeNode.cpp:62
void setChild(size_t index, const std::shared_ptr< TreeNode > &node)
Set a specific child of this node.
Definition: TreeNode.cpp:87
Definition: CompoundShapeToGraphics.cpp:30
std::shared_ptr< TreeData > m_data
Data of this node.
Definition: TreeNode.h:117
bool operator==(const TreeNode &node) const
Returns true if the nodes are equal; otherwise, returns false.
Definition: TreeNode.cpp:34
std::vector< std::shared_ptr< TreeNode > > m_children
Children of this node.
Definition: TreeNode.h:114
std::shared_ptr< TreeNode > getChild(size_t index) const
Returns the specified child of this node.
Definition: TreeNode.cpp:93
virtual ~TreeNode()
Destructor.
Definition: TreeNode.cpp:30
void accept(TreeVisitor *visitor)
Public entry point for visitor, currently this performs pre-order traversal of the tree.
Definition: TreeNode.cpp:99
size_t getNumChildren() const
Definition: TreeNode.cpp:72
virtual bool doAccept(TreeVisitor *visitor)=0
Private function for use with the visitor pattern, this needs to be implemented to make the correct d...
TreeNode()
Constructor. After construction, the node has no children, and the data is null.
Definition: TreeNode.cpp:27
bool operator!=(const TreeNode &node) const
Returns true if the nodes are not equal; otherwise, returns false.
Definition: TreeNode.cpp:39
void setData(std::shared_ptr< TreeData > data)
Sets the data of this node.
Definition: TreeNode.cpp:57
virtual bool isEqual(const TreeNode &node) const
Returns true if the nodes are equal; otherwise, returns false.
Definition: TreeNode.cpp:44
Basic tree node structure.
Definition: TreeNode.h:37
void addChild(const std::shared_ptr< TreeNode > &node)
Add a child to this node.
Definition: TreeNode.cpp:77
Abstract Class for visitors, this needs to be extended for other tree nodes when necessary return fal...
Definition: TreeVisitor.h:32
void setNumChildren(size_t numChildren)
Sets the number of children of this node.
Definition: TreeNode.cpp:67