34 #ifndef CARTOBASE_SMART_SHAREDPTR_H
35 #define CARTOBASE_SMART_SHAREDPTR_H
106 {
return get() == x; }
110 {
return get() == x.
get(); }
112 {
return get() == x.
get(); }
114 {
return get() != x; }
118 {
return get() != x.
get(); }
120 {
return get() != x.
get(); }
124 {
return get() < x.
get(); }
126 {
return get() < x.
get(); }
136 void reset( T* r = 0 );
151 template <
typename T>
163 bool externalowner =
false );
215 template <
typename T>
224 x->attachWeakPtr( *
this );
229 template <
typename T>
238 x->attachWeakPtr( *
this );
243 template <
typename T>
252 x->attachWeakPtr( *
this );
257 template <
typename T>
266 x->attachWeakPtr( *
this );
271 template <
typename T>
280 template <
typename T>
289 template <
typename T>
304 x->attachWeakPtr( *
this );
311 template <
typename T>
322 template <
typename T>
333 template <
typename T>
344 r->attachWeakPtr( *
this );
352 template <
typename T>
373 template <
typename T>
394 template <
typename T>
402 template <
typename T>
412 template <
typename T>
422 template <
typename T>
426 switch( referenceType() )
430 ++this->get()->weak_count;
442 template <
typename T>
450 template <
typename T>
455 reset( x.referenceType(), x.get() );
460 template <
typename T>
465 reset( WeakShared, x.get() );
470 template <
typename T>
474 reset( Strong, x.
get() );
479 template <
typename T>
483 reset( Weak, x.
get() );
488 template <
typename T>
493 if( this->get() && referenceType() == WeakShared )
494 --this->get()->weak_count;
495 if( referenceType() != Weak )
501 template <
typename T>
505 if( r == this->get() )
507 if( t != referenceType() )
512 switch( referenceType() )
525 switch( referenceType() )
538 switch( referenceType() )
543 r->attachWeakPtr(
static_cast<weak_ptr<T> &
>( *
this ) );
546 if( r->_refCounter == 1 )
564 switch( referenceType() )
583 r->attachWeakPtr( *
this );
Base class for reference counted objects (intrusive)
SharedObject allows to work with combined reference counting pointers and weak (Observer) pointers.
bool tryDelete()
tests if the shared object can be deleted.
bool testDeletable()
tests if the shared object can be deleted (no strong pointers to it).
SharedObject & operator=(const SharedObject &)
void disableRefCount()
called by destructors to avoid double deletion.
SharedObject(const SharedObject &x)
virtual ~SharedObject()
notifies observers
Base class for weakly referenced objects.
rc_ptr_trick merely makes a public access to the reference counter inside a rc_ptr.
Reference-counting pointer.
ref< T > & operator=(const ref< T > &other)
A multi-purpose general smart pointer, which can act as either a rc_ptr, a weak_ptr or a weak_shared_...
bool operator==(const shared_ptr< T > &x) const
bool operator<(const shared_ptr< T > &x) const
shared_ptr< T > & operator=(const shared_ptr< T > &x)
void reset(ReferenceType t, T *r=0)
shared_ptr(ReferenceType t=Weak, T *x=0, bool externalowner=false)
ReferenceType referenceType() const
bool operator!=(const shared_ptr< T > &x) const
Observer pointer, observing a shfj::WeakObject.
bool operator!=(const weak_ptr< T > &x) const
weak_ptr & operator=(const weak_ptr< Y > &r)
bool operator<(const weak_ptr< T > &x) const
bool operator==(const weak_ptr< T > &x) const
weak_shared_ptr: increments a reference count, is told and becomes null whenever the shared object is...
bool operator==(const T *x) const
bool operator<(const weak_shared_ptr< T > &x) const
bool operator!=(const T *x) const
weak_shared_ptr< T > & operator=(const weak_shared_ptr< T > &x)
weak_shared_ptr(T *x=0, bool externalowner=false)