JUCE  v6.1.6 (6.0.8-1114)
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::SingleThreadedReferenceCountedObject Class Reference

Adds reference-counting to an object. More...

#include <juce_ReferenceCountedObject.h>

Inheritance diagram for juce::SingleThreadedReferenceCountedObject:
Collaboration diagram for juce::SingleThreadedReferenceCountedObject:

Public Member Functions

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

Protected Member Functions

 SingleThreadedReferenceCountedObject ()=default
 Creates the reference-counted object (with an initial ref count of zero). More...
 
 SingleThreadedReferenceCountedObject (const SingleThreadedReferenceCountedObject &)
 Copying from another object does not affect this one's reference-count. More...
 
 SingleThreadedReferenceCountedObject (SingleThreadedReferenceCountedObject &&)
 Copying from another object does not affect this one's reference-count. More...
 
virtual ~SingleThreadedReferenceCountedObject ()
 Destructor. More...
 
SingleThreadedReferenceCountedObjectoperator= (const SingleThreadedReferenceCountedObject &)
 Copying from another object does not affect this one's reference-count. More...
 
SingleThreadedReferenceCountedObjectoperator= (SingleThreadedReferenceCountedObject &&)
 Copying from another object does not affect this one's reference-count. More...
 

Private Attributes

int refCount = 0
 

Friends

struct ContainerDeletePolicy< ReferenceCountedObject >
 

Detailed Description

Adds reference-counting to an object.

This is effectively a version of the ReferenceCountedObject class, but which uses a non-atomic counter, and so is not thread-safe (but which will be more efficient). For more details on how to use it, see the ReferenceCountedObject class notes.

See also
ReferenceCountedObject, ReferenceCountedObjectPtr, ReferenceCountedArray

@tags{Core}

Constructor & Destructor Documentation

◆ SingleThreadedReferenceCountedObject() [1/3]

juce::SingleThreadedReferenceCountedObject::SingleThreadedReferenceCountedObject ( )
protecteddefault

Creates the reference-counted object (with an initial ref count of zero).

◆ SingleThreadedReferenceCountedObject() [2/3]

juce::SingleThreadedReferenceCountedObject::SingleThreadedReferenceCountedObject ( const SingleThreadedReferenceCountedObject )
inlineprotected

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

◆ SingleThreadedReferenceCountedObject() [3/3]

juce::SingleThreadedReferenceCountedObject::SingleThreadedReferenceCountedObject ( SingleThreadedReferenceCountedObject &&  )
inlineprotected

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

◆ ~SingleThreadedReferenceCountedObject()

virtual juce::SingleThreadedReferenceCountedObject::~SingleThreadedReferenceCountedObject ( )
inlineprotectedvirtual

Destructor.

References jassert.

Member Function Documentation

◆ decReferenceCount()

void juce::SingleThreadedReferenceCountedObject::decReferenceCount ( )
inlinenoexcept

Decreases the object's reference count.

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

References jassert.

◆ decReferenceCountWithoutDeleting()

bool juce::SingleThreadedReferenceCountedObject::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.

References jassert.

◆ getReferenceCount()

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

Returns the object's current reference count.

◆ incReferenceCount()

void juce::SingleThreadedReferenceCountedObject::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.

◆ operator=() [1/2]

SingleThreadedReferenceCountedObject& juce::SingleThreadedReferenceCountedObject::operator= ( const SingleThreadedReferenceCountedObject )
inlineprotected

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

◆ operator=() [2/2]

SingleThreadedReferenceCountedObject& juce::SingleThreadedReferenceCountedObject::operator= ( SingleThreadedReferenceCountedObject &&  )
inlineprotected

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

Friends And Related Function Documentation

◆ ContainerDeletePolicy< ReferenceCountedObject >

Member Data Documentation

◆ refCount

int juce::SingleThreadedReferenceCountedObject::refCount = 0
private

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