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

itkFEMP.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkFEMP.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-01-30 21:53:03 $
00007   Version:   $Revision: 1.11 $
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 __itkFEMP_h
00018 #define __itkFEMP_h
00019 
00020 namespace itk {
00021 namespace fem {
00022 
00042 template<class T>
00043 class FEMP
00044 {
00045 public:
00046 
00052   FEMP() : m_Data(0)
00053     {
00054     }
00055 
00060   FEMP(const FEMP& x)
00061     {
00062     if (x.m_Data)
00063       {
00064       m_Data=static_cast<T*>(&*x.m_Data->Clone());
00065       }
00066     else
00067       {
00068       m_Data=0;
00069       }
00070     }
00072 
00079   explicit FEMP(typename T::Pointer x) : m_Data(x)
00080     {}
00081 
00085   ~FEMP()
00086     {
00087     #ifndef FEM_USE_SMART_POINTERS
00088     delete m_Data;
00089     #endif
00090     }
00091 
00095   const FEMP& operator= (const FEMP &rhs);
00096 
00100   typename T::Pointer operator-> () const { return m_Data; }
00101 
00106   operator T * () const
00107     {
00108     return m_Data;
00109     }
00110 
00115   bool IsNULL() const
00116     {
00117     return (m_Data==0);
00118     }
00119 
00120 private:
00121 
00125   typename T::Pointer m_Data;
00126 
00127 };
00128 
00129 template<class T>
00130 const FEMP<T>& FEMP<T>::operator= (const FEMP &rhs)
00131 {
00132 
00134   if (&rhs!=this) 
00135     {
00136 
00140     #ifndef FEM_USE_SMART_POINTERS
00141     delete m_Data;
00142     #else
00143     m_Data=0;
00144     #endif
00145 
00150     if (rhs.m_Data)
00151       {
00152       m_Data=static_cast<T*>(&*rhs.m_Data->Clone());
00153       }
00154     else
00155       {
00156       m_Data=0;
00157       }
00159 
00160     }
00161   return *this;
00162 }
00163 
00164 }} // end namespace itk::fem
00165 
00166 #endif // #ifndef __itkFEMP_h
00167 

Generated at Sat Feb 28 12:24:47 2009 for ITK by doxygen 1.5.6 written by Dimitri van Heesch, © 1997-2000