\section{KLib\-Factory Class Reference}
\label{classKLibFactory}\index{KLibFactory@{KLibFactory}}
If you develop a library that is to be loaded dynamically at runtime, then you should return a pointer to your factory.  


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

Inheritance diagram for KLib\-Factory:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=398pt]{classKLibFactory__inherit__graph}
\end{center}
\end{figure}
Collaboration diagram for KLib\-Factory:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=55pt]{classKLibFactory__coll__graph}
\end{center}
\end{figure}
\subsection*{Signals}
\begin{CompactItemize}
\item 
void {\bf object\-Created} ({\bf QObject} $\ast$obj)
\begin{CompactList}\small\item\em Emitted in {\bf create}{\rm (p.\,\pageref{classKLibFactory_a2})}. \item\end{CompactList}\end{CompactItemize}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KLib\-Factory} ({\bf QObject} $\ast${\bf parent}=0, const  char $\ast${\bf name}=0)
\begin{CompactList}\small\item\em Create a new factory. \item\end{CompactList}\item 
{\bf QObject} $\ast$ {\bf create} ({\bf QObject} $\ast${\bf parent}=0, const  char $\ast${\bf name}=0, const  char $\ast$classname=\char`\"{}QObject\char`\"{}, const  {\bf QString\-List} \&args={\bf QString\-List}())
\begin{CompactList}\small\item\em Creates a new object. \item\end{CompactList}\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
virtual {\bf QObject} $\ast$ {\bf create\-Object} ({\bf QObject} $\ast${\bf parent}=0, const  char $\ast${\bf name}=0, const  char $\ast$classname=\char`\"{}QObject\char`\"{}, const  {\bf QString\-List} \&args={\bf QString\-List}())=0
\begin{CompactList}\small\item\em Creates a new object. \item\end{CompactList}\item 
virtual void {\bf virtual\_\-hook} (int id, void $\ast$data)\label{classKLibFactory_b1}

\end{CompactItemize}


\subsection{Detailed Description}
If you develop a library that is to be loaded dynamically at runtime, then you should return a pointer to your factory. 

The K\_\-EXPORT\_\-COMPONENT\_\-FACTORY macro is provided for this purpose: \small\begin{alltt}
   K\_EXPORT\_COMPONENT\_FACTORY( libkspread, KSpreadFactory )
 \end{alltt}\normalsize 


The first macro argument is the name of your library, the second specifies the name of your factory.

In the constructor of your factory you should create an instance of {\bf KInstance}{\rm (p.\,\pageref{classKInstance})} like this: \small\begin{alltt}
     s\_global = new {\bf KInstance}{\rm (p.\,\pageref{classKInstance})}( "kspread" );
 \end{alltt}\normalsize 
 This {\bf KInstance}{\rm (p.\,\pageref{classKInstance})} is comparable to {\bf KGlobal}{\rm (p.\,\pageref{classKGlobal})} used by normal applications. It allows you to find resource files (images, XML, sound etc.) belonging to the library.

If you want to load a library, use {\bf KLib\-Loader}{\rm (p.\,\pageref{classKLibLoader})}. You can query {\bf KLib\-Loader}{\rm (p.\,\pageref{classKLibLoader})} directly for a pointer to the libraries factory by using the {\bf KLib\-Loader::factory}{\rm (p.\,\pageref{classKLibLoader_a1})}() function.

The KLib\-Factory is used to create the components, the library has to offer. The factory of KSpread for example will create instances of KSpread\-Doc, while the Konqueror factory will create Konq\-View widgets. All objects created by the factory must be derived from {\bf QObject}, since {\bf QObject} offers type safe casting.

KLib\-Factory is an abstract class. Reimplement the {\bf create\-Object}{\rm (p.\,\pageref{classKLibFactory_b0})}() method to give it functionality.

\begin{Desc}
\item[Author:]Torben Weis $<${\tt weis@kde.org}$>$ \end{Desc}




Definition at line 328 of file klibloader.h.

\subsection{Constructor \& Destructor Documentation}
\index{KLibFactory@{KLib\-Factory}!KLibFactory@{KLibFactory}}
\index{KLibFactory@{KLibFactory}!KLibFactory@{KLib\-Factory}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KLib\-Factory::KLib\-Factory ({\bf QObject} $\ast$ {\em parent} = 0, const char $\ast$ {\em name} = 0)}\label{classKLibFactory_a0}


Create a new factory. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em parent}]the parent of the {\bf QObject}, 0 for no parent \item[{\em name}]the name of the {\bf QObject}, 0 for no name \end{description}
\end{Desc}


