~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to krita/ui/kis_resourceserver.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  kis_resourceserver.h - part of KImageShop
 
3
 *
 
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>
 
7
 *
 
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.
 
12
 *
 
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.
 
17
 *
 
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.
 
21
 */
 
22
#ifndef KIS_RESOURCESERVER_H_
 
23
#define KIS_RESOURCESERVER_H_
 
24
 
 
25
#include <qstring.h>
 
26
#include <qstringlist.h>
 
27
 
 
28
#include "kis_generic_registry.h"
 
29
 
 
30
class KisResource;
 
31
 
 
32
class KisResourceServerBase : public QObject {
 
33
    Q_OBJECT
 
34
public:
 
35
    KisResourceServerBase(QString type);
 
36
    virtual ~KisResourceServerBase();
 
37
 
 
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; };
 
43
 
 
44
signals:
 
45
    void resourceAdded(KisResource*);
 
46
 
 
47
protected:
 
48
    virtual KisResource* createResource( QString filename ) = 0;
 
49
 
 
50
private:
 
51
    QValueList<KisResource*> m_resources;
 
52
    QString m_type;
 
53
 
 
54
    bool m_loaded;
 
55
 
 
56
};
 
57
 
 
58
 
 
59
template <class T> class KisResourceServer : public KisResourceServerBase {
 
60
    typedef KisResourceServerBase super;
 
61
 
 
62
public:
 
63
    KisResourceServer(QString type) :super( type ) {}
 
64
    virtual ~KisResourceServer(){}
 
65
 
 
66
private:
 
67
    KisResource* createResource( QString filename ){return new T(filename);}
 
68
};
 
69
 
 
70
 
 
71
 
 
72
 
 
73
class KisResourceServerRegistry : public KisGenericRegistry<KisResourceServerBase*>
 
74
{
 
75
 
 
76
public:
 
77
    virtual ~KisResourceServerRegistry();
 
78
 
 
79
    static KisResourceServerRegistry* instance();
 
80
 
 
81
private:
 
82
    KisResourceServerRegistry();
 
83
     KisResourceServerRegistry(const KisResourceServerRegistry&);
 
84
     KisResourceServerRegistry operator=(const KisResourceServerRegistry&);
 
85
 
 
86
    static KisResourceServerRegistry *m_singleton;
 
87
};
 
88
 
 
89
 
 
90
#endif // KIS_RESOURCESERVER_H_