/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
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.
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
along with OpenFOAM. If not, see .
\*---------------------------------------------------------------------------*/
#include "autoPtr.H"
#include "tmp.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template
inline void Foam::PtrList::free()
{
(this->ptrs_).free(); // free old pointers
}
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
template
inline constexpr Foam::PtrList::PtrList() noexcept
:
UPtrList()
{}
template
inline Foam::PtrList::PtrList(const label len)
:
UPtrList(len)
{}
template
inline Foam::PtrList::PtrList(const PtrList& list)
:
UPtrList(list.ptrs_.clone())
{}
template
inline Foam::PtrList::PtrList(PtrList&& list)
:
UPtrList(std::move(list))
{}
template
inline Foam::PtrList::PtrList(UList& list)
:
UPtrList(list.size())
{
// Take ownership of the pointer
forAll(list, i)
{
set(i, list[i]);
list[i] = nullptr;
}
}
template
template
inline Foam::PtrList::PtrList
(
const PtrList& list,
const CloneArg& cloneArg
)
:
UPtrList(list.clone(cloneArg)())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
inline void Foam::PtrList::clear()
{
(this->ptrs_).free(); // free old pointers
UPtrList::clear();
}
template
inline void Foam::PtrList::setSize(const label newLen)
{
this->resize(newLen);
}
template
inline void Foam::PtrList::append(T* ptr)
{
UPtrList::append(ptr);
}
template
inline void Foam::PtrList::append(autoPtr& aptr)
{
UPtrList::append(aptr.release());
}
template
inline void Foam::PtrList::append(autoPtr&& aptr)
{
UPtrList::append(aptr.release());
}
template
inline void Foam::PtrList::append(const tmp& tptr)
{
UPtrList::append(tptr.ptr());
}
template
inline const T* Foam::PtrList::set(const label i) const
{
return UPtrList::set(i);
}
template
inline Foam::autoPtr Foam::PtrList::set(const label i, T* ptr)
{
return autoPtr(UPtrList::set(i, ptr));
}
template
inline Foam::autoPtr Foam::PtrList::set(const label i, autoPtr& aptr)
{
return set(i, aptr.release());
}
template
inline Foam::autoPtr Foam::PtrList::set(const label i, autoPtr&& aptr)
{
return set(i, aptr.release());
}
template
inline Foam::autoPtr Foam::PtrList::set(const label i, const tmp& tptr)
{
return set(i, tptr.ptr());
}
template
inline Foam::autoPtr Foam::PtrList::release(const label i)
{
if (i < 0 || i >= this->size())
{
return nullptr;
}
return autoPtr(UPtrList::set(i, nullptr));
}
template
inline void Foam::PtrList::transfer(PtrList& list)
{
(this->ptrs_).free(); // free old pointers
UPtrList::transfer(list);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template
inline void Foam::PtrList::operator=(PtrList&& list)
{
this->transfer(list);
}
// ************************************************************************* //