Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Common/vtkSmartPointer.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkSmartPointer.h,v $
00005   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even 
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00013      PURPOSE.  See the above copyright notice for more information.
00014 
00015 =========================================================================*/
00038 #ifndef __vtkSmartPointer_h
00039 #define __vtkSmartPointer_h
00040 
00041 #include "vtkSmartPointerBase.h"
00042 
00043 template <class T>
00044 class vtkSmartPointer: public vtkSmartPointerBase
00045 {
00046 public:
00048   vtkSmartPointer() {}
00049   
00051   vtkSmartPointer(T* r): vtkSmartPointerBase(r) {}
00052   
00055   vtkSmartPointer(const vtkSmartPointerBase& r): vtkSmartPointerBase(r) {}
00056   
00058 
00060   vtkSmartPointer& operator=(T* r)
00061     {
00062     this->vtkSmartPointerBase::operator=(r);
00063     return *this;
00064     }
00066   
00068 
00070   vtkSmartPointer& operator=(const vtkSmartPointerBase& r)
00071     {
00072     this->vtkSmartPointerBase::operator=(r);
00073     return *this;
00074     }  
00076   
00078 
00079   T* GetPointer() const
00080     {
00081     return static_cast<T*>(this->Object);
00082     }
00084   
00086 
00088   T& operator*() const
00089     {
00090     return *static_cast<T*>(this->Object);
00091     }
00093   
00095 
00096   T* operator->() const
00097     {
00098     return static_cast<T*>(this->Object);
00099     }
00101 };
00102 
00103 #endif