JUCE  v6.1.6 (6.0.8-1114)
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::DynamicLibrary Class Reference

Handles the opening and closing of DLLs. More...

#include <juce_DynamicLibrary.h>

Collaboration diagram for juce::DynamicLibrary:

Public Member Functions

 DynamicLibrary ()=default
 Creates an unopened DynamicLibrary object. More...
 
 DynamicLibrary (const String &name)
 
 DynamicLibrary (DynamicLibrary &&other) noexcept
 Move constructor. More...
 
 ~DynamicLibrary ()
 Destructor. More...
 
void close ()
 Releases the currently-open DLL, or has no effect if none was open. More...
 
void * getFunction (const String &functionName) noexcept
 Tries to find a named function in the currently-open DLL, and returns a pointer to it. More...
 
void * getNativeHandle () const noexcept
 Returns the platform-specific native library handle. More...
 
bool open (const String &name)
 Opens a DLL. More...
 

Private Attributes

void * handle = nullptr
 

Detailed Description

Handles the opening and closing of DLLs.

This class can be used to open a DLL and get some function pointers from it. Since the DLL is freed when this object is deleted, it's handy for managing library lifetimes using RAII.

@tags{Core}

Constructor & Destructor Documentation

◆ DynamicLibrary() [1/3]

juce::DynamicLibrary::DynamicLibrary ( )
default

Creates an unopened DynamicLibrary object.

Call open() to actually open one.

◆ DynamicLibrary() [2/3]

juce::DynamicLibrary::DynamicLibrary ( const String name)
inline

References juce::gl::name.

◆ DynamicLibrary() [3/3]

juce::DynamicLibrary::DynamicLibrary ( DynamicLibrary &&  other)
inlinenoexcept

Move constructor.

References juce::gl::handle.

◆ ~DynamicLibrary()

juce::DynamicLibrary::~DynamicLibrary ( )
inline

Destructor.

If a library is currently open, it will be closed when this object is destroyed.

Member Function Documentation

◆ close()

void juce::DynamicLibrary::close ( )

Releases the currently-open DLL, or has no effect if none was open.

References handle.

Referenced by open().

◆ getFunction()

void * juce::DynamicLibrary::getFunction ( const String functionName)
noexcept

Tries to find a named function in the currently-open DLL, and returns a pointer to it.

If no library is open, or if the function isn't found, this will return a null pointer.

References juce::gl::handle.

◆ getNativeHandle()

void* juce::DynamicLibrary::getNativeHandle ( ) const
inlinenoexcept

Returns the platform-specific native library handle.

You'll need to cast this to whatever is appropriate for the OS that's in use.

References juce::gl::handle.

◆ open()

bool juce::DynamicLibrary::open ( const String name)

Opens a DLL.

The name and the method by which it gets found is of course platform-specific, and may or may not include a path, depending on the OS. If a library is already open when this method is called, it will first close the library before attempting to load the new one.

Returns
true if the library was successfully found and opened.

References close(), handle, and juce::gl::name.

Referenced by juce::AndroidHighPerformanceAudioHelpers::isProAudioDevice().

Member Data Documentation

◆ handle

void* juce::DynamicLibrary::handle = nullptr
private

Referenced by close(), and open().


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