\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=53pt]{classKLibLoader__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KLib\-Loader:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=156pt]{classKLibLoader__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf $\sim$KLib\-Loader} ()
\begin{CompactList}\small\item\em You should NEVER destruct an instance of KLib\-Loader until you know what you are doing. \item\end{CompactList}\item 
{\bf KLib\-Factory} $\ast$ {\bf factory} (const  char $\ast$libname)
\begin{CompactList}\small\item\em Loads and initializes a library. \item\end{CompactList}\item 
virtual {\bf KLibrary} $\ast$ {\bf library} (const  char $\ast$libname)
\begin{CompactList}\small\item\em Loads and initializes a library. \item\end{CompactList}\item 
{\bf KLibrary} $\ast$ {\bf global\-Library} (const  char $\ast${\bf name})
\begin{CompactList}\small\item\em Loads and initializes a library. \item\end{CompactList}\item 
{\bf QString} {\bf last\-Error\-Message} () const \label{classKLibLoader_a4}

\item 
virtual void {\bf unload\-Library} (const  char $\ast$libname)
\begin{CompactList}\small\item\em Unloads the library with the given name. \item\end{CompactList}\end{CompactItemize}
\subsection*{Static Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KLib\-Loader} $\ast$ {\bf self} ()
\begin{CompactList}\small\item\em Returns a pointer to the factory. \item\end{CompactList}\item 
void {\bf clean\-Up} ()\label{classKLibLoader_e1}

\item 
{\bf QString} {\bf find\-Library} (const  char $\ast${\bf name}, const  {\bf KInstance} $\ast$instance=KGlobal::instance())
\begin{CompactList}\small\item\em Helper method which looks for a library in the standard paths (\char`\"{}module\char`\"{} and \char`\"{}lib\char`\"{} resources). \item\end{CompactList}\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[Author:]Torben Weis $<${\tt weis@kde.org}$>$ \end{Desc}




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

References QAscii\-Dict\-Iterator::current().

\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 CARE :) \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(), library(), and KStd\-Action::name().\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 CARE :) \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 396 of file klibloader.cpp.

References QObject::connect(), QPtr\-List\-Iterator::current(), QObject::destroyed(), find\-Library(), QString::from\-Latin1(), QString::is\-Empty(), QString::latin1(), and KStd\-Action::name().

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

References library(), and KStd\-Action::name().\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 CARE :) 

Definition at line 459 of file klibloader.cpp.

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

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

Referenced by find\-Library().\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} = 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 337 of file klibloader.cpp.

References QString::arg(), d, KInstance::dirs(), QCString::find(), KStandard\-Dirs::find\-Resource(), QCString::find\-Rev(), KNotify\-Client::instance(), QString::is\-Empty(), KStd\-Action::name(), and self().

Referenced by library().

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