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 blockMesh, faBoundaryMesh, fvBoundaryMesh, IOPtrList< T >, pointBoundaryMesh, and polyBoundaryMesh.

Public Member Functions

constexpr PtrList () noexcept
 Construct null. 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 ownerskip 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...
 
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...
 
void append (T *ptr)
 Append an element to the end of the list. More...
 
void append (autoPtr< T > &aptr)
 Move append an element to the end of the list. More...
 
void append (autoPtr< T > &&aptr)
 Move append an element to the end of the list. More...
 
void append (const tmp< T > &tptr)
 Move or clone append a tmp to the end of the list. More...
 
void transfer (PtrList< T > &list)
 Transfer into this list and annul the argument list. More...
 
const Tset (const label i) const
 Return const pointer to element (if set) or nullptr. 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 > &aptr)
 Set element to given autoPtr and return old element. More...
 
autoPtr< Tset (const label i, autoPtr< T > &&aptr)
 Set element to given autoPtr and return old element. More...
 
autoPtr< Tset (const label i, const tmp< T > &tptr)
 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 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
 

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 65 of file List.H.

Constructor & Destructor Documentation

◆ PtrList() [1/10]

constexpr PtrList ( )
inlineconstexprnoexcept

Construct null.

Definition at line 44 of file PtrListI.H.

◆ PtrList() [2/10]

PtrList ( const label  len)
inlineexplicit

Construct with specified size, each element initialized to nullptr.

Definition at line 51 of file PtrListI.H.

◆ PtrList() [3/10]

PtrList ( const PtrList< T > &  list)
inline

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

Definition at line 58 of file PtrListI.H.

◆ PtrList() [4/10]

PtrList ( PtrList< T > &&  list)
inline

Move construct.

Definition at line 65 of file PtrListI.H.

◆ PtrList() [5/10]

PtrList ( UList< T * > &  list)
inlineexplicit

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

Definition at line 72 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 88 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 165 of file PtrListIO.C.

◆ PtrList() [10/10]

PtrList ( Istream is)

Construct from Istream using default Istream constructor class.

Definition at line 172 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 35 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:

◆ clear()

void clear ( )
inline

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

Definition at line 100 of file PtrListI.H.

Referenced by functionObjectList::clear(), AMIWeights::read(), 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(), ZoneMesh< cellZone, polyMesh >::operator()(), functionObjectList::read(), sampledSurfaces::read(), and ZoneMesh< cellZone, polyMesh >::ZoneMesh().

Here is the caller graph for this function:

◆ setSize()

◆ append() [1/4]

void append ( T ptr)
inline

Append an element to the end of the list.

Definition at line 115 of file PtrListI.H.

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

Here is the caller graph for this function:

◆ append() [2/4]

void append ( autoPtr< T > &  aptr)
inline

Move append an element to the end of the list.

Definition at line 122 of file PtrListI.H.

◆ append() [3/4]

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

Move append an element to the end of the list.

Definition at line 129 of file PtrListI.H.

◆ append() [4/4]

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

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

Definition at line 136 of file PtrListI.H.

◆ transfer()

void transfer ( PtrList< T > &  list)
inline

Transfer into this list and annul the argument list.

Definition at line 190 of file PtrListI.H.

Referenced by functionObjectList::read().

Here is the caller graph for this function:

◆ set() [1/5]

◆ set() [2/5]

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 150 of file PtrListI.H.

◆ set() [3/5]

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

Set element to given autoPtr and return old element.

Definition at line 157 of file PtrListI.H.

◆ set() [4/5]

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

Set element to given autoPtr and return old element.

Definition at line 164 of file PtrListI.H.

◆ set() [5/5]

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

Set element to given tmp and return old element.

Definition at line 171 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 178 of file PtrListI.H.

◆ 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 200 of file PtrListI.H.

◆ clone() [2/2]

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

Definition at line 82 of file PtrList.C.

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: