76template <
class ObjectType,
class ReferenceCountingType = ReferenceCountedObject>
129 inline ObjectType* get()
const noexcept {
return owner; }
130 void clearPointer()
noexcept { owner =
nullptr; }
155 jassert (sharedPointer ==
nullptr || sharedPointer->
get() ==
nullptr);
163 if (sharedPointer ==
nullptr)
173 return sharedPointer;
182 if (sharedPointer !=
nullptr)
183 sharedPointer->clearPointer();
189 return sharedPointer ==
nullptr ? 0 : (sharedPointer->getReferenceCount() - 1);
204 return o->masterReference.getSharedPointer (
o);
231#define JUCE_DECLARE_WEAK_REFERENCEABLE(Class) \
232 struct WeakRefMaster : public juce::WeakReference<Class>::Master { ~WeakRefMaster() { this->clear(); } }; \
233 WeakRefMaster masterReference; \
234 friend class juce::WeakReference<Class>; \
ReferencedType * get() const noexcept
Returns the object that this pointer references.
This class is embedded inside an object to which you want to attach WeakReference pointers.
int getNumActiveWeakReferences() const noexcept
Returns the number of WeakReferences that are out there pointing to this object.
void clear() noexcept
The object that owns this master pointer should call this before it gets destroyed,...
SharedRef getSharedPointer(ObjectType *object)
The first call to this method will create an internal object that is shared by all weak references to...
This class is used internally by the WeakReference class - don't use it directly in your code!
This class acts as a pointer which will automatically become null if the object to which it points is...
ObjectType * operator->() const noexcept
Returns the object that this pointer refers to, or null if the object no longer exists.
WeakReference()=default
Creates a null WeakReference.
ObjectType * get() const noexcept
Returns the object that this pointer refers to, or null if the object no longer exists.
WeakReference(WeakReference &&other) noexcept
Move constructor.
WeakReference & operator=(const WeakReference &other)
Copies another pointer to this one.
WeakReference(const WeakReference &other) noexcept
Creates a copy of another WeakReference.
bool wasObjectDeleted() const noexcept
This returns true if this reference has been pointing at an object, but that object has since been de...
WeakReference(ObjectType *object)
Creates a WeakReference that points at the given object.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...