Chombo + EB + MF
3.2
|
A reference-counting handle class. More...
#include <RefCountedPtr.H>
Public Types | |
typedef T | value_type |
typedef T * | pointer |
typedef T & | reference |
typedef RefCountedPtr< T, OP > | Self |
Public Member Functions | |
RefCountedPtr (pointer const ptr=0) | |
construct with POD pointer More... | |
RefCountedPtr (const Self &other) | |
copy More... | |
RefCountedPtr (const RefCountedPtr< typename RCPTypeTr< T >::InvertConstType, OP > &other) | |
const converting copy adds const qualifier. More... | |
template<typename S > | |
RefCountedPtr (const RefCountedPtr< S, OP > &other) | |
related converting copy More... | |
template<typename OP2 > | |
RefCountedPtr (const RefCountedPtr< T, OP2 > &other) | |
template<typename OP2 > | |
RefCountedPtr (const RefCountedPtr< typename RCPTypeTr< T >::InvertConstType, OP2 > &other) | |
~RefCountedPtr () | |
Destructor. More... | |
Self & | operator= (const Self &rhs) |
assignment operator copies pointer member More... | |
Self & | operator= (const RefCountedPtr< typename RCPTypeTr< T >::InvertConstType, OP > &rhs) |
const converting assignment operator adds const qualifier. More... | |
template<typename S > | |
Self & | operator= (const RefCountedPtr< S, OP > &rhs) |
related assignment operator More... | |
template<typename OP2 > | |
Self & | operator= (const RefCountedPtr< T, OP2 > &rhs) |
template<typename OP2 > | |
Self & | operator= (const RefCountedPtr< typename RCPTypeTr< T >::InvertConstType, OP2 > &rhs) |
pointer | operator-> () const |
dereference access operator used like a pointer derefence access function. More... | |
pointer const & | getRefToThePointer () const |
Return a const reference to the pointer and don't ask questions. More... | |
reference | operator* () const |
pointer dereference. More... | |
reference | operator[] (const int a_idx) const |
[] access More... | |
operator T* () const | |
auto conversion to regular pointer where required. More... | |
bool | isNull () const |
bool | isNonUnique () const |
true when refcount is one. More... | |
int | refCount () const |
void | swap (Self &b) |
void | neverDelete () |
Will never delete ptr_. More... | |
void | incrementMem () |
void | freeMem () |
RefCountedPtr (RefCountedPtr< T, OP > &&a_in) noexcept | |
move constructor More... | |
RefCountedPtr< T, OP > & | operator= (RefCountedPtr< T, OP > &&a_in) noexcept |
Static Public Member Functions | |
static const std::string & | name () |
Protected Member Functions | |
void | refUp () |
void | refDown () |
Protected Attributes | |
pointer | ptr_ |
int * | refCount_ |
Static Protected Attributes | |
static std::string | name_ |
static BArena | s_Arena |
static int | size_ = sizeof(T)+2*sizeof(int) |
Friends | |
template<typename T2 , typename OP2 > | |
class | RefCountedPtr |
A reference-counting handle class.
T | Type of object pointed to |
OP | Object Policy for T. If T* is an object pointer, use the RCPPointerPolicy. If T* is an array, use the RCPArrayPolicy to get proper destruction. If T* requires deletion with 'free', use the RCPFreePolicy. By default RCPPointerPolicy is used. |
This is to be used as a pointer to class T. This will feel and smell just like a built-in pointer except:
-# There is no need to call delete on the pointer. -# The default copy constructor and assignment implement ref-counting. -# The user may call isNonUnique to determine if this pointer is the only pointer to the data. This can be used to hide the ref-counting behavior of a class. -# Checks for dereference of a null pointer.
This class is completely inlined.
typical usage:
typedef T RefCountedPtr< T, OP >::value_type |
typedef T* RefCountedPtr< T, OP >::pointer |
typedef T& RefCountedPtr< T, OP >::reference |
typedef RefCountedPtr<T, OP> RefCountedPtr< T, OP >::Self |
|
inlineexplicit |
construct with POD pointer
|
inline |
copy
|
inline |
const converting copy adds const qualifier.
the related converting copy could be used but this avoids the dynamic_cast when just adding qualifiers
|
inline |
related converting copy
allows conversion between related POD pointers. E.g. base to derived (requires dynamic_cast) or derived to base.
|
inline |
|
inline |
|
inline |
Destructor.
|
inlinenoexcept |
move constructor
|
inline |
assignment operator copies pointer member
copies pointer member and integer pointer, decreases 'this' refcount before assignment, then increases refcount of this=rhs.
|
inline |
const converting assignment operator adds const qualifier.
|
inline |
related assignment operator
allows conversion between related POD pointers. E.g. base to derived (requires dynamic_cast) or derived to base.
|
inline |
|
inline |
|
inline |
dereference access operator used like a pointer derefence access function.
|
inline |
Return a const reference to the pointer and don't ask questions.
Same as operator -> but obtains the reference even if the pointer has not yet been assigned. Used in some early setup where we want to track the RCP but it hasn't been defined yet. If you want the pointer and know it has been allocated, -> should be preferred.
|
inline |
pointer dereference.
|
inline |
[] access
|
inline |
auto conversion to regular pointer where required.
kind of dangerous. Deleting the returned pointer will cause havoc.
|
inline |
|
inline |
true when refcount is one.
|
inline |
Referenced by EBISLayout::refCount().
|
inline |
|
inline |
Will never delete ptr_.
useful in functions that need to return a pointer which, under some circumstances, we want to own, and under others we don't.
|
inlinestatic |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlineprotected |
|
inlineprotected |
|
friend |
|
protected |
Referenced by RefCountedPtr< DataFactory< NodeFArrayBox > >::freeMem(), RefCountedPtr< DataFactory< NodeFArrayBox > >::getRefToThePointer(), RefCountedPtr< DataFactory< NodeFArrayBox > >::isNull(), RefCountedPtr< WGSRefinementCriterion >::operator WGSRefinementCriterion *(), RefCountedPtr< DataFactory< NodeFArrayBox > >::operator*(), RefCountedPtr< DataFactory< NodeFArrayBox > >::operator->(), RefCountedPtr< DataFactory< NodeFArrayBox > >::operator=(), RefCountedPtr< DataFactory< NodeFArrayBox > >::operator[](), RefCountedPtr< DataFactory< NodeFArrayBox > >::RefCountedPtr(), RefCountedPtr< DataFactory< NodeFArrayBox > >::refDown(), RefCountedPtr< DataFactory< NodeFArrayBox > >::refUp(), and RefCountedPtr< DataFactory< NodeFArrayBox > >::swap().
|
protected |
Referenced by RefCountedPtr< DataFactory< NodeFArrayBox > >::freeMem(), RefCountedPtr< DataFactory< NodeFArrayBox > >::incrementMem(), RefCountedPtr< DataFactory< NodeFArrayBox > >::isNonUnique(), RefCountedPtr< DataFactory< NodeFArrayBox > >::neverDelete(), RefCountedPtr< DataFactory< NodeFArrayBox > >::operator=(), RefCountedPtr< DataFactory< NodeFArrayBox > >::refCount(), RefCountedPtr< DataFactory< NodeFArrayBox > >::RefCountedPtr(), RefCountedPtr< DataFactory< NodeFArrayBox > >::refDown(), RefCountedPtr< DataFactory< NodeFArrayBox > >::refUp(), and RefCountedPtr< DataFactory< NodeFArrayBox > >::swap().
|
staticprotected |
Referenced by RefCountedPtr< DataFactory< NodeFArrayBox > >::name().
|
staticprotected |
|
staticprotected |