PSCF v1.1
Public Types | Public Member Functions | List of all members
Util::FlexPtr< T > Class Template Reference

A pointer that may or may not own the object to which it points. More...

#include <FlexPtr.h>

Public Types

typedef T element_type
 Type of object pointed to. More...
 

Public Member Functions

 FlexPtr ()
 Constructor. More...
 
 ~FlexPtr ()
 Destructor. More...
 
void acquire (T *p)
 Copy a built-in pointer, and accept ownership. More...
 
void copy (T *p)
 Copy a built-in pointer, without accepting ownership. More...
 
T & operator* () const
 Dereference. More...
 
T * operator-> () const
 Member access. More...
 
T * get () const
 Return the built-in pointer. More...
 

Detailed Description

template<typename T>
class Util::FlexPtr< T >

A pointer that may or may not own the object to which it points.

FlexPtr overloads * and ->, and thus mimics a built-in pointer in most respects.

The acquire(T*) method copies a built-in pointer and accept ownership of the object to which it points, i.e., accepts responsibility for deleting the object, normally when the FlexPtr goes out of scope.

The copy(T*) method copies a built-in pointer without accepting ownership, i.e., without accepting responsibility for deleting the object to which it points.

Both acquire() and copy() destroy any object that is already owned by this FlexPtr before copying of a new pointer.

Definition at line 35 of file FlexPtr.h.

Member Typedef Documentation

◆ element_type

template<typename T >
typedef T Util::FlexPtr< T >::element_type

Type of object pointed to.

Definition at line 41 of file FlexPtr.h.

Constructor & Destructor Documentation

◆ FlexPtr()

template<typename T >
Util::FlexPtr< T >::FlexPtr ( )
inline

Constructor.

Definition at line 46 of file FlexPtr.h.

◆ ~FlexPtr()

template<typename T >
Util::FlexPtr< T >::~FlexPtr ( )
inline

Destructor.

Deletes any object that is owned by this FlexPtr.

Definition at line 56 of file FlexPtr.h.

Member Function Documentation

◆ acquire()

template<typename T >
void Util::FlexPtr< T >::acquire ( T *  p)
inline

Copy a built-in pointer, and accept ownership.

If this FlexPtr already owns an object, it will be deleted before acquiring a new pointer.

Throws an Exception if p is null.

Parameters
pBuilt-in pointer to be acquired.

Definition at line 73 of file FlexPtr.h.

References UTIL_THROW.

◆ copy()

template<typename T >
void Util::FlexPtr< T >::copy ( T *  p)
inline

Copy a built-in pointer, without accepting ownership.

If this FlexPtr already owns an object, it will be deleted before copying a new pointer.

Parameters
pBuilt-in pointer to be copied.

Definition at line 93 of file FlexPtr.h.

References UTIL_THROW.

◆ operator*()

template<typename T >
T & Util::FlexPtr< T >::operator* ( ) const
inline

Dereference.

Definition at line 108 of file FlexPtr.h.

◆ operator->()

template<typename T >
T * Util::FlexPtr< T >::operator-> ( ) const
inline

Member access.

Definition at line 114 of file FlexPtr.h.

◆ get()

template<typename T >
T * Util::FlexPtr< T >::get ( ) const
inline

Return the built-in pointer.

Definition at line 120 of file FlexPtr.h.

Referenced by Util::isNull().


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