Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkTreeNode.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkTreeNode.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-03-03 15:10:44 $
00007   Version:   $Revision: 1.9 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkTreeNode_h
00018 #define __itkTreeNode_h
00019 
00020 #include <vector>
00021 #include <algorithm>
00022 #include <iostream>
00023 #include <itkObject.h>
00024 #include <itkObjectFactory.h>
00025 
00026 namespace itk
00027 {
00041 template <class TValueType>
00042 class TreeNode : public Object
00043 {
00044 
00045 public:
00046 
00048   typedef Object                    Superclass;
00049   typedef TreeNode<TValueType>      Self;
00050   typedef SmartPointer<Self>        Pointer;
00051   typedef SmartPointer<const Self>  ConstPointer;
00052   typedef std::vector<Pointer>      ChildrenListType;
00053 
00055   itkNewMacro( Self );
00056 
00058   itkTypeMacro( TreeNode, Object );
00059 
00061   const TValueType& Get() const;
00062 
00064   TValueType Set(const TValueType data);
00065 
00067   TreeNode<TValueType>* GetChild( int number ) const;
00068 
00070   TreeNode<TValueType>* GetParent( ) const;
00071 
00073   bool HasChildren( ) const;
00074 
00076   bool HasParent( ) const;
00077 
00079   void SetParent( TreeNode<TValueType>* n );
00080 
00082   int CountChildren( ) const;
00083 
00085   bool Remove( TreeNode<TValueType> *n );
00086 
00088   unsigned int GetNumberOfChildren(unsigned int depth=0, char * name=NULL ) const;
00089 
00091   bool ReplaceChild( TreeNode<TValueType> *oldChild, TreeNode<TValueType> *newChild );
00092 
00094   int ChildPosition( const TreeNode<TValueType> *node ) const;
00095 
00097   int ChildPosition( TValueType node ) const;
00098 
00100   void AddChild( TreeNode<TValueType> *node );
00101 
00103   virtual void AddChild( int number, TreeNode<TValueType> *node );
00104 
00106 #if !defined(CABLE_CONFIGURATION)
00107   virtual ChildrenListType* GetChildren( unsigned int depth=0, char * name=NULL) const;
00108 #endif
00109 
00111 #if !defined(CABLE_CONFIGURATION)
00112   virtual ChildrenListType& GetChildrenList() {return m_Children;}
00113 #endif
00114 
00116   //virtual void SetData(TValueType data) {m_Data = data;}
00117 
00118 protected:
00119 
00120   TreeNode();
00121   virtual ~TreeNode();
00122   TValueType       m_Data;
00123   Self*            m_Parent;
00124   ChildrenListType m_Children;
00125 private:
00126   TreeNode(const Self&); //purposely not implemented
00127   void operator=(const Self&); //purposely not implemented
00128 };
00129 
00130 } // end namespace itk
00131 
00132 // Define instantiation macro for this template.
00133 #define ITK_TEMPLATE_TreeNode(_, EXPORT, x, y) namespace itk { \
00134   _(1(class EXPORT TreeNode< ITK_TEMPLATE_1 x >)) \
00135   namespace Templates { typedef TreeNode< ITK_TEMPLATE_1 x > \
00136                                                   TreeNode##y; } \
00137   }
00138 
00139 #if ITK_TEMPLATE_EXPLICIT
00140 # include "Templates/itkTreeNode+-.h"
00141 #endif
00142 
00143 #if ITK_TEMPLATE_TXX
00144 # include "itkTreeNode.txx"
00145 #endif
00146 
00147 
00148 #endif
00149 

Generated at Mon Jul 12 2010 20:03:39 for ITK by doxygen 1.7.1 written by Dimitri van Heesch, © 1997-2000