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: 2003/09/10 14:29:43 $
00007   Version:   $Revision: 1.10 $
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 
00023 
00024 
00025 
00045 template<class T>
00046 class FEMP
00047 {
00048 public:
00049 
00055   FEMP() : m_Data(0)
00056   {
00057   }
00058 
00063   FEMP(const FEMP& x)
00064   {      
00065     if (x.m_Data) { m_Data=static_cast<T*>(&*x.m_Data->Clone()); }
00066     else { m_Data=0; }
00067   }
00069 
00076   explicit FEMP(typename T::Pointer x) : m_Data(x)
00077   {
00078   }
00079 
00083   ~FEMP()
00084   {
00085     #ifndef FEM_USE_SMART_POINTERS
00086     delete m_Data;
00087     #endif
00088   }
00089 
00093   const FEMP& operator= (const FEMP &rhs);
00094 
00098   typename T::Pointer operator-> () const { return m_Data; }
00099 
00104   operator T * () const
00105   {
00106     return m_Data;
00107   }
00108 
00113   bool IsNULL() const
00114   {
00115     return (m_Data==0);
00116   }
00117 
00118 private:
00119 
00123   typename T::Pointer m_Data;
00124 
00125 };
00126 
00127 
00128 
00129 
00130 template<class T>
00131 const FEMP<T>& FEMP<T>::operator= (const FEMP &rhs)
00132 {
00133 
00135   if (&rhs!=this) 
00136   {      
00137 
00141     #ifndef FEM_USE_SMART_POINTERS
00142     delete m_Data;
00143     #else
00144     m_Data=0;
00145     #endif
00146 
00151     if (rhs.m_Data) { m_Data=static_cast<T*>(&*rhs.m_Data->Clone()); }
00152     else { m_Data=0; }
00154 
00155   }
00156   return *this;
00157 }
00158 
00159 
00160 
00161 
00162 }} // end namespace itk::fem
00163 
00164 #endif // #ifndef __itkFEMP_h
00165 

Generated at Wed Nov 5 21:24:46 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000