16 #ifndef SURGSIM_DATASTRUCTURES_TREENODE_H 17 #define SURGSIM_DATASTRUCTURES_TREENODE_H 22 #include "SurgSim/DataStructures/TreeVisitor.h" 27 namespace DataStructures
47 void setData(std::shared_ptr<TreeData> data);
50 const std::shared_ptr<TreeData>&
getData()
const;
58 std::shared_ptr<TreeNode>&
getChild(
size_t index);
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);
114 std::vector<std::shared_ptr<TreeNode>> m_children;
117 std::shared_ptr<TreeData> m_data;
124 #endif // SURGSIM_DATASTRUCTURES_TREENODE_H Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
virtual bool isEqual(const TreeNode &node) const
Returns true if the nodes are equal; otherwise, returns false.
Definition: TreeNode.cpp:44
Abstract Class for visitors, this needs to be extended for other tree nodes when necessary return fal...
Definition: TreeVisitor.h:31
const std::shared_ptr< TreeData > & getData() const
Definition: TreeNode.cpp:62
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
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
virtual ~TreeNode()
Destructor.
Definition: TreeNode.cpp:30
std::shared_ptr< TreeNode > & getChild(size_t index)
Returns the specified child of this node.
Definition: TreeNode.cpp:93