bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
agg_util::RCPtr< T > Class Template Reference

A reference to an RCObject which automatically ref() and deref() on creation and destruction. More...

#include <RCObject.h>

Inheritance diagram for agg_util::RCPtr< T >:
Inheritance graph
Collaboration diagram for agg_util::RCPtr< T >:
Collaboration graph

Public Member Functions

T * get () const
 
T & operator* () const
 
T * operator-> () const
 
RCPtroperator= (const RCPtr &rhs)
 
 RCPtr (const RCPtr &from)
 
 RCPtr (T *pRef=0)
 
T * refAndGet () const
 

Detailed Description

template<class T>
class agg_util::RCPtr< T >

A reference to an RCObject which automatically ref() and deref() on creation and destruction.

Use this for temporary references to an RCObject* instead of std::unique_ptr to avoid leaks or double deletion. It is templated to allow RCObject subclass specific pointers.

For example,

RCPtr<RCObject> obj = RCPtr<RCObject>(new RCObject()); // count is now 1. // make a call to add to container that might throw exception. // we assume the container will up the ref() itself on a successful addition. addToContainer(obj.get()); // if previous line exceptions, ~RCPtr will unref() it back to 0, causing it to delete. // if we get here, the object is safely in the container and has been ref() to 2, // so ~RCPtr correctly drops it back to 1.

Note
We don't have a class for weak references, so make sure to not generate reference loops with back pointers (circular ref graphs) Back pointers should be raw pointers (until/unless we add weak references) and ref() should only be called when it's a strong reference! (ie one that shares ownership).

Definition at line 284 of file RCObject.h.

Constructor & Destructor Documentation

◆ RCPtr() [1/2]

template<class T>
agg_util::RCPtr< T >::RCPtr ( T * pRef = 0)
inline

Definition at line 286 of file RCObject.h.

◆ RCPtr() [2/2]

template<class T>
agg_util::RCPtr< T >::RCPtr ( const RCPtr< T > & from)
inline

Definition at line 292 of file RCObject.h.

◆ ~RCPtr()

template<class T>
agg_util::RCPtr< T >::~RCPtr ( )
inline

Definition at line 298 of file RCObject.h.

Member Function Documentation

◆ get()

template<class T>
T * agg_util::RCPtr< T >::get ( ) const
inline

Definition at line 335 of file RCObject.h.

◆ operator*()

template<class T>
T & agg_util::RCPtr< T >::operator* ( ) const
inline

Definition at line 321 of file RCObject.h.

◆ operator->()

template<class T>
T * agg_util::RCPtr< T >::operator-> ( ) const
inline

Definition at line 329 of file RCObject.h.

◆ operator=()

template<class T>
RCPtr & agg_util::RCPtr< T >::operator= ( const RCPtr< T > & rhs)
inline

Definition at line 307 of file RCObject.h.

◆ refAndGet()

template<class T>
T * agg_util::RCPtr< T >::refAndGet ( ) const
inline

If not null, ref() the object and then return it.

Useful for adding a reference to a container, e.g.:

RCPtr<T> myObj; vector<T> myVecOfObj; myVecOfObj.push_back(myObj.refAndGet());

Returns

Definition at line 353 of file RCObject.h.


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