A smart-pointer class which points to a reference-counted object. More...
#include <juce_ReferenceCountedObject.h>
Public Types | |
typedef ReferenceCountedObjectClass | ReferencedType |
The class being referenced by this pointer. More... | |
Public Member Functions | |
ReferenceCountedObjectPtr () noexcept | |
Creates a pointer to a null object. More... | |
ReferenceCountedObjectPtr (ReferencedType *refCountedObject) noexcept | |
Creates a pointer to an object. More... | |
ReferenceCountedObjectPtr (decltype(nullptr)) noexcept | |
Creates a pointer to a null object. More... | |
ReferenceCountedObjectPtr (const ReferenceCountedObjectPtr &other) noexcept | |
Copies another pointer. More... | |
template<typename Convertible > | |
ReferenceCountedObjectPtr (const ReferenceCountedObjectPtr< Convertible > &other) noexcept | |
Copies another pointer. More... | |
ReferenceCountedObjectPtr (ReferenceCountedObjectPtr &&other) noexcept | |
Takes-over the object from another pointer. More... | |
~ReferenceCountedObjectPtr () | |
Destructor. More... | |
ReferencedType * | get () const noexcept |
Returns the object that this pointer references. More... | |
ReferencedType * | getObject () const noexcept |
Returns the object that this pointer references. More... | |
operator ReferencedType * () const noexcept | |
Returns the object that this pointer references. More... | |
ReferencedType * | operator-> () const noexcept |
ReferenceCountedObjectPtr & | operator= (const ReferenceCountedObjectPtr &other) |
Changes this pointer to point at a different object. More... | |
template<typename Convertible > | |
ReferenceCountedObjectPtr & | operator= (const ReferenceCountedObjectPtr< Convertible > &other) |
Changes this pointer to point at a different object. More... | |
ReferenceCountedObjectPtr & | operator= (ReferencedType *const newObject) |
Changes this pointer to point at a different object. More... | |
ReferenceCountedObjectPtr & | operator= (ReferenceCountedObjectPtr &&other) |
Takes-over the object from another pointer. More... | |
Static Private Member Functions | |
static void | decIfNotNull (ReferencedType *o) noexcept |
static void | incIfNotNull (ReferencedType *o) noexcept |
Private Attributes | |
ReferencedType * | referencedObject |
A smart-pointer class which points to a reference-counted object.
The template parameter specifies the class of the object you want to point to - the easiest way to make a class reference-countable is to simply make it inherit from ReferenceCountedObject or SingleThreadedReferenceCountedObject, but if you need to, you can roll your own reference-countable class by implementing a set of methods called incReferenceCount(), decReferenceCount(), and decReferenceCountWithoutDeleting(). See ReferenceCountedObject for examples of how these methods should behave.
When using this class, you'll probably want to create a typedef to abbreviate the full templated name - e.g.
typedef ReferenceCountedObjectClass ReferenceCountedObjectPtr< ReferenceCountedObjectClass >::ReferencedType |
The class being referenced by this pointer.
|
inlinenoexcept |
Creates a pointer to a null object.
|
inlinenoexcept |
Creates a pointer to an object.
This will increment the object's reference-count.
|
inlinenoexcept |
Creates a pointer to a null object.
|
inlinenoexcept |
Copies another pointer.
This will increment the object's reference-count.
|
inlinenoexcept |
Copies another pointer.
This will increment the object's reference-count (if it is non-null).
|
inlinenoexcept |
Takes-over the object from another pointer.
|
inline |
Destructor.
This will decrement the object's reference-count, which will cause the object to be deleted when the ref-count hits zero.
|
inlinestaticprivatenoexcept |
|
inlinenoexcept |
Returns the object that this pointer references.
The pointer returned may be null, of course.
Referenced by WeakReference< InterprocessConnection >::get(), ReferenceCountedObjectPtr< ImagePixelData >::operator=(), and WeakReference< InterprocessConnection >::wasObjectDeleted().
|
inlinenoexcept |
Returns the object that this pointer references.
The pointer returned may be null, of course.
|
inlinestaticprivatenoexcept |
|
inlinenoexcept |
Returns the object that this pointer references.
The pointer returned may be null, of course.
|
inlinenoexcept |
|
inline |
Changes this pointer to point at a different object.
The reference count of the old object is decremented, and it might be deleted if it hits zero. The new object's count is incremented.
|
inline |
Changes this pointer to point at a different object.
The reference count of the old object is decremented, and it might be deleted if it hits zero. The new object's count is incremented.
|
inline |
Changes this pointer to point at a different object.
The reference count of the old object is decremented, and it might be deleted if it hits zero. The new object's count is incremented.
|
inline |
Takes-over the object from another pointer.
|
private |
Referenced by ReferenceCountedObjectPtr< ImagePixelData >::operator=().