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
Steinberg::OPtr< I > Class Template Reference

OPtr - "owning" smart pointer used for newly created FObjects. More...

#include "smartpointer.h"

Inheritance diagram for Steinberg::OPtr< I >:
Steinberg::IPtr< I >

Public Member Functions

 OPtr (I *p)
 
 OPtr (const IPtr< I > &p)
 
 OPtr (const OPtr< I > &p)
 
I * operator= (I *_ptr)
 
- Public Member Functions inherited from Steinberg::IPtr< I >
 IPtr (I *ptr, bool addRef=true)
 
 IPtr (const IPtr &)
 
template<class T >
 IPtr (const IPtr< T > &other)
 
I * operator= (I *ptr)
 
IPtroperator= (const IPtr &other)
 
template<class T >
IPtroperator= (const IPtr< T > &other)
 
 operator I* () const
 
I * operator-> () const
 
I * get () const
 
void reset (I *obj=nullptr)
 
I * take () SMTG_NOEXCEPT
 

Additional Inherited Members

- Static Public Member Functions inherited from Steinberg::IPtr< I >
template<typename T >
static IPtr< T > adopt (T *obj) SMTG_NOEXCEPT
 
- Protected Attributes inherited from Steinberg::IPtr< I >
I * ptr
 

Detailed Description

template<class I>
class Steinberg::OPtr< I >

OPtr - "owning" smart pointer used for newly created FObjects.

FUnknown implementations are supposed to have a refCount of 1 right after creation. So using an IPtr on newly created objects would lead to a leak. Instead the OPtr can be used in this case.
Example:

OPtr<IPath> path = FHostCreate (IPath, hostClasses);
// no release is needed...
OPtr - "owning" smart pointer used for newly created FObjects.

The assignment operator takes ownership of a new object and releases the old. So its safe to write:

OPtr<IPath> path = FHostCreate (IPath, hostClasses);
path = FHostCreate (IPath, hostClasses);
path = 0;

This is the difference to using an IPtr with addRef=false.

// DONT DO THIS:
IPtr<IPath> path (FHostCreate (IPath, hostClasses), false);
path = FHostCreate (IPath, hostClasses);
path = 0;
IPtr - Smart pointer template class.

This will lead to a leak!

Definition at line 209 of file smartpointer.h.

Constructor & Destructor Documentation

◆ OPtr() [1/4]

template<class I >
Steinberg::OPtr< I >::OPtr ( I *  p)

Definition at line 213 of file smartpointer.h.

◆ OPtr() [2/4]

template<class I >
Steinberg::OPtr< I >::OPtr ( const IPtr< I > &  p)

Definition at line 214 of file smartpointer.h.

◆ OPtr() [3/4]

template<class I >
Steinberg::OPtr< I >::OPtr ( const OPtr< I > &  p)

Definition at line 215 of file smartpointer.h.

◆ OPtr() [4/4]

template<class I >
Steinberg::OPtr< I >::OPtr ( )

Definition at line 216 of file smartpointer.h.

Member Function Documentation

◆ operator=()

template<class I >
I * Steinberg::OPtr< I >::operator= ( I *  _ptr)

Definition at line 217 of file smartpointer.h.


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