Commits

Henning Schröder  committed 3fe4ccb

singleton pattern

  • Participants
  • Parent commits 718fa04

Comments (0)

Files changed (2)

File embpyqt/embeddedpyqt.cpp

 #include <qdebug.h>
 
 
+EmbeddedPyQt *EmbeddedPyQt::_instance = 0;
+
+
 EmbeddedPyQt::EmbeddedPyQt(QObject *parent) :
     QObject(parent)
 {
+    EmbeddedPyQt::_instance = this;
     setObjectName("embeddedPyQt");
     QApplication::instance()->setProperty("embedded_pyqt",
                                           qVariantFromValue((QObject*)this));

File embpyqt/embeddedpyqt.h

 #include <QStringList>
 #include "pythonize.h"
 
+#define RAISE(type, msg) EmbeddedPyQt::instance()->raiseException(type, msg);
+#define REGISTER_CLASS(cls) EmbeddedPyQt::instance()->registerMetaObject(cls::staticMetaObject);
+#define REGISTER_INSTANCE(obj) EmbeddedPyQt::instance()->registerObject(obj);
 
 
 class EmbeddedPyQt : public QObject
 
 public:
     explicit EmbeddedPyQt(QObject *parent = 0);
-    static EmbeddedPyQt *instance;
     void init(const QString &filename);
-
+    static EmbeddedPyQt *instance();
 signals:
     void executionRequested(const QString &command, bool globalContext);
 
     void execute(const QString &command, bool globalContext);
 
 private:
+    static EmbeddedPyQt *_instance;
     Pythonize *python;
     QMap<QString,const QMetaObject*> classes;
     QMap<QString,const QObject*> objects;