KLibLoader Class Reference
from PyKDE4.kdecore import *
Inherits: QObject
Detailed Description
\class KLibLoader klibloader.h <KLibLoader>
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.
- Deprecated:
- You have two other possibilites: KPluginLoader or KService.createInstance for plugins KLibrary for other libraries
- See also:
- KLibrary
- See also:
- KPluginLoader
Enumerations | |
ComponentLoadingError | { ErrNoLibrary, ErrNoFactory, ErrNoComponent, ErrServiceProvidesNoLibrary, ErrNoServiceFound } |
Methods | |
__init__ (self) | |
KPluginFactory | factory (self, QString libname, QLibrary.LoadHints loadHint=0) |
QString | lastErrorMessage (self) |
KLibrary | library (self, QString libname, QLibrary.LoadHints loadHint=0) |
unloadLibrary (self, QString libname) | |
Static Methods | |
QString | errorString (int componentLoadingError) |
QString | findLibrary (QString libname, KComponentData cData=KGlobal.mainComponent()) |
KLibLoader | self () |
Method Documentation
__init__ | ( | self ) |
QString errorString | ( | int | componentLoadingError | |
) |
Returns a translated error message for componentLoadingError
- Parameters:
-
componentLoadingError the error code, as returned in the "error" output parameter of createInstance.
KPluginFactory factory | ( | self, | ||
QString | libname, | |||
QLibrary.LoadHints | loadHint=0 | |||
) |
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.
You can, however, give a library name ending in ".so" (or whatever is used on your platform), and the library will be loaded without resolving dependencies. Use with caution.
- Returns:
- the KPluginFactory, or 0 if the library does not exist or it does not have a factory
- See also:
- library
QString findLibrary | ( | QString | libname, | |
KComponentData | cData=KGlobal.mainComponent() | |||
) |
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:
-
libname 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. cData a KComponentData used to get the standard paths
QString lastErrorMessage | ( | self ) |
Returns an error message that can be useful to debug the problem. Returns QString() 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() if there was no error
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.
You can, however, give a library name ending in ".so" (or whatever is used on your platform), and the library will be loaded without resolving dependencies. Use with caution.
- 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
KLibLoader self | ( | ) |
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.
- Deprecated:
- use KPluginLoader
unloadLibrary | ( | self, | ||
QString | libname | |||
) |
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.
You can, however, give a library name ending in ".so" (or whatever is used on your platform), and the library will be loaded without resolving dependencies. Use with caution.
Enumeration Documentation
ComponentLoadingError |
This enum type defines the possible error cases that can happen when loading a component.
<ul> <li><code>ErrNoLibrary</code> - the specified library could not be loaded. Use KLibLoader.lastErrorMessage for details.</li> <li><code>ErrNoFactory</code> - the library does not export a factory for creating components</li> <li><code>ErrNoComponent</code> - the factory does not support creating components of the specified type</li> <li><code>ErrServiceProvidesNoLibrary</code> - the specified service provides no shared library (when using KService)</li> <li><code>ErrNoServiceFound</code> - no service implementing the given servicetype and fullfilling the given constraint expression can be found (when using KServiceTypeTrader).</li> </ul>
- Enumerator:
-
ErrNoLibrary = 1 ErrNoFactory ErrNoComponent ErrServiceProvidesNoLibrary ErrNoServiceFound