\section{KParts::Generic\-Factory$<$ T $>$ Class Template Reference}
\label{classKParts_1_1GenericFactory}\index{KParts::GenericFactory@{KParts::GenericFactory}}
A template for a {\bf KParts::Factory}{\rm (p.\,\pageref{classKParts_1_1Factory})} implementation.  


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

\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
virtual {\bf KParts::Part} $\ast$ {\bf create\-Part\-Object} ({\bf QWidget} $\ast$parent\-Widget, const  char $\ast$widget\-Name, {\bf QObject} $\ast$parent, const  char $\ast$name, const  char $\ast$class\-Name, const  {\bf QString\-List} \&args)\label{classKParts_1_1GenericFactory_a1}

\end{CompactItemize}


\subsection{Detailed Description}
\subsubsection*{template$<$class T$>$ class KParts::Generic\-Factory$<$ T $>$}

A template for a {\bf KParts::Factory}{\rm (p.\,\pageref{classKParts_1_1Factory})} implementation. 

It implements the pure virtual create\-Part\-Object method by instantiating the template argument when requested through the class\-Name field. In addition it is a container for a part's {\bf KInstance} object, by providing a static {\bf KInstance} $\ast$instance() method.

The template argument has to inherit from {\bf KParts::Part}{\rm (p.\,\pageref{classKParts_1_1Part})} and has to implement two methods: 1) There needs to be a public constructor with the following signature: My\-Part( QWidget $\ast$parent\-Widget, const char $\ast$widget\-Name, QObject $\ast$parent, const char $\ast$name, const QString\-List\& args )

2) It needs to provide one static method to create a {\bf KAbout\-Data} object per request, holding information about the component's name, its authors, license, etc. The signature of that static method has to be {\bf KAbout\-Data} $\ast$create\-About\-Data()

The template will take care of memory management of the {\bf KInstance} and the {\bf KAbout\-Data} object.

For advanced use you can also inherit from the template and re-implement additionally the virtual {\bf KInstance} $\ast$create\-Instance() method, for example in case you want to extend the paths of your instance's {\bf KStandard\-Dirs} object.

If a {\bf KParts::Read\-Only\-Part}{\rm (p.\,\pageref{classKParts_1_1ReadOnlyPart})} is requested through this factory and the template argument implements a {\bf KParts::Read\-Write\-Part}{\rm (p.\,\pageref{classKParts_1_1ReadWritePart})} then set\-Read\-Write( false ) will automatically be called in create\-Part\-Object.

Use the factory through the K\_\-EXPORT\_\-COMPONENT\_\-FACTORY macro, like that: \small\begin{alltt}
 typedef KParts::GenericFactory$<$YourKPart$>$ YourKPartFactory;
 K\_EXPORT\_COMPONENT\_FACTORY( yourlibrary, YourKPartFactory );
 \end{alltt}\normalsize 
 yourlibrary is the library name that you compiled your KPart into. 



Definition at line 83 of file genericfactory.h.

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