summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2016-02-16 15:34:08 +0100
committerWillem Jan Palenstijn <Willem.Jan.Palenstijn@cwi.nl>2016-02-16 15:34:08 +0100
commit8cfe13a410a051e5a6b9835e3a4cd6c808cf5d29 (patch)
tree69d3538b061d3e7cddfbeb85cc33d80333abf52e
parent9847d2c4a8287f220f169236b4fa1962d50d1187 (diff)
downloadastra-8cfe13a410a051e5a6b9835e3a4cd6c808cf5d29.tar.gz
astra-8cfe13a410a051e5a6b9835e3a4cd6c808cf5d29.tar.bz2
astra-8cfe13a410a051e5a6b9835e3a4cd6c808cf5d29.tar.xz
astra-8cfe13a410a051e5a6b9835e3a4cd6c808cf5d29.zip
Add astra_mex delete/info based on index manager
-rw-r--r--include/astra/AstraObjectManager.h1
-rw-r--r--matlab/mex/astra_mex_c.cpp49
2 files changed, 50 insertions, 0 deletions
diff --git a/include/astra/AstraObjectManager.h b/include/astra/AstraObjectManager.h
index 8b9da30..35b4534 100644
--- a/include/astra/AstraObjectManager.h
+++ b/include/astra/AstraObjectManager.h
@@ -53,6 +53,7 @@ namespace astra {
*/
class CAstraObjectManagerBase {
+public:
virtual std::string getInfo(int index) const =0;
virtual void remove(int index) =0;
virtual std::string getType() const =0;
diff --git a/matlab/mex/astra_mex_c.cpp b/matlab/mex/astra_mex_c.cpp
index fdf4f33..a8623be 100644
--- a/matlab/mex/astra_mex_c.cpp
+++ b/matlab/mex/astra_mex_c.cpp
@@ -36,10 +36,14 @@ $Id$
#include "mexInitFunctions.h"
#include "astra/Globals.h"
+#include "astra/AstraObjectManager.h"
+
#ifdef ASTRA_CUDA
#include "../cuda/2d/darthelper.h"
#include "astra/CompositeGeometryManager.h"
#endif
+
+
using namespace std;
using namespace astra;
@@ -144,6 +148,47 @@ void astra_mex_version(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[
//-----------------------------------------------------------------------------------------
+void astra_mex_info(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
+{
+ if (nrhs < 2) {
+ mexErrMsgTxt("Usage: astra_mex('info', index/indices);\n");
+ return;
+ }
+
+ for (int i = 1; i < nrhs; i++) {
+ int iDataID = (int)(mxGetScalar(prhs[i]));
+ CAstraObjectManagerBase *ptr;
+ ptr = CAstraIndexManager::getSingleton().get(iDataID);
+ if (ptr) {
+ mexPrintf("%s\t%s\n", ptr->getType().c_str(), ptr->getInfo(iDataID).c_str());
+ }
+ }
+
+}
+
+//-----------------------------------------------------------------------------------------
+
+void astra_mex_delete(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
+{
+ if (nrhs < 2) {
+ mexErrMsgTxt("Usage: astra_mex('delete', index/indices);\n");
+ return;
+ }
+
+ for (int i = 1; i < nrhs; i++) {
+ int iDataID = (int)(mxGetScalar(prhs[i]));
+ CAstraObjectManagerBase *ptr;
+ ptr = CAstraIndexManager::getSingleton().get(iDataID);
+ if (ptr)
+ ptr->remove(iDataID);
+ }
+
+}
+
+
+
+//-----------------------------------------------------------------------------------------
+
static void printHelp()
{
mexPrintf("Please specify a mode of operation.\n");
@@ -178,6 +223,10 @@ void mexFunction(int nlhs, mxArray* plhs[],
astra_mex_credits(nlhs, plhs, nrhs, prhs);
} else if (sMode == std::string("set_gpu_index")) {
astra_mex_set_gpu_index(nlhs, plhs, nrhs, prhs);
+ } else if (sMode == std::string("info")) {
+ astra_mex_info(nlhs, plhs, nrhs, prhs);
+ } else if (sMode == std::string("delete")) {
+ astra_mex_delete(nlhs, plhs, nrhs, prhs);
} else {
printHelp();
}