JUCE  v6.1.6 (6.0.8-1114)
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::SingletonHolder< Type, MutexType, onlyCreateOncePerRun > Struct Template Reference

Used by the JUCE_DECLARE_SINGLETON macros to manage a static pointer to a singleton instance. More...

#include <juce_Singleton.h>

Inheritance diagram for juce::SingletonHolder< Type, MutexType, onlyCreateOncePerRun >:
Collaboration diagram for juce::SingletonHolder< Type, MutexType, onlyCreateOncePerRun >:

Public Member Functions

 SingletonHolder ()=default
 
 ~SingletonHolder ()
 
void clear (Type *expectedObject) noexcept
 Called by the class's destructor to clear the pointer if it is currently set to the given object. More...
 
void deleteInstance ()
 Deletes and resets the current instance, if there is one. More...
 
Type * get ()
 Returns the current instance, or creates a new instance if there isn't one. More...
 
Type * getWithoutChecking ()
 Returns the current instance, or creates a new instance if there isn't one, but doesn't do any locking, or checking for recursion or error conditions. More...
 

Public Attributes

std::atomic< Type * > instance { nullptr }
 

Detailed Description

template<typename Type, typename MutexType, bool onlyCreateOncePerRun>
struct juce::SingletonHolder< Type, MutexType, onlyCreateOncePerRun >

Used by the JUCE_DECLARE_SINGLETON macros to manage a static pointer to a singleton instance.

You generally won't use this directly, but see the macros JUCE_DECLARE_SINGLETON, JUCE_DECLARE_SINGLETON_SINGLETHREADED, JUCE_DECLARE_SINGLETON_SINGLETHREADED_MINIMAL, and JUCE_IMPLEMENT_SINGLETON for how it is intended to be used.

@tags{Core}

Constructor & Destructor Documentation

◆ SingletonHolder()

template<typename Type , typename MutexType , bool onlyCreateOncePerRun>
juce::SingletonHolder< Type, MutexType, onlyCreateOncePerRun >::SingletonHolder ( )
default

◆ ~SingletonHolder()

template<typename Type , typename MutexType , bool onlyCreateOncePerRun>
juce::SingletonHolder< Type, MutexType, onlyCreateOncePerRun >::~SingletonHolder ( )
inline

Member Function Documentation

◆ clear()

template<typename Type , typename MutexType , bool onlyCreateOncePerRun>
void juce::SingletonHolder< Type, MutexType, onlyCreateOncePerRun >::clear ( Type *  expectedObject)
inlinenoexcept

Called by the class's destructor to clear the pointer if it is currently set to the given object.

References juce::SingletonHolder< Type, MutexType, onlyCreateOncePerRun >::instance.

◆ deleteInstance()

template<typename Type , typename MutexType , bool onlyCreateOncePerRun>
void juce::SingletonHolder< Type, MutexType, onlyCreateOncePerRun >::deleteInstance ( )
inline

Deletes and resets the current instance, if there is one.

References juce::SingletonHolder< Type, MutexType, onlyCreateOncePerRun >::instance.

◆ get()

template<typename Type , typename MutexType , bool onlyCreateOncePerRun>
Type* juce::SingletonHolder< Type, MutexType, onlyCreateOncePerRun >::get ( )
inline

◆ getWithoutChecking()

template<typename Type , typename MutexType , bool onlyCreateOncePerRun>
Type* juce::SingletonHolder< Type, MutexType, onlyCreateOncePerRun >::getWithoutChecking ( )
inline

Returns the current instance, or creates a new instance if there isn't one, but doesn't do any locking, or checking for recursion or error conditions.

References juce::SingletonHolder< Type, MutexType, onlyCreateOncePerRun >::instance, and juce::gl::p.

Referenced by juce::SingletonHolder< Type, MutexType, onlyCreateOncePerRun >::get().

Member Data Documentation

◆ instance


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