ITK  4.1.0
Insight Segmentation and Registration Toolkit
itkSmartPointerForwardReference.h
Go to the documentation of this file.
00001 /*=========================================================================
00002  *
00003  *  Copyright Insight Software Consortium
00004  *
00005  *  Licensed under the Apache License, Version 2.0 (the "License");
00006  *  you may not use this file except in compliance with the License.
00007  *  You may obtain a copy of the License at
00008  *
00009  *         http://www.apache.org/licenses/LICENSE-2.0.txt
00010  *
00011  *  Unless required by applicable law or agreed to in writing, software
00012  *  distributed under the License is distributed on an "AS IS" BASIS,
00013  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  *  See the License for the specific language governing permissions and
00015  *  limitations under the License.
00016  *
00017  *=========================================================================*/
00018 #ifndef __itkSmartPointerForwardReference_h
00019 #define __itkSmartPointerForwardReference_h
00020 
00021 #include "itkWeakPointer.h"
00022 
00023 #include <iostream>
00024 
00025 namespace itk
00026 {
00047 template< class T >
00048 class ITK_EXPORT SmartPointerForwardReference
00049 {
00050 public:
00052   SmartPointerForwardReference ()
00053   { m_Pointer = 0; }
00054 
00056   SmartPointerForwardReference (const SmartPointerForwardReference< T > & p);
00057 
00059   SmartPointerForwardReference (const WeakPointer< T > & p);
00060 
00062   SmartPointerForwardReference (T *p);
00063 
00065   ~SmartPointerForwardReference ();
00066 
00068   T * operator->() const;
00069 
00071   operator T *() const;
00072 
00074   T * GetPointer() const;
00075 
00077   bool operator<(const SmartPointerForwardReference & r);
00078 
00080   bool operator>(const SmartPointerForwardReference & r);
00081 
00083   bool operator<=(const SmartPointerForwardReference & r);
00084 
00086   bool operator>=(const SmartPointerForwardReference & r);
00087 
00089   SmartPointerForwardReference & operator=(const SmartPointerForwardReference & r);
00090 
00092   SmartPointerForwardReference & operator=(const WeakPointer< T > & r);
00093 
00095   SmartPointerForwardReference & operator=(T *r);
00096 
00098   T * Print(std::ostream & os) const;
00099 
00100 private:
00102   T *m_Pointer;
00103 
00104   void Register();
00105 
00106   void UnRegister();
00107 };
00108 
00109 template< typename T >
00110 std::ostream & operator<<(std::ostream & os, SmartPointerForwardReference< T > p)
00111 {
00112   p.Print(os);
00113   return os;
00114 }
00115 } // end namespace itk
00116 
00117 #endif
00118