OpenShot Library | OpenShotAudio 0.2.2
juce::ReferenceCountedObjectPtr< ObjectType > Class Template Reference

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.
 
 ReferenceCountedObjectPtr (decltype(nullptr)) noexcept
 Creates a pointer to a null object. More...
 
 ReferenceCountedObjectPtr (ReferencedType *refCountedObject) noexcept
 Creates a pointer to an object. More...
 
 ReferenceCountedObjectPtr (ReferencedType &refCountedObject) noexcept
 Creates a pointer to an object. More...
 
 ReferenceCountedObjectPtr (const ReferenceCountedObjectPtr &other) noexcept
 Copies another pointer. More...
 
 ReferenceCountedObjectPtr (ReferenceCountedObjectPtr &&other) noexcept
 Takes-over the object from another pointer. More...
 
template<typename Convertible >
 ReferenceCountedObjectPtr (const ReferenceCountedObjectPtr< Convertible > &other) noexcept
 Copies another pointer. More...
 
ReferenceCountedObjectPtroperator= (const ReferenceCountedObjectPtr &other)
 Changes this pointer to point at a different object. More...
 
template<typename Convertible >
ReferenceCountedObjectPtroperator= (const ReferenceCountedObjectPtr< Convertible > &other)
 Changes this pointer to point at a different object. More...
 
ReferenceCountedObjectPtroperator= (ReferencedType *newObject)
 Changes this pointer to point at a different object. More...
 
ReferenceCountedObjectPtroperator= (ReferencedType &newObject)
 Changes this pointer to point at a different object. More...
 
ReferenceCountedObjectPtroperator= (decltype(nullptr))
 Resets this pointer to a null pointer. More...
 
ReferenceCountedObjectPtroperator= (ReferenceCountedObjectPtr &&other) noexcept
 Takes-over the object from another pointer. More...
 
 ~ReferenceCountedObjectPtr ()
 Destructor. More...
 
ReferencedTypeget () const noexcept
 Returns the object that this pointer references. More...
 
void reset () noexcept
 Resets this object to a null pointer. More...
 
ReferencedTypeoperator-> () const noexcept
 
ReferencedTypeoperator* () const noexcept
 Dereferences the object that this pointer references. More...
 
bool operator== (decltype(nullptr)) const noexcept
 Checks whether this pointer is null. More...
 
bool operator!= (decltype(nullptr)) const noexcept
 Checks whether this pointer is null. 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!= (const ObjectType *other) const noexcept
 Compares two ReferenceCountedObjectPtrs. More...
 
bool operator!= (const ReferenceCountedObjectPtr &other) const noexcept
 Compares two ReferenceCountedObjectPtrs. More...
 
 operator ReferencedType * () const noexcept
 Returns the object that this pointer references. More...
 

Static Public Member Functions

static void decIfNotNull (ReferencedType *o) noexcept
 

Static Public Attributes

static JUCE_DEPRECATED_WITH_BODY(ReferencedType *getObject() const, { return get();}) private voi incIfNotNull )(ReferencedType *o) noexcept
 

Detailed Description

template<class ObjectType>
class juce::ReferenceCountedObjectPtr< ObjectType >

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.

struct MyClass : public ReferenceCountedObject
{
...
}
A smart-pointer class which points to a reference-counted object.
A base class which provides methods for reference-counting.
See also
ReferenceCountedObject, ReferenceCountedObjectArray

Definition at line 250 of file juce_ReferenceCountedObject.h.

Member Typedef Documentation

◆ ReferencedType

template<class ObjectType >
using juce::ReferenceCountedObjectPtr< ObjectType >::ReferencedType = ObjectType

The class being referenced by this pointer.

Definition at line 254 of file juce_ReferenceCountedObject.h.

Constructor & Destructor Documentation

◆ ReferenceCountedObjectPtr() [1/6]

template<class ObjectType >
juce::ReferenceCountedObjectPtr< ObjectType >::ReferenceCountedObjectPtr ( decltype(nullptr)  )
inlinenoexcept

Creates a pointer to a null object.

Definition at line 261 of file juce_ReferenceCountedObject.h.

◆ ReferenceCountedObjectPtr() [2/6]

