JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
Public Member Functions | List of all members
juce::Component::SafePointer< ComponentType > Class Template Reference

Holds a pointer to some type of Component, which automatically becomes null if the component is deleted. More...

#include "juce_Component.h"

Public Member Functions

 SafePointer ()=default
 Creates a null SafePointer.
 
 SafePointer (ComponentType *component)
 Creates a SafePointer that points at the given component.
 
 SafePointer (const SafePointer &other) noexcept
 Creates a copy of another SafePointer.
 
SafePointeroperator= (const SafePointer &other)
 Copies another pointer to this one.
 
SafePointeroperator= (ComponentType *newComponent)
 Copies another pointer to this one.
 
ComponentTypegetComponent () const noexcept
 Returns the component that this pointer refers to, or null if the component no longer exists.
 
 operator ComponentType * () const noexcept
 Returns the component that this pointer refers to, or null if the component no longer exists.
 
ComponentTypeoperator-> () const noexcept
 Returns the component that this pointer refers to, or null if the component no longer exists.
 
void deleteAndZero ()
 If the component is valid, this deletes it and sets this pointer to null.
 
bool operator== (ComponentType *component) const noexcept
 
bool operator!= (ComponentType *component) const noexcept
 

Detailed Description

template<class ComponentType>
class juce::Component::SafePointer< ComponentType >

Holds a pointer to some type of Component, which automatically becomes null if the component is deleted.

If you're using a component which may be deleted by another event that's outside of your control, use a SafePointer instead of a normal pointer to refer to it, and you can test whether it's null before using it to see if something has deleted it.

The ComponentType template parameter must be Component, or some subclass of Component.

You may also want to use a WeakReference<Component> object for the same purpose.

Definition at line 2307 of file juce_Component.h.

Constructor & Destructor Documentation

◆ SafePointer() [1/2]

template<class ComponentType >
juce::Component::SafePointer< ComponentType >::SafePointer ( ComponentType component)

Creates a SafePointer that points at the given component.

Definition at line 2314 of file juce_Component.h.

◆ SafePointer() [2/2]

template<class ComponentType >
juce::Component::SafePointer< ComponentType >::SafePointer ( const SafePointer< ComponentType > &  other)
noexcept

Creates a copy of another SafePointer.

Definition at line 2317 of file juce_Component.h.

Member Function Documentation

◆ deleteAndZero()

If the component is valid, this deletes it and sets this pointer to null.

Definition at line 2335 of file juce_Component.h.

◆ getComponent()

template<class ComponentType >
ComponentType * juce::Component::SafePointer< ComponentType >::getComponent ( ) const
noexcept

Returns the component that this pointer refers to, or null if the component no longer exists.

Definition at line 2326 of file juce_Component.h.

◆ operator ComponentType *()

Returns the component that this pointer refers to, or null if the component no longer exists.

Definition at line 2329 of file juce_Component.h.

◆ operator!=()

template<class ComponentType >
bool juce::Component::SafePointer< ComponentType >::operator!= ( ComponentType component) const
noexcept

Definition at line 2338 of file juce_Component.h.

◆ operator->()

Returns the component that this pointer refers to, or null if the component no longer exists.

Definition at line 2332 of file juce_Component.h.

◆ operator=() [1/2]

Copies another pointer to this one.

Definition at line 2323 of file juce_Component.h.

◆ operator=() [2/2]

Copies another pointer to this one.

Definition at line 2320 of file juce_Component.h.

◆ operator==()

Definition at line 2337 of file juce_Component.h.


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