\section{KLib\-Loader Class Reference}
\label{classKLibLoader}\index{KLibLoader@{KLibLoader}}
The KLib\-Loader allows you to load libraries dynamically at runtime.  


{\tt \#include $<$klibloader.h$>$}

Inheritance diagram for KLib\-Loader:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=51pt]{classKLibLoader__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KLib\-Loader:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=138pt]{classKLibLoader__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf $\sim$KLib\-Loader} ()
\item 
{\bf KLib\-Factory} $\ast$ {\bf factory} (const char $\ast$libname)
\item 
virtual {\bf KLibrary} $\ast$ {\bf library} (const char $\ast$libname)
\item 
{\bf KLibrary} $\ast$ {\bf global\-Library} (const char $\ast${\bf name})
\item 
{\bf QString} {\bf last\-Error\-Message} () const \label{classKLibLoader_a4}

\item 
virtual void {\bf unload\-Library} (const char $\ast$libname)
\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
static {\bf KLib\-Loader} $\ast$ {\bf self} ()
\item 
static void {\bf clean\-Up} ()\label{classKLibLoader_e1}

\item 
static {\bf QString} {\bf find\-Library} (const char $\ast${\bf name}, const {\bf KInstance} $\ast$instance=KGlobal::instance())
\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
{\bf KLib\-Loader} ({\bf QObject} $\ast${\bf parent}=0, const char $\ast${\bf name}=0)\label{classKLibLoader_b0}

\item 
virtual void {\bf virtual\_\-hook} (int id, void $\ast$data)\label{classKLibLoader_b1}

\end{CompactItemize}
\subsection*{Friends}
\begin{CompactItemize}
\item 
class {\bf KLibrary}\label{classKLibLoader_n0}

\end{CompactItemize}


\subsection{Detailed Description}
The KLib\-Loader allows you to load libraries dynamically at runtime. 

Dependent libraries are loaded automatically.

KLib\-Loader follows the singleton pattern. You can not create multiple instances. Use {\bf self()}{\rm (p.\,\pageref{classKLibLoader_e0})} to get a pointer to the loader.

\begin{Desc}
\item[See also:]{\bf KLibrary}{\rm (p.\,\pageref{classKLibrary})} \end{Desc}
\begin{Desc}
\item[Author:]Torben Weis $<${\tt weis@kde.org}$>$ \end{Desc}




Definition at line 142 of file klibloader.h.

\subsection{Constructor \& Destructor Documentation}
\index{KLibLoader@{KLib\-Loader}!~KLibLoader@{$\sim$KLibLoader}}
\index{~KLibLoader@{$\sim$KLibLoader}!KLibLoader@{KLib\-Loader}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KLib\-Loader::$\sim${\bf KLib\-Loader} ()}\label{classKLibLoader_a0}


You should NEVER destruct an instance of KLib\-Loader until you know what you are doing. 

This will release the loaded libraries. 

Definition at line 316 of file klibloader.cpp.

References QAscii\-Dict\-Iterator::current(), and endl().

\subsection{Member Function Documentation}
\index{KLibLoader@{KLib\-Loader}!factory@{factory}}
\index{factory@{factory}!KLibLoader@{KLib\-Loader}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KLib\-Factory} $\ast$ KLib\-Loader::factory (const char $\ast$ {\em libname})}\label{classKLibLoader_a1}


Loads and initializes a library. 

Loading a library multiple times is handled gracefully.

This is a convenience function that returns the factory immediately \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em libname}]This is the library name without extension. Usually that is something like \char`\"{}libkspread\char`\"{}. The function will then search for a file named \char`\"{}libkspread.la\char`\"{} in the {\bf KDE}{\rm (p.\,\pageref{namespaceKDE})} library paths. The $\ast$.la files are created by libtool and contain important information especially about the libraries dependencies on other shared libs. Loading a \char`\"{}libfoo.so\char`\"{} could not solve the dependencies problem.\end{description}
\end{Desc}
You can, however, give a library name ending in \char`\"{}.so\char`\"{} (or whatever is used on your platform), and the library will be loaded without resolving dependencies. Use with caution. \begin{Desc}
\item[Returns:]the {\bf KLib\-Factory}{\rm (p.\,\pageref{classKLibFactory})}, or 0 if the library does not exist or it does not have a factory \end{Desc}
\begin{Desc}
\item[See also:]{\bf library}{\rm (p.\,\pageref{classKLibLoader_a2})} \end{Desc}


Definition at line 476 of file klibloader.cpp.

References KLibrary::factory(), and library().\index{KLibLoader@{KLib\-Loader}!library@{library}}
\index{library@{library}!KLibLoader@{KLib\-Loader}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KLibrary} $\ast$ KLib\-Loader::library (const char $\ast$ {\em libname})\hspace{0.3cm}{\tt  [virtual]}}\label{classKLibLoader_a2}


Loads and initializes a library. 

Loading a library multiple times is handled gracefully.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em libname}]This is the library name without extension. Usually that is something like \char`\"{}libkspread\char`\"{}. The function will then search for a file named \char`\"{}libkspread.la\char`\"{} in the {\bf KDE}{\rm (p.\,\pageref{namespaceKDE})} library paths. The $\ast$.la files are created by libtool and contain important information especially about the libraries dependencies on other shared libs. Loading a \char`\"{}libfoo.so\char`\"{} could not solve the dependencies problem.\end{description}
\end{Desc}
You can, however, give a library name ending in \char`\"{}.so\char`\"{} (or whatever is used on your platform), and the library will be loaded without resolving dependencies. Use with caution. \begin{Desc}
\item[Returns:]{\bf KLibrary}{\rm (p.\,\pageref{classKLibrary})} is invalid (0) when the library couldn't be dlopened. in such a case you can retrieve the error message by calling KLib\-Loader::last\-Error\-Message()\end{Desc}
\begin{Desc}
\item[See also:]{\bf factory}{\rm (p.\,\pageref{classKLibLoader_a1})} \end{Desc}


