ITK  4.2.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 
69 
72 
74  bool HasChildren() const;
75 
77  bool HasParent() const;
78 
81 
84 
87 
89  ChildIdentifier GetNumberOfChildren(unsigned int depth = 0, char *name = NULL) const;
90 
93 
96 
98  ChildIdentifier ChildPosition(TValueType node) const;
99 
101  void AddChild(TreeNode< TValueType > *node);
102 
104  virtual void AddChild(ChildIdentifier number, TreeNode< TValueType > *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 protected:
120 
121  TreeNode();
122  virtual ~TreeNode();
123  TValueType m_Data;
124 
126 
128 private:
129  TreeNode(const Self &); //purposely not implemented
130  void operator=(const Self &); //purposely not implemented
131 };
132 } // end namespace itk
133 
134 // Define instantiation macro for this template.
135 #define ITK_TEMPLATE_TreeNode(_, EXPORT, TypeX, TypeY) \
136  namespace itk \
137  { \
138  _( 1 ( class EXPORT TreeNode< ITK_TEMPLATE_1 TypeX > ) ) \
139  namespace Templates \
140  { \
141  typedef TreeNode< ITK_TEMPLATE_1 TypeX > \
142  TreeNode##TypeY; \
143  } \
144  }
145 
146 #if ITK_TEMPLATE_EXPLICIT
147 #include "Templates/itkTreeNode+-.h"
148 #endif
149 
150 #if ITK_TEMPLATE_TXX
151 #include "itkTreeNode.hxx"
152 #endif
153 
154 #endif
155