class KGenericFactory

This template provides a generic implementation of a KLibFactory , for use with shared library components. More...

Definition#include <kgenericfactory.h>
Template formKGenericFactory<template >
InheritsKGenericFactoryBase [public ], KGenericFactoryBase [public ], KGenericFactoryBase [public ], KLibFactory [public ], KLibFactory [public ], KLibFactory [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Methods

Protected Methods


Detailed Description

This template provides a generic implementation of a KLibFactory , for use with shared library components. It implements the pure virtual createObject method of KLibFactory 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.

Note that each class in the specified in the typelist template argument needs to provide a certain constructor:

The args QStringList passed to the constructor is the args string list that the caller passed to KLibFactory's create method.

In addition upon instantiation this template provides a central KInstance object for your component, accessible through the static instance() method. The instanceName argument of the KGenericFactory constructor is passed to the KInstance object.

The creation of the KInstance object can be customized by inheriting from this template class and re-implementing the virtual createInstance method. For example it could look like this:


     KInstance *MyFactory::createInstance()
     {
         return new KInstance( myAboutData );
     }

Example of usage of the whole template:


     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<Products> );

 KGenericFactory ( const char *instanceName = 0 )

KGenericFactory

QObjectcreateObject ( QObject *parent, const char *name, const char *className, const QStringList &args )

createObject

[protected virtual]

Reimplemented from KLibFactory.

 KGenericFactory ( const char *instanceName = 0 )

KGenericFactory

QObjectcreateObject ( QObject *parent, const char *name, const char *className, const QStringList &args )

createObject

[protected virtual]

Reimplemented from KLibFactory.

 KGenericFactory ( const char *instanceName = 0 )

KGenericFactory

QObjectcreateObject ( QObject *parent, const char *name, const char *className, const QStringList &args )

createObject

[protected virtual]

Reimplemented from KLibFactory.


Generated by: dfaure on faure on Tue Apr 16 08:49:00 2002, using kdoc 2.0a53.