#include <reference-count.h>
Public Member Functions | |
void | incref () const |
void | decref () const |
Smart (ReferenceCountedObject *p=0) | |
Smart (const Smart< ReferenceCountedObject > &o) | |
Smart< ReferenceCountedObject > & | operator= (const Smart< ReferenceCountedObject > &o) |
template<class AnotherReferenceCountedObject > | |
Smart< ReferenceCountedObject > & | operator= (const Smart< AnotherReferenceCountedObject > &o) |
bool | operator== (const Smart< ReferenceCountedObject > &o) const |
bool | operator!= (const Smart< ReferenceCountedObject > &o) const |
bool | operator< (const Smart< ReferenceCountedObject > &o) const |
bool | operator<= (const Smart< ReferenceCountedObject > &o) const |
bool | operator>= (const Smart< ReferenceCountedObject > &o) const |
~Smart () | |
ReferenceCountedObject & | operator* () |
ReferenceCountedObject * | operator-> () |
operator bool () | |
template<class AnotherReferenceCountedObject > | |
operator Smart< AnotherReferenceCountedObject > () | |
Public Attributes | |
ReferenceCountedObject * | ptr |
Definition at line 89 of file reference-count.h.
Smart< ReferenceCountedObject >::Smart | ( | ReferenceCountedObject * | p = 0 |
) | [inline, explicit] |
Definition at line 120 of file reference-count.h.
Smart< ReferenceCountedObject >::Smart | ( | const Smart< ReferenceCountedObject > & | o | ) | [inline] |
Definition at line 124 of file reference-count.h.
Definition at line 164 of file reference-count.h.
void Smart< ReferenceCountedObject >::decref | ( | ) | const [inline] |
The general idea is to decrease the reference count of the underlying object in an atomic manner. If the object reaches zero we delete it. With the deletion there are some tricky semantics involved. For instance, if the object that is deleted suddenly passes itself to another one then the reference count will be increased again. However, the object was just being deleted, which means that it should not be deleted again. There are two possible strategies to use this file. Either you do care about using an object that is being deleted (leave everything as it is, the program will crash when you do so). Or you don't care about it and really only want one deletion. In that case, uncomment the assert in the incref method. In both cases, we detect a deletion operation by decreffing the pointer once more.
Definition at line 111 of file reference-count.h.
void Smart< ReferenceCountedObject >::incref | ( | ) | const [inline] |
Smart< ReferenceCountedObject >::operator bool | ( | ) | [inline] |
Definition at line 176 of file reference-count.h.
Smart< ReferenceCountedObject >::operator Smart< AnotherReferenceCountedObject > | ( | ) | [inline] |
Definition at line 181 of file reference-count.h.
bool Smart< ReferenceCountedObject >::operator!= | ( | const Smart< ReferenceCountedObject > & | o | ) | const [inline] |
Definition at line 148 of file reference-count.h.
ReferenceCountedObject& Smart< ReferenceCountedObject >::operator* | ( | ) | [inline] |
Definition at line 168 of file reference-count.h.
ReferenceCountedObject* Smart< ReferenceCountedObject >::operator-> | ( | ) | [inline] |
Definition at line 172 of file reference-count.h.
bool Smart< ReferenceCountedObject >::operator< | ( | const Smart< ReferenceCountedObject > & | o | ) | const [inline] |
Definition at line 152 of file reference-count.h.
bool Smart< ReferenceCountedObject >::operator<= | ( | const Smart< ReferenceCountedObject > & | o | ) | const [inline] |
Definition at line 156 of file reference-count.h.
Smart<ReferenceCountedObject>& Smart< ReferenceCountedObject >::operator= | ( | const Smart< AnotherReferenceCountedObject > & | o | ) | [inline] |
Definition at line 136 of file reference-count.h.
Smart<ReferenceCountedObject>& Smart< ReferenceCountedObject >::operator= | ( | const Smart< ReferenceCountedObject > & | o | ) | [inline] |
Definition at line 128 of file reference-count.h.
bool Smart< ReferenceCountedObject >::operator== | ( | const Smart< ReferenceCountedObject > & | o | ) | const [inline] |
Definition at line 144 of file reference-count.h.
bool Smart< ReferenceCountedObject >::operator>= | ( | const Smart< ReferenceCountedObject > & | o | ) | const [inline] |
Definition at line 160 of file reference-count.h.
Definition at line 92 of file reference-count.h.