OpenShot Library | libopenshot-audio 0.2.0
juce::OptionalScopedPointer< ObjectType > Class Template Reference

Holds a pointer to an object which can optionally be deleted when this pointer goes out of scope. More...

#include <juce_OptionalScopedPointer.h>

Public Member Functions

 OptionalScopedPointer ()=default
 Creates an empty OptionalScopedPointer.
 
 OptionalScopedPointer (ObjectType *objectToHold, bool takeOwnership)
 Creates an OptionalScopedPointer to point to a given object, and specifying whether the OptionalScopedPointer will delete it.
 
 OptionalScopedPointer (OptionalScopedPointer &objectToTransferFrom)
 Takes ownership of the object that another OptionalScopedPointer holds.
 
OptionalScopedPointeroperator= (OptionalScopedPointer &objectToTransferFrom)
 Takes ownership of the object that another OptionalScopedPointer holds.
 
 ~OptionalScopedPointer ()
 The destructor may or may not delete the object that is being held, depending on the takeOwnership flag that was specified when the object was first passed into an OptionalScopedPointer constructor.
 
 operator ObjectType * () const noexcept
 Returns the object that this pointer is managing.
 
ObjectTypeget () const noexcept
 Returns the object that this pointer is managing.
 
ObjectTypeoperator* () const noexcept
 Returns the object that this pointer is managing.
 
ObjectTypeoperator-> () const noexcept
 Lets you access methods and properties of the object that this pointer is holding.
 
ObjectTyperelease () noexcept
 Removes the current object from this OptionalScopedPointer without deleting it.
 
void reset ()
 Resets this pointer to null, possibly deleting the object that it holds, if it has ownership of it.
 
void clear ()
 Does the same thing as reset().
 
void set (ObjectType *newObject, bool takeOwnership)
 Makes this OptionalScopedPointer point at a new object, specifying whether the OptionalScopedPointer will take ownership of the object.
 
void setOwned (ObjectType *newObject)
 Makes this OptionalScopedPointer point at a new object, and take ownership of that object.
 
void setNonOwned (ObjectType *newObject)
 Makes this OptionalScopedPointer point at a new object, but will not take ownership of that object.
 
bool willDeleteObject () const noexcept
 Returns true if the target object will be deleted when this pointer object is deleted.
 
void swapWith (OptionalScopedPointer< ObjectType > &other) noexcept
 Swaps this object with another OptionalScopedPointer.
 

Detailed Description

template<class ObjectType>
class juce::OptionalScopedPointer< ObjectType >

Holds a pointer to an object which can optionally be deleted when this pointer goes out of scope.

This acts in many ways like a ScopedPointer, but allows you to specify whether or not the object is deleted.

See also
ScopedPointer

Definition at line 43 of file juce_OptionalScopedPointer.h.

Constructor & Destructor Documentation

◆ OptionalScopedPointer() [1/2]

template<class ObjectType >
juce::OptionalScopedPointer< ObjectType >::OptionalScopedPointer ( ObjectType objectToHold,
bool  takeOwnership 
)
inline

Creates an OptionalScopedPointer to point to a given object, and specifying whether the OptionalScopedPointer will delete it.

If takeOwnership is true, then the OptionalScopedPointer will act like a ScopedPointer, deleting the object when it is itself deleted. If this parameter is false, then the OptionalScopedPointer just holds a normal pointer to the object, and won't delete it.

Definition at line 57 of file juce_OptionalScopedPointer.h.

◆ OptionalScopedPointer() [2/2]

template<class ObjectType >
juce::OptionalScopedPointer< ObjectType >::OptionalScopedPointer ( OptionalScopedPointer< ObjectType > &  objectToTransferFrom)
inline

Takes ownership of the object that another OptionalScopedPointer holds.

Like a normal ScopedPointer, the objectToTransferFrom object will become null, as ownership of the managed object is transferred to this object.

The flag to indicate whether or not to delete the managed object is also copied from the source object.

Definition at line 70 of file juce_OptionalScopedPointer.h.

◆ ~OptionalScopedPointer()

The destructor may or may not delete the object that is being held, depending on the takeOwnership flag that was specified when the object was first passed into an OptionalScopedPointer constructor.

Definition at line 100 of file juce_OptionalScopedPointer.h.

References juce::OptionalScopedPointer< ObjectType >::reset().

Member Function Documentation

◆ operator=()

template<class ObjectType >
OptionalScopedPointer & juce::OptionalScopedPointer< ObjectType >::operator= ( OptionalScopedPointer< ObjectType > &  objectToTransferFrom)
inline

