2007-05-23 09:51:28 +02:00
|
|
|
/*
|
2007-08-06 13:20:02 +02:00
|
|
|
* Copyright 2006-2007 Aaron Seigo <aseigo@kde.org>
|
2007-05-23 09:51:28 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-08-06 13:20:02 +02:00
|
|
|
* it under the terms of the GNU Library General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2, or
|
|
|
|
* (at your option) any later version.
|
2007-05-23 09:51:28 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
{
|
|
|
|
|
2008-07-01 20:56:43 +02:00
|
|
|
class DataEngineManagerPrivate;
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2008-04-23 21:05:47 +02:00
|
|
|
Plasma::DataEngine* engine(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
|
|
|
*/
|
2008-04-23 22:04:53 +02:00
|
|
|
Plasma::DataEngine* loadEngine(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.
|
|
|
|
*/
|
2008-04-23 22:04:53 +02:00
|
|
|
void unloadEngine(const QString& name);
|
2007-05-23 09:51:28 +02:00
|
|
|
|
2007-05-27 09:59:17 +02:00
|
|
|
/**
|
|
|
|
* Returns a listing of all known engines by name
|
|
|
|
*/
|
2008-04-23 21:37:42 +02:00
|
|
|
static QStringList listAllEngines();
|
2007-05-23 09:51:28 +02:00
|
|
|
|
|
|
|
private:
|
2008-04-23 22:58:15 +02:00
|
|
|
/**
|
|
|
|
* Default constructor. The singleton method self() is the
|
|
|
|
* preferred access mechanism.
|
|
|
|
*/
|
|
|
|
DataEngineManager();
|
|
|
|
~DataEngineManager();
|
|
|
|
|
2008-07-01 20:56:43 +02:00
|
|
|
DataEngineManagerPrivate* const d;
|
2008-04-23 22:58:15 +02:00
|
|
|
|
|
|
|
friend class DataEngineManagerSingleton;
|
2007-05-23 09:51:28 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Plasma
|
|
|
|
|
|
|
|
#endif // multiple inclusion guard
|