Definition at line 66 of file klibloader.cpp.

References KStd\-Action::name().

\subsection{Member Function Documentation}
\index{KLibFactory@{KLib\-Factory}!create@{create}}
\index{create@{create}!KLibFactory@{KLib\-Factory}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QObject} $\ast$ KLib\-Factory::create ({\bf QObject} $\ast$ {\em parent} = 0, const char $\ast$ {\em name} = 0, const char $\ast$ {\em classname} = \char`\"{}QObject\char`\"{}, const {\bf QString\-List} \& {\em args} = {\bf QString\-List}())}\label{classKLibFactory_a2}


Creates a new object. 

The returned object has to be derived from the requested classname.

It is valid behavior to create different kinds of objects depending on the requested {\tt classname}. For example a koffice library may usually return a pointer to Ko\-Document. But if asked for a \char`\"{}QWidget\char`\"{}, it could create a wrapper widget, that encapsulates the Koffice specific features.

{\bf create()}{\rm (p.\,\pageref{classKLibFactory_a2})} automatically emits a signal {\bf object\-Created}{\rm (p.\,\pageref{classKLibFactory_l0})} to tell the library about its newly created object. This is very important for reference counting, and allows unloading the library automatically once all its objects have been destroyed.

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em parent}]the parent of the {\bf QObject}, 0 for no parent \item[{\em name}]the name of the {\bf QObject}, 0 for no name \item[{\em classname}]the name of the class \item[{\em args}]a list of arguments \end{description}
\end{Desc}


Definition at line 76 of file klibloader.cpp.

References create\-Object(), KStd\-Action::name(), and object\-Created().\index{KLibFactory@{KLib\-Factory}!objectCreated@{objectCreated}}
\index{objectCreated@{objectCreated}!KLibFactory@{KLib\-Factory}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KLib\-Factory::object\-Created ({\bf QObject} $\ast$ {\em obj})\hspace{0.3cm}{\tt  [signal]}}\label{classKLibFactory_l0}


Emitted in {\bf create}{\rm (p.\,\pageref{classKLibFactory_a2})}. 

\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em obj}]the new object \end{description}
\end{Desc}


Referenced by create().\index{KLibFactory@{KLib\-Factory}!createObject@{createObject}}
\index{createObject@{createObject}!KLibFactory@{KLib\-Factory}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QObject} $\ast$ KLib\-Factory::create\-Object ({\bf QObject} $\ast$ {\em parent} = 0, const char $\ast$ {\em name} = 0, const char $\ast$ {\em classname} = \char`\"{}QObject\char`\"{}, const {\bf QString\-List} \& {\em args} = {\bf QString\-List}())\hspace{0.3cm}{\tt  [protected, pure virtual]}}\label{classKLibFactory_b0}


Creates a new object. 

The returned object has to be derived from the requested classname.

It is valid behavior to create different kinds of objects depending on the requested {\tt classname}. For example a koffice library may usually return a pointer to Ko\-Document. But if asked for a \char`\"{}QWidget\char`\"{}, it could create a wrapper widget, that encapsulates the Koffice specific features.

This function is called by {\bf create()}{\rm (p.\,\pageref{classKLibFactory_a2})} \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em parent}]the parent of the {\bf QObject}, 0 for no parent \item[{\em name}]the name of the {\bf QObject}, 0 for no name \item[{\em classname}]the name of the class \item[{\em args}]a list of arguments \end{description}
\end{Desc}


Implemented in {\bf KParts::Factory}, {\bf KGeneric\-Factory$<$ Product, Parent\-Type $>$} {\rm (p.\,\pageref{classKGenericFactory_b0})}, {\bf KGeneric\-Factory$<$ KType\-List$<$ Product, Product\-List\-Tail $>$, QObject $>$} {\rm (p.\,\pageref{classKGenericFactory_3_01KTypeList_3_01Product_00_01ProductListTail_01_4_00_01QObject_01_4_b0})}, and {\bf KGeneric\-Factory$<$ KType\-List$<$ Product, Product\-List\-Tail $>$, KType\-List$<$ Parent\-Type, Parent\-Type\-List\-Tail $>$ $>$} {\rm (p.\,\pageref{classKGenericFactory_3_01KTypeList_3_01Product_00_01ProductListTail_01_4_00_01KTypeList_3_01ParentType_00_01ParentTypeListTail_01_4_01_4_b0})}.

Definition at line 85 of file klibloader.cpp.

Referenced by create().

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