2007-05-23 09:51:28 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2006 Aaron Seigo <aseigo@kde.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Library General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this program; if not, write to the
|
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2007-07-20 10:06:27 +02:00
|
|
|
#ifndef PLASMA_DATAENGINEMANAGER_H
|
|
|
|
#define PLASMA_DATAENGINEMANAGER_H
|
2007-05-23 09:51:28 +02:00
|
|
|
|
2007-05-30 18:47:36 +02:00
|
|
|
#include <QtCore/QHash>
|
2007-06-10 08:01:15 +02:00
|
|
|
#include <plasma/dataengine.h>
|
2007-05-23 09:51:28 +02:00
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2007-05-27 09:59:17 +02:00
|
|
|
/**
|
|
|
|
* @brief DataEngine loader and life time manager
|
|
|
|
*
|
|
|
|
* Plasma::DataEngineManager provides facilities for listing, loading and
|
|
|
|
* according to reference count unloading of DataEngines.
|
|
|
|
**/
|
2007-07-23 01:20:50 +02:00
|
|
|
class PLASMA_EXPORT DataEngineManager: public QObject
|
2007-05-23 09:51:28 +02:00
|
|
|
{
|
2007-07-23 01:20:50 +02:00
|
|
|
Q_OBJECT
|
2007-05-23 09:51:28 +02:00
|
|
|
public:
|
2007-05-27 09:59:17 +02:00
|
|
|
/**
|
|
|
|
* Singleton pattern accessor.
|
|
|
|
*/
|
|
|
|
static DataEngineManager* self();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default constructor. Usually the singleton method self() is the
|
|
|
|
* preferred access mechanism.
|
|
|
|
*/
|
2007-05-23 09:51:28 +02:00
|
|
|
DataEngineManager();
|
|
|
|
~DataEngineManager();
|
|
|
|
|
2007-05-27 09:59:17 +02:00
|
|
|
/**
|
|
|
|
* Returns a data engine object if one is loaded and available.
|
2007-06-03 00:23:26 +02:00
|
|
|
* On failure, the fallback NullEngine (which does nothing and
|
|
|
|
* !isValid()) is returned.
|
2007-05-27 09:59:17 +02:00
|
|
|
*
|
|
|
|
* @param name the name of the engine
|
|
|
|
*/
|
2007-05-23 09:51:28 +02:00
|
|
|
Plasma::DataEngine* dataEngine(const QString& name) const;
|
2007-05-27 09:59:17 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Loads a data engine and increases the reference count on it.
|
|
|
|
* This should be called once per object (or set of objects) using the
|
|
|
|
* DataEngine. Afterwards, dataEngine should be used or the return
|
|
|
|
* value cached. Call unloadDataEngine when finished with the engine.
|
|
|
|
*
|
|
|
|
* @param name the name of the engine
|
2007-06-03 00:23:26 +02:00
|
|
|
* @return the data engine that was loaded, or the NullEngine on failure.
|
2007-05-27 09:59:17 +02:00
|
|
|
*/
|
2007-05-23 09:51:28 +02:00
|
|
|
Plasma::DataEngine* loadDataEngine(const QString& name);
|
2007-05-27 09:59:17 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Decreases the reference count on the engine. If the count reaches
|
|
|
|
* zero, then the engine is deleted to save resources.
|
|
|
|
*/
|
2007-05-23 09:51:28 +02:00
|
|
|
void unloadDataEngine(const QString& name);
|
|
|
|
|
2007-05-27 09:59:17 +02:00
|
|
|
/**
|
|
|
|
* Returns a listing of all known engines by name
|
|
|
|
*/
|
|
|
|
static QStringList knownEngines();
|
2007-05-23 09:51:28 +02:00
|
|
|
|
|
|
|
private:
|
2007-05-24 21:36:05 +02:00
|
|
|
class Private;
|
|
|
|
Private* const d;
|
2007-05-23 09:51:28 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Plasma
|
|
|
|
|
|
|
|
#endif // multiple inclusion guard
|