PtrListI.H 4.03 KB
Newer Older
1
2
3
4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
OpenFOAM bot's avatar
OpenFOAM bot committed
5
6
7
8
    \\  /    A nd           | Copyright (C) 2018-2019 OpenCFD Ltd.
     \\/     M anipulation  |
-------------------------------------------------------------------------------
                            | Copyright (C) 2011-2016 OpenFOAM Foundation
9
10
11
12
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

13
14
15
16
    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
17
18
19
20
21
22
23

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
24
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
25
26
27
28
29
30

\*---------------------------------------------------------------------------*/

#include "autoPtr.H"
#include "tmp.H"

31
32
33
34
35
// * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //

template<class T>
inline void Foam::PtrList<T>::free()
{
36
    (this->ptrs_).free(); // free old pointers
37
38
39
}


Mark OLESEN's avatar
Mark OLESEN committed
40
// * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * * //
41

42
43
44
45
46
47
48
template<class T>
inline constexpr Foam::PtrList<T>::PtrList() noexcept
:
    UPtrList<T>()
{}


49
template<class T>
50
51
52
53
54
55
56
57
inline Foam::PtrList<T>::PtrList(const label len)
:
    UPtrList<T>(len)
{}


template<class T>
inline Foam::PtrList<T>::PtrList(const PtrList<T>& list)
Mark OLESEN's avatar
Mark OLESEN committed
58
:
59
    UPtrList<T>(list.ptrs_.clone())
Mark OLESEN's avatar
Mark OLESEN committed
60
{}
61
62


mattijs's avatar
mattijs committed
63
template<class T>
64
inline Foam::PtrList<T>::PtrList(PtrList<T>&& list)
Mark OLESEN's avatar
Mark OLESEN committed
65
:
66
    UPtrList<T>(std::move(list))
Mark OLESEN's avatar
Mark OLESEN committed
67
68
69
{}


70
71
72
73
74
75
76
77
78
79
80
81
template<class T>
template<class CloneArg>
inline Foam::PtrList<T>::PtrList
(
    const PtrList<T>& list,
    const CloneArg& cloneArg
)
:
    UPtrList<T>(list.clone(cloneArg)())
{}


Mark OLESEN's avatar
Mark OLESEN committed
82
83
// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

84
85
86
template<class T>
inline void Foam::PtrList<T>::clear()
{
87
    (this->ptrs_).free(); // free old pointers
88
89
90
91
    UPtrList<T>::clear();
}


Mark OLESEN's avatar
Mark OLESEN committed
92
template<class T>
93
inline void Foam::PtrList<T>::setSize(const label newLen)
mattijs's avatar
mattijs committed
94
{
95
    this->resize(newLen);
mattijs's avatar
mattijs committed
96
97
98
99
}


template<class T>
100
inline void Foam::PtrList<T>::append(T* ptr)
mattijs's avatar
mattijs committed
101
{
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
    UPtrList<T>::append(ptr);
}


template<class T>
inline void Foam::PtrList<T>::append(autoPtr<T>& aptr)
{
    return UPtrList<T>::append(aptr.release());
}


template<class T>
inline void Foam::PtrList<T>::append(autoPtr<T>&& aptr)
{
    return UPtrList<T>::append(aptr.release());
mattijs's avatar
mattijs committed
117
118
119
120
}


template<class T>
Mark OLESEN's avatar
Mark OLESEN committed
121
inline void Foam::PtrList<T>::append(const tmp<T>& tptr)
mattijs's avatar
mattijs committed
122
{
123
    return UPtrList<T>::append(tptr.ptr());
mattijs's avatar
mattijs committed
124
125
126
}


127
template<class T>
128
inline const T* Foam::PtrList<T>::set(const label i) const
129
{
130
    return UPtrList<T>::set(i);
131
132
133
134
}


template<class T>
135
inline Foam::autoPtr<T> Foam::PtrList<T>::set(const label i, T* ptr)
136
{
137
    return autoPtr<T>(UPtrList<T>::set(i, ptr));
138
139
140
141
}


template<class T>
142
inline Foam::autoPtr<T> Foam::PtrList<T>::set(const label i, autoPtr<T>& aptr)
143
{
144
    return set(i, aptr.release());
145
146
147
148
}


template<class T>
149
inline Foam::autoPtr<T> Foam::PtrList<T>::set(const label i, autoPtr<T>&& aptr)
150
151
152
153
154
155
{
    return set(i, aptr.release());
}


template<class T>
156
inline Foam::autoPtr<T> Foam::PtrList<T>::set(const label i, const tmp<T>& tptr)
157
{
158
    return set(i, tptr.ptr());
Mark OLESEN's avatar
Mark OLESEN committed
159
160
161
162
}


template<class T>
163
inline void Foam::PtrList<T>::transfer(PtrList<T>& list)
Mark OLESEN's avatar
Mark OLESEN committed
164
{
165
    (this->ptrs_).free(); // free old pointers
166
    UPtrList<T>::transfer(list);
167
168
169
}


Mark OLESEN's avatar
Mark OLESEN committed
170
171
172
// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //

template<class T>
173
inline void Foam::PtrList<T>::operator=(PtrList<T>&& list)
Mark OLESEN's avatar
Mark OLESEN committed
174
{
175
    this->transfer(list);
Mark OLESEN's avatar
Mark OLESEN committed
176
177
178
}


179
// ************************************************************************* //