2
* kis_resourceserver.h - part of KImageShop
4
* Copyright (c) 1999 Matthias Elter <elter@kde.org>
5
* Copyright (c) 2003 Patrick Julien <freak@codepimps.org>
6
* Copyright (c) 2005 Sven Langkamp <longamp@reallygood.de>
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or
11
* (at your option) any later version.
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
#ifndef KIS_RESOURCESERVER_H_
23
#define KIS_RESOURCESERVER_H_
26
#include <qstringlist.h>
28
#include "kis_generic_registry.h"
32
class KisResourceServerBase : public QObject {
35
KisResourceServerBase(QString type);
36
virtual ~KisResourceServerBase();
38
void loadResources(QStringList filenames);
39
/// Adds an already loaded resource to the server
40
void addResource(KisResource* resource);
41
QValueList<KisResource*> resources();
42
QString type() { return m_type; };
45
void resourceAdded(KisResource*);
48
virtual KisResource* createResource( QString filename ) = 0;
51
QValueList<KisResource*> m_resources;
59
template <class T> class KisResourceServer : public KisResourceServerBase {
60
typedef KisResourceServerBase super;
63
KisResourceServer(QString type) :super( type ) {}
64
virtual ~KisResourceServer(){}
67
KisResource* createResource( QString filename ){return new T(filename);}
73
class KisResourceServerRegistry : public KisGenericRegistry<KisResourceServerBase*>
77
virtual ~KisResourceServerRegistry();
79
static KisResourceServerRegistry* instance();
82
KisResourceServerRegistry();
83
KisResourceServerRegistry(const KisResourceServerRegistry&);
84
KisResourceServerRegistry operator=(const KisResourceServerRegistry&);
86
static KisResourceServerRegistry *m_singleton;
90
#endif // KIS_RESOURCESERVER_H_