ITK  4.4.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< class TValueType >
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 TValueType & Get() const;
63 
65  TValueType Set(const TValueType 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 = NULL) const;
90 
92  bool ReplaceChild(Self *oldChild, Self *newChild);
93 
95  ChildIdentifier ChildPosition(const Self *node) const;
96 
98  ChildIdentifier ChildPosition(TValueType 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 = NULL) const;
109 
110 #endif
111 
113 #if !defined( CABLE_CONFIGURATION )
115 #endif
116 
118  //virtual void SetData(TValueType data) {m_Data = data;}
119 
120 protected:
121 
122  TreeNode();
123  virtual ~TreeNode();
124  TValueType 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
141