File indexing completed on 2024-04-21 14:55:35

0001 /* This file is part of the KDE libraries
0002    Copyright (C) 2007 Bernhard Loos <nhuh.put@web.de.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 KLIBRARY_H
0019 #define KLIBRARY_H
0020 
0021 #include <kdelibs4support_export.h>
0022 
0023 #include <QLibrary>
0024 
0025 class KLibraryPrivate;
0026 
0027 class KPluginFactory;
0028 
0029 /**
0030  * \class KLibrary klibrary.h <KLibrary>
0031  *
0032  * KLibrary searches for libraries in the same way that KPluginLoader searches
0033  * for plugins.
0034  *
0035  * @deprecated since 5.0, use QLibrary and KPluginLoader::findPlugin() instead
0036  */
0037 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KLibrary : public QLibrary
0038 {
0039     Q_OBJECT
0040     Q_PROPERTY(QString fileName READ fileName WRITE setFileName)
0041 public:
0042     /**
0043      * @deprecated since 5.0, use QFunctionPointer
0044      */
0045     typedef void (*void_function_ptr)();
0046 
0047     KDELIBS4SUPPORT_DEPRECATED explicit KLibrary(QObject *parent = nullptr);
0048     KDELIBS4SUPPORT_DEPRECATED explicit KLibrary(const QString &name, QObject *parent = nullptr);
0049     KLibrary(const QString &name, int verNum, QObject *parent = nullptr);
0050 
0051     ~KLibrary() override;
0052 
0053     /**
0054      * @deprecated since 4.0, use KPluginLoader::factory
0055      */
0056     KDELIBS4SUPPORT_DEPRECATED KPluginFactory *factory(const char *factoryname = nullptr)
0057     {
0058         // there is nothing sensible we can do: kdelibs 4 plugins depended on
0059         // support from Qt that no longer exists
0060         Q_UNUSED(factoryname) return nullptr;
0061     }
0062 
0063     /**
0064      * @deprecated since 5.0, use QLibrary::resolve
0065      */
0066     KDELIBS4SUPPORT_DEPRECATED void_function_ptr resolveFunction(const char *name)
0067     {
0068         return resolve(name);
0069     }
0070 
0071     void setFileName(const QString &name);
0072 
0073     bool unload()
0074     {
0075         return false;
0076     }
0077 private:
0078     KLibraryPrivate *d_ptr;
0079 };
0080 
0081 #endif