cartobase
5.0.5
|
SharedObject allows to work with combined reference counting pointers and weak (Observer) pointers. More...
#include <cartobase/smart/sharedptr.h>
Public Member Functions | |
SharedObject () | |
SharedObject (const SharedObject &x) | |
virtual | ~SharedObject () |
notifies observers More... | |
SharedObject & | operator= (const SharedObject &) |
bool | testDeletable () |
tests if the shared object can be deleted (no strong pointers to it). More... | |
bool | tryDelete () |
tests if the shared object can be deleted. More... | |
![]() | |
template<typename T > | |
void | attachWeakPtr (weak_ptr< T > &) const |
template<typename T > | |
void | detachWeakPtr (weak_ptr< T > &) const |
template<typename T > | |
void | attachWeakPtr (weak_shared_ptr< T > &) const |
template<typename T > | |
void | detachWeakPtr (weak_shared_ptr< T > &) const |
virtual | ~WeakObject () |
![]() | |
RCObject () | |
RCObject (const RCObject &) | |
RCObject & | operator= (const RCObject &) |
virtual | ~RCObject () |
Protected Member Functions | |
void | disableRefCount () |
called by destructors to avoid double deletion. More... | |
![]() | |
WeakObject () | |
WeakObject (const WeakObject &) | |
WeakObject & | operator= (const WeakObject &) |
Friends | |
template<typename T > | |
class | weak_shared_ptr |
template<typename T > | |
class | shared_ptr |
class | rc_ptr_trick |
Additional Inherited Members | |
![]() | |
typedef int | RefCounterType |
SharedObject allows to work with combined reference counting pointers and weak (Observer) pointers.
Definition at line 47 of file sharedptr.h.
carto::SharedObject::SharedObject | ( | ) |
carto::SharedObject::SharedObject | ( | const SharedObject & | x | ) |
|
virtual |
notifies observers
|
protected |
called by destructors to avoid double deletion.
Sets the reference counter to -1, so any additional existing smart pointer will not delete the SharedObject another time.
Referenced by operator=().
|
inline |
Definition at line 55 of file sharedptr.h.
References disableRefCount(), testDeletable(), and tryDelete().
Referenced by carto::weak_shared_ptr< T >::operator->(), and carto::shared_ptr< T >::operator<().
bool carto::SharedObject::testDeletable | ( | ) |
tests if the shared object can be deleted (no strong pointers to it).
The test also returns false if no smart pointer at all points to the object (counters are 0), because it may mean the SharedObject has been allocated on the heap and must not be deleted by the C++ delete operator.
Referenced by operator=().
bool carto::SharedObject::tryDelete | ( | ) |
tests if the shared object can be deleted.
If possible, it is actually deleted (suicide is commited and the object is not valid any more after this call)
Referenced by operator=().
|
friend |
Definition at line 80 of file sharedptr.h.
|
friend |
Definition at line 79 of file sharedptr.h.
|
friend |
Definition at line 78 of file sharedptr.h.