This is a smart intrusive reference counting pointer that throws a error on empty access. More...
#include <cppdb/ref_ptr.h>
Public Member Functions | |
ref_ptr (T *v=0) | |
~ref_ptr () | |
ref_ptr (ref_ptr const &other) | |
ref_ptr const & | operator= (ref_ptr const &other) |
T * | get () const |
operator bool () const | |
T * | operator-> () const |
T & | operator* () const |
void | reset (T *v=0) |
This is a smart intrusive reference counting pointer that throws a error on empty access.
The T should follow these concepts:
T::add_ref() // increases reference count IntegerType T::del_ref() // decreases reference count and returns its current value static T::dispose(T *) // destroys the object
cppdb::ref_ptr< T >::ref_ptr | ( | T * | v = 0 | ) | [inline] |
Default create a new object, if v is not null increases its reference count and stores it
cppdb::ref_ptr< T >::~ref_ptr | ( | ) | [inline] |
Dereference the object, if reference count goes to 0 destroys it calling T::dispose
cppdb::ref_ptr< T >::ref_ptr | ( | ref_ptr< T > const & | other | ) | [inline] |
Copy a pointer
T* cppdb::ref_ptr< T >::get | ( | ) | const [inline] |
Get he pointer value, it may return NULL in case of empty pointer
cppdb::ref_ptr< T >::operator bool | ( | ) | const [inline] |
Cast to boolean type: check if the pointer is not empty in similar way as you check ordinary pointers.
T& cppdb::ref_ptr< T >::operator* | ( | ) | const [inline] |
Returns reference to object, throws cppdb_error if it is NULL
T* cppdb::ref_ptr< T >::operator-> | ( | ) | const [inline] |
Returns pointer to object, throws cppdb_error if it is NULL
ref_ptr const& cppdb::ref_ptr< T >::operator= | ( | ref_ptr< T > const & | other | ) | [inline] |
Assign a pointer
void cppdb::ref_ptr< T >::reset | ( | T * | v = 0 | ) | [inline] |
Reset the pointer with new value - old object is dereferenced new is added.