A smart-pointer class which points to a reference-counted object. More...
#include <juce_ReferenceCountedObject.h>
Public Types | |
using | ReferencedType = ObjectType |
The class being referenced by this pointer. More... | |
Public Member Functions | |
ReferenceCountedObjectPtr ()=default | |
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 (decltype(nullptr)) noexcept | |
Creates a pointer to a null object. More... | |
ReferenceCountedObjectPtr (ReferenceCountedObjectPtr &&other) noexcept | |
Takes-over the object from another pointer. More... | |
ReferenceCountedObjectPtr (ReferencedType &refCountedObject) noexcept | |
Creates a pointer to an object. More... | |
ReferenceCountedObjectPtr (ReferencedType *refCountedObject) noexcept | |
Creates a pointer to an object. More... | |
~ReferenceCountedObjectPtr () | |
Destructor. More... | |
ReferencedType * | get () const noexcept |
Returns the object that this pointer references. More... | |
operator ReferencedType * () const noexcept | |
Returns the object that this pointer references. More... | |
bool | operator!= (const ObjectType *other) const noexcept |
Compares two ReferenceCountedObjectPtrs. More... | |
bool | operator!= (const ReferenceCountedObjectPtr &other) const noexcept |
Compares two ReferenceCountedObjectPtrs. More... | |
bool | operator!= (decltype(nullptr)) const noexcept |
Checks whether this pointer is null. More... | |
ReferencedType & | operator* () const noexcept |
Dereferences 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= (decltype(nullptr)) |
Resets this pointer to a null pointer. More... | |
ReferenceCountedObjectPtr & | operator= (ReferenceCountedObjectPtr &&other) noexcept |
Takes-over the object from another pointer. More... | |
ReferenceCountedObjectPtr & | operator= (ReferencedType &newObject) |
Changes this pointer to point at a different object. More... | |
ReferenceCountedObjectPtr & | operator= (ReferencedType *newObject) |
Changes this pointer to point at a different object. More... | |
bool | operator== (const ObjectType *other) const noexcept |
Compares two ReferenceCountedObjectPtrs. More... | |
bool | operator== (const ReferenceCountedObjectPtr &other) const noexcept |
Compares two ReferenceCountedObjectPtrs. More... | |
bool | operator== (decltype(nullptr)) const noexcept |
Checks whether this pointer is null. More... | |
void | reset () noexcept |
Resets this object to a null pointer. More... | |
Static Private Member Functions | |
static void | decIfNotNull (ReferencedType *o) noexcept |
static void | incIfNotNull (ReferencedType *o) noexcept |
Private Attributes | |
ReferencedType * | referencedObject = nullptr |
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.
@tags{Core}
using juce::ReferenceCountedObjectPtr< ObjectType >::ReferencedType = ObjectType |
The class being referenced by this pointer.
|
default |
Creates a pointer to a null object.
|
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 an object.
This will increment the object's reference-count.
|
inlinenoexcept |
Copies another pointer.
This will increment the object's reference-count.
|
inlinenoexcept |
Takes-over the object from another pointer.
|
inlinenoexcept |
Copies another pointer.
This will increment the object's reference-count (if it is non-null).
|
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 juce::ReferenceCountedArray< juce::AudioProcessorGraph::Node >::add(), juce::ReferenceCountedArray< juce::AudioProcessorGraph::Node >::addIfNotAlreadyThere(), juce::WeakReference< juce::Component >::get(), juce::WeakReference< ObjectType, ReferenceCountingType >::Master::getSharedPointer(), juce::ReferenceCountedArray< juce::AudioProcessorGraph::Node >::insert(), juce::nsDictionaryToVar(), juce::ReferenceCountedObjectPtr< juce::ReferenceCountedObject >::operator=(), juce::ReferenceCountedArray< juce::AudioProcessorGraph::Node >::removeObject(), juce::ReferenceCountedArray< juce::AudioProcessorGraph::Node >::set(), juce::WeakReference< juce::Component >::wasObjectDeleted(), and juce::WeakReference< ObjectType, ReferenceCountingType >::Master::~Master().
|
inlinestaticprivatenoexcept |
|
inlinenoexcept |
Returns the object that this pointer references.
The pointer returned may be null, of course. Note that this methods allows the compiler to be very lenient with what it allows you to do with the pointer, it's safer to disable this by setting JUCE_STRICT_REFCOUNTEDPOINTER=1, which increased type safety and can prevent some common slip-ups.
|
inlinenoexcept |
Compares two ReferenceCountedObjectPtrs.
|
inlinenoexcept |
Compares two ReferenceCountedObjectPtrs.
|
inlinenoexcept |
Checks whether this pointer is null.
|
inlinenoexcept |
Dereferences 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.
Referenced by juce::ReferenceCountedObjectPtr< juce::ReferenceCountedObject >::operator=().
|
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 |
Resets this pointer to a null pointer.
|
inlinenoexcept |
Takes-over the object from another pointer.
|
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.
|
inlinenoexcept |
Compares two ReferenceCountedObjectPtrs.
|
inlinenoexcept |
Compares two ReferenceCountedObjectPtrs.
|
inlinenoexcept |
Checks whether this pointer is null.
|
inlinenoexcept |
Resets this object to a null pointer.
Referenced by juce::RenderingHelpers::CachedGlyphEdgeTable< RendererType >::generate(), and juce::ReferenceCountedObjectPtr< juce::ReferenceCountedObject >::operator=().
|
private |
Referenced by juce::ReferenceCountedObjectPtr< juce::ReferenceCountedObject >::get(), juce::ReferenceCountedObjectPtr< juce::ReferenceCountedObject >::operator ReferencedType *(), juce::ReferenceCountedObjectPtr< juce::ReferenceCountedObject >::operator!=(), juce::ReferenceCountedObjectPtr< juce::ReferenceCountedObject >::operator*(), juce::ReferenceCountedObjectPtr< juce::ReferenceCountedObject >::operator->(), juce::ReferenceCountedObjectPtr< juce::ReferenceCountedObject >::operator=(), juce::ReferenceCountedObjectPtr< juce::ReferenceCountedObject >::operator==(), juce::ReferenceCountedObjectPtr< juce::ReferenceCountedObject >::ReferenceCountedObjectPtr(), juce::ReferenceCountedObjectPtr< juce::ReferenceCountedObject >::reset(), and juce::ReferenceCountedObjectPtr< juce::ReferenceCountedObject >::~ReferenceCountedObjectPtr().