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

itkTreeIteratorClone.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkTreeIteratorClone.h,v $
00005   Language:  C++
00006   Date:      $Date: 2004/07/23 20:07:14 $
00007   Version:   $Revision: 1.1 $
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 __itkTreeIteratorClone_h
00018 #define __itkTreeIteratorClone_h
00019 
00020 #include "itkMacro.h"
00021 #include <iostream>
00022 
00023 namespace itk
00024 {
00025 
00026 template <class TObjectType>
00027 class ITK_EXPORT TreeIteratorClone 
00028 {
00029 public:
00030   
00032   typedef TreeIteratorClone<TObjectType> Self;
00033   typedef TObjectType ObjectType;
00034 
00036   TreeIteratorClone () 
00037     { 
00038     m_Pointer = 0; 
00039     }
00040 
00042   TreeIteratorClone (const TreeIteratorClone<ObjectType> &p)
00043     { 
00044 
00045     if(p.m_Pointer != NULL)
00046       {
00047       m_Pointer = p.m_Pointer->Clone();
00048       }
00049     }
00050   
00052   TreeIteratorClone (ObjectType *p)
00053     { 
00054     m_Pointer = 0;
00055     if(p!=NULL)
00056       {
00057       m_Pointer=p->Clone();
00058       }
00059     }                             
00061 
00063   TreeIteratorClone (const ObjectType &p)
00064     { 
00065     m_Pointer = 0;
00066     m_Pointer=const_cast<ObjectType*>(&p)->Clone();
00067     }                             
00069 
00071   ~TreeIteratorClone ()
00072     {
00073     delete m_Pointer;
00074     m_Pointer = 0;
00075     }
00076 
00078   ObjectType *operator -> () const
00079     { return m_Pointer; }
00080 
00082   bool IsNotNull() const
00083   { return m_Pointer != 0; }
00084   bool IsNull() const
00085   { return m_Pointer == 0; }
00087 
00089   template <typename R>
00090   bool operator == ( R r ) const
00091     { return (m_Pointer == (ObjectType*)(r) ); }
00092 
00093   template <typename R>
00094   bool operator != ( R r ) const
00095     { return (m_Pointer != (ObjectType*)(r) ); }
00096     
00098   ObjectType *GetPointer () const 
00099     { return m_Pointer; }
00100 
00102   bool operator < (const TreeIteratorClone &r) const
00103     { return (void*)m_Pointer < (void*) r.m_Pointer; }
00104 
00106   bool operator > (const TreeIteratorClone &r) const
00107     { return (void*)m_Pointer > (void*) r.m_Pointer; }
00108 
00110   bool operator <= (const TreeIteratorClone &r) const
00111     { return (void*)m_Pointer <= (void*) r.m_Pointer; }
00112 
00114   bool operator >= (const TreeIteratorClone &r) const
00115     { return (void*)m_Pointer >= (void*) r.m_Pointer; }
00116 
00118   TreeIteratorClone &operator = (const TreeIteratorClone &r)
00119     { return this->operator = (r.GetPointer()); }
00120 
00122   TreeIteratorClone &operator = (const ObjectType *r)
00123     {                                                              
00124     if (m_Pointer != r)
00125       {
00126       delete m_Pointer;
00127       m_Pointer = 0;  
00128       if(r!=NULL) 
00129         m_Pointer=const_cast<ObjectType*>(r)->Clone();
00130       }
00131     return *this;
00132     }
00134 
00135   Self &
00136   operator++()
00137     {
00138     if(m_Pointer)
00139       ++(*m_Pointer);
00140     return *this;
00141     }
00142   
00144   ObjectType *Print (std::ostream& os) const 
00145     { 
00146     // This prints the object pointed to by the pointer  
00147     (*m_Pointer).Print(os);  
00148     return m_Pointer;
00149     } 
00151 
00152 private:
00154   ObjectType* m_Pointer;
00155 };  
00156 
00157 
00158 template <typename T>
00159 std::ostream& operator<< (std::ostream& os, TreeIteratorClone<T> p) 
00160 {
00161   p.Print(os); 
00162   return os;
00163 }
00164 
00165 } // end namespace itk
00166   
00167 #endif
00168 

Generated at Sun Sep 23 14:27:13 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000