File indexing completed on 2024-12-08 09:37:16
0001 /* This file is part of the KDE libraries 0002 Copyright (C) 1999 Torben Weis <weis@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License version 2 as published by the Free Software Foundation. 0007 0008 This library is distributed in the hope that it will be useful, 0009 but WITHOUT ANY WARRANTY; without even the implied warranty of 0010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0011 Library General Public License for more details. 0012 0013 You should have received a copy of the GNU Library General Public License 0014 along with this library; see the file COPYING.LIB. If not, write to 0015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0016 Boston, MA 02110-1301, USA. 0017 */ 0018 #ifndef KLIBLOADER_H 0019 #define KLIBLOADER_H 0020 0021 #include "kdelibs4support_export.h" 0022 0023 #include "kglobal.h" 0024 0025 #include <QObject> 0026 #include <QStringList> 0027 #include <QHash> 0028 #include <QLibrary> 0029 #include <QtPlugin> 0030 0031 #include "kpluginfactory.h" 0032 #include "kpluginloader.h" 0033 #include "klibrary.h" 0034 0035 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED 0036 0037 class KDELIBS4SUPPORT_DEPRECATED_EXPORT K_EXPORT_COMPONENT_FACTORY_is_deprecated_use_KPluginFactory 0038 { 0039 }; 0040 0041 #define K_EXPORT_COMPONENT_FACTORY( libname, factory ) \ 0042 K_EXPORT_COMPONENT_FACTORY_is_deprecated_use_KPluginFactory dummy; 0043 0044 /** 0045 * \class KLibLoader klibloader.h <KLibLoader> 0046 * 0047 * @deprecated since 4.0, use KPluginLoader, KService::createInstance or 0048 * QLibrary instead. 0049 * 0050 * @see QLibrary, KPluginLoader 0051 * @author Torben Weis <weis@kde.org> 0052 */ 0053 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KLibLoader : public QObject //krazy:exclude=dpointer (private class is kept as a global static) 0054 { 0055 friend class KLibLoaderPrivate; 0056 0057 Q_OBJECT 0058 public: 0059 /** 0060 * Loads a factory from a plugin. 0061 * 0062 * @deprecated since 4.0, use KPluginLoader::factory() 0063 */ 0064 KPluginFactory *factory(const QString &libname, QLibrary::LoadHints loadHint = {}); 0065 0066 /** 0067 * Loads and initializes a library. 0068 * 0069 * @deprecated since 4.0, use QLibrary directly, or KPluginLoader for 0070 * plugins; KPluginLoader::findPlugin() can be used if the library is 0071 * installed in the plugin directory. 0072 */ 0073 KLibrary *library(const QString &libname, QLibrary::LoadHints loadHint = {}); 0074 0075 /** 0076 * Returns an error message that can be useful to debug the problem. 0077 * 0078 * Returns QString() if the last call to library() was successful. 0079 * You can call this function more than once. The error message is only 0080 * reset by a new call to library(). 0081 * 0082 * @return the last error message, or QString() if there was no error 0083 */ 0084 QString lastErrorMessage() const; 0085 0086 /** 0087 * @deprecated since 4.0, does nothing. 0088 */ 0089 void unloadLibrary(const QString &libname); 0090 0091 /** 0092 * Returns a pointer to the factory. 0093 * 0094 * Use this function to get an instance of KLibLoader. 0095 * 0096 * @return a pointer to the loader. If no loader exists until now 0097 * then one is created. 0098 * 0099 * @deprecated since 4.0, use KPluginLoader, KService::createInstance or 0100 * QLibrary instead. 0101 */ 0102 static KDELIBS4SUPPORT_DEPRECATED KLibLoader *self(); 0103 0104 /** 0105 * @deprecated since 5.0, if the library is in a plugin directory, use 0106 * KPluginLoader::findPlugin(); if it is in a library directory, pass the 0107 * name directly to QLibrary. 0108 */ 0109 static KDELIBS4SUPPORT_DEPRECATED QString findLibrary(const QString &libname, const KComponentData &cData = KGlobal::mainComponent()); 0110 0111 private: 0112 ~KLibLoader() override; 0113 0114 KLibLoader(); 0115 }; 0116 0117 #endif 0118 #endif