.TH "KGenericFactory< KTypeList< Product, ProductListTail >, KTypeList< ParentType, ParentTypeListTail > >" kde3 "11 Jun 2005" "Version Version 3.4.1" "kdecore Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KGenericFactory< KTypeList< Product, ProductListTail >, KTypeList< ParentType, ParentTypeListTail > > \- 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 ProductListTail, class ParentType, class ParentTypeListTail> class KGenericFactory< KTypeList< Product, ProductListTail >, KTypeList< ParentType, ParentTypeListTail > >"
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 classes in the given typelist template argument when the class name argument of createObject matches a class names in the given hierarchy of classes.
.PP
Note that each class in the specified in the typelist 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 \fBKGenericFactory\fP 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 );
         ...
     };

     class MyDialogComponent : public KDialogBase
     {
         Q_ OBJECT
     public:
         MyDialogComponent( QWidget *parentWidget, const char *name,
                            const QStringList &args );
         ...
     };

     typedef K_TYPELIST_2( MyPlugin, MyDialogComponent ) Products;
     K_EXPORT_COMPONENT_FACTORY( libmyplugin, KGenericFactory&lt;Products&gt; )

.fi
.PP
 
.PP
Definition at line 362 of file kgenericfactory.h.
.SH "Member Function Documentation"
.PP 
.SS "template<class Product, class ProductListTail, class ParentType, class ParentTypeListTail> \fBKGenericFactory\fP< \fBKTypeList\fP< Product, ProductListTail >, \fBKTypeList\fP< ParentType, ParentTypeListTail > >::\fBKGenericFactory\fP (const \fBKAboutData\fP * data)\fC [inline]\fP"
.PP
\fBSince:\fP
.RS 4
3.3 
.RE
.PP

.PP
Definition at line 374 of file kgenericfactory.h.
.SS "template<class Product, class ProductListTail, class ParentType, class ParentTypeListTail> virtual \fBQObject\fP* \fBKGenericFactory\fP< \fBKTypeList\fP< Product, ProductListTail >, \fBKTypeList\fP< ParentType, ParentTypeListTail > >::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 380 of file kgenericfactory.h.

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