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
containers
LinkedLists
accessTypes
LPtrList
LPtrList.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::LPtrList
26
27
Description
28
Template class for non-intrusive linked PtrLists.
29
30
SourceFiles
31
LPtrList.C
32
LPtrListIO.C
33
34
\*---------------------------------------------------------------------------*/
35
36
#ifndef LPtrList_H
37
#define LPtrList_H
38
39
#include <
OpenFOAM/LList.H
>
40
41
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42
43
namespace
Foam
44
{
45
46
// Forward declaration of friend functions and operators
47
48
template
<
class
LListBase,
class
T>
class
LPtrList;
49
50
template
<
class
LListBase,
class
T>
51
Istream&
operator
>>
52
(
53
Istream&,
54
LPtrList<LListBase, T>&
55
);
56
57
template
<
class
LListBase,
class
T>
58
Ostream&
operator
<<
59
(
60
Ostream&,
61
const
LPtrList<LListBase, T>&
62
);
63
64
65
/*---------------------------------------------------------------------------*\
66
Class LPtrList Declaration
67
\*---------------------------------------------------------------------------*/
68
69
template
<
class
LListBase,
class
T>
70
class
LPtrList
71
:
72
public
LList
<LListBase, T*>
73
{
74
// Private member functions
75
76
//- Read from Istream using given Istream constructor class
77
template
<
class
INew>
78
void
read(
Istream
&,
const
INew
& inewt);
79
80
81
public
:
82
83
// Forward declaration of STL iterators
84
85
class
iterator
;
86
friend
class
iterator
;
87
88
class
const_iterator
;
89
friend
class
const_iterator
;
90
91
92
// Constructors
93
94
//- Null construct
95
LPtrList
()
96
{}
97
98
//- Construct given initial T
99
LPtrList
(
T
* a)
100
:
101
LList
<
LListBase
,
T
*>(a)
102
{}
103
104
//- Construct from Istream using given Istream constructor class
105
template
<
class
INew>
106
LPtrList
(
Istream
&,
const
INew
&);
107
108
//- Construct from Istream using default Istream constructor class
109
LPtrList
(
Istream
&);
110
111
//- Construct as copy
112
LPtrList
(
const
LPtrList
&);
113
114
115
// Destructor
116
117
~LPtrList
();
118
119
120
// Member Functions
121
122
// Access
123
124
//- Return the first entry added
125
T
&
first
()
126
{
127
return
*
LList<LListBase, T*>::first
();
128
}
129
130
//- Return const access to the first entry added
131
const
T
&
first
()
const
132
{
133
return
*
LList<LListBase, T*>::first
();
134
}
135
136
//- Return the last entry added
137
T
&
last
()
138
{
139
return
*
LList<LListBase, T*>::last
();
140
}
141
142
//- Return const access to the last entry added
143
const
T
&
last
()
const
144
{
145
return
*
LList<LListBase, T*>::last
();
146
}
147
148
149
// Edit
150
151
//- Remove the head element from the list and delete the pointer
152
bool
eraseHead
();
153
154
//- Clear the contents of the list
155
void
clear
();
156
157
//- Transfer the contents of the argument into this List
158
// and annull the argument list.
159
void
transfer
(
LPtrList<LListBase, T>
&);
160
161
162
// Member operators
163
164
//- Assign copy
165
void
operator=
(
const
LPtrList<LListBase, T>
&);
166
167
168
// STL type definitions
169
170
//- Type that can be used for storing into LPtrList::value_type
171
// objects.
172
typedef
T
&
reference
;
173
174
//- Type that can be used for storing into constant
175
// LPtrList::value_type objects.
176
typedef
T
&
const_reference
;
177
178
179
// STL iterator
180
181
typedef
typename
LListBase::iterator
LListBase_iterator
;
182
183
//- An STL-conforming iterator
184
class
iterator
185
:
186
public
LList
<LListBase, T*>
::iterator
187
{
188
189
public
:
190
191
//- Construct from base iterator
192
iterator
193
(
194
LListBase_iterator
baseIter
195
)
196
:
197
LList<LListBase, T*>::iterator
(baseIter)
198
{}
199
200
201
// Member operators
202
203
T
&
operator*
()
204
{
205
return
*(
LList<LListBase, T*>::iterator::operator*
());
206
}
207
208
T
&
operator()
()
209
{
210
return
operator*
();
211
}
212
};
213
214
215
// STL const_iterator
216
217
typedef
typename
LListBase::const_iterator
LListBase_const_iterator
;
218
219
//- An STL-conforming const_iterator
220
class
const_iterator
221
:
222
public
LList
<LListBase, T*>
::const_iterator
223
{
224
225
public
:
226
227
//- Construct from base const_iterator
228
const_iterator
229
(
230
LListBase_const_iterator
baseIter
231
)
232
:
233
LList<LListBase, T*>::const_iterator
(baseIter)
234
{}
235
236
//- Construct from base iterator
237
const_iterator
238
(
239
LListBase_iterator
baseIter
240
)
241
:
242
LList<LListBase, T*>::const_iterator
(baseIter)
243
{}
244
245
246
// Member operators
247
248
const
T
&
operator*
()
249
{
250
return
*(
LList<LListBase, T*>::const_iterator::operator*
());
251
}
252
253
const
T
&
operator()
()
254
{
255
return
operator*
();
256
}
257
};
258
259
260
// IOstream operators
261
262
friend
Istream
&
operator
>> <
LListBase
,
T
>
263
(
264
Istream
&,
265
LPtrList<LListBase, T>
&
266
);
267
268
friend
Ostream
& operator<< <LListBase, T>
269
(
270
Ostream
&,
271
const
LPtrList<LListBase, T>
&
272
);
273
};
274
275
276
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
277
278
}
// End namespace Foam
279
280
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
281
282
#ifdef NoRepository
283
# include <
OpenFOAM/LPtrList.C
>
284
#endif
285
286
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287
288
#endif
289
290
// ************************ vim: set sw=4 sts=4 et: ************************ //