openshot-audio  0.1.2
Classes | Public Types | Public Member Functions | List of all members
juce::WeakReference< ObjectType, ReferenceCountingType > Class Template Reference

#include <juce_core.h>

Classes

class  Master
 
class  SharedPointer
 

Public Types

typedef ReferenceCountedObjectPtr< SharedPointerSharedRef
 

Public Member Functions

 WeakReference () noexcept
 
 WeakReference (ObjectType *const object)
 
 WeakReference (const WeakReference &other) noexcept
 
WeakReferenceoperator= (const WeakReference &other)
 
WeakReferenceoperator= (ObjectType *const newObject)
 
ObjectType * get () const noexcept
 
 operator ObjectType * () const noexcept
 
ObjectType * operator-> () noexcept
 
const ObjectType * operator-> () const noexcept
 
bool wasObjectDeleted () const noexcept
 
bool operator== (ObjectType *const object) const noexcept
 
bool operator!= (ObjectType *const object) const noexcept
 

Detailed Description

template<class ObjectType, class ReferenceCountingType = ReferenceCountedObject>
class juce::WeakReference< ObjectType, ReferenceCountingType >

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.

E.g.

class MyObject
{
public:
MyObject()
{
// If you're planning on using your WeakReferences in a multi-threaded situation, you may choose
// to create a WeakReference to the object here in the constructor, which will pre-initialise the
// embedded object, avoiding an (extremely unlikely) race condition that could occur if multiple
// threads overlap while creating the first WeakReference to it.
}
~MyObject()
{
// This will zero all the references - you need to call this in your destructor.
masterReference.clear();
}
private:
// You need to embed a variable of this type, with the name "masterReference" inside your object. If the
// variable is not public, you should make your class a friend of WeakReference<MyObject> so that the
// WeakReference class can access it.
friend class WeakReference<MyObject>;
};
// Here's an example of using a pointer..
MyObject* n = new MyObject();
WeakReference<MyObject> myObjectRef = n;
MyObject* pointer1 = myObjectRef; // returns a valid pointer to 'n'
delete n;
MyObject* pointer2 = myObjectRef; // returns a null pointer
See also
WeakReference::Master

Member Typedef Documentation

template<class ObjectType, class ReferenceCountingType = ReferenceCountedObject>
typedef ReferenceCountedObjectPtr<SharedPointer> juce::WeakReference< ObjectType, ReferenceCountingType >::SharedRef

Constructor & Destructor Documentation

template<class ObjectType, class ReferenceCountingType = ReferenceCountedObject>
juce::WeakReference< ObjectType, ReferenceCountingType >::WeakReference ( )
inlinenoexcept

Creates a null SafePointer.

template<class ObjectType, class ReferenceCountingType = ReferenceCountedObject>
juce::WeakReference< ObjectType, ReferenceCountingType >::WeakReference ( ObjectType *const  object)
inline

Creates a WeakReference that points at the given object.

template<class ObjectType, class ReferenceCountingType = ReferenceCountedObject>
juce::WeakReference< ObjectType, ReferenceCountingType >::WeakReference ( const WeakReference< ObjectType, ReferenceCountingType > &  other)
inlinenoexcept

Creates a copy of another WeakReference.

Member Function Documentation

template<class ObjectType, class ReferenceCountingType = ReferenceCountedObject>
ObjectType* juce::WeakReference< ObjectType, ReferenceCountingType >::get ( ) const
inlinenoexcept

Returns the object that this pointer refers to, or null if the object no longer exists.

template<class ObjectType, class ReferenceCountingType = ReferenceCountedObject>
juce::WeakReference< ObjectType, ReferenceCountingType >::operator ObjectType * ( ) const
inlinenoexcept

Returns the object that this pointer refers to, or null if the object no longer exists.

template<class ObjectType, class ReferenceCountingType = ReferenceCountedObject>
bool juce::WeakReference< ObjectType, ReferenceCountingType >::operator!= ( ObjectType *const  object) const
inlinenoexcept
template<class ObjectType, class ReferenceCountingType = ReferenceCountedObject>
ObjectType* juce::WeakReference< ObjectType, ReferenceCountingType >::operator-> ( )
inlinenoexcept

Returns the object that this pointer refers to, or null if the object no longer exists.

template<class ObjectType, class ReferenceCountingType = ReferenceCountedObject>
const ObjectType* juce::WeakReference< ObjectType, ReferenceCountingType >::operator-> ( ) const
inlinenoexcept

Returns the object that this pointer refers to, or null if the object no longer exists.

template<class ObjectType, class ReferenceCountingType = ReferenceCountedObject>
WeakReference& juce::WeakReference< ObjectType, ReferenceCountingType >::operator= ( const WeakReference< ObjectType, ReferenceCountingType > &  other)
inline

Copies another pointer to this one.

template<class ObjectType, class ReferenceCountingType = ReferenceCountedObject>
WeakReference& juce::WeakReference< ObjectType, ReferenceCountingType >::operator= ( ObjectType *const  newObject)
inline

Copies another pointer to this one.

template<class ObjectType, class ReferenceCountingType = ReferenceCountedObject>
bool juce::WeakReference< ObjectType, ReferenceCountingType >::operator== ( ObjectType *const  object) const
inlinenoexcept
template<class ObjectType, class ReferenceCountingType = ReferenceCountedObject>
bool juce::WeakReference< ObjectType, ReferenceCountingType >::wasObjectDeleted ( ) const
inlinenoexcept

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.


The documentation for this class was generated from the following file: