diff options
author | Daniel M. Pelt <D.M.Pelt@cwi.nl> | 2015-07-20 14:07:21 +0200 |
---|---|---|
committer | Willem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl> | 2015-07-23 11:57:18 +0200 |
commit | d91b51f6d58003de84a9d6dd8189fceba0e81a5a (patch) | |
tree | 215492c645ee57fb1cd65bab1c8f7bd0aabd058e /matlab | |
parent | 37abc22cf8d26fa3f7e282a1ee50a2a129d5a295 (diff) | |
download | astra-d91b51f6d58003de84a9d6dd8189fceba0e81a5a.tar.gz astra-d91b51f6d58003de84a9d6dd8189fceba0e81a5a.tar.bz2 astra-d91b51f6d58003de84a9d6dd8189fceba0e81a5a.tar.xz astra-d91b51f6d58003de84a9d6dd8189fceba0e81a5a.zip |
Allow registering plugins without explicit name, and fix exception handling when running in Matlab
Diffstat (limited to 'matlab')
-rw-r--r-- | matlab/mex/astra_mex_plugin_c.cpp | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/matlab/mex/astra_mex_plugin_c.cpp b/matlab/mex/astra_mex_plugin_c.cpp index 2d9b9a0..177fcf4 100644 --- a/matlab/mex/astra_mex_plugin_c.cpp +++ b/matlab/mex/astra_mex_plugin_c.cpp @@ -37,9 +37,6 @@ $Id$ #include "astra/PluginAlgorithm.h" -#include "Python.h" -#include "bytesobject.h" - using namespace std; using namespace astra; @@ -52,29 +49,25 @@ using namespace astra; void astra_mex_plugin_get_registered(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) { astra::CPluginAlgorithmFactory *fact = astra::CPluginAlgorithmFactory::getSingletonPtr(); - PyObject *dict = fact->getRegistered(); - PyObject *key, *value; - Py_ssize_t pos = 0; - while (PyDict_Next(dict, &pos, &key, &value)) { - mexPrintf("%s: %s\n",PyBytes_AsString(key),PyBytes_AsString(value)); + std::map<std::string, std::string> mp = fact->getRegisteredMap(); + for(std::map<std::string,std::string>::iterator it=mp.begin();it!=mp.end();it++){ + mexPrintf("%s: %s\n",it->first.c_str(), it->second.c_str()); } - Py_DECREF(dict); } //----------------------------------------------------------------------------------------- -/** astra_mex_plugin('register', name, class_name); +/** astra_mex_plugin('register', class_name); * * Register plugin. */ void astra_mex_plugin_register(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) { - if (3 <= nrhs) { - string name = mexToString(prhs[1]); - string class_name = mexToString(prhs[2]); + if (2 <= nrhs) { + string class_name = mexToString(prhs[1]); astra::CPluginAlgorithmFactory *fact = astra::CPluginAlgorithmFactory::getSingletonPtr(); - fact->registerPlugin(name, class_name); + fact->registerPlugin(class_name); }else{ - mexPrintf("astra_mex_plugin('register', name, class_name);\n"); + mexPrintf("astra_mex_plugin('register', class_name);\n"); } } |