PtrList< T > Class Template Reference

A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers. The operator[] returns a reference to the object, not the pointer. More...

Inherited by faBoundaryMesh, fvBoundaryMesh, IOPtrList< T >, pointBoundaryMesh, and polyBoundaryMesh.

Public Member Functions

constexpr PtrList () noexcept
 Default construct. More...
 
 PtrList (const label len)
 Construct with specified size, each element initialized to nullptr. More...
 
 PtrList (const PtrList< T > &list)
 Copy construct using 'clone()' method on each element. More...
 
 PtrList (PtrList< T > &&list)
 Move construct. More...
 
 PtrList (UList< T * > &list)
 Take ownership of pointers in the list, set old pointers to null. More...
 
template<class CloneArg >
 PtrList (const PtrList< T > &list, const CloneArg &cloneArgs)
 Copy construct using 'clone()' method on each element. More...
 
 PtrList (PtrList< T > &list, bool reuse)
 Construct as copy or re-use as specified. More...
 
 PtrList (const SLPtrList< T > &list)
 Copy construct using 'clone()' on each element of SLPtrList<T> More...
 
template<class INew >
 PtrList (Istream &is, const INew &inew)
 Construct from Istream using given Istream constructor class. More...
 
 PtrList (Istream &is)
 Construct from Istream using default Istream constructor class. More...
 
 ~PtrList ()
 Destructor. More...
 
template<class... Args>
PtrList< Tclone (Args &&... args) const
 Make a copy by cloning each of the list elements. More...
 
const Tset (const label i) const
 Return const pointer to element (can be nullptr),. More...
 
void clear ()
 Clear the PtrList. Delete allocated entries and set size to zero. More...
 
void resize (const label newLen)
 Adjust size of PtrList. More...
 
void setSize (const label newLen)
 Same as resize() More...
 
template<class... Args>
void emplace_append (Args &&... args)
 Construct and append an element to the end of the list. More...
 
void append (T *ptr)
 Append an element to the end of the list. More...
 
void append (autoPtr< T > &ptr)
 Move append an element to the end of the list. More...
 
void append (autoPtr< T > &&ptr)
 Move append an element to the end of the list. More...
 
void append (std::unique_ptr< T > &&ptr)
 Move append an element to the end of the list. More...
 
void append (const refPtr< T > &ptr)
 Move or clone append a refPtr to the end of the list. More...
 
void append (const tmp< T > &ptr)
 Move or clone append a tmp to the end of the list. More...
 
template<class... Args>
autoPtr< Templace (const label i, Args &&... args)
 Construct and set an element. More...
 
autoPtr< Tset (const label i, T *ptr)
 Set element to given pointer and return old element (can be null) More...
 
autoPtr< Tset (const label i, autoPtr< T > &ptr)
 Set element to given autoPtr and return old element. More...
 
autoPtr< Tset (const label i, autoPtr< T > &&ptr)
 Set element to given autoPtr and return old element. More...
 
autoPtr< Tset (const label i, std::unique_ptr< T > &&ptr)
 Set element to given unique_ptr and return old element. More...
 
autoPtr< Tset (const label i, const refPtr< T > &ptr)
 Set element to given refPtr and return old element. More...
 
autoPtr< Tset (const label i, const tmp< T > &ptr)
 Set element to given tmp and return old element. More...
 
autoPtr< Trelease (const label i)
 Release ownership of the pointer at the given position. More...
 
void transfer (PtrList< T > &list)
 Transfer into this list and annul the argument list. More...
 
void operator= (const PtrList< T > &list)
 Copy assignment. More...
 
void operator= (PtrList< T > &&list)
 Move assignment. More...
 
template<class... Args>
Foam::PtrList< Tclone (Args &&... args) const
 
template<class... Args>
Foam::autoPtr< Templace (const label i, Args &&... args)
 

Protected Member Functions

template<class INew >
void readIstream (Istream &is, const INew &inew)
 Read from Istream using Istream constructor class. More...
 
void free ()
 Delete the allocated entries, but retain the list size. More...
 

Friends

Istreamoperator>> (Istream &is, PtrList< T > &list)
 Read from Istream, discarding contents of existing list. More...
 

Detailed Description

template<class T>
class Foam::PtrList< T >

A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers. The operator[] returns a reference to the object, not the pointer.

See also
Foam::UPtrList Foam::PtrDynList
Source files

Definition at line 59 of file List.H.

Constructor & Destructor Documentation

◆ PtrList() [1/10]

constexpr PtrList ( )
inlineconstexprnoexcept

Default construct.

Definition at line 45 of file PtrListI.H.

◆ PtrList() [2/10]

PtrList ( const label  len)
inlineexplicit

