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(); }
113 bool operator != (
const T* x )
const 114 {
return get() != x; }
118 {
return get() != x.
get(); }
120 {
return get() != x.
get(); }
121 bool operator < ( const weak_shared_ptr<T> & x )
const 123 bool operator < ( const rc_ptr<T> & x )
const 124 {
return get() < x.
get(); }
125 bool operator < ( const weak_ptr<T> & x )
const 126 {
return get() < x.
get(); }
129 T* operator -> ()
const 136 void reset( T* r = 0 );
151 template <
typename T>
163 bool externalowner =
false );
182 bool operator != (
const T* x )
const 190 bool operator < ( const shared_ptr<T> & x )
const 192 bool operator < ( const rc_ptr<T> & x )
const 194 bool operator < ( const weak_ptr<T> & x )
const 196 bool operator < ( const weak_shared_ptr<T> & x )
const 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>
430 ++this->
get()->weak_count;
442 template <
typename T>
450 template <
typename T>
455 reset( x.referenceType(), x.get() );
460 template <
typename T>
470 template <
typename T>
479 template <
typename T>
488 template <
typename T>
494 --this->
get()->weak_count;
501 template <
typename T>
505 if( r == this->
get() )
543 r->attachWeakPtr(
static_cast<weak_ptr<T> &
>( *
this ) );
546 if( r->_refCounter == 1 )
583 r->attachWeakPtr( *
this );
Observer pointer, observing a shfj::WeakObject.
shared_ptr< T > & operator=(const shared_ptr< T > &x)
virtual ~SharedObject()
notifies observers
friend class weak_shared_ptr
A multi-purpose general smart pointer, which can act as either a rc_ptr, a weak_ptr or a weak_shared_...
ref< T > & operator=(const ref< T > &other)
Base class for reference counted objects (intrusive)
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 carto::block< T, N > &b1, const carto::block< T, N > &b2)
VoxelRGB operator*(const VoxelRGB &aa, const uint8_t &bb)
Reference-counting pointer.
SharedObject & operator=(const SharedObject &)
rc_ptr_trick merely makes a public access to the reference counter inside a rc_ptr.
Base class for weakly referenced objects.
void disableRefCount()
called by destructors to avoid double deletion.
bool operator<(const weak_ptr< T > &x) const
weak_ptr & operator=(const weak_ptr< Y > &r)
bool testDeletable()
tests if the shared object can be deleted (no strong pointers to it).
weak_shared_ptr(T *x=0, bool externalowner=false)
ReferenceType referenceType() const
bool tryDelete()
tests if the shared object can be deleted.
SharedObject allows to work with combined reference counting pointers and weak (Observer) pointers...
bool operator==(const weak_ptr< T > &x) const
void reset(ReferenceType t, T *r=0)
shared_ptr(ReferenceType t=Weak, T *x=0, bool externalowner=false)