JUCE v8.0.9
JUCE API
 
Loading...
Searching...
No Matches
juce::Animator::Weak Class Reference

#include <juce_Animator.h>

Collaboration diagram for juce::Animator::Weak:

Public Member Functions

 Weak ()=default
 Constructor used by the Animator implementation.
 
 Weak (std::shared_ptr< Impl > p)
 Constructor used by the Animator implementation.
 
void * getKey () const
 
std::optional< Animatorlock () const
 If the referenced Animator implementation object still exists it returns an Animator object storing a strong reference to it.
 

Private Attributes

Impl * originalPtr {}
 
std::weak_ptr< Impl > ptr
 

Detailed Description

Stores a weak reference to the Animator's underlying implementation. Animator objects store a strong reference to the implementation, so it won't be deleted as long as an Animator object references it. Instead of copying the Animator, you can use makeWeak() to create a weak reference, which will not prevent deletion of the underlying implementation, but allows you to create a strong reference using the lock function for as long as the underlying object is alive.

This class is used by the AnimatorUpdater, and it's unlikely you will need to use it directly.

See also
AnimatorUpdater, VBlankAnimatorUpdater

Constructor & Destructor Documentation

◆ Weak() [1/2]

juce::Animator::Weak::Weak ( )
default

Constructor used by the Animator implementation.

To obtain a weak reference use Animator::makeWeak().

◆ Weak() [2/2]

juce::Animator::Weak::Weak ( std::shared_ptr< Impl >  p)
inlineexplicit

Constructor used by the Animator implementation.

To obtain a weak reference use Animator::makeWeak().

Member Function Documentation

◆ getKey()

void * juce::Animator::Weak::getKey ( ) const
inline

Used internally for storing the reference in a std::map.

◆ lock()

std::optional< Animator > juce::Animator::Weak::lock ( ) const
inline

If the referenced Animator implementation object still exists it returns an Animator object storing a strong reference to it.

If the implementation object was deleted it returns a nullopt.

Member Data Documentation

◆ originalPtr

Impl* juce::Animator::Weak::originalPtr {}
private

◆ ptr

std::weak_ptr<Impl> juce::Animator::Weak::ptr
private

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