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-2024 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  append(const_cast<autoPtr<T>&>(aptr).ptr());
51 }
52 
53 
54 template<class T>
55 inline void Foam::PtrList<T>::append(const tmp<T>& t)
56 {
57  append(const_cast<tmp<T>&>(t).ptr());
58 }
59 
60 
61 template<class T>
62 inline bool Foam::PtrList<T>::set(const label i) const
63 {
64  return this->ptrs_[i] != nullptr;
65 }
66 
67 
68 template<class T>
70 {
71  autoPtr<T> old(this->ptrs_[i]);
72  this->ptrs_[i] = ptr;
73  return old;
74 }
75 
76 
77 template<class T>
79 (
80  const label i,
81  const autoPtr<T>& aptr
82 )
83 {
84  return set(i, const_cast<autoPtr<T>&>(aptr).ptr());
85 }
86 
87 
88 template<class T>
90 (
91  const label i,
92  const tmp<T>& t
93 )
94 {
95  return set(i, const_cast<tmp<T>&>(t).ptr());
96 }
97 
98 
99 // ************************************************************************* //
bool set(const label) const
Is element set.
Definition: PtrListI.H:62
void resize(const label)
Alias for setSize(const label)
Definition: PtrListI.H:32
void append(T *)
Append an element at the end of the list.
Definition: PtrListI.H:39
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A class for managing temporary objects.
Definition: tmp.H:55
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
points setSize(newPointi)