PLCnext API Documentation 25.0.2.69
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Arp::System::Commons::Runtime::SharedLibrary Class Reference

High level API to enable work with dynamically loadable shared libraries. More...

#include <SharedLibrary.hpp>

Public Types

using SymbolNames = std::vector< String >
 

Public Member Functions

 SharedLibrary (void)
 Constructs an SharedLibrary instance.
 
 SharedLibrary (const SharedLibrary &arg)=delete
 Copy contructor.
 
SharedLibrary & operator= (const SharedLibrary &arg)=delete
 Assignment operator.
 
 ~SharedLibrary (void)
 Destructs this instance and frees all resouces.
 
SymbolNames GetExportedFunctionNames (const String &path) const
 Loads the specified shared library. More...
 
void Load (const String &path, SharedLibraryMemoryLockOption sharedLibraryMemoryLockOption=SharedLibraryMemoryLockOption::Nothing)
 Loads the specified shared library. More...
 
bool TryLoad (const String &path, SharedLibraryMemoryLockOption sharedLibraryMemoryLockOption=SharedLibraryMemoryLockOption::Nothing)
 Loads the specified shared library. More...
 
void Unload (void)
 Unloads the shared library. More...
 
void * GetFunctionAddress (const String &symbolName)
 Returns the address where specified symbol is located in the memory. More...
 

Static Public Member Functions

static String GetArpLibrariesDirectory (void)
 
static String GetFormattedPath (const String &path)
 Formats the path depending on OS. More...
 
static bool ProbeLibrary (const String &path, String &probedPath)
 Probes the library More...
 

Detailed Description

High level API to enable work with dynamically loadable shared libraries.

Member Function Documentation

◆ GetExportedFunctionNames()

SharedLibrary::SymbolNames Arp::System::Commons::Runtime::SharedLibrary::GetExportedFunctionNames ( const String &  path) const

Loads the specified shared library.

Symbols exposed by the shared library are globally available after a successfull load.

Parameters
pathThe complete path to the library to load.
Exceptions
Arp::Exceptionif the library could not be loaded.

◆ GetFormattedPath()

String Arp::System::Commons::Runtime::SharedLibrary::GetFormattedPath ( const String &  path)
static

Formats the path depending on OS.

Parameters
pathPath that shall be formatted.
Returns
Formatted path.

◆ GetFunctionAddress()

void * Arp::System::Commons::Runtime::SharedLibrary::GetFunctionAddress ( const String &  symbolName)

Returns the address where specified symbol is located in the memory.

Parameters
symbolNameName of queried symbol.
Returns
Valid memory address on success, NULL if symbol could not be found.

◆ Load()

void Arp::System::Commons::Runtime::SharedLibrary::Load ( const String &  path,
SharedLibraryMemoryLockOption  sharedLibraryMemoryLockOption = SharedLibraryMemoryLockOption::Nothing 
)

Loads the specified shared library.

Symbols exposed by the shared library are globally available after a successfull load.

Parameters
pathThe complete path to the library to load.
sharedLibraryMemoryLockOptionOptionally option to lock memory of shared library. If not set, then is set SharedLibraryMemoryLockOption::Nothing.
Exceptions
Arp::Exceptionif the library could not be loaded.

◆ ProbeLibrary()

bool Arp::System::Commons::Runtime::SharedLibrary::ProbeLibrary ( const String &  path,
String &  probedPath 
)
static

Probes the library

Parameters
pathPath to library
probedPathProbed path to library
Returns
true, if library could be probed. Otherwise false.

◆ TryLoad()

bool Arp::System::Commons::Runtime::SharedLibrary::TryLoad ( const String &  path,
SharedLibraryMemoryLockOption  sharedLibraryMemoryLockOption = SharedLibraryMemoryLockOption::Nothing 
)

Loads the specified shared library.

Symbols exposed by the shared library are globally available after a successfull load.

Parameters
pathThe complete path to the library to load.
sharedLibraryMemoryLockOptionOptionally option to lock memory of shared library. If not set, then is set SharedLibraryMemoryLockOption::Nothing.
Returns
true on success, otherwise false.

◆ Unload()

void Arp::System::Commons::Runtime::SharedLibrary::Unload ( void  )

Unloads the shared library.

Exceptions
Arp::Exceptionin case the unload fails.

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