Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions | ![]() |
The QUnknownInterface class is the base class for all interfaces of the Qt Component Model. More...
#include <qcom.h>
Inherited by QAccessibleInterface, QFeatureListInterface, QComponentInterface, QComponentFactoryInterface, QLibraryInterface and QComponentServerInterface.
All interfaces in the component object model are derived from the QUnknownInterface. This interface provides control of the object's lifetime and the ability to navigate a component implementing multiple interfaces. The object's lifetime is controlled using a reference count that is increased and decreased using the functions addRef and release, respectively. The queryInterface function determines whether the component supports a specific interface. For every interface a Unique Universal Identifier (UUID) is provided to identify requests for the interface. In Qt, this identifier is wrapped in the QUuid class that provides convenience operators for comparison and copying.
See also Component Model.
Increases the reference counter for this interface by one and returns the old reference count.
Example:
int MyComponent::addRef() { return ref++; }
This function must be called when this interface is returned as a result of a queryInterface() call. It should be called for every new copy of a pointer to this interface.
See also queryInterface() and release().
Sets iface to point to an interface specified with request, or 0 if this interface can't provide the requested interface. An implementation of this function must call addRef() on the pointer it returns. Possible return values for this function are QS_OK when the call succeeds, or QE_NOINTERFACE if the requested interface cannot be provided.
Example:
QRESULT MyComponent::queryInterface( const QUuid &request, QUnknownInterface** iface ) { *iface = 0; if ( request == IID_QUnknownInterface ) *iface = this; else if ( request == IID_... ) *iface = (...*)this; ... else return QE_NOINTERFACE (*iface)->addRef(); return QS_OK; }
There are five requirements for implementations of queryInterface:
See also addRef() and release().
Decreases the reference count for this interface by one and returns the new reference count. If the reference count falls to 0, the object is freed from memory.
Example:
int MyComponent::release() { if ( !--ref ) { delete this; return 0; } return ref; }
This function should be called whenever a copy of a pointer to this interface is no longer needed.
See also addRef().
This file is part of the Qt toolkit, copyright © 1995-2001 Trolltech, all rights reserved.
Copyright © 2001 Trolltech | Trademarks | Qt version 3.0.0-beta4
|