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

11
12
13
14
    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.
15
16
17
18
19
20
21

    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
22
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
23
24
25
26
27
28

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

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

29
30
31
32
33
// * * * * * * * * * * * * Protected Member Functions  * * * * * * * * * * * //

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


Mark OLESEN's avatar
Mark OLESEN committed
38
// * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * * //
39

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


47
template<class T>
48
49
50
51
52
53
54
55
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
56
:
57
    UPtrList<T>(list.ptrs_.clone())
Mark OLESEN's avatar
Mark OLESEN committed
58
{}
59
60


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


68
69
70
71
72
73
74
75
76
77
78
79
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
80
81
// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

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


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


template<class T>
98
inline void Foam::PtrList<T>::append(T* ptr)
mattijs's avatar
mattijs committed
99
{
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
    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
115
116
117
118
}


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


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


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


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


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


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


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


Mark OLESEN's avatar
Mark OLESEN committed
168
169
170
// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //

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


177
// ************************************************************************* //