Finished logical separation of core and GUI. Monolithic build should work as expected.
[quassel.git] / main / quassel.h
index 0c2a11b..3d2b541 100644 (file)
 #ifndef _QUASSEL_H_
 #define _QUASSEL_H_
 
-class Logger;
-class QIcon;
-class QString;
+class Quassel;
 
-#include <QHash>
+#include <QtCore>
+//#include <QMutex>
 
+/* Some global stuff */
+typedef QMap<QString, QVariant> VarMap;
+extern Quassel *quassel;
 
 /**
  * A static class containing global data.
+ * This is used in both core and GUI modules. Where appropriate, accessors are thread-safe
+ * to account for that fact.
  */
-class Quassel {
+class Quassel : public QObject {
+  Q_OBJECT
 
   public:
-    static void init();
-    static Logger *getLogger();
-    static void setLogger(Logger *);
+    Quassel();
+    //static Logger *getLogger();
+    //static void setLogger(Logger *);
 
-    static QIcon *getIcon(QString symbol);
+//    static QIcon *getIcon(QString symbol);
+
+    QVariant getData(QString key);
+
+  public slots:
+    void putData(QString key, const QVariant &data);
+
+  signals:
+    void dataChanged(QString key, const QVariant &data);
+
+  public:
+    enum RunMode { Monolithic, GUIOnly, CoreOnly };
+    static RunMode runMode;
 
   private:
     static void initIconMap();
     
-    static Logger *logger;
+    //static Logger *logger;
+
+//    static QString iconPath;
+    QHash<QString, QString> iconMap;
+    QMutex mutex;
+    QHash<QString, QVariant> data;
+};
+
+class Exception {
+  public:
+    Exception(QString msg = "Unknown Exception") : _msg(msg) {};
+    virtual inline QString msg() { return _msg; }
 
-    static QString iconPath;
-    static QHash<QString, QString> iconMap;
+  protected:
+    QString _msg;
 
 };