Construct with specified size, each element initialized to nullptr.

Definition at line 52 of file PtrListI.H.

◆ PtrList() [3/10]

PtrList ( const PtrList< T > &  list)
inline

Copy construct using 'clone()' method on each element.

Definition at line 59 of file PtrListI.H.

◆ PtrList() [4/10]

PtrList ( PtrList< T > &&  list)
inline

Move construct.

Definition at line 66 of file PtrListI.H.

◆ PtrList() [5/10]

PtrList ( UList< T * > &  list)
inlineexplicit

Take ownership of pointers in the list, set old pointers to null.

Definition at line 73 of file PtrListI.H.

◆ PtrList() [6/10]

PtrList ( const PtrList< T > &  list,
const CloneArg &  cloneArgs 
)
inline

Copy construct using 'clone()' method on each element.

Definition at line 85 of file PtrListI.H.

◆ PtrList() [7/10]

PtrList ( PtrList< T > &  list,
bool  reuse 
)

Construct as copy or re-use as specified.

Definition at line 36 of file PtrList.C.

◆ PtrList() [8/10]

PtrList ( const SLPtrList< T > &  list)
explicit

Copy construct using 'clone()' on each element of SLPtrList<T>

Definition at line 54 of file PtrList.C.

◆ PtrList() [9/10]

PtrList ( Istream is,
const INew inew 
)

Construct from Istream using given Istream constructor class.

Definition at line 145 of file PtrListIO.C.

◆ PtrList() [10/10]

PtrList ( Istream is)

Construct from Istream using default Istream constructor class.

Definition at line 152 of file PtrListIO.C.

◆ ~PtrList()

~PtrList ( )

Destructor.

Definition at line 72 of file PtrList.C.

Member Function Documentation

◆ readIstream()

void readIstream ( Istream is,
const INew inew 
)
protected

Read from Istream using Istream constructor class.

Definition at line 38 of file PtrListIO.C.

◆ free()

void free ( )
inlineprotected

Delete the allocated entries, but retain the list size.

Definition at line 36 of file PtrListI.H.

◆ clone() [1/2]

PtrList<T> clone ( Args &&...  args) const

Make a copy by cloning each of the list elements.

Referenced by attachPolyTopoChanger::attach(), PtrList< transferModel >::clone(), polyTopoChange::makeMesh(), fvMeshTools::newMesh(), and fvMeshSubset::setCellSubset().

Here is the caller graph for this function:

◆ set() [1/7]

const T* set ( const label  i) const
inline

Return const pointer to element (can be nullptr),.

without bounds checking - same as get(). The return value can also be tested as a bool.

Definition at line 138 of file PtrList.H.

Referenced by fvMeshAdder::add(), polyMeshAdder::add(), phaseSystem::addField(), fvMeshTools::addPatch(), meshRefinement::appendPatch(), diffusionMulticomponent< ReactionThermo, ThermoType >::correct(), boundaryMesh::deletePatch(), fvMeshDistribute::distribute(), phaseSystem::fillFields(), forAll(), lduPrimitiveMesh::gather(), surfaceZonesInfo::getAllClosedNamedSurfaces(), surfaceZonesInfo::getClosedNamedSurfaces(), surfaceZonesInfo::getInsidePointNamedSurfaces(), surfaceZonesInfo::getNamedSurfaces(), surfaceZonesInfo::getStandaloneNamedSurfaces(), surfaceZonesInfo::getUnclosedNamedSurfaces(), PDRblock::innerMesh(), LUscalarMatrix::LUscalarMatrix(), fvMeshAdder::MapDimFields(), fvMeshAdder::MapSurfaceFields(), fvMeshAdder::MapVolFields(), pointBoundaryMesh::pointBoundaryMesh(), polyBoundaryMesh::polyBoundaryMesh(), multiRegion::read(), boundaryMesh::read(), externalCoupled::readDataMaster(), polyMesh::readUpdate(), refinementSurfaces::refinementSurfaces(), refinementFeatures::regionEdgeTrees(), trackingInverseDistance::update(), inverseDistance::update(), optimisationType::updateGradientsAndValues(), OFstreamCollator::write(), externalCoupled::writeDataMaster(), streamLineBase::writeToFile(), and ZoneMesh< cellZone, polyMesh >::ZoneMesh().

Here is the caller graph for this function:

◆ clear()

void clear ( )
inline

Clear the PtrList. Delete allocated entries and set size to zero.

Definition at line 97 of file PtrListI.H.

Referenced by functionObjectList::clear(), fvMatrix< Type >::clear(), functionObjectList::read(), sampledSurfaces::read(), polyMesh::readUpdate(), polyMesh::removeBoundary(), and decompositionMethod::setConstraints().