template<class ObjectType >
juce::ReferenceCountedObjectPtr< ObjectType >::ReferenceCountedObjectPtr ( ReferencedType refCountedObject)
inlinenoexcept

Creates a pointer to an object.

This will increment the object's reference-count.

Definition at line 266 of file juce_ReferenceCountedObject.h.

◆ ReferenceCountedObjectPtr() [3/6]

template<class ObjectType >
juce::ReferenceCountedObjectPtr< ObjectType >::ReferenceCountedObjectPtr ( ReferencedType refCountedObject)
inlinenoexcept

Creates a pointer to an object.

This will increment the object's reference-count.

Definition at line 275 of file juce_ReferenceCountedObject.h.

◆ ReferenceCountedObjectPtr() [4/6]

template<class ObjectType >
juce::ReferenceCountedObjectPtr< ObjectType >::ReferenceCountedObjectPtr ( const ReferenceCountedObjectPtr< ObjectType > &  other)
inlinenoexcept

Copies another pointer.

This will increment the object's reference-count.

Definition at line 284 of file juce_ReferenceCountedObject.h.

◆ ReferenceCountedObjectPtr() [5/6]

template<class ObjectType >
juce::ReferenceCountedObjectPtr< ObjectType >::ReferenceCountedObjectPtr ( ReferenceCountedObjectPtr< ObjectType > &&  other)
inlinenoexcept

Takes-over the object from another pointer.

Definition at line 291 of file juce_ReferenceCountedObject.h.

◆ ReferenceCountedObjectPtr() [6/6]

template<class ObjectType >
template<typename Convertible >
juce::ReferenceCountedObjectPtr< ObjectType >::ReferenceCountedObjectPtr ( const ReferenceCountedObjectPtr< Convertible > &  other)
inlinenoexcept

Copies another pointer.

This will increment the object's reference-count (if it is non-null).

Definition at line 301 of file juce_ReferenceCountedObject.h.

◆ ~ReferenceCountedObjectPtr()

template<class ObjectType >
juce::ReferenceCountedObjectPtr< ObjectType >::~ReferenceCountedObjectPtr ( )
inline

Destructor.

This will decrement the object's reference-count, which will cause the object to be deleted when the ref-count hits zero.

Definition at line 376 of file juce_ReferenceCountedObject.h.

Member Function Documentation

◆ operator=() [1/6]

template<class ObjectType >
ReferenceCountedObjectPtr & juce::ReferenceCountedObjectPtr< ObjectType >::operator= ( const ReferenceCountedObjectPtr< ObjectType > &  other)
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.

Definition at line 311 of file juce_ReferenceCountedObject.h.

References juce::ReferenceCountedObjectPtr< ObjectType >::operator=().

Referenced by juce::ReferenceCountedObjectPtr< ObjectType >::operator=().

◆ operator=() [2/6]

template<class ObjectType >
template<typename Convertible >
ReferenceCountedObjectPtr & juce::ReferenceCountedObjectPtr< ObjectType >::operator= ( const ReferenceCountedObjectPtr< Convertible > &  other)
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.

Definition at line 321 of file juce_ReferenceCountedObject.h.

References juce::ReferenceCountedObjectPtr< ObjectType >::get(), and juce::ReferenceCountedObjectPtr< ObjectType >::operator=().

◆ operator=() [3/6]

template<class ObjectType >
ReferenceCountedObjectPtr & juce::ReferenceCountedObjectPtr< ObjectType >::operator= ( ReferencedType newObject)
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.

Definition at line 331 of file juce_ReferenceCountedObject.h.

References juce::ReferenceCountedObjectPtr< ObjectType >::operator=(), and juce::ReferenceCountedObjectPtr< ObjectType >::reset().

◆ operator=() [4/6]

template<class ObjectType >
ReferenceCountedObjectPtr & juce::ReferenceCountedObjectPtr< ObjectType >::operator= ( ReferencedType newObject)
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.

Definition at line 345 of file juce_ReferenceCountedObject.h.

◆ operator=() [5/6]

template<class ObjectType >
ReferenceCountedObjectPtr & juce::ReferenceCountedObjectPtr< ObjectType >::operator= ( decltype(nullptr)  )
inline

Resets this pointer to a null pointer.

Definition at line 359 of file juce_ReferenceCountedObject.h.

