• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KDECore

klibloader.h

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002    Copyright (C) 1999 Torben Weis <weis@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
00017 */
00018 #ifndef KLIBLOADER_H
00019 #define KLIBLOADER_H
00020 
00021 #include <qobject.h>
00022 #include <qstring.h>
00023 #include <qstringlist.h>
00024 #include <qasciidict.h>
00025 #include <qptrlist.h>
00026 #include <kglobal.h>
00027 
00028 #include <stdlib.h> // For backwards compatibility
00029 
00030 class KInstance;
00031 class QTimer;
00032 class KLibrary;
00033 class KLibFactory;
00034 class KLibFactoryPrivate;
00035 class KLibLoaderPrivate;
00036 class KLibraryPrivate;
00037 
00038 # define K_EXPORT_COMPONENT_FACTORY( libname, factory ) \
00039     extern "C" { KDE_EXPORT void *init_##libname() { return new factory; } }
00040 
00050 class KDECORE_EXPORT KLibrary : public QObject
00051 {
00052     friend class KLibLoader;
00053     friend class QAsciiDict<KLibrary>;
00054 
00055     Q_OBJECT
00056 public:
00060     KLibrary( const QString& libname, const QString& filename, void * handle );
00061 
00066     QString name() const;
00067 
00072     QString fileName() const;
00073 
00078     KLibFactory* factory();
00079 
00089     void* symbol( const char* name ) const;
00090 
00100     bool hasSymbol( const char* name ) const;
00101 
00107     void unload() const;
00108 
00109 private slots:
00110     void slotObjectCreated( QObject *obj );
00111     void slotObjectDestroyed();
00112     void slotTimeout();
00113 
00114 private:
00119     ~KLibrary();
00120 
00121     QString m_libname;
00122     QString m_filename;
00123     KLibFactory* m_factory;
00124     void * m_handle;
00125     QPtrList<QObject> m_objs;
00126     QTimer *m_timer;
00127     KLibraryPrivate *d;
00128 };
00129 
00130 class KLibWrapPrivate;
00131 
00142 class KDECORE_EXPORT KLibLoader : public QObject
00143 {
00144     friend class KLibrary;
00145 
00146     Q_OBJECT
00147 public:
00153     ~KLibLoader();
00154 
00175     KLibFactory* factory( const char* libname );
00176 
00197     virtual KLibrary* library( const char* libname );
00198 
00221     KLibrary* globalLibrary( const char *name );
00222 
00230     QString lastErrorMessage() const;
00231 
00246     virtual void unloadLibrary( const char *libname );
00247 
00254     static KLibLoader* self();
00255 
00264     static void cleanUp();
00265 
00276     static QString findLibrary( const char * name, const KInstance * instance = KGlobal::instance() );
00277 
00278 protected:
00279     KLibLoader( QObject* parent = 0, const char* name = 0 );
00280 
00281 private slots:
00282     void slotLibraryDestroyed();
00283 private:
00284     void close_pending( KLibWrapPrivate * );
00285     QAsciiDict<KLibWrapPrivate> m_libs;
00286 
00287     static KLibLoader* s_self;
00288 
00289 protected:
00290     virtual void virtual_hook( int id, void* data );
00291 private:
00292     KLibLoaderPrivate *d;
00293 };
00294 
00333 class KDECORE_EXPORT KLibFactory : public QObject
00334 {
00335     Q_OBJECT
00336 public:
00342     KLibFactory( QObject* parent = 0, const char* name = 0 );
00343     virtual ~KLibFactory();
00344 
00366      QObject* create( QObject* parent = 0, const char* name = 0, const char* classname = "QObject", const QStringList &args = QStringList() );
00367 
00368 signals:
00373     void objectCreated( QObject *obj );
00374 
00375 
00376 protected:
00377 
00394     virtual QObject* createObject( QObject* parent = 0, const char* name = 0,
00395                                    const char* className = "QObject",
00396                                    const QStringList &args = QStringList() ) = 0;
00397 
00398 
00399 protected:
00400     virtual void virtual_hook( int id, void* data );
00401 private:
00402     KLibFactoryPrivate *d;
00403 };
00404 
00405 #endif

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal