KDECore
KLibLoader Class Reference
The KLibLoader allows you to load libraries dynamically at runtime. More...
#include <klibloader.h>
Public Member Functions | |
KLibFactory * | factory (const char *libname) |
KLibrary * | globalLibrary (const char *name) |
QString | lastErrorMessage () const |
virtual KLibrary * | library (const char *libname) |
virtual void | unloadLibrary (const char *libname) |
~KLibLoader () | |
Static Public Member Functions | |
static void | cleanUp () |
static QString | findLibrary (const char *name, const KInstance *instance=KGlobal::instance()) |
static KLibLoader * | self () |
Protected Member Functions | |
KLibLoader (QObject *parent=0, const char *name=0) | |
virtual void | virtual_hook (int id, void *data) |
Detailed Description
The KLibLoader allows you to load libraries dynamically at runtime.Dependent libraries are loaded automatically.
KLibLoader follows the singleton pattern. You can not create multiple instances. Use self() to get a pointer to the loader.
- See also:
- KLibrary
Definition at line 142 of file klibloader.h.
Constructor & Destructor Documentation
KLibLoader::~KLibLoader | ( | ) |
You should NEVER destruct an instance of KLibLoader until you know what you are doing.
This will release the loaded libraries.
Definition at line 316 of file klibloader.cpp.
KLibLoader::KLibLoader | ( | QObject * | parent = 0 , |
|
const char * | name = 0 | |||
) | [protected] |
Definition at line 302 of file klibloader.cpp.
Member Function Documentation
void KLibLoader::cleanUp | ( | ) | [static] |
For internal use only.
Internal Method, called by the KApplication destructor. Do not call it. This is what makes it possible to rely on ~KLibFactory being called in all cases, whether the library is unloaded while the application is running or when exiting.
Definition at line 293 of file klibloader.cpp.
KLibFactory * KLibLoader::factory | ( | const char * | libname | ) |
Loads and initializes a library.
Loading a library multiple times is handled gracefully.
This is a convenience function that returns the factory immediately
- Parameters:
-
libname This is the library name without extension. Usually that is something like "libkspread". The function will then search for a file named "libkspread.la" in the KDE library paths. The *.la files are created by libtool and contain important information especially about the libraries dependencies on other shared libs. Loading a "libfoo.so" could not solve the dependencies problem.
- Returns:
- the KLibFactory, or 0 if the library does not exist or it does not have a factory
- See also:
- library
Definition at line 476 of file klibloader.cpp.
QString KLibLoader::findLibrary | ( | const char * | name, | |
const KInstance * | instance = KGlobal::instance() | |||
) | [static] |
Helper method which looks for a library in the standard paths ("module" and "lib" resources).
Made public for code that doesn't use KLibLoader itself, but still wants to open modules.
- Parameters:
-
name of the library. If it is not a path, the function searches in the "module" and "lib" resources. If there is no extension, ".la" will be appended. instance a KInstance used to get the standard paths
Definition at line 349 of file klibloader.cpp.
KLibrary * KLibLoader::globalLibrary | ( | const char * | name | ) |
Loads and initializes a library.
Loading a library multiple times is handled gracefully. The library is loaded such that the symbols are globally accessible so libraries with dependencies can be loaded sequentially.
- Parameters:
-
name This is the library name without extension. Usually that is something like "libkspread". The function will then search for a file named "libkspread.la" in the KDE library paths. The *.la files are created by libtool and contain important information especially about the libraries dependencies on other shared libs. Loading a "libfoo.so" could not solve the dependencies problem.
- Returns:
- KLibrariy is invalid (0) when the library couldn't be dlopened. in such a case you can retrieve the error message by calling KLibLoader::lastErrorMessage()
- See also:
- factory
Definition at line 374 of file klibloader.cpp.
QString KLibLoader::lastErrorMessage | ( | ) | const |
Returns an error message that can be useful to debug the problem.
Returns QString::null if the last call to library() was successful. You can call this function more than once. The error message is only reset by a new call to library().
- Returns:
- the last error message, or QString::null if there was no error
Definition at line 454 of file klibloader.cpp.
KLibrary * KLibLoader::library | ( | const char * | libname | ) | [virtual] |
Loads and initializes a library.
Loading a library multiple times is handled gracefully.
- Parameters:
-
libname This is the library name without extension. Usually that is something like "libkspread". The function will then search for a file named "libkspread.la" in the KDE library paths. The *.la files are created by libtool and contain important information especially about the libraries dependencies on other shared libs. Loading a "libfoo.so" could not solve the dependencies problem.
- Returns:
- KLibrary is invalid (0) when the library couldn't be dlopened. in such a case you can retrieve the error message by calling KLibLoader::lastErrorMessage()
- See also:
- factory
Definition at line 390 of file klibloader.cpp.
KLibLoader * KLibLoader::self | ( | ) | [static] |
Returns a pointer to the factory.
Use this function to get an instance of KLibLoader.
- Returns:
- a pointer to the loader. If no loader exists until now then one is created.
Definition at line 286 of file klibloader.cpp.
void KLibLoader::unloadLibrary | ( | const char * | libname | ) | [virtual] |
Unloads the library with the given name.
- Parameters:
-
libname This is the library name without extension. Usually that is something like "libkspread". The function will then search for a file named "libkspread.la" in the KDE library paths. The *.la files are created by libtool and contain important information especially about the libraries dependencies on other shared libs. Loading a "libfoo.so" could not solve the dependencies problem.
Definition at line 459 of file klibloader.cpp.
void KLibLoader::virtual_hook | ( | int | id, | |
void * | data | |||
) | [protected, virtual] |
Definition at line 574 of file klibloader.cpp.
The documentation for this class was generated from the following files: