File indexing completed on 2023-10-01 04:11:43
0001 /* 0002 SPDX-FileCopyrightText: 2012 Aaron Seigo <aseigo@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef PLASMA_DATAENGINECONSUMER_H 0008 #define PLASMA_DATAENGINECONSUMER_H 0009 0010 #include <QUrl> 0011 0012 #include <plasma/plasma_export.h> 0013 0014 namespace Plasma 0015 { 0016 class DataEngine; 0017 class DataEngineConsumerPrivate; 0018 0019 /** 0020 * @class DataEngineConsumer plasma/dataengineconsumer.h <Plasma/DataEngineConsumer> 0021 * 0022 * @brief A class that makes it safe and easy to use DataEngines 0023 * 0024 * DataEngineConsumer provides access to DataEngines, which are internally reference 0025 * counted and shared between all users of them. The only public method provided is 0026 * dataEngine which returns engines upon request. 0027 * 0028 * When the DataEngineConsumer class is deleted, all engines accessed using it are 0029 * de-referenced and possibly deleted (in the case that there are no other users of 0030 * the engine in question). 0031 * 0032 * DataEngineConsumer can be subclassed by other C++ classes to allow this simple 0033 * API to be used directly from these classes in a convenient manner. 0034 **/ 0035 class PLASMA_EXPORT DataEngineConsumer 0036 { 0037 public: 0038 /** 0039 * Constructs a DataEngineConsumer 0040 **/ 0041 DataEngineConsumer(); 0042 ~DataEngineConsumer(); 0043 0044 /** 0045 * Returns a Plasma::DataEngine. It never returns a null pointer, and the 0046 * DataEngine returned should not be deleted. All DataEngines will be dereferenced 0047 * once this DataEngineConsumer instance is deleted. 0048 * 0049 * It is safe and fast to request the same engine more than once. 0050 * 0051 * @param name the name of the DataEngine. This corresponds to the plugin name 0052 * of the DataEngine. 0053 */ 0054 DataEngine *dataEngine(const QString &name); 0055 0056 private: 0057 DataEngineConsumerPrivate *const d; 0058 }; 0059 0060 } // namespace Plasma 0061 0062 #endif