PtrListI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
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 \*---------------------------------------------------------------------------*/
25 
26 #include "autoPtr.H"
27 #include "tmp.H"
28 
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30 
31 template<class T>
32 inline void Foam::PtrList<T>::resize(const label newSize)
33 {
34  this->setSize(newSize);
35 }
36 
37 
38 template<class T>
39 inline void Foam::PtrList<T>::append(T* ptr)
40 {
41  label sz = this->size();
42  this->setSize(sz+1);
43  this->ptrs_[sz] = ptr;
44 }
45 
46 
47 template<class T>
48 inline void Foam::PtrList<T>::append(const autoPtr<T>& aptr)
49 {
50  return append(const_cast<autoPtr<T>&>(aptr).ptr());
51 }
52 
53 
54 template<class T>
55 inline void Foam::PtrList<T>::append
56 (
57  const tmp<T>& t
58 )
59 {
60  return append(const_cast<tmp<T>&>(t).ptr());
61 }
62 
63 
64 template<class T>
65 inline bool Foam::PtrList<T>::set(const label i) const
66 {
67  return this->ptrs_[i] != nullptr;
68 }
69 
70 
71 template<class T>
73 {
74  autoPtr<T> old(this->ptrs_[i]);
75  this->ptrs_[i] = ptr;
76  return old;
77 }
78 
79 
80 template<class T>
82 (
83  const label i,
84  const autoPtr<T>& aptr
85 )
86 {
87  return set(i, const_cast<autoPtr<T>&>(aptr).ptr());
88 }
89 
90 
91 template<class T>
93 (
94  const label i,
95  const tmp<T>& t
96 )
97 {
98  return set(i, const_cast<tmp<T>&>(t).ptr());
99 }
100 
101 
102 // ************************************************************************* //
void append(T *)
Append an element at the end of the list.
Definition: PtrListI.H:39
bool set(const label) const
Is element set.
Definition: PtrListI.H:65
points setSize(newPointi)
const volScalarField & T
void resize(const label)
Alias for setSize(const label)
Definition: PtrListI.H:32
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
A class for managing temporary objects.
Definition: PtrList.H:53