Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
Public Member Functions | Static Public Member Functions | List of all members
jau::os::NativeLibrary Class Reference

Runtime libary dynamic library (RTLD) access. More...

#include <native_lib.hpp>

Inheritance diagram for jau::os::NativeLibrary:
Collaboration diagram for jau::os::NativeLibrary:

Public Member Functions

void close () noexcept
 Closes this native library. More...
 
DynamicLinkerdynamicLinker () const noexcept
 Returns the used DynamicLinker reference. More...
 
DynamicLinker::symhandle_t dynamicLookupFunction (const std::string &funcName) const noexcept override
 Returns the function handle for function funcName gathered within the associated native library. More...
 
DynamicLinker::symhandle_t dynamicLookupFunctionGlobal (const std::string &funcName) const noexcept override
 Returns the function handle for function funcName gathered globally within all loaded libraries. More...
 
bool isOpen () const noexcept
 Returns true if this instance isValid() and not close()'ed, otherwise false. More...
 
bool isValid () const noexcept
 Returns true if this instance is valid, i.e. More...
 
DynamicLinker::libhandle_t libraryHandle () const noexcept
 Returns the native library handle if valid and not closed, otherwise nullptr. More...
 
const std::string & libraryPath () const noexcept
 Returns the path of the opened native library file. More...
 
const std::string & resolvedLibraryPath () const noexcept
 Returns the resolved native path of the opened native library, might be libraryPath() if not supported by OS. More...
 
std::string toString () const noexcept
 
- Public Member Functions inherited from jau::os::DynamicLookup
virtual ~DynamicLookup () noexcept=default
 
virtual DynamicLinker::symhandle_t dynamicLookupFunction (const std::string &funcName) const noexcept=0
 Returns the function handle for function funcName gathered within the associated native library. More...
 
virtual DynamicLinker::symhandle_t dynamicLookupFunctionGlobal (const std::string &funcName) const noexcept=0
 Returns the function handle for function funcName gathered globally within all loaded libraries. More...
 
bool isFunctionAvailable (const std::string &funcName) const noexcept
 Queries whether function 'funcName' is available. More...
 

Static Public Member Functions

static NativeLibrary open (const std::string &libName, const bool searchSystemPath, const bool searchSystemPathFirst, const bool global) noexcept
 Opens the given native library, assuming it has the same base name on all platforms. More...
 
static NativeLibrary open (const std::string &libName, const bool searchSystemPath, const bool searchSystemPathFirst, const bool global, const std::string &symbolName) noexcept
 Opens the given native library, assuming it has the same base name on all platforms. More...
 

Detailed Description

Runtime libary dynamic library (RTLD) access.

Definition at line 44 of file native_lib.hpp.

Member Function Documentation

◆ dynamicLookupFunction()

DynamicLinker::symhandle_t jau::os::NativeLibrary::dynamicLookupFunction ( const std::string &  funcName) const
inlineoverridevirtualnoexcept

Returns the function handle for function funcName gathered within the associated native library.

Implements jau::os::DynamicLookup.

Definition at line 80 of file native_lib.hpp.

◆ dynamicLookupFunctionGlobal()

DynamicLinker::symhandle_t jau::os::NativeLibrary::dynamicLookupFunctionGlobal ( const std::string &  funcName) const
inlineoverridevirtualnoexcept

Returns the function handle for function funcName gathered globally within all loaded libraries.

Implements jau::os::DynamicLookup.

Definition at line 84 of file native_lib.hpp.

◆ dynamicLinker()

DynamicLinker & jau::os::NativeLibrary::dynamicLinker ( ) const
inlinenoexcept

Returns the used DynamicLinker reference.

Definition at line 89 of file native_lib.hpp.

◆ isValid()

bool jau::os::NativeLibrary::isValid ( ) const
inlinenoexcept

Returns true if this instance is valid, i.e.

native library successfully opened once but not necessarily isOpen() now.

