ITK  4.6.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 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 
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( CABLE_CONFIGURATION )
108  virtual ChildrenListType * GetChildren(unsigned int depth = 0, char *name = ITK_NULLPTR) const;
109 
110 #endif
111 
113 #if !defined( CABLE_CONFIGURATION )
115 #endif
116 
118  //virtual void SetData(TValue data) {m_Data = data;}
119 
120 protected:
121 
122  TreeNode();
123  virtual ~TreeNode();
124  TValue m_Data;
125 
127 
129 
130 private:
131  TreeNode(const Self &); //purposely not implemented
132  void operator=(const Self &); //purposely not implemented
133 };
134 } // end namespace itk
135 
136 #ifndef ITK_MANUAL_INSTANTIATION
137 #include "itkTreeNode.hxx"
138 #endif
139 
140 #endif
void AddChild(Self *node)
const TValue & Get() const
Light weight base class for most itk classes.
Represents a node in a tree.
Definition: itkTreeNode.h:43
bool Remove(Self *n)
ChildIdentifier ChildPosition(const Self *node) const
Self * GetParent() const
std::vector< Pointer > ChildrenListType
Definition: itkTreeNode.h:52
signed long OffsetValueType
Definition: itkIntTypes.h:154
bool ReplaceChild(Self *oldChild, Self *newChild)
Self * GetChild(ChildIdentifier number) const
TreeNode< TValue > Self
Definition: itkTreeNode.h:49
Object Superclass
Definition: itkTreeNode.h:48
ChildIdentifier GetNumberOfChildren(unsigned int depth=0, char *name=ITK_NULLPTR) const
virtual ChildrenListType & GetChildrenList()
Definition: itkTreeNode.h:114
void operator=(const Self &)
bool HasChildren() const
virtual ChildrenListType * GetChildren(unsigned int depth=0, char *name=ITK_NULLPTR) const
TValue Set(const TValue data)
void SetParent(Self *n)
Self * m_Parent
Definition: itkTreeNode.h:126
ChildrenListType m_Children
Definition: itkTreeNode.h:128
::itk::OffsetValueType ChildIdentifier
Definition: itkTreeNode.h:53
bool HasParent() const
ChildIdentifier CountChildren() const
SmartPointer< Self > Pointer
Definition: itkTreeNode.h:50
Base class for most ITK classes.
Definition: itkObject.h:57
virtual ~TreeNode()
SmartPointer< const Self > ConstPointer
Definition: itkTreeNode.h:51