Home
Downloads
Documentation
Installation
User Guide
man-pages
API Documentation
README
Release Notes
Changes
License
Support
SourceForge Project
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
OpenFOAM
memory
autoPtr
autoPtr.H
Go to the documentation of this file.
1
/*---------------------------------------------------------------------------*\
2
========= |
3
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4
\\ / O peration |
5
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6
\\/ M anipulation |
7
-------------------------------------------------------------------------------
8
License
9
This file is part of OpenFOAM.
10
11
OpenFOAM is free software: you can redistribute it and/or modify it
12
under the terms of the GNU General Public License as published by
13
the Free Software Foundation, either version 3 of the License, or
14
(at your option) any later version.
15
16
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19
for more details.
20
21
You should have received a copy of the GNU General Public License
22
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23
24
Class
25
Foam::autoPtr
26
27
Description
28
An auto-pointer similar to the STL auto_ptr but with automatic casting
29
to a reference to the type and with pointer allocation checking on access.
30
31
SourceFiles
32
autoPtrI.H
33
34
\*---------------------------------------------------------------------------*/
35
36
#ifndef autoPtr_H
37
#define autoPtr_H
38
39
#include <cstddef>
40
41
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42
43
namespace
Foam
44
{
45
46
/*---------------------------------------------------------------------------*\
47
Class autoPtr Declaration
48
\*---------------------------------------------------------------------------*/
49
50
template
<
class
T>
51
class
autoPtr
52
{
53
// Public data
54
55
//- Pointer to object
56
mutable
T
* ptr_;
57
58
59
public
:
60
61
// Constructors
62
63
//- Store object pointer
64
inline
explicit
autoPtr
(
T
* = 0);
65
66
//- Construct as copy by transfering pointer to this autoPtr and
67
// setting the arguments pointer to NULL
68
inline
autoPtr
(
const
autoPtr<T>
&);
69
70
71
// Destructor
72
73
//- Delete object if pointer is not NULL
74
inline
~autoPtr
();
75
76
77
// Member Functions
78
79
// Check
80
81
//- Return true if the autoPtr is empty (ie, no pointer set).
82
inline
bool
empty
()
const
;
83
84
//- Return true if the autoPtr valid (ie, the pointer is set).
85
inline
bool
valid
()
const
;
86
87
88
// Edit
89
90
//- Return object pointer for reuse
91
inline
T
*
ptr
();
92
93
//- Set pointer to that given.
94
// If object pointer already set issue a FatalError.
95
inline
void
set
(
T
*);
96
97
//- If object pointer already set, delete object and set to given pointer
98
inline
void
reset
(
T
* = 0);
99
100
//- Delete object and set pointer to NULL, if the pointer is valid.
101
inline
void
clear
();
102
103
104
// Member operators
105
106
//- Return reference to the object data
107
inline
T
&
operator()
();
108
109
//- Return const reference to the object data
110
inline
const
T
&
operator()
()
const
;
111
112
// inline T& operator*();
113
// inline const T& operator*() const;
114
115
inline
operator
const
T
&()
const
;
116
117
//- Return object pointer
118
inline
T
*
operator->
();
119
120
//- Return const object pointer
121
inline
const
T
*
operator->
()
const
;
122
123
//- Take over object pointer from parameter
124
inline
void
operator=
(
const
autoPtr<T>
&);
125
};
126
127
128
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129
130
}
// End namespace Foam
131
132
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133
134
#include "
autoPtrI.H
"
135
136
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137
138
#endif
139
140
// ************************ vim: set sw=4 sts=4 et: ************************ //