class KLibLoader

# class KLibLoader | The KLibLoader allows you to load libraries dynamically at runtime. More...
Definition | `#include <klibloader.h>`
Inherits | QObject (qt) [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Methods

- ~KLibLoader ()
- KLibFactory* factory ( const char* libname )
- virtual KLibrary* library ( const char* libname )
- KLibrary* globalLibrary ( const char *name )
- QString lastErrorMessage () const
- virtual void unloadLibrary ( const char *libname )

#### Public Static Methods

- static KLibLoader* self ()
- static void cleanUp ()
- static QString findLibrary ( const char * name, const KInstance * instance = KGlobal::instance() )

#### Protected Methods

- 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.

~KLibLoader () | ### ~KLibLoader

You should NEVER destruct an instance of KLibLoader until you know what you are doing. This will release the loaded libraries.

KLibFactory* factory ( const char* libname ) | ### factory

Loads and initializes a library. Loading a library multiple times is handled gracefully.

This is a convenience function that returns the factory immediately

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 CARE :)

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

KLibrary* library ( const char* libname ) | ### library

[virtual]

Loads and initializes a library. Loading a library multiple times is handled gracefully.

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 CARE :)

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

KLibrary* globalLibrary ( const char *name ) | ### globalLibrary

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.

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 CARE :)

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: 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

QString lastErrorMessage () | ### lastErrorMessage

[const]

void unloadLibrary ( const char *libname ) | ### unloadLibrary

[virtual]

Unloads the library with the given name.

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 CARE :)

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.

KLibLoader* self () | ### 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.

void cleanUp () | ### cleanUp

[static]

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.

QString findLibrary ( const char * name, const KInstance * instance = KGlobal::instance() ) | ### findLibrary

[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

KLibLoader ( QObject* parent = 0, const char* name = 0 ) | ### KLibLoader

[protected]

void virtual_hook ( int id, void* data ) | ### virtual_hook

[protected virtual]

- Author: Torben Weis
- Generated: root on macppc.ports.openbsd.org on Sat Sep 6 10:36:15 2003, using kdoc 2.0a54.