Here is the caller graph for this function:

◆ resize()

void resize ( const label  newLen)

Adjust size of PtrList.

New entries are initialized to nullptr, removed entries are deleted

Definition at line 103 of file PtrList.C.

Referenced by regionModel::interRegionAMI(), multiRegion::read(), sampledSurfaces::read(), PtrList< transferModel >::setSize(), and ZoneMesh< cellZone, polyMesh >::ZoneMesh().

Here is the caller graph for this function:

◆ setSize()

◆ emplace_append()

void emplace_append ( Args &&...  args)
inline

Construct and append an element to the end of the list.

Definition at line 106 of file PtrListI.H.

◆ append() [1/6]

void append ( T ptr)
inline

Append an element to the end of the list.

Definition at line 113 of file PtrListI.H.

Referenced by singleProcessorFaceSets::add(), triSurfaceLoader::load(), and streamLineBase::trimToBox().

Here is the caller graph for this function:

◆ append() [2/6]

void append ( autoPtr< T > &  ptr)
inline

Move append an element to the end of the list.

Definition at line 120 of file PtrListI.H.

◆ append() [3/6]

void append ( autoPtr< T > &&  ptr)
inline

Move append an element to the end of the list.

Definition at line 127 of file PtrListI.H.

◆ append() [4/6]

void append ( std::unique_ptr< T > &&  ptr)
inline

Move append an element to the end of the list.

Definition at line 134 of file PtrListI.H.

◆ append() [5/6]

void append ( const refPtr< T > &  ptr)
inline

Move or clone append a refPtr to the end of the list.

Definition at line 141 of file PtrListI.H.

◆ append() [6/6]

void append ( const tmp< T > &  ptr)
inline

Move or clone append a tmp to the end of the list.

Definition at line 148 of file PtrListI.H.

◆ emplace() [1/2]

autoPtr<T> emplace ( const label  i,
Args &&...  args 
)
inline

Construct and set an element.

◆ set() [2/7]

Foam::autoPtr< T > set ( const label  i,
T ptr 
)
inline

Set element to given pointer and return old element (can be null)

No-op if the new pointer value is identical to the current content.

Definition at line 167 of file PtrListI.H.

◆ set() [3/7]

Foam::autoPtr< T > set ( const label  i,
autoPtr< T > &  ptr 
)
inline

Set element to given autoPtr and return old element.

Definition at line 179 of file PtrListI.H.

Referenced by PtrList< transferModel >::set().

Here is the caller graph for this function:

◆ set() [4/7]

Foam::autoPtr< T > set ( const label  i,
autoPtr< T > &&  ptr 
)
inline

Set element to given autoPtr and return old element.

Definition at line 190 of file PtrListI.H.

◆ set() [5/7]

Foam::autoPtr< T > set ( const label  i,
std::unique_ptr< T > &&  ptr 
)
inline

Set element to given unique_ptr and return old element.

Definition at line 201 of file PtrListI.H.

◆ set() [6/7]

Foam::autoPtr< T > set ( const label  i,
const refPtr< T > &  ptr 
)
inline

Set element to given refPtr and return old element.

Definition at line 212 of file PtrListI.H.

◆ set() [7/7]

Foam::autoPtr< T > set ( const label  i,
const tmp< T > &  ptr 
)
inline

Set element to given tmp and return old element.

Definition at line 223 of file PtrListI.H.

◆ release()

Foam::autoPtr< T > release ( const label  i)
inline

Release ownership of the pointer at the given position.

Out of bounds addressing is a no-op and returns nullptr.

Definition at line 233 of file PtrListI.H.

◆ transfer()

void transfer ( PtrList< T > &  list)
inline

Transfer into this list and annul the argument list.

Definition at line 245 of file PtrListI.H.

Referenced by functionObjectList::read().

Here is the caller graph for this function:

◆ operator=() [1/2]

void operator= ( const PtrList< T > &  list)

Copy assignment.

For existing list entries, values are copied from the list. For new list entries, pointers are cloned from the list.

Definition at line 133 of file PtrList.C.

◆ operator=() [2/2]

void operator= ( PtrList< T > &&  list)
inline

Move assignment.

Definition at line 255 of file PtrListI.H.

◆ clone() [2/2]

Foam::PtrList<T> clone ( Args &&...  args) const

Definition at line 82 of file PtrList.C.

◆ emplace() [2/2]

Foam::autoPtr<T> emplace ( const label  i,
Args &&...  args 
)
inline

Definition at line 157 of file PtrListI.H.

Friends And Related Function Documentation

◆ operator>>

Istream& operator>> ( Istream is,
PtrList< T > &  list 
)
friend

Read from Istream, discarding contents of existing list.


The documentation for this class was generated from the following files: