summaryrefslogtreecommitdiffstats
path: root/matlab
diff options
context:
space:
mode:
authorWillem Jan Palenstijn <wjp@usecode.org>2018-10-23 12:20:18 +0200
committerGitHub <noreply@github.com>2018-10-23 12:20:18 +0200
commiteb97daad97596d54e0da8987ef1c5b1dd91c124f (patch)
treee0f98656f13716b42898c6aefd8abbcc7353d4bc /matlab
parent6730face204f40c57c3e8fe58ea9749494d669a6 (diff)
parent03ff113ac48f21956247b164a83000b5f6ab311d (diff)
downloadastra-eb97daad97596d54e0da8987ef1c5b1dd91c124f.tar.gz
astra-eb97daad97596d54e0da8987ef1c5b1dd91c124f.tar.bz2
astra-eb97daad97596d54e0da8987ef1c5b1dd91c124f.tar.xz
astra-eb97daad97596d54e0da8987ef1c5b1dd91c124f.zip
Merge pull request #170 from wjp/feature_flags
Add support for checking features at run-time
Diffstat (limited to 'matlab')
-rw-r--r--matlab/mex/astra_mex_algorithm_c.cpp2
-rw-r--r--matlab/mex/astra_mex_c.cpp38
-rw-r--r--matlab/mex/astra_mex_data3d_c.cpp2
-rw-r--r--matlab/mex/astra_mex_direct_c.cpp2
-rw-r--r--matlab/mex/mexDataManagerHelpFunctions.cpp2
-rw-r--r--matlab/mex/mexHelpFunctions.h6
6 files changed, 41 insertions, 11 deletions
diff --git a/matlab/mex/astra_mex_algorithm_c.cpp b/matlab/mex/astra_mex_algorithm_c.cpp
index 80c0424..7804eeb 100644
--- a/matlab/mex/astra_mex_algorithm_c.cpp
+++ b/matlab/mex/astra_mex_algorithm_c.cpp
@@ -34,8 +34,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
#include "mexInitFunctions.h"
#include "astra/Globals.h"
-#define USE_MATLAB_UNDOCUMENTED
-
#ifdef USE_MATLAB_UNDOCUMENTED
extern "C" { bool utIsInterruptPending(); }
diff --git a/matlab/mex/astra_mex_c.cpp b/matlab/mex/astra_mex_c.cpp
index f494ce6..43c438e 100644
--- a/matlab/mex/astra_mex_c.cpp
+++ b/matlab/mex/astra_mex_c.cpp
@@ -35,6 +35,7 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
#include "mexInitFunctions.h"
#include "astra/Globals.h"
+#include "astra/Features.h"
#include "astra/AstraObjectManager.h"
#ifdef ASTRA_CUDA
@@ -132,6 +133,7 @@ void astra_mex_set_gpu_index(int nlhs, mxArray* plhs[], int nrhs, const mxArray*
#endif
}
+//-----------------------------------------------------------------------------------------
/** get_gpu_info = astra_mex('get_gpu_info');
*
* Get GPU info
@@ -149,6 +151,38 @@ void astra_mex_get_gpu_info(int nlhs, mxArray* plhs[], int nrhs, const mxArray*
//-----------------------------------------------------------------------------------------
+/** has_feature = astra_mex('has_feature');
+ *
+ * Check a feature flag. See include/astra/Features.h.
+ */
+void astra_mex_has_feature(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[])
+{
+ if (2 > nrhs) {
+ mexErrMsgTxt("Usage: astra_mex('has_feature', feature);\n");
+ return;
+ }
+
+ string sMode = mexToString(prhs[0]);
+ bool ret = false;
+
+ // NB: When adding features here, also document them centrally in
+ // include/astra/Features.h
+ if (sMode == "mex_link") {
+#ifdef USE_MATLAB_UNDOCUMENTED
+ ret = true;
+#else
+ ret = false;
+#endif
+ } else {
+ ret = astra::hasFeature(sMode);
+ }
+
+ plhs[0] = mxCreateDoubleScalar(ret ? 1 : 0);
+}
+
+
+
+//-----------------------------------------------------------------------------------------
/** version_number = astra_mex('version');
*
* Fetch the version number of the toolbox.
@@ -208,7 +242,7 @@ void astra_mex_delete(int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]
static void printHelp()
{
mexPrintf("Please specify a mode of operation.\n");
- mexPrintf(" Valid modes: version, use_cuda, credits, set_gpu_index, info, delete\n");
+ mexPrintf(" Valid modes: version, use_cuda, credits, set_gpu_index, has_feature, info, delete\n");
}
//-----------------------------------------------------------------------------------------
@@ -241,6 +275,8 @@ void mexFunction(int nlhs, mxArray* plhs[],
astra_mex_set_gpu_index(nlhs, plhs, nrhs, prhs);
} else if (sMode == std::string("get_gpu_info")) {
astra_mex_get_gpu_info(nlhs, plhs, nrhs, prhs);
+ } else if (sMode == std::string("has_feature")) {
+ astra_mex_has_feature(nlhs, plhs, nrhs, prhs);
} else if (sMode == std::string("info")) {
astra_mex_info(nlhs, plhs, nrhs, prhs);
} else if (sMode == std::string("delete")) {
diff --git a/matlab/mex/astra_mex_data3d_c.cpp b/matlab/mex/astra_mex_data3d_c.cpp
index 5504955..4642693 100644
--- a/matlab/mex/astra_mex_data3d_c.cpp
+++ b/matlab/mex/astra_mex_data3d_c.cpp
@@ -55,8 +55,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
using namespace std;
using namespace astra;
-#define USE_MATLAB_UNDOCUMENTED
-
//-----------------------------------------------------------------------------------------
/**
* id = astra_mex_io_data('create', datatype, geometry, data);
diff --git a/matlab/mex/astra_mex_direct_c.cpp b/matlab/mex/astra_mex_direct_c.cpp
index 1a129f4..0090d13 100644
--- a/matlab/mex/astra_mex_direct_c.cpp
+++ b/matlab/mex/astra_mex_direct_c.cpp
@@ -54,8 +54,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
using namespace std;
using namespace astra;
-#define USE_MATLAB_UNDOCUMENTED
-
class CFloat32CustomMemory_simple : public astra::CFloat32CustomMemory {
public:
diff --git a/matlab/mex/mexDataManagerHelpFunctions.cpp b/matlab/mex/mexDataManagerHelpFunctions.cpp
index a71928b..dc225ac 100644
--- a/matlab/mex/mexDataManagerHelpFunctions.cpp
+++ b/matlab/mex/mexDataManagerHelpFunctions.cpp
@@ -36,8 +36,6 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
#include "astra/Float32VolumeData3DMemory.h"
#include "astra/Float32ProjectionData3DMemory.h"
-#define USE_MATLAB_UNDOCUMENTED
-
#ifdef USE_MATLAB_UNDOCUMENTED
extern "C" {
mxArray *mxCreateSharedDataCopy(const mxArray *pr);
diff --git a/matlab/mex/mexHelpFunctions.h b/matlab/mex/mexHelpFunctions.h
index bf22929..56994dc 100644
--- a/matlab/mex/mexHelpFunctions.h
+++ b/matlab/mex/mexHelpFunctions.h
@@ -28,6 +28,10 @@ along with the ASTRA Toolbox. If not, see <http://www.gnu.org/licenses/>.
#ifndef _INC_ASTRA_MEX_HELPFUNCTIONS
#define _INC_ASTRA_MEX_HELPFUNCTIONS
+
+#define USE_MATLAB_UNDOCUMENTED
+
+
#include <string>
#include <list>
#include <iostream>
@@ -66,6 +70,4 @@ mxArray* XMLNodeToStruct(astra::XMLNode xml);
mxArray* stringToMxArray(std::string input);
mxArray* buildStruct(std::map<std::string, mxArray*> mInput);
-
-
#endif