VTK
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
dox
Common
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
=========================================================================*/
55
#ifndef __vtkNew_h
56
#define __vtkNew_h
57
58
#include "
vtkIOStream.h
"
59
60
class
vtkObjectBase
;
61
62
template
<
class
T>
63
class
vtkNew
64
{
66
67
void
CheckObjectBase(
vtkObjectBase
*) {}
68
public
:
69
// Description:
70
// Create a new T on construction.
71
vtkNew
() : Object(T::New())
72
{
73
this->CheckObjectBase(this->Object);
74
}
76
78
79
~vtkNew
()
80
{
81
T* obj = this->Object;
82
if
(obj)
83
{
84
this->Object = 0;
85
obj->Delete();
86
}
87
}
89
91
93
T*
operator->
()
const
94
{
95
return
this->Object;
96
}
98
100
104
T*
GetPointer
()
const
105
{
106
return
this->Object;
107
}
109
110
private
:
111
vtkNew
(
vtkNew<T>
const
&);
// Not implemented.
112
void
operator=(
vtkNew<T>
const
&);
// Not implemented.
113
T* Object;
114
};
115
117
118
template
<
class
T>
119
inline
ostream& operator << (ostream& os, const vtkNew<T>& p)
120
{
121
return
os << p.GetPointer();
122
}
124
125
#endif
vtkNew::~vtkNew
~vtkNew()
Definition:
vtkNew.h:79
vtkNew::vtkNew
vtkNew()
Definition:
vtkNew.h:71
vtkNew::operator->
T * operator->() const
Definition:
vtkNew.h:93
vtkObjectBase
abstract base class for most VTK objects
Definition:
vtkObjectBase.h:59
vtkNew::GetPointer
T * GetPointer() const
Definition:
vtkNew.h:104
vtkNew
Allocate and hold a VTK object.
Definition:
vtkNew.h:63
vtkIOStream.h
Generated on Thu Oct 24 2019 21:14:25 for VTK by
1.8.6