Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

QComponentFactory Class Reference

The QComponentFactory class provides static functions to create and register components. More...

#include <qcomponentfactory.h>

List of all member functions.

Static Public Members


Detailed Description

The QComponentFactory class provides static functions to create and register components.

The component factory provides static convenience functions that can be used both by applications to instantiate components, and by component servers to register components.

The createInstance() function provides a pointer to an interface implemented in a specific component.

Use registerServer() to load a component server and register its components, and unregisterServer() to unregsiter the components. The component exported by the component server has to implement the QComponentRegistrationInterface. registerComponent() and unregisterComponent() register and unregister single components from the system component registry, and should be used by implementations of the QComponentServerInterface.

See also QComponentRegistrationInterface, QComponentFactoryInterface and Component Model.


Member Function Documentation

QRESULT QComponentFactory::createInstance ( const QUuid & cid, const QUuid & iid, QUnknownInterface ** iface, QUnknownInterface * outer = 0 ) [static]

Searches for the component identifier cid in the system component registry, loads the corresponding component server and queries for the interface iid. iface is set to the resulting interface pointer.

The parameter outer is a pointer to the outer interface used for containment and aggregation and is propagated to the createInstance implementation of the QComponentFactoryInterface in the component server if provided.

The function returns QS_OK if the interface was successfully instantiated, QE_NOINTERFACE if the component does not provide an interface iid, or QE_NOCOMPONENT if there was an error loading the component.

Example:

  MyInterface *iface;
  if ( QComponentFactory::createInstance( IID_MyInterface, CID_MyComponent, (QUnknownInterface**)&iface ) == QS_OK )
      ...
      iface->release();
  }
  

bool QComponentFactory::registerComponent ( const QUuid & cid, const QString & filepath, const QString & description = QString::null ) [static]

Registers the component with id cid in the system component registry and returns TRUE if the component was registerd successfully, otherwise returns FALSE. The component is registered with an optional description and is provided by the server at filepath. This function does nothing if a component with an identical cid is already registered on the system.

Call this function for each component in an implementation of registerComponents.

See also unregisterComponent() and registerServer().

QRESULT QComponentFactory::registerServer ( const QString & filename ) [static]

Loads the shared library filename and queries for a QComponentRegistrationInterface. If the library implements this interface, the registerComponents function is called.

Returns TRUE if the interface is found and successfully registered, otherwise returns FALSE.

bool QComponentFactory::unregisterComponent ( const QUuid & cid ) [static]

Unregisters the component with id cid from the system component registry and returns TRUE if the component was unregistered successfully, otherwise returns FALSE.

Call this function for each component in an implementation of unregisterComponents.

See also registerComponent() and unregisterServer().

QRESULT QComponentFactory::unregisterServer ( const QString & filename ) [static]

Loads the shared library filename and queries for a QComponentRegistrationInterface. If the library implements this interface, the unregisterComponents function is called.

Returns TRUE if the interface is found and successfully unregistered, otherwise returns FALSE.


This file is part of the Qt toolkit, copyright © 1995-2001 Trolltech, all rights reserved.


Copyright © 2001 TrolltechTrademarks
Qt version 3.0.0-beta5