OpenShot Library | libopenshot-audio
0.2.0
|
80 template <
class ObjectType,
class ReferenceCountingType = ReferenceCountedObject>
106 ObjectType*
get() const noexcept {
return holder !=
nullptr ? holder->
get() :
nullptr; }
109 operator ObjectType*()
const noexcept {
return get(); }
126 bool operator== (ObjectType*
object)
const noexcept {
return get() == object; }
127 bool operator!= (ObjectType*
object)
const noexcept {
return get() != object; }
137 explicit SharedPointer (ObjectType* obj) noexcept : owner (obj) {}
139 inline ObjectType* get()
const noexcept {
return owner; }
140 void clearPointer() noexcept { owner =
nullptr; }
165 jassert (sharedPointer ==
nullptr || sharedPointer->
get() ==
nullptr);
173 if (sharedPointer ==
nullptr)
180 jassert (sharedPointer->
get() !=
nullptr);
183 return sharedPointer;
192 if (sharedPointer !=
nullptr)
193 sharedPointer->clearPointer();
199 return sharedPointer ==
nullptr ? 0 : (sharedPointer->getReferenceCount() - 1);
205 JUCE_DECLARE_NON_COPYABLE (
Master)
211 static inline SharedRef getRef (ObjectType* o)
214 return o->masterReference.getSharedPointer (o);
241 #define JUCE_DECLARE_WEAK_REFERENCEABLE(Class) \
242 struct WeakRefMaster : public juce::WeakReference<Class>::Master { ~WeakRefMaster() { this->clear(); } }; \
243 WeakRefMaster masterReference; \
244 friend class juce::WeakReference<Class>; \
WeakReference()=default
Creates a null WeakReference.
WeakReference(WeakReference &&other) noexcept
Move constructor.
WeakReference(ObjectType *object)
Creates a WeakReference that points at the given object.
ObjectType * get() const noexcept
Returns the object that this pointer refers to, or null if the object no longer exists.
void clear() noexcept
The object that owns this master pointer should call this before it gets destroyed,...
int getNumActiveWeakReferences() const noexcept
Returns the number of WeakReferences that are out there pointing to this object.
const ObjectType * operator->() const noexcept
Returns the object that this pointer refers to, or null if the object no longer exists.
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 acts as a pointer which will automatically become null if the object to which it points is...
WeakReference & operator=(const WeakReference &other)
Copies another pointer to this one.
ObjectType * operator->() noexcept
Returns the object that this pointer refers to, or null if the object no longer exists.
This class is embedded inside an object to which you want to attach WeakReference pointers.
bool wasObjectDeleted() const noexcept
This returns true if this reference has been pointing at an object, but that object has since been de...
ReferencedType * get() const noexcept
Returns the object that this pointer references.
WeakReference(const WeakReference &other) noexcept
Creates a copy of another WeakReference.
This class is used internally by the WeakReference class - don't use it directly in your code!