Definition at line 390 of file klibloader.cpp.

References QString::arg(), QObject::connect(), QObject::destroyed(), endl(), find\-Library(), QString::from\-Latin1(), QAscii\-Dict::insert(), and QString::is\-Empty().

Referenced by factory(), and global\-Library().\index{KLibLoader@{KLib\-Loader}!globalLibrary@{globalLibrary}}
\index{globalLibrary@{globalLibrary}!KLibLoader@{KLib\-Loader}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KLibrary} $\ast$ KLib\-Loader::global\-Library (const char $\ast$ {\em name})}\label{classKLibLoader_a3}


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.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em name}]This is the library name without extension. Usually that is something like \char`\"{}libkspread\char`\"{}. The function will then search for a file named \char`\"{}libkspread.la\char`\"{} in the {\bf KDE}{\rm (p.\,\pageref{namespaceKDE})} library paths. The $\ast$.la files are created by libtool and contain important information especially about the libraries dependencies on other shared libs. Loading a \char`\"{}libfoo.so\char`\"{} could not solve the dependencies problem.\end{description}
\end{Desc}
You can, however, give a library name ending in \char`\"{}.so\char`\"{} (or whatever is used on your platform), and the library will be loaded without resolving dependencies. Use with caution. \begin{Desc}
\item[Returns:]KLibrariy is invalid (0) when the library couldn't be dlopened. in such a case you can retrieve the error message by calling KLib\-Loader::last\-Error\-Message()\end{Desc}
\begin{Desc}
\item[See also:]{\bf factory}{\rm (p.\,\pageref{classKLibLoader_a1})} \end{Desc}


Definition at line 374 of file klibloader.cpp.

References endl(), and library().\index{KLibLoader@{KLib\-Loader}!unloadLibrary@{unloadLibrary}}
\index{unloadLibrary@{unloadLibrary}!KLibLoader@{KLib\-Loader}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KLib\-Loader::unload\-Library (const char $\ast$ {\em libname})\hspace{0.3cm}{\tt  [virtual]}}\label{classKLibLoader_a5}


Unloads the library with the given name. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em libname}]This is the library name without extension. Usually that is something like \char`\"{}libkspread\char`\"{}. The function will then search for a file named \char`\"{}libkspread.la\char`\"{} in the {\bf KDE}{\rm (p.\,\pageref{namespaceKDE})} library paths. The $\ast$.la files are created by libtool and contain important information especially about the libraries dependencies on other shared libs. Loading a \char`\"{}libfoo.so\char`\"{} could not solve the dependencies problem.\end{description}
\end{Desc}
You can, however, give a library name ending in \char`\"{}.so\char`\"{} (or whatever is used on your platform), and the library will be loaded without resolving dependencies. Use with caution. 

Definition at line 459 of file klibloader.cpp.

References QObject::destroyed(), QObject::disconnect(), and QAscii\-Dict::remove().

Referenced by KLibrary::unload().\index{KLibLoader@{KLib\-Loader}!self@{self}}
\index{self@{self}!KLibLoader@{KLib\-Loader}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf KLib\-Loader} $\ast$ KLib\-Loader::self ()\hspace{0.3cm}{\tt  [static]}}\label{classKLibLoader_e0}


Returns a pointer to the factory. 

Use this function to get an instance of KLib\-Loader. \begin{Desc}
\item[Returns:]a pointer to the loader. If no loader exists until now then one is created. \end{Desc}


Definition at line 286 of file klibloader.cpp.

Referenced by KLibrary::factory(), KLibrary::KLibrary(), and KLibrary::symbol().\index{KLibLoader@{KLib\-Loader}!findLibrary@{findLibrary}}
\index{findLibrary@{findLibrary}!KLibLoader@{KLib\-Loader}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QString} KLib\-Loader::find\-Library (const char $\ast$ {\em name}, const {\bf KInstance} $\ast$ {\em instance} = {\tt KGlobal::instance()})\hspace{0.3cm}{\tt  [static]}}\label{classKLibLoader_e2}


Helper method which looks for a library in the standard paths (\char`\"{}module\char`\"{} and \char`\"{}lib\char`\"{} resources). 

Made public for code that doesn't use KLib\-Loader itself, but still wants to open modules. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em name}]of the library. If it is not a path, the function searches in the \char`\"{}module\char`\"{} and \char`\"{}lib\char`\"{} resources. If there is no extension, \char`\"{}.la\char`\"{} will be appended. \item[{\em instance}]a {\bf KInstance}{\rm (p.\,\pageref{classKInstance})} used to get the standard paths \end{description}
\end{Desc}


Definition at line 349 of file klibloader.cpp.

References QFile::decode\-Name(), KInstance::dirs(), endl(), KStandard\-Dirs::find\-Resource(), QString::is\-Empty(), and QString::left().

Referenced by library().

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
klibloader.h\item 
klibloader.cpp\end{CompactItemize}
