JUCE
|
This class acts as a pointer which will automatically become null if the object to which it points is deleted. More...
Classes | |
class | Master |
This class is embedded inside an object to which you want to attach WeakReference pointers. More... | |
class | SharedPointer |
This class is used internally by the WeakReference class - don't use it directly in your code! More... | |
Public Types | |
using | SharedRef = ReferenceCountedObjectPtr< SharedPointer > |
Public Member Functions | |
WeakReference ()=default | |
Creates a null WeakReference. More... | |
WeakReference (ObjectType *object) | |
Creates a WeakReference that points at the given object. More... | |
WeakReference (const WeakReference &other) noexcept | |
Creates a copy of another WeakReference. More... | |
WeakReference (WeakReference &&other) noexcept | |
Move constructor. More... | |
WeakReference & | operator= (const WeakReference &other) |
Copies another pointer to this one. More... | |
WeakReference & | operator= (ObjectType *newObject) |
Copies another pointer to this one. More... | |
WeakReference & | operator= (WeakReference &&other) noexcept |
Move assignment operator. More... | |
ObjectType * | get () const noexcept |
Returns the object that this pointer refers to, or null if the object no longer exists. More... | |
operator ObjectType * () const noexcept | |
Returns the object that this pointer refers to, or null if the object no longer exists. More... | |
ObjectType * | operator-> () const noexcept |
Returns the object that this pointer refers to, or null if the object no longer exists. More... | |
bool | wasObjectDeleted () const noexcept |
This returns true if this reference has been pointing at an object, but that object has since been deleted. More... | |
bool | operator== (ObjectType *object) const noexcept |
bool | operator!= (ObjectType *object) const noexcept |
This class acts as a pointer which will automatically become null if the object to which it points is deleted.
To accomplish this, the source object needs to cooperate by performing a couple of simple tasks. It must embed a WeakReference::Master object, which stores a shared pointer object, and must clear this master pointer in its destructor.
Note that WeakReference is not designed to be thread-safe, so if you're accessing it from different threads, you'll need to do your own locking around all uses of the pointer and the object it refers to.
E.g.
using WeakReference< ObjectType, ReferenceCountingType >::SharedRef = ReferenceCountedObjectPtr<SharedPointer> |
|
default |
Creates a null WeakReference.
WeakReference< ObjectType, ReferenceCountingType >::WeakReference | ( | ObjectType * | object | ) |
Creates a WeakReference that points at the given object.
|
noexcept |
Creates a copy of another WeakReference.
|
noexcept |
Move constructor.
WeakReference& WeakReference< ObjectType, ReferenceCountingType >::operator= | ( | const WeakReference< ObjectType, ReferenceCountingType > & | other | ) |
Copies another pointer to this one.
WeakReference& WeakReference< ObjectType, ReferenceCountingType >::operator= | ( | ObjectType * | newObject | ) |
Copies another pointer to this one.
|
noexcept |
Move assignment operator.
|
noexcept |
Returns the object that this pointer refers to, or null if the object no longer exists.
Referenced by ModalCallbackFunction::forComponent().
|
noexcept |
Returns the object that this pointer refers to, or null if the object no longer exists.
|
noexcept |
Returns the object that this pointer refers to, or null if the object no longer exists.
|
noexcept |
This returns true if this reference has been pointing at an object, but that object has since been deleted.
If this reference was only ever pointing at a null pointer, this will return false. Using operator=() to make this refer to a different object will reset this flag to match the status of the reference from which you're copying.
|
noexcept |
|
noexcept |