|
Arcade architecture
|
A class for dynamically loading and managing modules. More...
#include <LibLoader.hpp>
Public Member Functions | |
| Loader::ModuleType_t | getModuleType () const |
| Get the type of the loaded module. More... | |
| const char * | getModulePath () const |
| Get the path of the loaded module. More... | |
| template<class T > | |
| T * | initEntryPoint () |
| Initializes and retrieves an instance of a class from a dynamically loaded library. More... | |
| void | closeLib () |
| Closes the currently loaded library. More... | |
| void | openLib (const std::string &path) |
| Opens a shared library from the specified file path. More... | |
| LibLoader ()=default | |
| Constructor for the LibLoader class. More... | |
| ~LibLoader () | |
| Destructor for the LibLoader class. More... | |
Protected Types | |
| typedef Loader::ModuleType_t(* | GetModuleTypeFct) () |
Protected Attributes | |
| void * | _moduleHandle = nullptr |
| std::string | _modulePath |
| Loader::ModuleType_t | _moduleType = Loader::ModuleType_t::TYPE_COUNT |
| GetModuleTypeFct | _getModuleType = nullptr |
A class for dynamically loading and managing modules.
The LibLoader class is responsible for loading dynamic libraries (modules) at runtime. It provides methods to retrieve module type, path, and name, and to create instances of display modules.
|
protected |
Function pointer to retrieve module type.
|
default |
| Loader::LibLoader::~LibLoader | ( | ) |
Destructor for the LibLoader class.
Cleans up resources and unloads the module if it is loaded.
| void Loader::LibLoader::closeLib | ( | ) |
Closes the currently loaded library.
This function is responsible for properly unloading and releasing any resources associated with the dynamically loaded library. It ensures that the library is no longer in use and prevents resource leaks.
|
inline |
Get the path of the loaded module.
|
inline |
Get the type of the loaded module.
|
inline |
Initializes and retrieves an instance of a class from a dynamically loaded library.
This template function attempts to locate and invoke the "getClass" function from a dynamically loaded library. The "getClass" function is expected to return a pointer to an instance of the specified class type T. If the function cannot be found or invoked, an exception is thrown.
| T | The type of the class to be instantiated. |
T. | DllException | If the "getClass" function cannot be retrieved or invoked. |
| void Loader::LibLoader::openLib | ( | const std::string & | path | ) |
Opens a shared library from the specified file path.
This function attempts to load a shared library located at the given file path. It is typically used to dynamically load external libraries at runtime.
| path | The file path to the shared library to be loaded. It should be a valid path to a shared library file. |
| std::runtime_error | If the library cannot be opened or loaded. |
|
protected |
Pointer to the function that retrieves module type.
|
protected |
Handle to the loaded module.
|
protected |
Path to the module file.
|
protected |
Type of the module.