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 Definition: CompoundShapeToGraphics.cpp:29
virtual bool isEqual(const TreeNode &node) const
Returns true if the nodes are equal; otherwise, returns false.
Definition: TreeNode.cpp:44
std::shared_ptr< TreeNode > getChild(size_t index) const
Returns the specified child of this node.
Definition: TreeNode.cpp:93
std::shared_ptr< TreeData > m_data
Data of this node.
Definition: TreeNode.h:117
Abstract Class for visitors, this needs to be extended for other tree nodes when necessary return fal...
Definition: TreeVisitor.h:31
Basic tree node structure.
Definition: TreeNode.h:36
virtual bool doAccept(TreeVisitor *visitor)=0
Private function for use with the visitor pattern, this needs to be implemented to make the correct d...
void setNumChildren(size_t numChildren)
Sets the number of children of this node.
Definition: TreeNode.cpp:67
void accept(TreeVisitor *visitor)
Public entry point for visitor, currently this performs pre-order traversal of the tree...
Definition: TreeNode.cpp:99
TreeNode()
Constructor. After construction, the node has no children, and the data is null.
Definition: TreeNode.cpp:27
size_t getNumChildren() const
Definition: TreeNode.cpp:72
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
void setData(std::shared_ptr< TreeData > data)
Sets the data of this node.
Definition: TreeNode.cpp:57
void setChild(size_t index, const std::shared_ptr< TreeNode > &node)
Set a specific child of this node.
Definition: TreeNode.cpp:87
void addChild(const std::shared_ptr< TreeNode > &node)
Add a child to this node.
Definition: TreeNode.cpp:77
bool operator!=(const TreeNode &node) const
Returns true if the nodes are not equal; otherwise, returns false.
Definition: TreeNode.cpp:39
std::shared_ptr< TreeData > getData() const
Definition: TreeNode.cpp:62
virtual ~TreeNode()
Destructor.
Definition: TreeNode.cpp:30