Takes ownership of the object that another OptionalScopedPointer holds.

Like a normal ScopedPointer, the objectToTransferFrom object will become null, as ownership of the managed object is transferred to this object.

The ownership flag that says whether or not to delete the managed object is also copied from the source object.

Definition at line 84 of file juce_OptionalScopedPointer.h.

References juce::OptionalScopedPointer< ObjectType >::reset().

◆ operator ObjectType *()

template<class ObjectType >
juce::OptionalScopedPointer< ObjectType >::operator ObjectType * ( ) const
inlinenoexcept

Returns the object that this pointer is managing.

Definition at line 107 of file juce_OptionalScopedPointer.h.

◆ get()

template<class ObjectType >
ObjectType * juce::OptionalScopedPointer< ObjectType >::get ( ) const
inlinenoexcept

Returns the object that this pointer is managing.

Definition at line 110 of file juce_OptionalScopedPointer.h.

Referenced by juce::OptionalScopedPointer< ObjectType >::set().

◆ operator*()

template<class ObjectType >
ObjectType & juce::OptionalScopedPointer< ObjectType >::operator* ( ) const
inlinenoexcept

Returns the object that this pointer is managing.

Definition at line 113 of file juce_OptionalScopedPointer.h.

◆ operator->()

template<class ObjectType >
ObjectType * juce::OptionalScopedPointer< ObjectType >::operator-> ( ) const
inlinenoexcept

Lets you access methods and properties of the object that this pointer is holding.

Definition at line 116 of file juce_OptionalScopedPointer.h.

◆ release()

template<class ObjectType >
ObjectType * juce::OptionalScopedPointer< ObjectType >::release ( )
inlinenoexcept

Removes the current object from this OptionalScopedPointer without deleting it.

This will return the current object, and set this OptionalScopedPointer to a null pointer.

Definition at line 122 of file juce_OptionalScopedPointer.h.

◆ reset()

◆ clear()

template<class ObjectType >
void juce::OptionalScopedPointer< ObjectType >::clear ( )
inline

Does the same thing as reset().

Definition at line 134 of file juce_OptionalScopedPointer.h.

References juce::OptionalScopedPointer< ObjectType >::reset().

◆ set()

template<class ObjectType >
void juce::OptionalScopedPointer< ObjectType >::set ( ObjectType newObject,
bool  takeOwnership 
)
inline

Makes this OptionalScopedPointer point at a new object, specifying whether the OptionalScopedPointer will take ownership of the object.

If takeOwnership is true, then the OptionalScopedPointer will act like a ScopedPointer, deleting the object when it is itself deleted. If this parameter is false, then the OptionalScopedPointer just holds a normal pointer to the object, and won't delete it.

Definition at line 143 of file juce_OptionalScopedPointer.h.

References juce::OptionalScopedPointer< ObjectType >::get(), and juce::OptionalScopedPointer< ObjectType >::reset().

Referenced by juce::OptionalScopedPointer< ObjectType >::setNonOwned(), and juce::OptionalScopedPointer< ObjectType >::setOwned().

◆ setOwned()

template<class ObjectType >
void juce::OptionalScopedPointer< ObjectType >::setOwned ( ObjectType newObject)
inline

Makes this OptionalScopedPointer point at a new object, and take ownership of that object.

Definition at line 155 of file juce_OptionalScopedPointer.h.

References juce::OptionalScopedPointer< ObjectType >::set().

◆ setNonOwned()

template<class ObjectType >
void juce::OptionalScopedPointer< ObjectType >::setNonOwned ( ObjectType newObject)
inline

Makes this OptionalScopedPointer point at a new object, but will not take ownership of that object.

Definition at line 161 of file juce_OptionalScopedPointer.h.

References juce::OptionalScopedPointer< ObjectType >::set().

◆ willDeleteObject()

template<class ObjectType >
bool juce::OptionalScopedPointer< ObjectType >::willDeleteObject ( ) const
inlinenoexcept

Returns true if the target object will be deleted when this pointer object is deleted.

Definition at line 169 of file juce_OptionalScopedPointer.h.

◆ swapWith()

template<class ObjectType >
void juce::OptionalScopedPointer< ObjectType >::swapWith ( OptionalScopedPointer< ObjectType > &  other)
inlinenoexcept

Swaps this object with another OptionalScopedPointer.

The two objects simply exchange their states.

Definition at line 175 of file juce_OptionalScopedPointer.h.

References juce::Array< ElementType, TypeOfCriticalSectionToUse, minimumAllocatedSize >::swapWith().


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