.TH "KLibFactory" kde3 "11 Jun 2005" "Version Version 3.4.1" "kdecore Library" \" -*- nroff -*-
.ad l
.nh
.SH NAME
KLibFactory \- If you develop a library that is to be loaded dynamically at runtime, then you should return a pointer to your factory.  

.PP
.SH SYNOPSIS
.br
.PP
\fC#include <klibloader.h>\fP
.PP
Inherits \fBQObject\fP.
.PP
Inherited by \fBKGenericFactory< Product, ParentType >\fP, \fBKGenericFactory< KTypeList< Product, ProductListTail >, KTypeList< ParentType, ParentTypeListTail > >\fP, \fBKGenericFactory< KTypeList< Product, ProductListTail >, QObject >\fP, \fBKOCRDialogFactory\fP, \fBKParts::Factory\fP, and \fBKScanDialogFactory\fP.
.PP
.SS "Signals"

.in +1c
.ti -1c
.RI "void \fBobjectCreated\fP (\fBQObject\fP *obj)"
.br
.in -1c
.SS "Public Member Functions"

.in +1c
.ti -1c
.RI "\fBKLibFactory\fP (\fBQObject\fP *\fBparent\fP=0, const char *\fBname\fP=0)"
.br
.ti -1c
.RI "\fBQObject\fP * \fBcreate\fP (\fBQObject\fP *\fBparent\fP=0, const char *\fBname\fP=0, const char *classname='QObject', const \fBQStringList\fP &args=\fBQStringList\fP())"
.br
.in -1c
.SS "Protected Member Functions"

.in +1c
.ti -1c
.RI "virtual \fBQObject\fP * \fBcreateObject\fP (\fBQObject\fP *\fBparent\fP=0, const char *\fBname\fP=0, const char *\fBclassName\fP='QObject', const \fBQStringList\fP &args=\fBQStringList\fP())=0"
.br
.ti -1c
.RI "virtual void \fBvirtual_hook\fP (int id, void *data)"
.br
.in -1c
.SH "Detailed Description"
.PP 
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: 
.PP
.nf
   K_EXPORT_COMPONENT_FACTORY( libkspread, KSpreadFactory )

.fi
.PP
.PP
The first macro argument is the name of your library, the second specifies the name of your factory.
.PP
In the constructor of your factory you should create an instance of \fBKInstance\fP like this: 
.PP
.nf
     s_global = new KInstance( 'kspread' );

.fi
.PP
 This \fBKInstance\fP is comparable to \fBKGlobal\fP used by normal applications. It allows you to find resource files (images, XML, sound etc.) belonging to the library.
.PP
If you want to load a library, use \fBKLibLoader\fP. You can query \fBKLibLoader\fP directly for a pointer to the libraries factory by using the \fBKLibLoader::factory()\fP function.
.PP
The KLibFactory is used to create the components, the library has to offer. The factory of KSpread for example will create instances of KSpreadDoc, while the Konqueror factory will create KonqView widgets. All objects created by the factory must be derived from \fBQObject\fP, since \fBQObject\fP offers type safe casting.
.PP
KLibFactory is an abstract class. Reimplement the \fBcreateObject()\fP method to give it functionality.
.PP
\fBAuthor:\fP
.RS 4
Torben Weis <weis@kde.org> 
.RE
.PP

.PP
Definition at line 330 of file klibloader.h.
.SH "Constructor & Destructor Documentation"
.PP 
.SS "KLibFactory::KLibFactory (\fBQObject\fP * parent = \fC0\fP, const char * name = \fC0\fP)"
.PP
Create a new factory. 
.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 
.RE
.PP

.PP
Definition at line 71 of file klibloader.cpp.
.SH "Member Function Documentation"
.PP 
.SS "\fBQObject\fP * KLibFactory::create (\fBQObject\fP * parent = \fC0\fP, const char * name = \fC0\fP, const char * classname = \fC'QObject'\fP, const \fBQStringList\fP & args = \fC\fBQStringList\fP()\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
\fBcreate()\fP automatically emits a signal objectCreated 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.
.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
Definition at line 81 of file klibloader.cpp.
.PP
References createObject(), and objectCreated().
.SS "void KLibFactory::objectCreated (\fBQObject\fP * obj)\fC [signal]\fP"
.PP
Emitted in \fBcreate\fP. 
.PP
\fBParameters:\fP
.RS 4
\fIobj\fP the new object 
.RE
.PP

.PP
Referenced by create().
.SS "\fBQObject\fP * KLibFactory::createObject (\fBQObject\fP * parent = \fC0\fP, const char * name = \fC0\fP, const char * className = \fC'QObject'\fP, const \fBQStringList\fP & args = \fC\fBQStringList\fP()\fP)\fC [protected, pure 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
Implemented in \fBKParts::Factory\fP, \fBKOCRDialogFactory\fP, \fBKScanDialogFactory\fP, \fBKGenericFactory< Product, ParentType >\fP, \fBKGenericFactory< KTypeList< Product, ProductListTail >, QObject >\fP, and \fBKGenericFactory< KTypeList< Product, ProductListTail >, KTypeList< ParentType, ParentTypeListTail > >\fP.
.PP
Definition at line 90 of file klibloader.cpp.
.PP
Referenced by create().

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