ITK  4.13.0
Insight Segmentation and Registration Toolkit
itkTreeNode.h
Go to the documentation of this file.
1 /*=========================================================================
2  *
3  * Copyright Insight Software Consortium
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0.txt
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  *=========================================================================*/
18 #ifndef itkTreeNode_h
19 #define itkTreeNode_h
20 
21 #include <vector>
22 #include <algorithm>
23 #include <iostream>
24 #include "itkObject.h"
25 #include "itkObjectFactory.h"
26 #include "itkIntTypes.h"
27 
28 namespace itk
29 {
42 template< typename TValue >
43 class ITK_TEMPLATE_EXPORT TreeNode:public Object
44 {
45 public:
46 
48  typedef Object Superclass;
52  typedef std::vector< Pointer > ChildrenListType;
54 
56  itkNewMacro(Self);
57 
59  itkTypeMacro(TreeNode, Object);
60 
62  const TValue & Get() const;
63 
65  TValue Set(const TValue data);
66 
68  Self * GetChild(ChildIdentifier number) const;
69 
71  Self * GetParent() const;
72 
74  bool HasChildren() const;
75 
77  bool HasParent() const;
78 
80  void SetParent(Self *n);
81 
83  ChildIdentifier CountChildren() const;
84 
86  bool Remove(Self *n);
87 
89  ChildIdentifier GetNumberOfChildren(unsigned int depth = 0, char *name = ITK_NULLPTR) const;
90 
92  bool ReplaceChild(Self *oldChild, Self *newChild);
93 
95  ChildIdentifier ChildPosition(const Self *node) const;
96 
98  ChildIdentifier ChildPosition(TValue node) const;
99 
101  void AddChild(Self *node);
102 
104  virtual void AddChild(ChildIdentifier number, Self *node);
105 
107 #if !defined( ITK_WRAPPING_PARSER )
108  virtual ChildrenListType * GetChildren(unsigned int depth = 0, char *name = ITK_NULLPTR) const;
109 
110 #endif
111 
113 #if !defined( ITK_WRAPPING_PARSER )
114  virtual ChildrenListType & GetChildrenList() { return m_Children; }
115 #endif
116 
118  //virtual void SetData(TValue data) {m_Data = data;}
119 
120 protected:
121 
122  TreeNode();
123  virtual ~TreeNode() ITK_OVERRIDE;
124  TValue m_Data;
125 
126  Self *m_Parent;
127 
128  ChildrenListType m_Children;
129 
130 private:
131  ITK_DISALLOW_COPY_AND_ASSIGN(TreeNode);
132 };
133 } // end namespace itk
134 
135 #ifndef ITK_MANUAL_INSTANTIATION
136 #include "itkTreeNode.hxx"
137 #endif
138 
139 #endif
Light weight base class for most itk classes.
Represents a node in a tree.
Definition: itkTreeNode.h:43
std::vector< Pointer > ChildrenListType
Definition: itkTreeNode.h:52
signed long OffsetValueType
Definition: itkIntTypes.h:154
TreeNode< TValue > Self
Definition: itkTreeNode.h:49
Object Superclass
Definition: itkTreeNode.h:48
virtual ChildrenListType & GetChildrenList()
Definition: itkTreeNode.h:114
::itk::OffsetValueType ChildIdentifier
Definition: itkTreeNode.h:53
SmartPointer< Self > Pointer
Definition: itkTreeNode.h:50
Base class for most ITK classes.
Definition: itkObject.h:59
SmartPointer< const Self > ConstPointer
Definition: itkTreeNode.h:51