Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

QPluginManager< Type > Class Template Reference

The QPluginManager class provides basic functions to access a certain kind of functionality in libraries. More...

#include </home/clem/local/src/opie/qmake/include/private/qpluginmanager_p.h>

Inheritance diagram for QPluginManager< Type >:

Inheritance graph
[legend]
Collaboration diagram for QPluginManager< Type >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 QPluginManager (const QUuid &id, const QStringList &paths=QString::null, const QString &suffix=QString::null, bool cs=TRUE)
QRESULT queryInterface (const QString &feature, Type **iface) const

Detailed Description

template<class Type>
class QPluginManager< Type >

The QPluginManager class provides basic functions to access a certain kind of functionality in libraries.

For internal use only.

A common usage of components is to extend the existing functionality in an application using plugins. The application defines interfaces that abstract a certain group of functionality, and a plugin provides a specialized implementation of one or more of those interfaces.

The QPluginManager template has to be instantiated with an interface definition and the IID for this interface.

  QPluginManager<MyPluginInterface> *manager = new QPluginManager<MyPluginInterface>( IID_MyPluginInterface );

It searches a specified directory for all shared libraries, queries for components that implement the specific interface and reads information about the features the plugin wants to add to the application. The component can provide the set of features provided by implementing either the QFeatureListInterface or the QComponentInformationInterface. The strings returned by the implementations of

  QStringList QFeatureListInterface::featureList() const

or

  QString QComponentInformationInterface::name() const

respectively, can then be used to access the component that provides the requested feature:

  MyPluginInterface *iface;
  manager->queryInterface( "feature", &iface );
  if ( iface )
      iface->execute( "feature" );

The application can use a QPluginManager instance to create parts of the user interface based on the list of features found in plugins:

  QPluginManager<MyPluginInterface> *manager = new QPluginManager<MyPluginInterface>( IID_ImageFilterInterface );
  manager->addLibraryPath(...);

  QStringList features = manager->featureList();
  for ( QStringList::Iterator it = features.begin(); it != features.end(); ++it ) {
      MyPluginInterface *iface;
      manager->queryInterface( *it, &iface );

      // use QAction to provide toolbuttons and menuitems for each feature...
  }

Definition at line 60 of file qpluginmanager_p.h.


Constructor & Destructor Documentation

template<class Type>
QPluginManager< Type >::QPluginManager const QUuid id,
const QStringList paths = QString::null,
const QString suffix = QString::null,
bool  cs = TRUE
[inline]
 

Creates an QPluginManager for interfaces id that will load all shared library files in the paths + suffix. If cs is FALSE the manager will handle feature strings case insensitive.

Warning:
Setting the cs flag to FALSE requires that components also convert to lower case when comparing with passed strings, so this has to be handled with care and documented very well.
See also:
QApplication::libraryPaths()

Definition at line 63 of file qpluginmanager_p.h.


Member Function Documentation

template<class Type>
QRESULT QPluginManager< Type >::queryInterface const QString feature,
Type **  iface
const [inline]
 

Sets iface to point to the interface providing feature.

See also:
featureList(), library()

Definition at line 65 of file qpluginmanager_p.h.

References QGPluginManager::queryUnknownInterface().


The documentation for this class was generated from the following files:
Generated on Sat Nov 5 17:48:11 2005 for OPIE by  doxygen 1.4.2