|
cartobase 6.0.16
|
Constant Ref to an object of class T. More...
#include <cartobase/smart/rcptr.h>


Public Types | |
| typedef T | referenced_type |
Public Member Functions | |
| const_ref () | |
| const_ref (const T *pObject) | |
| const_ref (const T *pObject, bool externalowner) | |
| template<class U> | |
| const_ref (std::auto_ptr< U > r) | |
| const_ref (const ref< T > &other) | |
| const_ref (const const_ref< T > &other) | |
| template<class R> | |
| const_ref (const ref< R > &o) | |
| template<class R> | |
| const_ref (const const_ref< R > &other) | |
| ~const_ref () | |
| const_ref< T > & | operator= (const ref< T > &other) |
| const_ref< T > & | operator= (const const_ref< T > &other) |
| bool | isNull () const |
| bool | operator== (const ref< T > &other) const |
| bool | operator== (const T *pointer) const |
| bool | operator== (const const_ref< T > &other) const |
| bool | operator!= (const ref< T > &other) const |
| bool | operator!= (const const_ref< T > &other) const |
| bool | operator!= (const T *pointer) const |
| const T * | operator-> () const |
| const T & | operator* () const |
| const T * | pointer () const |
| int | refCount () const |
Public Member Functions inherited from carto::RefData< T > | |
| int | count () const |
Friends | |
| class | DefaultRefConstruction |
| class | RCObject |
| template<class R> | |
| class | ref |
Constant Ref to an object of class T.
The purpose of this class is to provide a way to reference dynamically allocated objects without worrying about their destruction. To avoid confusion with built-in C++ references we call a Ref an object of class const_ref or ref.
A Ref act as a pointer on a dynamically allocated object (with new). The main difference between a Ref an a pointer is the link that exists between the Ref lifetime and the pointed object lifetime. An object pointed to by a Ref is destroyed when the last Ref pointed to it is destroyed. Therefore a Ref contains two things: a pointer to an object and a reference counter. Each time a Ref is created, the counter is incremented. When a Ref is destroyed, the counter is decremented and if the counter is null, the object is destroyed (with delete).
A Ref can be used to reference any object created by new. Therefore it can be used with existing classes.
A and B are never destroyed. new can be used to build only one Ref. If it is used to build several Ref, the object will be destroyed several times and the program will crash. See RCObject to avoid this problem. | typedef T carto::const_ref< T >::referenced_type |
|
inline |
Definition at line 310 of file rcptr.h.
Referenced by const_ref(), const_ref(), operator!=(), operator=(), operator=(), and operator==().
|
inlineexplicit |
|
inlineexplicit |
|
inline |
|
inline |
Definition at line 349 of file rcptr.h.
References const_ref().
|
inline |
Definition at line 373 of file rcptr.h.
References const_ref().
|
inline |
|
inline |
|
inline |
Definition at line 394 of file rcptr.h.
References const_ref().
|
inline |
|
inline |
|
inline |
|
inline |
| const_ref< T > & carto::const_ref< T >::operator= | ( | const const_ref< T > & | other | ) |
Definition at line 451 of file rcptr.h.
References const_ref().
| const_ref< T > & carto::const_ref< T >::operator= | ( | const ref< T > & | other | ) |
Definition at line 433 of file rcptr.h.
References const_ref(), and ref.
Referenced by carto::ref< T >::operator=(), and carto::weak_shared_ptr< T >::operator=().
|
inline |
Definition at line 392 of file rcptr.h.
References const_ref().
|
inline |
|
inline |
|
inline |
Definition at line 405 of file rcptr.h.
Referenced by operator!=(), and operator==().
|
inline |
|
friend |
Definition at line 302 of file rcptr.h.
References DefaultRefConstruction.
Referenced by DefaultRefConstruction.
|
friend |
Definition at line 305 of file rcptr.h.
References ref.
Referenced by const_ref(), const_ref(), operator!=(), operator=(), operator==(), and ref.