opensurgsim
Tree.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_DATASTRUCTURES_TREE_H
17 #define SURGSIM_DATASTRUCTURES_TREE_H
18 
19 #include <memory>
20 
21 namespace SurgSim
22 {
23 
24 namespace DataStructures
25 {
26 
27 class TreeNode;
28 
32 class Tree
33 {
34 public:
36  Tree();
37 
39  virtual ~Tree();
40 
43  void setRoot(std::shared_ptr<TreeNode> root);
44 
46  std::shared_ptr<TreeNode> getRoot() const;
47 
52  bool operator==(const Tree& tree) const;
53 
58  bool operator!=(const Tree& tree) const;
59 
60 protected:
65  virtual bool isEqual(const Tree& tree) const;
66 
67 private:
69  std::shared_ptr<TreeNode> m_root;
70 
71 };
72 
73 }; // namespace DataStructures
74 
75 }; // namespace SurgSim
76 
77 #endif // SURGSIM_DATASTRUCTURES_TREE_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
Basic tree structure.
Definition: Tree.h:32
virtual ~Tree()
Destructor.
Definition: Tree.cpp:28
virtual bool isEqual(const Tree &tree) const
Recurses through the tree, starting at the root.
Definition: Tree.cpp:42
Tree()
Constructor. After construction, the root is null.
Definition: Tree.cpp:24
bool operator==(const Tree &tree) const
If the trees are not of the same type, returns false; otherwise, compares with the implementation of ...
Definition: Tree.cpp:32
void setRoot(std::shared_ptr< TreeNode > root)
Sets the root of the tree.
Definition: Tree.cpp:47
bool operator!=(const Tree &tree) const
If the trees are not of the same type, returns false; otherwise, compares with the implementation of ...
Definition: Tree.cpp:37
std::shared_ptr< TreeNode > getRoot() const
Definition: Tree.cpp:52