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

tdecore

Signals | Public Member Functions | Protected Member Functions | List of all members
KLibFactory Class Referenceabstract

#include <klibloader.h>

Inheritance diagram for KLibFactory:
KGenericFactory< Product, ParentType > KGenericFactory< KTypeList< Product, ProductListTail >, KTypeList< ParentType, ParentTypeListTail > > KGenericFactory< KTypeList< Product, ProductListTail >, TQObject >

Signals

void objectCreated (TQObject *obj)
 

Public Member Functions

 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=0, const char *name=0, const char *className="TQObject", const TQStringList &args=TQStringList())=0
 
virtual void virtual_hook (int id, void *data)
 

Detailed Description

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:

K_EXPORT_COMPONENT_FACTORY( libkspread, KSpreadFactory )

The first macro argument is the name of your library, the second specifies the name of your factory.

NOTE: you probably want to use KGenericFactory<PluginClassName> instead of writing your own factory.

In the constructor of your factory you should create an instance of TDEInstance like this:

s_global = new TDEInstance( "kspread" );
TDEInstance
Access to KDE global objects for use in shared libraries.
Definition: kinstance.h:48

This TDEInstance is comparable to TDEGlobal used by normal applications. It allows you to find resource files (images, XML, sound etc.) belonging to the library.

If you want to load a library, use KLibLoader. You can query KLibLoader directly for a pointer to the libraries factory by using the KLibLoader::factory() function.

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 TQObject, since TQObject offers type safe casting.

KLibFactory is an abstract class. Reimplement the createObject() method to give it functionality.

Author
Torben Weis weis@.nosp@m.kde..nosp@m.org

Definition at line 333 of file klibloader.h.

Constructor & Destructor Documentation

◆ KLibFactory()

KLibFactory::KLibFactory ( TQObject *  parent = 0,
const char *  name = 0 
)

Create a new factory.

Parameters
parentthe parent of the TQObject, 0 for no parent
namethe name of the TQObject, 0 for no name

Definition at line 73 of file klibloader.cpp.

◆ ~KLibFactory()

KLibFactory::~KLibFactory ( )
virtual

Definition at line 78 of file klibloader.cpp.

Member Function Documentation

◆ create()

TQObject * KLibFactory::create ( TQObject *  parent = 0,
const char *  name = 0,
const char *  classname = "TQObject",
const TQStringList &  args = TQStringList() 
)

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.

create() 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.

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

Definition at line 83 of file klibloader.cpp.

◆ createObject()

TQObject * KLibFactory::createObject ( TQObject *  parent = 0,
const char *  name = 0,
const char *  className = "TQObject",
const TQStringList &  args = TQStringList() 
)
protectedpure virtual

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

Implemented in KGenericFactory< Product, ParentType >, KGenericFactory< KTypeList< Product, ProductListTail >, TQObject >, KGenericFactory< KTypeList< Product, ProductListTail >, KTypeList< ParentType, ParentTypeListTail > >, and KParts::Factory.

Definition at line 92 of file klibloader.cpp.

◆ objectCreated

void KLibFactory::objectCreated ( TQObject *  obj)
signal

Emitted in create.

Parameters
objthe new object

◆ virtual_hook()

void KLibFactory::virtual_hook ( int  id,
void *  data 
)
protectedvirtual

Definition at line 579 of file klibloader.cpp.


The documentation for this class was generated from the following files:
  • klibloader.h
  • klibloader.cpp

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.