QLibrary Class Reference
The API for this class is under development and is subject to change.
We do not recommend the use of this class for production work at this time.
The QLibrary class provides a wrapper for handling shared libraries.
More...
#include <qlibrary.h>
List of all member functions.
Public Members
enum
Policy { Delayed, Immediately, Manual }
QLibrary ( const QString & filename, Policy pol = Delayed )
void *
resolve ( const char * symb )
bool
unload ( bool force = FALSE )
QRESULT
queryInterface ( const QUuid & request, QUnknownInterface ** iface )
Detailed Description
The QLibrary class provides a wrapper for handling shared libraries.
Member Type Documentation
QLibrary::Policy
This enum type defines the various policies a QLibrary can have with respect to
loading and unloading the shared library.
The policy can be:
- QLibrary::Delayed - The library get's loaded as soon as needed
- QLibrary::Immediately - The library is loaded immediately
- QLibrary::Manual - The library has to be unloaded manually
Member Function Documentation
QLibrary::QLibrary ( const QString & filename, Policy pol = Delayed )
Creates a QLibrary object for the shared library filename.
The library get's loaded if pol is Immediately.
Note that filename must not include the (platform specific) file extension.
See also setPolicy() and unload().
QLibrary::~QLibrary ()
Deletes the QLibrary object.
The library will be unloaded if the policy is not Manual.
See also unload() and setPolicy().
bool QLibrary::isLoaded () const
Returns whether the library is loaded.
See also unload.
QString QLibrary::library () const
Returns the filename of the shared library this QLibrary object handles.
Policy QLibrary::policy () const
Returns the current policy.
See also setPolicy.
QRESULT QLibrary::queryInterface ( const QUuid & request, QUnknownInterface ** iface )
Forwards the query to the component and returns the result.
The library gets loaded if necessary.
See also QUnknownInterface::queryInterface.
void * QLibrary::resolve ( const char * symb )
Returns the address of the exported symbol symb. The library gets
loaded if necessary. The function returns NULL if the symbol could
not be resolved, or if loading the library failed.
typedef int (*addProc)( int, int );
addProc add = (addProc) library->resolve( "add" );
if ( add )
return add( 5, 8 );
else
return 5 + 8;
See also queryInterface.
void QLibrary::setPolicy ( Policy pol )
Sets the current policy to pol.
The library is loaded if pol is set to Immediately.
See also LibraryPolicy.
bool QLibrary::unload ( bool force = FALSE )
Releases the component and unloads the library when successful.
Returns TRUE if the library could be unloaded, otherwise FALSE.
If the component implements the QLibraryInterface, the cleanup()
function of this interface will be called. The unloading will be
cancelled if the subsequent call to canUnload() returns FALSE.
This function gets called automatically in the destructor if
the policy is not Manual.
Warning:
If force is set to TRUE, the library gets unloaded at any cost,
which is in most cases a segmentation fault, so you should know what
you're doing!
See also queryInterface and resolve.
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit,
copyright © 1995-2001
Trolltech, all rights reserved.
Copyright © 2001 Trolltech | Trademarks
| Qt version 3.0.0-beta1-beta1
|