From 0d06afc38d7a8443a079d25d72ec4b4b15353974 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 3 Jul 2018 14:32:23 +0200 Subject: Allow access to python plugin object via algorithm interface --- python/astra/src/PythonPluginAlgorithm.cpp | 8 ++++++++ python/astra/src/PythonPluginAlgorithm.h | 3 +++ 2 files changed, 11 insertions(+) (limited to 'python/astra/src') diff --git a/python/astra/src/PythonPluginAlgorithm.cpp b/python/astra/src/PythonPluginAlgorithm.cpp index d461f06..3c892ff 100644 --- a/python/astra/src/PythonPluginAlgorithm.cpp +++ b/python/astra/src/PythonPluginAlgorithm.cpp @@ -124,6 +124,14 @@ void CPluginAlgorithm::run(int _iNrIterations){ PyGILState_Release(state); } +PyObject *CPluginAlgorithm::getInstance() const { + if (instance) + Py_INCREF(instance); + return instance; +} + + + CPythonPluginAlgorithmFactory::CPythonPluginAlgorithmFactory(){ if(!Py_IsInitialized()){ Py_Initialize(); diff --git a/python/astra/src/PythonPluginAlgorithm.h b/python/astra/src/PythonPluginAlgorithm.h index 947e30d..b7072d6 100644 --- a/python/astra/src/PythonPluginAlgorithm.h +++ b/python/astra/src/PythonPluginAlgorithm.h @@ -49,6 +49,9 @@ public: bool initialize(const Config& _cfg); void run(int _iNrIterations); + // Return instance (including INCREF) + PyObject *getInstance() const; + private: PyObject * instance; -- cgit v1.2.3