VTK
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
dox
Common
Core
vtkNew.h
Go to the documentation of this file.
1
/*=========================================================================
2
3
Program: Visualization Toolkit
4
Module: vtkNew.h
5
6
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7
All rights reserved.
8
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10
This software is distributed WITHOUT ANY WARRANTY; without even
11
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12
PURPOSE. See the above copyright notice for more information.
13
14
=========================================================================*/
58
#ifndef __vtkNew_h
59
#define __vtkNew_h
60
61
#include "
vtkIOStream.h
"
62
63
class
vtkObjectBase
;
64
65
template
<
class
T>
66
class
vtkNew
67
{
69
70
void
CheckObjectBase(
vtkObjectBase
*) {}
71
public
:
73
74
75
vtkNew
() : Object(T::New())
76
{
77
this->CheckObjectBase(this->Object);
78
}
80
82
83
~vtkNew
()
84
{
85
T* obj = this->Object;
86
if
(obj)
87
{
88
this->Object = 0;
89
obj->Delete();
90
}
91
}
93
95
97
T*
operator->
()
const
98
{
99
return
this->Object;
100
}
102
104
108
T*
GetPointer
()
const
109
{
110
return
this->Object;
111
}
113
114
private
:
115
vtkNew
(
vtkNew<T>
const
&);
// Not implemented.
116
void
operator=(
vtkNew<T>
const
&);
// Not implemented.
117
T* Object;
118
};
119
121
122
template
<
class
T>
123
inline
ostream& operator << (ostream& os, const vtkNew<T>& p)
124
{
125
return
os << p.GetPointer();
126
}
128
129
#endif
130
// VTK-HeaderTest-Exclude: vtkNew.h
Generated on Thu May 24 2012 22:22:08 for VTK by
1.8.1