.TH "KGenericFactory" kde3 "11 Jun 2005" "Version Version 3.4.1" "kdecore Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KGenericFactory \- This template provides a generic implementation of a \fBKLibFactory\fP , for use with shared library components.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <kgenericfactory.h>\fP
.PP
Inherits \fBKLibFactory\fP, and KGenericFactoryBase.
.PP
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBKGenericFactory\fP (const char *instanceName=0)"
.br
.ti -1c
.RI "\fBKGenericFactory\fP (const \fBKAboutData\fP *data)"
.br
.in -1c
.SS "Protected Member Functions"

.in +1c
.ti -1c
.RI "virtual \fBQObject\fP * \fBcreateObject\fP (\fBQObject\fP *\fBparent\fP, const char *\fBname\fP, const char *\fBclassName\fP, const \fBQStringList\fP &args)"
.br
.in -1c
.SH "Detailed Description"
.PP 

.SS "template<class Product, class ParentType = QObject> class KGenericFactory< Product, ParentType >"
This template provides a generic implementation of a \fBKLibFactory\fP , for use with shared library components. 

It implements the pure virtual createObject method of \fBKLibFactory\fP and instantiates objects of the specified class (template argument) when the class name argument of createObject matches a class name in the given hierarchy.
.PP
In case you are developing a KParts component, skip this file and go directly to \fBKParts::GenericFactory\fP .
.PP
Note that the class specified as template argument needs to provide a certain constructor: 
.PD 0

.IP "\(bu" 2
If the class is derived from \fBQObject\fP then it needs to have a constructor like: \fCMyClass( \fBQObject\fP *parent, const char *name, const \fBQStringList\fP &args );\fP 
.IP "\(bu" 2
If the class is derived from \fBQWidget\fP then it needs to have a constructor like: \fCMyWidget( \fBQWidget\fP *parent, const char *name, const \fBQStringList\fP &args);\fP 
.IP "\(bu" 2
If the class is derived from \fBKParts::Part\fP then it needs to have a constructor like: \fCMyPart( \fBQWidget\fP *parentWidget, const char *widgetName, \fBQObject\fP *parent, const char *name, const \fBQStringList\fP &args );\fP 
.PP
The args \fBQStringList\fP passed to the constructor is the args string list that the caller passed to KLibFactory's create method.
.PP
In addition upon instantiation this template provides a central \fBKInstance\fP object for your component, accessible through the static instance() method. The instanceName argument of the KGenericFactory constructor is passed to the \fBKInstance\fP object.
.PP
The creation of the \fBKInstance\fP object can be customized by inheriting from this template class and re-implementing the virtual createInstance method. For example it could look like this: 
.PP
.nf
     KInstance *MyFactory::createInstance()
     {
         return new KInstance( myAboutData );
     }

.fi
.PP
.PP
Example of usage of the whole template: 
.PP
.nf
     class MyPlugin : public KParts::Plugin
     {
         Q_ OBJECT
     public:
         MyPlugin( QObject *parent, const char *name,
                   const QStringList &args );
         ...
     };

     K_EXPORT_COMPONENT_FACTORY( libmyplugin, KGenericFactory&lt;MyPlugin&gt; )

.fi
.PP
 
.PP
Definition at line 173 of file kgenericfactory.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "template<class Product, class ParentType = QObject> \fBKGenericFactory\fP< Product, ParentType >::\fBKGenericFactory\fP (const \fBKAboutData\fP * data)\fC [inline]\fP"
.PP
\fBSince:\fP
.RS 4
3.3 
.RE
.PP

.PP
Definition at line 183 of file kgenericfactory.h.
.SH "Member Function Documentation"
.PP 
.SS "template<class Product, class ParentType = QObject> virtual \fBQObject\fP* \fBKGenericFactory\fP< Product, ParentType >::createObject (\fBQObject\fP * parent, const char * name, const char * className, const \fBQStringList\fP & args)\fC [inline, protected, virtual]\fP"
.PP
Creates a new object. 
.PP
The returned object has to be derived from the requested classname.
.PP
It is valid behavior to create different kinds of objects depending on the requested \fCclassName\fP. For example a koffice library may usually return a pointer to KoDocument. But if asked for a 'QWidget', it could create a wrapper widget, that encapsulates the Koffice specific features.
.PP
This function is called by \fBcreate()\fP 
.PP
\fBParameters:\fP
.RS 4
\fIparent\fP the parent of the \fBQObject\fP, 0 for no parent 
.br
\fIname\fP the name of the \fBQObject\fP, 0 for no name 
.br
\fIclassName\fP the name of the class 
.br
\fIargs\fP a list of arguments 
.RE
.PP

.PP
Implements \fBKLibFactory\fP.
.PP
Definition at line 189 of file kgenericfactory.h.

.SH "Author"
.PP 
Generated automatically by Doxygen for kdecore Library from the source code.
