kdecore Library API Documentation

KLibLoader Class Reference

The KLibLoader allows you to load libraries dynamically at runtime. More...

#include <klibloader.h>

Inheritance diagram for KLibLoader:

QObject List of all members.

Public Member Functions

 ~KLibLoader ()
 You should NEVER destruct an instance of KLibLoader until you know what you are doing.

KLibFactoryfactory (const char *libname)
 Loads and initializes a library.

virtual KLibrarylibrary (const char *libname)
 Loads and initializes a library.

KLibraryglobalLibrary (const char *name)
 Loads and initializes a library.

QString lastErrorMessage () const
virtual void unloadLibrary (const char *libname)
 Unloads the library with the given name.


Static Public Member Functions

KLibLoaderself ()
 Returns a pointer to the factory.

void cleanUp ()
QString findLibrary (const char *name, const KInstance *instance=KGlobal::instance())
 Helper method which looks for a library in the standard paths ("module" and "lib" resources).


Protected Member Functions

 KLibLoader (QObject *parent=0, const char *name=0)
virtual void virtual_hook (int id, void *data)

Friends

class KLibrary

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.

Author:
Torben Weis <weis@kde.org>

Definition at line 140 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 319 of file klibloader.cpp.

References QAsciiDictIterator::current().


Member Function Documentation

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

References KLibrary::factory(), library(), and KStdAction::name().

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.
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 :)
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 396 of file klibloader.cpp.

References QObject::connect(), QPtrListIterator::current(), QObject::destroyed(), findLibrary(), QString::fromLatin1(), QString::isEmpty(), QString::latin1(), and KStdAction::name().

Referenced by factory(), and globalLibrary().

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:
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 CARE :)
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 380 of file klibloader.cpp.

References library(), and KStdAction::name().

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

Definition at line 459 of file klibloader.cpp.

References QObject::destroyed(), and QObject::disconnect().

Referenced by KLibrary::unload().

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 289 of file klibloader.cpp.

Referenced by findLibrary().

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 337 of file klibloader.cpp.

References QString::arg(), d, KInstance::dirs(), QCString::find(), KStandardDirs::findResource(), QCString::findRev(), KNotifyClient::instance(), QString::isEmpty(), KStdAction::name(), and self().

Referenced by library().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 27 22:14:51 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001