00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: $RCSfile: vtkSmartPointer.h,v $ 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00025 #ifndef __vtkSmartPointer_h 00026 #define __vtkSmartPointer_h 00027 00028 #include "vtkSmartPointerBase.h" 00029 00030 template <class T> 00031 class vtkSmartPointer: public vtkSmartPointerBase 00032 { 00033 public: 00035 vtkSmartPointer() {} 00036 00038 vtkSmartPointer(T* r): vtkSmartPointerBase(r) {} 00039 00042 vtkSmartPointer(const vtkSmartPointerBase& r): vtkSmartPointerBase(r) {} 00043 00045 00047 vtkSmartPointer& operator=(T* r) 00048 { 00049 this->vtkSmartPointerBase::operator=(r); 00050 return *this; 00051 } 00053 00055 00057 vtkSmartPointer& operator=(const vtkSmartPointerBase& r) 00058 { 00059 this->vtkSmartPointerBase::operator=(r); 00060 return *this; 00061 } 00063 00065 00066 T* GetPointer() const 00067 { 00068 return static_cast<T*>(this->Object); 00069 } 00071 00073 00075 T& operator*() const 00076 { 00077 return *static_cast<T*>(this->Object); 00078 } 00080 00082 00083 T* operator->() const 00084 { 00085 return static_cast<T*>(this->Object); 00086 } 00088 }; 00089 00090 #endif