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     }                             
00060 
00062   TreeIteratorClone (const ObjectType &p)
00063     { 
00064     m_Pointer = 0;
00065     m_Pointer=const_cast<ObjectType*>(&p)->Clone();
00066     }                             
00067   
00069   ~TreeIteratorClone ()
00070     {
00071     delete m_Pointer;
00072     m_Pointer = 0;
00073     }
00074   
00076   ObjectType *operator -> () const
00077     { return m_Pointer; }
00078 
00080   bool IsNotNull() const
00081   { return m_Pointer != 0; }
00082   bool IsNull() const
00083   { return m_Pointer == 0; }
00084 
00086   template <typename R>
00087   bool operator == ( R r ) const
00088     { return (m_Pointer == (ObjectType*)(r) ); }
00089 
00090   template <typename R>
00091   bool operator != ( R r ) const
00092     { return (m_Pointer != (ObjectType*)(r) ); }
00093     
00095   ObjectType *GetPointer () const 
00096     { return m_Pointer; }
00097   
00099   bool operator < (const TreeIteratorClone &r) const
00100     { return (void*)m_Pointer < (void*) r.m_Pointer; }
00101   
00103   bool operator > (const TreeIteratorClone &r) const
00104     { return (void*)m_Pointer > (void*) r.m_Pointer; }
00105 
00107   bool operator <= (const TreeIteratorClone &r) const
00108     { return (void*)m_Pointer <= (void*) r.m_Pointer; }
00109 
00111   bool operator >= (const TreeIteratorClone &r) const
00112     { return (void*)m_Pointer >= (void*) r.m_Pointer; }
00113 
00115   TreeIteratorClone &operator = (const TreeIteratorClone &r)
00116     { return this->operator = (r.GetPointer()); }
00117   
00119   TreeIteratorClone &operator = (const ObjectType *r)
00120     {                                                              
00121     if (m_Pointer != r)
00122       {
00123       delete m_Pointer;
00124       m_Pointer = 0;  
00125       if(r!=NULL) 
00126         m_Pointer=const_cast<ObjectType*>(r)->Clone();
00127       }
00128     return *this;
00129     }
00130 
00131   Self &
00132   operator++()
00133     {
00134     if(m_Pointer)
00135       ++(*m_Pointer);
00136     return *this;
00137     }
00138   
00140   ObjectType *Print (std::ostream& os) const 
00141     { 
00142     // This prints the object pointed to by the pointer  
00143     (*m_Pointer).Print(os);  
00144     return m_Pointer;
00145     } 
00146 
00147 private:
00149   ObjectType* m_Pointer;
00150 };  
00151 
00152 
00153 template <typename T>
00154 std::ostream& operator<< (std::ostream& os, TreeIteratorClone<T> p) 
00155 {
00156   p.Print(os); 
00157   return os;
00158 }
00159 
00160 } // end namespace itk
00161   
00162 #endif

Generated at Thu May 25 00:09:37 2006 for ITK by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2000