See also
resolvedLibraryPath()

Definition at line 95 of file native_lib.hpp.

Here is the caller graph for this function:

◆ isOpen()

bool jau::os::NativeLibrary::isOpen ( ) const
inlinenoexcept

Returns true if this instance isValid() and not close()'ed, otherwise false.

Definition at line 98 of file native_lib.hpp.

Here is the caller graph for this function:

◆ libraryHandle()

DynamicLinker::libhandle_t jau::os::NativeLibrary::libraryHandle ( ) const
inlinenoexcept

Returns the native library handle if valid and not closed, otherwise nullptr.

Definition at line 101 of file native_lib.hpp.

◆ libraryPath()

const std::string & jau::os::NativeLibrary::libraryPath ( ) const
inlinenoexcept

Returns the path of the opened native library file.

Definition at line 104 of file native_lib.hpp.

◆ resolvedLibraryPath()

const std::string & jau::os::NativeLibrary::resolvedLibraryPath ( ) const
inlinenoexcept

Returns the resolved native path of the opened native library, might be libraryPath() if not supported by OS.

If this native library is not isValid(), method returns an empty string.

See also
isValid()

Definition at line 112 of file native_lib.hpp.

◆ close()

void jau::os::NativeLibrary::close ( )
inlinenoexcept

Closes this native library.

Further lookup operations are not allowed after calling this method.

Definition at line 115 of file native_lib.hpp.

Here is the caller graph for this function:

◆ toString()

std::string jau::os::NativeLibrary::toString ( ) const
inlinenoexcept

Definition at line 125 of file native_lib.hpp.

Here is the caller graph for this function:

◆ open() [1/2]

static NativeLibrary jau::os::NativeLibrary::open ( const std::string &  libName,
const bool  searchSystemPath,
const bool  searchSystemPathFirst,
const bool  global 
)
inlinestaticnoexcept

Opens the given native library, assuming it has the same base name on all platforms.

The searchSystemPath argument changes the behavior to either use the default system path or not at all.

Assuming searchSystemPath is true, the searchSystemPathFirst argument changes the behavior to first search the default system path rather than searching it last.

Parameters
libNamelibrary name, with or without prefix and suffix
searchSystemPathif true library shall be searched in the system path (default), otherwise false.
searchSystemPathFirstif true system path shall be searched first (default), rather than searching it last. if searchSystemPath is false this argument is ignored.
globalif true allows system wide access of the loaded library, otherwise access is restricted to the process.
Returns
NativeLibrary instance, use isValid() to check whether the native library was loaded successful.

Definition at line 152 of file native_lib.hpp.

Here is the caller graph for this function:

◆ open() [2/2]

static NativeLibrary jau::os::NativeLibrary::open ( const std::string &  libName,
const bool  searchSystemPath,
const bool  searchSystemPathFirst,
const bool  global,
const std::string &  symbolName 
)
inlinestaticnoexcept

Opens the given native library, assuming it has the same base name on all platforms.

The searchSystemPath argument changes the behavior to either use the default system path or not at all.

Assuming searchSystemPath is true, the searchSystemPathFirst argument changes the behavior to first search the default system path rather than searching it last.

Parameters
libNamelibrary name, with or without prefix and suffix
searchSystemPathif true library shall be searched in the system path (default), otherwise false.
searchSystemPathFirstif true system path shall be searched first (default), rather than searching it last. if searchSystemPath is false this argument is ignored.
loaderClassLoader to locate the library
globalif true allows system wide access of the loaded library, otherwise access is restricted to the process.
symbolNameoptional symbol name for an OS which requires the symbol's address to retrieve the path of the containing library
Returns
NativeLibrary instance, use isValid() to check whether the native library was loaded successful.
Exceptions
SecurityExceptionif user is not granted access for the named library.
Since
2.4.0

Definition at line 180 of file native_lib.hpp.


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