OpenShot Library | libopenshot-audio 0.2.0
juce::ReferenceCountedObject Class Reference

A base class which provides methods for reference-counting. More...

#include <juce_ReferenceCountedObject.h>

+ Inheritance diagram for juce::ReferenceCountedObject:

Public Member Functions

void incReferenceCount () noexcept
 Increments the object's reference count.
 
void decReferenceCount () noexcept
 Decreases the object's reference count.
 
bool decReferenceCountWithoutDeleting () noexcept
 Decreases the object's reference count.
 
int getReferenceCount () const noexcept
 Returns the object's current reference count.
 

Protected Member Functions

 ReferenceCountedObject ()=default
 Creates the reference-counted object (with an initial ref count of zero).
 
 ReferenceCountedObject (const ReferenceCountedObject &) noexcept
 Copying from another object does not affect this one's reference-count.
 
 ReferenceCountedObject (ReferenceCountedObject &&) noexcept
 Copying from another object does not affect this one's reference-count.
 
ReferenceCountedObjectoperator= (const ReferenceCountedObject &) noexcept
 Copying from another object does not affect this one's reference-count.
 
ReferenceCountedObjectoperator= (ReferenceCountedObject &&) noexcept
 Copying from another object does not affect this one's reference-count.
 
virtual ~ReferenceCountedObject ()
 Destructor.
 
void resetReferenceCount () noexcept
 Resets the reference count to zero without deleting the object.
 

Friends

struct ContainerDeletePolicy< ReferenceCountedObject >
 

Detailed Description

A base class which provides methods for reference-counting.

To add reference-counting to a class, derive it from this class, and use the ReferenceCountedObjectPtr class to point to it.

e.g.

{
void foo();
// This is a neat way of declaring a typedef for a pointer class,
// rather than typing out the full templated name each time..
};
MyClass::Ptr p = new MyClass();
MyClass::Ptr p2 = p;
p = nullptr;
p2->foo();
Holds a resizable array of primitive or copy-by-value objects.
Definition juce_Array.h:60
A base class which provides methods for reference-counting.

Once a new ReferenceCountedObject has been assigned to a pointer, be careful not to delete the object manually.

This class uses an Atomic<int> value to hold the reference count, so that the pointers can be passed between threads safely. For a faster but non-thread-safe version, use SingleThreadedReferenceCountedObject instead.

See also
ReferenceCountedObjectPtr, ReferenceCountedArray, SingleThreadedReferenceCountedObject

Definition at line 64 of file juce_ReferenceCountedObject.h.

Constructor & Destructor Documentation

◆ ReferenceCountedObject() [1/2]

juce::ReferenceCountedObject::ReferenceCountedObject ( const ReferenceCountedObject )
inlineprotectednoexcept

Copying from another object does not affect this one's reference-count.

Definition at line 109 of file juce_ReferenceCountedObject.h.

◆ ReferenceCountedObject() [2/2]

juce::ReferenceCountedObject::ReferenceCountedObject ( ReferenceCountedObject &&  )
inlineprotectednoexcept

Copying from another object does not affect this one's reference-count.

Definition at line 111 of file juce_ReferenceCountedObject.h.

◆ ~ReferenceCountedObject()

virtual juce::ReferenceCountedObject::~ReferenceCountedObject ( )
inlineprotectedvirtual

Destructor.

Definition at line 118 of file juce_ReferenceCountedObject.h.

Member Function Documentation

◆ incReferenceCount()

void juce::ReferenceCountedObject::incReferenceCount ( )
inlinenoexcept

Increments the object's reference count.

This is done automatically by the smart pointer, but is public just in case it's needed for nefarious purposes.

Definition at line 73 of file juce_ReferenceCountedObject.h.

◆ decReferenceCount()

void juce::ReferenceCountedObject::decReferenceCount ( )
inlinenoexcept

Decreases the object's reference count.

If the count gets to zero, the object will be deleted.

Definition at line 81 of file juce_ReferenceCountedObject.h.

◆ decReferenceCountWithoutDeleting()

bool juce::ReferenceCountedObject::decReferenceCountWithoutDeleting ( )
inlinenoexcept

Decreases the object's reference count.

If the count gets to zero, the object will not be deleted, but this method will return true, allowing the caller to take care of deletion.

Definition at line 93 of file juce_ReferenceCountedObject.h.

◆ getReferenceCount()

int juce::ReferenceCountedObject::getReferenceCount ( ) const
inlinenoexcept

Returns the object's current reference count.

Definition at line 100 of file juce_ReferenceCountedObject.h.

◆ operator=() [1/2]

ReferenceCountedObject & juce::ReferenceCountedObject::operator= ( const ReferenceCountedObject )
inlineprotectednoexcept

Copying from another object does not affect this one's reference-count.

Definition at line 113 of file juce_ReferenceCountedObject.h.

◆ operator=() [2/2]

ReferenceCountedObject & juce::ReferenceCountedObject::operator= ( ReferenceCountedObject &&  )
inlineprotectednoexcept

Copying from another object does not affect this one's reference-count.

Definition at line 115 of file juce_ReferenceCountedObject.h.

◆ resetReferenceCount()

void juce::ReferenceCountedObject::resetReferenceCount ( )
inlineprotectednoexcept

Resets the reference count to zero without deleting the object.

You should probably never need to use this!

Definition at line 127 of file juce_ReferenceCountedObject.h.

Friends And Related Symbol Documentation

◆ ContainerDeletePolicy< ReferenceCountedObject >


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