autoPtr< T > Class Template Reference

An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and with pointer allocation checking on access. More...

Public Types

typedef T Type
 

Public Member Functions

 autoPtr (T *=nullptr)
 Store object pointer. More...
 
 autoPtr (const autoPtr< T > &)
 Construct as copy by transferring pointer to this autoPtr and. More...
 
 autoPtr (const autoPtr< T > &, const bool reuse)
 Construct either by transferring pointer or cloning. More...
 
 ~autoPtr ()
 Destructor, delete object if pointer is not nullptr. More...
 
bool empty () const
 Return true if the autoPtr is empty (ie, no pointer set) More...
 
bool valid () const
 Return true if the autoPtr valid (ie, the pointer is set) More...
 
Tptr ()
 Return object pointer for reuse. More...
 
void set (T *)
 Set pointer to that given. More...
 
void reset (T *=nullptr)
 If object pointer already set, delete object and set to given. More...
 
void clear ()
 Delete object (if the pointer is valid) and set pointer to. More...
 
Toperator() ()
 Return reference to the object data. More...
 
const Toperator() () const
 Return const reference to the object data. More...
 
Toperator* ()
 Return reference to the object data. More...
 
const Toperator* () const
 Return const reference to the object data. More...
 
 operator const T & () const
 Const cast to the underlying type reference. More...
 
Toperator-> ()
 Return object pointer. More...
 
const Toperator-> () const
 Return const object pointer. More...
 
void operator= (T *)
 Take over the object pointer from parameter. More...
 
void operator= (const autoPtr< T > &)
 Take over the object pointer from parameter. More...
 

Detailed Description

template<class T>
class Foam::autoPtr< T >

An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and with pointer allocation checking on access.

Source files

Definition at line 50 of file autoPtr.H.

Member Typedef Documentation

◆ Type

typedef T Type

Definition at line 60 of file autoPtr.H.

Constructor & Destructor Documentation

◆ autoPtr() [1/3]

autoPtr ( T p = nullptr)
inlineexplicit

Store object pointer.

Definition at line 32 of file autoPtrI.H.

◆ autoPtr() [2/3]

autoPtr ( const autoPtr< T > &  ap)
inline

Construct as copy by transferring pointer to this autoPtr and.

setting the arguments pointer to nullptr

Definition at line 39 of file autoPtrI.H.

◆ autoPtr() [3/3]

autoPtr ( const autoPtr< T > &  ap,
const bool  reuse 
)
inline

Construct either by transferring pointer or cloning.

Should only be called with type that supports cloning

Definition at line 48 of file autoPtrI.H.

References autoPtr< T >::ptr(), and autoPtr< T >::valid().

Here is the call graph for this function:

◆ ~autoPtr()

~autoPtr
inline

Destructor, delete object if pointer is not nullptr.

Definition at line 67 of file autoPtrI.H.

References clear().

Here is the call graph for this function:

Member Function Documentation

◆ empty()

bool empty
inline

Return true if the autoPtr is empty (ie, no pointer set)

Definition at line 76 of file autoPtrI.H.

Referenced by phaseSystem::generateInterfacialModels(), and vtkMesh::topo().

Here is the caller graph for this function:

◆ valid()

◆ ptr()

T * ptr
inline

◆ set()

void set ( T p)
inline

Set pointer to that given.

If object pointer already set issue a FatalError

Definition at line 99 of file autoPtrI.H.

Referenced by phaseSystem::generateInterfacialModels(), rigidBodyModel::merge(), SidedInterfacialModel< blendedDiffusiveMassTransferModel >::SidedInterfacialModel(), and SidedInterfacialModel< ModelType >::SidedInterfacialModel().

Here is the caller graph for this function:

◆ reset()

◆ clear()

void clear
inline

Delete object (if the pointer is valid) and set pointer to.

nullptr

Definition at line 126 of file autoPtrI.H.

Referenced by meshRefinement::distribute(), massFractions::execute(), distribution::New(), forcing::readCoeffs(), and masterUncollatedFileOperation::readStream().

Here is the caller graph for this function:

◆ operator()() [1/2]

T & operator()
inline

Return reference to the object data.

Definition at line 135 of file autoPtrI.H.

◆ operator()() [2/2]

const T & operator()
inline

Return const reference to the object data.

Definition at line 150 of file autoPtrI.H.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Foam::name(), and Foam::T().

Here is the call graph for this function:

◆ operator*() [1/2]

T & operator*
inline

Return reference to the object data.

Definition at line 165 of file autoPtrI.H.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Foam::name(), and Foam::T().

Here is the call graph for this function:

◆ operator*() [2/2]

const T & operator*
inline

Return const reference to the object data.

Definition at line 180 of file autoPtrI.H.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Foam::name(), and Foam::T().

Here is the call graph for this function:

◆ operator const T &()

operator const T &
inline

Const cast to the underlying type reference.

Definition at line 195 of file autoPtrI.H.

◆ operator->() [1/2]

T * operator->
inline

Return object pointer.

Definition at line 202 of file autoPtrI.H.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Foam::name(), and Foam::T().

Here is the call graph for this function:

◆ operator->() [2/2]

const T * operator->
inline

Return const object pointer.

Definition at line 217 of file autoPtrI.H.

◆ operator=() [1/2]

void operator= ( T p)
inline

Take over the object pointer from parameter.

Definition at line 224 of file autoPtrI.H.

References p.

◆ operator=() [2/2]

void operator= ( const autoPtr< T > &  ap)
inline

Take over the object pointer from parameter.

Definition at line 231 of file autoPtrI.H.


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