Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Burger::CodeLibrary Class Reference

Manage code library files. More...

Public Member Functions

 CodeLibrary () noexcept
 Initialize variables.
 
 ~CodeLibrary () noexcept
 Release variables.
 
eError init (const char *pFilename) noexcept
 Load in a shared library.
 
void shutdown (void) noexcept
 Release a shared library.
 
void * get_function (const char *pFunctionName) noexcept
 Grab a function pointer from a shared library.
 
uint_t is_initialized (void) const noexcept
 Has a library been loaded?
 

Private Member Functions

 CodeLibrary (const CodeLibrary &)=delete
 
CodeLibraryoperator= (const CodeLibrary &)=delete
 
 CodeLibrary (CodeLibrary &&)=delete
 
CodeLibraryoperator= (CodeLibrary &&)=delete
 

Private Attributes

void * m_pLibInstance
 Instance of the code library.
 

Detailed Description

Manage code library files.


Loading a DLL, .so or any other type of shared library is managed with this generic class. Initialize it with a call to init() and then call get_function() to extract each and every pointer to the code or data contained within.

If this class is shut down by the shutdown(void) call, all of the pointers will become invalid and should never be used again.

Constructor & Destructor Documentation

◆ CodeLibrary() [1/3]

Burger::CodeLibrary::CodeLibrary ( const CodeLibrary & )
privatedelete

◆ CodeLibrary() [2/3]

Burger::CodeLibrary::CodeLibrary ( CodeLibrary && )
privatedelete

◆ CodeLibrary() [3/3]

Burger::CodeLibrary::CodeLibrary ( )
inlinenoexcept

Initialize variables.


On creation, variables are initialized but no attempt is made to load in a shared library. The shared library is loaded only with a call to init()

See also
init(const char *) and shutdown(void)

◆ ~CodeLibrary()

Burger::CodeLibrary::~CodeLibrary ( )
noexcept

Release variables.


On disposal, if a share library was loaded, it will be released and all function pointers will be invalid.

See also
shutdown(void)

Member Function Documentation

◆ get_function()

void * Burger::CodeLibrary::get_function ( const char * pFunctionName)
noexcept

Grab a function pointer from a shared library.


Search the loaded library for a specific function and if found, return the pointer to use to call it.

Parameters
pFunctionNamePointer to a "C" string of the function's name.
Returns
nullptr on failure or a valid pointer to the function in the l ibrary.

◆ init()

Burger::eError Burger::CodeLibrary::init ( const char * pFilename)
noexcept

Load in a shared library.


If the filename has any colons in it, it's assumed to be a full pathname and the library is directly loaded. If the library name has no colons, it's assumed to be a system code library and the system path(s) are searched until it is found.

Parameters
pFilenamePointer to a UTF-8 encoded pathname to the library
Returns
eError error code
See also
get_function()

◆ is_initialized()

uint_t Burger::CodeLibrary::is_initialized ( void ) const
inlinenoexcept

Has a library been loaded?


Returns TRUE if a library was successfully loaded and ready for querying for function pointers.

Returns
TRUE if a library is loaded, FALSE if not.

◆ operator=() [1/2]

CodeLibrary & Burger::CodeLibrary::operator= ( CodeLibrary && )
privatedelete

◆ operator=() [2/2]

CodeLibrary & Burger::CodeLibrary::operator= ( const CodeLibrary & )
privatedelete

◆ shutdown()

void Burger::CodeLibrary::shutdown ( void )
noexcept

Release a shared library.


If a library was loaded, release it back to the operating system.

Note
All function pointers returned by calls to CodeLibrary::get_function() will be immediately invalid after this call is complete.

Member Data Documentation

◆ m_pLibInstance

void* Burger::CodeLibrary::m_pLibInstance
private

Instance of the code library.