Shared pointer. More...
#include <IntrusivePtr.h>
Inherits ts::IntrusivePtrBase.
Public Types | |
typedef super::Counter | Counter |
Promote type for reference counter. | |
Public Member Functions | |
IntrusivePtr () | |
Default constructor (0 initialized). | |
IntrusivePtr (T *obj) | |
Construct from instance. | |
~IntrusivePtr () | |
Destructor. | |
IntrusivePtr (const self &src) | |
Copy constructor. | |
self & | operator= (const self &src) |
Self assignement. | |
self & | operator= (T *obj) |
Assign from instance. | |
self & | assign (T *obj) |
Assign from instance. | |
void | reset (T *obj) |
Assign from instance. | |
bool | release () |
Clear reference without cleanup. | |
bool | isNull () const |
Test if the pointer is zero (NULL ). | |
T * | operator-> () const |
Member dereference. | |
T & | operator* () const |
Dereference. | |
T * | get () const |
Access raw pointer. | |
operator T * () const | |
User conversion to raw pointer. | |
template<typename X > | |
IntrusivePtr (IntrusivePtr< X > const &that) | |
Cross type construction. | |
template<typename X > | |
self & | operator= (IntrusivePtr< X > const &that) |
Cross type assignment. | |
bool | isShared () const |
Check for multiple references. | |
bool | unique () const |
Check for a single reference (shared_ptr compatibility). | |
Counter | useCount () const |
Reference count. |
Shared pointer.
This is a reference counted smart pointer. A single object is jointly ownded by a set of pointers. When the last of the pointers is destructed the target object is also destructed.
The smart pointer actions can be changed through class specific policy by specializing the IntrusivePtrPolicy
template class.
Definition at line 135 of file IntrusivePtr.h.
typedef super::Counter ts::IntrusivePtr< T >::Counter |
Promote type for reference counter.
Reimplemented from ts::IntrusivePtrBase.
Definition at line 142 of file IntrusivePtr.h.
ts::IntrusivePtr< T >::IntrusivePtr | ( | ) |
Default constructor (0 initialized).
Definition at line 403 of file IntrusivePtr.h.
ts::IntrusivePtr< T >::IntrusivePtr | ( | T * | obj | ) |
Construct from instance.
The instance becomes referenced and owned by the pointer.
Definition at line 408 of file IntrusivePtr.h.
ts::IntrusivePtr< T >::~IntrusivePtr | ( | ) |
Destructor.
Definition at line 413 of file IntrusivePtr.h.
ts::IntrusivePtr< T >::IntrusivePtr | ( | const self & | src | ) |
Copy constructor.
Definition at line 418 of file IntrusivePtr.h.
ts::IntrusivePtr< T >::IntrusivePtr | ( | IntrusivePtr< X > const & | that | ) |
Cross type construction.
This succeeds if an X* can be implicitly converted to a T*.
that | Foreign pointer. |
Definition at line 424 of file IntrusivePtr.h.
IntrusivePtr< T > & ts::IntrusivePtr< T >::assign | ( | T * | obj | ) |
Assign from instance.
The instance becomes referenced and owned by the pointer. The reference to the current object is dropped.
operator=
for compatibility. obj | Target instance. |
Definition at line 452 of file IntrusivePtr.h.
T * ts::IntrusivePtr< T >::get | ( | void | ) | const |
Access raw pointer.
Definition at line 469 of file IntrusivePtr.h.
Referenced by ts::dynamic_ptr_cast(), ts::config::Path::instance(), ts::config::detail::ValueTable::instance(), ts::operator!=(), ts::IntrusivePtrPolicy< T >::Order::operator()(), ts::IntrusivePtr< T >::operator=(), ts::operator==(), ts::ptr_cast(), and ts::Errata::push().
bool ts::IntrusivePtr< T >::isNull | ( | ) | const |
Test if the pointer is zero (NULL
).
Definition at line 544 of file IntrusivePtr.h.
bool ts::IntrusivePtr< T >::isShared | ( | ) | const |
Check for multiple references.
true
if more than one smart pointer references the object, false
otherwise. Definition at line 592 of file IntrusivePtr.h.
Referenced by ts::config::Path::reset().
ts::IntrusivePtr< T >::operator T * | ( | ) | const |
User conversion to raw pointer.
Definition at line 587 of file IntrusivePtr.h.
T & ts::IntrusivePtr< T >::operator* | ( | ) | const |
Dereference.
Definition at line 463 of file IntrusivePtr.h.
T * ts::IntrusivePtr< T >::operator-> | ( | ) | const |
Member dereference.
Definition at line 457 of file IntrusivePtr.h.
IntrusivePtr< T > & ts::IntrusivePtr< T >::operator= | ( | T * | obj | ) |
Assign from instance.
The instance becomes referenced and owned by the pointer. The reference to the current object is dropped.
obj | Target instance. |
Definition at line 446 of file IntrusivePtr.h.
References ts::IntrusivePtr< T >::reset().
IntrusivePtr< T > & ts::IntrusivePtr< T >::operator= | ( | IntrusivePtr< X > const & | that | ) |
Cross type assignment.
This succeeds if an X* can be implicitily converted to a T*.
that | Foreign pointer. |
Definition at line 438 of file IntrusivePtr.h.
References ts::IntrusivePtr< T >::get(), and ts::IntrusivePtr< T >::reset().
IntrusivePtr< T > & ts::IntrusivePtr< T >::operator= | ( | const self & | src | ) |
Self assignement.
Definition at line 430 of file IntrusivePtr.h.
References ts::IntrusivePtr< T >::reset().
bool ts::IntrusivePtr< T >::release | ( | ) |
Clear reference without cleanup.
This unsets this smart pointer and decrements the reference count, but does not perform any finalization on the target object. This can easily lead to memory leaks and in some sense vitiates the point of this class, but it is occasionally the right thing to do. Use with caution.
true
if there are no references upon return, false
if the reference count is not zero. Definition at line 529 of file IntrusivePtr.h.
void ts::IntrusivePtr< T >::reset | ( | T * | obj | ) |
Assign from instance.
The instance becomes referenced and owned by the pointer. The reference to the current object is dropped.
Definition at line 521 of file IntrusivePtr.h.
Referenced by ts::config::detail::ValueTable::instance(), and ts::IntrusivePtr< T >::operator=().
bool ts::IntrusivePtr< T >::unique | ( | ) | const |
Check for a single reference (shared_ptr
compatibility).
true
if this object is not shared. Definition at line 597 of file IntrusivePtr.h.
IntrusivePtr< T >::Counter ts::IntrusivePtr< T >::useCount | ( | ) | const |
Reference count.
Definition at line 602 of file IntrusivePtr.h.
Referenced by ts::Errata::pre_write().