References juce::ReferenceCountedObjectPtr< ObjectType >::reset().

◆ operator=() [6/6]

template<class ObjectType >
ReferenceCountedObjectPtr & juce::ReferenceCountedObjectPtr< ObjectType >::operator= ( ReferenceCountedObjectPtr< ObjectType > &&  other)
inlinenoexcept

Takes-over the object from another pointer.

Definition at line 366 of file juce_ReferenceCountedObject.h.

◆ get()

◆ reset()

template<class ObjectType >
void juce::ReferenceCountedObjectPtr< ObjectType >::reset ( )
inlinenoexcept

Resets this object to a null pointer.

Definition at line 388 of file juce_ReferenceCountedObject.h.

Referenced by juce::ReferenceCountedObjectPtr< ObjectType >::operator=().

◆ operator->()

template<class ObjectType >
ReferencedType * juce::ReferenceCountedObjectPtr< ObjectType >::operator-> ( ) const
inlinenoexcept

Definition at line 396 of file juce_ReferenceCountedObject.h.

◆ operator*()

template<class ObjectType >
ReferencedType & juce::ReferenceCountedObjectPtr< ObjectType >::operator* ( ) const
inlinenoexcept

Dereferences the object that this pointer references.

The pointer returned may be null, of course.

Definition at line 405 of file juce_ReferenceCountedObject.h.

◆ operator==() [1/3]

template<class ObjectType >
bool juce::ReferenceCountedObjectPtr< ObjectType >::operator== ( decltype(nullptr)  ) const
inlinenoexcept

Checks whether this pointer is null.

Definition at line 408 of file juce_ReferenceCountedObject.h.

◆ operator!=() [1/3]

template<class ObjectType >
bool juce::ReferenceCountedObjectPtr< ObjectType >::operator!= ( decltype(nullptr)  ) const
inlinenoexcept

Checks whether this pointer is null.

Definition at line 410 of file juce_ReferenceCountedObject.h.

◆ operator==() [2/3]

template<class ObjectType >
bool juce::ReferenceCountedObjectPtr< ObjectType >::operator== ( const ObjectType *  other) const
inlinenoexcept

Compares two ReferenceCountedObjectPtrs.

Definition at line 413 of file juce_ReferenceCountedObject.h.

◆ operator==() [3/3]

template<class ObjectType >
bool juce::ReferenceCountedObjectPtr< ObjectType >::operator== ( const ReferenceCountedObjectPtr< ObjectType > &  other) const
inlinenoexcept

Compares two ReferenceCountedObjectPtrs.

Definition at line 415 of file juce_ReferenceCountedObject.h.

◆ operator!=() [2/3]

template<class ObjectType >
bool juce::ReferenceCountedObjectPtr< ObjectType >::operator!= ( const ObjectType *  other) const
inlinenoexcept

Compares two ReferenceCountedObjectPtrs.

Definition at line 417 of file juce_ReferenceCountedObject.h.

◆ operator!=() [3/3]

template<class ObjectType >
bool juce::ReferenceCountedObjectPtr< ObjectType >::operator!= ( const ReferenceCountedObjectPtr< ObjectType > &  other) const
inlinenoexcept

Compares two ReferenceCountedObjectPtrs.

Definition at line 419 of file juce_ReferenceCountedObject.h.

◆ operator ReferencedType *()

template<class ObjectType >
juce::ReferenceCountedObjectPtr< ObjectType >::operator ReferencedType * ( ) const
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.

Definition at line 432 of file juce_ReferenceCountedObject.h.

◆ decIfNotNull()

template<class ObjectType >
static void juce::ReferenceCountedObjectPtr< ObjectType >::decIfNotNull ( ReferencedType o)
inlinestaticnoexcept

Definition at line 449 of file juce_ReferenceCountedObject.h.

Member Data Documentation

◆ incIfNotNull

template<class ObjectType >
JUCE_DEPRECATED_WITH_BODY(ReferencedType *getObject() const, { return get();}) private voi juce::ReferenceCountedObjectPtr< ObjectType >::incIfNotNull) (ReferencedType *o) noexcept
inlinestaticnoexcept

Definition at line 443 of file juce_ReferenceCountedObject.h.


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