21#include "tdelibs_export.h"
113 : ptr(t) {
if ( ptr ) ptr->_TDEShared_ref(); }
120 : ptr(p.ptr) {
if ( ptr ) ptr->_TDEShared_ref(); }
129 if ( ptr == p.ptr )
return *
this;
130 if ( ptr ) ptr->_TDEShared_unref();
132 if ( ptr ) ptr->_TDEShared_ref();
136 if ( ptr == p )
return *
this;
137 if ( ptr ) ptr->_TDEShared_unref();
139 if ( ptr ) ptr->_TDEShared_ref();
142 bool operator== (
const TDESharedPtr<T>& p )
const {
return ( ptr == p.ptr ); }
143 bool operator!= (
const TDESharedPtr<T>& p )
const {
return ( ptr != p.ptr ); }
144 bool operator== (
const T* p )
const {
return ( ptr == p ); }
145 bool operator!= (
const T* p )
const {
return ( ptr != p ); }
146 bool operator!()
const {
return ( ptr == 0 ); }
147 operator T*()
const {
return ptr; }
159 const T*
data()
const {
return ptr; }
161 const T& operator*()
const {
return *ptr; }
162 T& operator*() {
return *ptr; }
163 const T* operator->()
const {
return ptr; }
164 T* operator->() {
return ptr; }
170 int count()
const {
return ptr->_TDEShared_count(); }
Can be used to control the lifetime of an object that has derived TDEShared.
TDESharedPtr()
Creates a null pointer.
~TDESharedPtr()
Unreferences the object that this pointer points to.
TDESharedPtr(const TDESharedPtr &p)
Copies a pointer.
int count() const
Returns the number of references.
T * data()
Returns the pointer.
TDESharedPtr(T *t)
Creates a new pointer.
const T * data() const
Returns the pointer.
Reference counting for shared objects.
void _TDEShared_unref() const
Releases a reference (decreases the reference count by one).
void _TDEShared_ref() const
Increases the reference count by one.
TDEShared()
Standard constructor.
TDEShared(const TDEShared &)
Copy constructor.
TDEShared & operator=(const TDEShared &)
Overloaded assignment operator.
int _TDEShared_count() const
Return the current number of references held.