• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

Public Member Functions | Protected Member Functions | List of all members
KGenericFactory< Product, ParentType > Class Template Reference

#include <kgenericfactory.h>

Inheritance diagram for KGenericFactory< Product, ParentType >:
KLibFactory

Public Member Functions

 KGenericFactory (const char *instanceName=0)
 
 KGenericFactory (const TDEAboutData *data)
 
- Public Member Functions inherited from KLibFactory
 KLibFactory (TQObject *parent=0, const char *name=0)
 
TQObject * create (TQObject *parent=0, const char *name=0, const char *classname="TQObject", const TQStringList &args=TQStringList())
 

Protected Member Functions

virtual TQObject * createObject (TQObject *parent, const char *name, const char *className, const TQStringList &args)
 
- Protected Member Functions inherited from KLibFactory
virtual TQObject * createObject (TQObject *parent=0, const char *name=0, const char *className="TQObject", const TQStringList &args=TQStringList())=0
 
virtual void virtual_hook (int id, void *data)
 

Additional Inherited Members

- Signals inherited from KLibFactory
void objectCreated (TQObject *obj)
 

Detailed Description

template<class Product, class ParentType = TQObject>
class KGenericFactory< Product, ParentType >

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 class (template argument) when the class name argument of createObject matches a class name in the given hierarchy.

In case you are developing a KParts component, skip this file and go directly to KParts::GenericFactory .

Note that the class specified as 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 );
}
TDEInstance
Access to KDE global objects for use in shared libraries.
Definition: kinstance.h:48

Example of usage of the whole template:

class MyPlugin : public KParts::Plugin
{
Q_ OBJECT
public:
MyPlugin( TQObject *parent, const char *name,
const TQStringList &args );
...
};
K_EXPORT_COMPONENT_FACTORY( libmyplugin, KGenericFactory&lt;MyPlugin&gt; )
KGenericFactory
This template provides a generic implementation of a KLibFactory , for use with shared library compon...
Definition: kgenericfactory.h:174
KParts::Plugin

Definition at line 173 of file kgenericfactory.h.

Constructor & Destructor Documentation

◆ KGenericFactory() [1/2]

template<class Product , class ParentType = TQObject>
KGenericFactory< Product, ParentType >::KGenericFactory ( const char *  instanceName = 0)
inline

Definition at line 176 of file kgenericfactory.h.

◆ KGenericFactory() [2/2]

template<class Product , class ParentType = TQObject>
KGenericFactory< Product, ParentType >::KGenericFactory ( const TDEAboutData *  data)
inline
Since
3.3

Definition at line 183 of file kgenericfactory.h.

Member Function Documentation

◆ createObject()

template<class Product , class ParentType = TQObject>
virtual TQObject * KGenericFactory< Product, ParentType >::createObject ( TQObject *  parent,
const char *  name,
const char *  className,
const TQStringList &  args 
)
inlineprotectedvirtual

Creates a new object.

The returned object has to be derived from the requested classname.

It is valid behavior to create different kinds of objects depending on the requested className. For example a koffice library may usually return a pointer to KoDocument. But if asked for a "TQWidget", it could create a wrapper widget, that encapsulates the Koffice specific features.

This function is called by create()

Parameters
parentthe parent of the TQObject, 0 for no parent
namethe name of the TQObject, 0 for no name
classNamethe name of the class
argsa list of arguments

Implements KLibFactory.

Definition at line 189 of file kgenericfactory.h.


The documentation for this class was generated from the following file:
  • kgenericfactory.h

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.