tdecore
KGenericFactory< KTypeList< Product, ProductListTail >, TQObject > Class Template Reference
This template provides a generic implementation of a KLibFactory , for use with shared library components. More...
#include <kgenericfactory.h>

Public Member Functions | |
KGenericFactory (const char *instanceName=0) | |
KGenericFactory (const TDEAboutData *data) | |
Protected Member Functions | |
virtual TQObject * | createObject (TQObject *parent, const char *name, const char *className, const TQStringList &args) |
Detailed Description
template<class Product, class ProductListTail>
class KGenericFactory< KTypeList< Product, ProductListTail >, TQObject >
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:
-
If the class is derived from TQObject then it needs to have a constructor like:
MyClass( TQObject *parent, const char *name, const TQStringList &args );
-
If the class is derived from TQWidget then it needs to have a constructor like:
MyWidget( TQWidget *parent, const char *name, const TQStringList &args);
-
If the class is derived from KParts::Part then it needs to have a constructor like:
MyPart( TQWidget *parentWidget, const char *widgetName, TQObject *parent, const char *name, const TQStringList &args );
The args TQStringList 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 TDEInstance object for your component, accessible through the static instance() method. The instanceName argument of the KGenericFactory constructor is passed to the TDEInstance object.
The creation of the TDEInstance object can be customized by inheriting from this template class and re-implementing the virtual createInstance method. For example it could look like this:
TDEInstance *MyFactory::createInstance() { return new TDEInstance( myAboutData ); }
Example of usage of the whole template:
class MyPlugin : public KParts::Plugin { Q_ OBJECT public: MyPlugin( TQObject *parent, const char *name, const TQStringList &args ); ... }; class MyDialogComponent : public KDialogBase { Q_ OBJECT public: MyDialogComponent( TQWidget *parentWidget, const char *name, const TQStringList &args ); ... }; typedef K_TYPELIST_2( MyPlugin, MyDialogComponent ) Products; K_EXPORT_COMPONENT_FACTORY( libmyplugin, KGenericFactory<Products> )
Definition at line 266 of file kgenericfactory.h.
Constructor & Destructor Documentation
KGenericFactory< KTypeList< Product, ProductListTail >, TQObject >::KGenericFactory | ( | const TDEAboutData * | data | ) | [inline] |
- Since:
- 3.3
Definition at line 278 of file kgenericfactory.h.
The documentation for this class was generated from the following file: