KDELibs4Support

klibloader.h
1 /* This file is part of the KDE libraries
2  Copyright (C) 1999 Torben Weis <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 #ifndef KLIBLOADER_H
19 #define KLIBLOADER_H
20 
21 #include "kdelibs4support_export.h"
22 
23 #include "kglobal.h"
24 
25 #include <QObject>
26 #include <QStringList>
27 #include <QHash>
28 #include <QLibrary>
29 #include <QtPlugin>
30 
31 #include "kpluginfactory.h"
32 #include "kpluginloader.h"
33 #include "klibrary.h"
34 
35 #ifndef KDELIBS4SUPPORT_NO_DEPRECATED
36 
37 class KDELIBS4SUPPORT_DEPRECATED_EXPORT K_EXPORT_COMPONENT_FACTORY_is_deprecated_use_KPluginFactory
38 {
39 };
40 
41 #define K_EXPORT_COMPONENT_FACTORY( libname, factory ) \
42  K_EXPORT_COMPONENT_FACTORY_is_deprecated_use_KPluginFactory dummy;
43 
44 /**
45  * \class KLibLoader klibloader.h <KLibLoader>
46  *
47  * @deprecated since 4.0, use KPluginLoader, KService::createInstance or
48  * QLibrary instead.
49  *
50  * @see QLibrary, KPluginLoader
51  * @author Torben Weis <[email protected]>
52  */
53 class KDELIBS4SUPPORT_DEPRECATED_EXPORT KLibLoader : public QObject //krazy:exclude=dpointer (private class is kept as a global static)
54 {
55  friend class KLibLoaderPrivate;
56 
57  Q_OBJECT
58 public:
59  /**
60  * Loads a factory from a plugin.
61  *
62  * @deprecated since 4.0, use KPluginLoader::factory()
63  */
64  KPluginFactory *factory(const QString &libname, QLibrary::LoadHints loadHint = {});
65 
66  /**
67  * Loads and initializes a library.
68  *
69  * @deprecated since 4.0, use QLibrary directly, or KPluginLoader for
70  * plugins; KPluginLoader::findPlugin() can be used if the library is
71  * installed in the plugin directory.
72  */
73  KLibrary *library(const QString &libname, QLibrary::LoadHints loadHint = {});
74 
75  /**
76  * Returns an error message that can be useful to debug the problem.
77  *
78  * Returns QString() if the last call to library() was successful.
79  * You can call this function more than once. The error message is only
80  * reset by a new call to library().
81  *
82  * @return the last error message, or QString() if there was no error
83  */
84  QString lastErrorMessage() const;
85 
86  /**
87  * @deprecated since 4.0, does nothing.
88  */
89  void unloadLibrary(const QString &libname);
90 
91  /**
92  * Returns a pointer to the factory.
93  *
94  * Use this function to get an instance of KLibLoader.
95  *
96  * @return a pointer to the loader. If no loader exists until now
97  * then one is created.
98  *
99  * @deprecated since 4.0, use KPluginLoader, KService::createInstance or
100  * QLibrary instead.
101  */
102  static KDELIBS4SUPPORT_DEPRECATED KLibLoader *self();
103 
104  /**
105  * @deprecated since 5.0, if the library is in a plugin directory, use
106  * KPluginLoader::findPlugin(); if it is in a library directory, pass the
107  * name directly to QLibrary.
108  */
109  static KDELIBS4SUPPORT_DEPRECATED QString findLibrary(const QString &libname, const KComponentData &cData = KGlobal::mainComponent());
110 
111 private:
112  ~KLibLoader() override;
113 
114  KLibLoader();
115 };
116 
117 #endif
118 #endif
KLibrary searches for libraries in the same way that KPluginLoader searches for plugins.
Definition: klibrary.h:37
typedef LoadHints
const KComponentData & mainComponent()
Returns the global component data.
Definition: kglobal.cpp:107
Per component data.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Jun 20 2021 22:58:14 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.