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

dox/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 =========================================================================*/ 00029 #ifndef __vtkSmartPointer_h 00030 #define __vtkSmartPointer_h 00031 00032 #include "vtkSmartPointerBase.h" 00033 00034 template <class T> 00035 class vtkSmartPointer: public vtkSmartPointerBase 00036 { 00037 public: 00039 vtkSmartPointer() {} 00040 00042 vtkSmartPointer(T* r): vtkSmartPointerBase(r) {} 00043 00046 vtkSmartPointer(const vtkSmartPointerBase& r): vtkSmartPointerBase(r) {} 00047 00049 00051 vtkSmartPointer& operator=(T* r) 00052 { 00053 this->vtkSmartPointerBase::operator=(r); 00054 return *this; 00055 } 00057 00059 00061 vtkSmartPointer& operator=(const vtkSmartPointerBase& r) 00062 { 00063 this->vtkSmartPointerBase::operator=(r); 00064 return *this; 00065 } 00067 00069 00070 T* GetPointer() const 00071 { 00072 return static_cast<T*>(this->Object); 00073 } 00075 00077 00079 T& operator*() const 00080 { 00081 return *static_cast<T*>(this->Object); 00082 } 00084 00086 00087 T* operator->() const 00088 { 00089 return static_cast<T*>(this->Object); 00090 } 00092 }; 00093 00094 #endif