VTK
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
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
vtkNew::~vtkNew
~vtkNew()
Definition:
vtkNew.h:83
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:57
vtkNew::GetPointer
T * GetPointer() const
Definition:
vtkNew.h:108
vtkNew
Allocate and hold a VTK object.
Definition:
vtkNew.h:66
vtkIOStream.h
Generated on Wed Mar 19 2014 12:51:25 for VTK by
1.8.6