3d2b54128e820e8863e13c8299b7c9a8312bb56b
[quassel.git] / main / quassel.h
1 /***************************************************************************
2  *   Copyright (C) 2005 by The Quassel Team                                *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef _QUASSEL_H_
22 #define _QUASSEL_H_
23
24 class Quassel;
25
26 #include <QtCore>
27 //#include <QMutex>
28
29 /* Some global stuff */
30 typedef QMap<QString, QVariant> VarMap;
31 extern Quassel *quassel;
32
33 /**
34  * A static class containing global data.
35  * This is used in both core and GUI modules. Where appropriate, accessors are thread-safe
36  * to account for that fact.
37  */
38 class Quassel : public QObject {
39   Q_OBJECT
40
41   public:
42     Quassel();
43     //static Logger *getLogger();
44     //static void setLogger(Logger *);
45
46 //    static QIcon *getIcon(QString symbol);
47
48     QVariant getData(QString key);
49
50   public slots:
51     void putData(QString key, const QVariant &data);
52
53   signals:
54     void dataChanged(QString key, const QVariant &data);
55
56   public:
57     enum RunMode { Monolithic, GUIOnly, CoreOnly };
58     static RunMode runMode;
59
60   private:
61     static void initIconMap();
62     
63     //static Logger *logger;
64
65 //    static QString iconPath;
66     QHash<QString, QString> iconMap;
67     QMutex mutex;
68     QHash<QString, QVariant> data;
69 };
70
71 class Exception {
72   public:
73     Exception(QString msg = "Unknown Exception") : _msg(msg) {};
74     virtual inline QString msg() { return _msg; }
75
76   protected:
77     QString _msg;
78
79 };
80
81 #endif