VTK
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
home
boeckb
code
depot
group-kitware
vtk
build-release
Utilities
Doxygen
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
}
112
T*
Get
()
const
113
{
114
return
this->Object;
115
}
117
118
private
:
119
vtkNew
(
vtkNew<T>
const
&);
// Not implemented.
120
void
operator=(
vtkNew<T>
const
&);
// Not implemented.
121
T* Object;
122
};
123
125
126
template
<
class
T>
127
inline
ostream& operator << (ostream& os, const vtkNew<T>& p)
128
{
129
return
os << p.GetPointer();
130
}
132
133
#endif
134
// VTK-HeaderTest-Exclude: vtkNew.h
vtkNew::~vtkNew
~vtkNew()
Definition:
vtkNew.h:83
vtkNew::Get
T * Get() const
Definition:
vtkNew.h:112
vtkNew::vtkNew
vtkNew()
Definition:
vtkNew.h:75
vtkNew::operator->
T * operator->() const
Definition:
vtkNew.h:97
vtkObjectBase
abstract base class for most VTK objects
Definition:
vtkObjectBase.h:59
vtkNew::GetPointer
T * GetPointer() const
Definition:
vtkNew.h:108
vtkNew
Allocate and hold a VTK object.
Definition:
vtkNew.h:66
vtkIOStream.h
Generated by
1.8.9.1