summaryrefslogtreecommitdiffstats
path: root/matlab/mex/mexInitFunctions.cpp
diff options
context:
space:
mode:
authorDaniel M. Pelt <D.M.Pelt@cwi.nl>2015-03-13 17:12:42 +0100
committerDaniel M. Pelt <D.M.Pelt@cwi.nl>2015-03-13 17:12:42 +0100
commitf21700e00e81538d5510973a51b8ae97fb4a24dd (patch)
treed1dcd07f2a29243e279fe2915c5db7814e99ea13 /matlab/mex/mexInitFunctions.cpp
parente4614cf09b90cc9a0e38d370bb090a11f3877b33 (diff)
downloadastra-f21700e00e81538d5510973a51b8ae97fb4a24dd.tar.gz
astra-f21700e00e81538d5510973a51b8ae97fb4a24dd.tar.bz2
astra-f21700e00e81538d5510973a51b8ae97fb4a24dd.tar.xz
astra-f21700e00e81538d5510973a51b8ae97fb4a24dd.zip
Enable logging to Matlab window using callback function
Also introduces a mex initialize function that is called at the first invocation of any mex method.
Diffstat (limited to 'matlab/mex/mexInitFunctions.cpp')
-rw-r--r--matlab/mex/mexInitFunctions.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/matlab/mex/mexInitFunctions.cpp b/matlab/mex/mexInitFunctions.cpp
new file mode 100644
index 0000000..d8a50d7
--- /dev/null
+++ b/matlab/mex/mexInitFunctions.cpp
@@ -0,0 +1,24 @@
+#include <mex.h>
+#include "astra/Logging.h"
+
+bool mexIsInitialized=false;
+
+/**
+ * Callback to print log message to Matlab window.
+ *
+ */
+void logCallBack(const char *msg, size_t len){
+ mexPrintf(msg);
+}
+
+/**
+ * Initialize mex functions.
+ *
+ */
+void initASTRAMex(){
+ if(mexIsInitialized) return;
+ if(!astra::CLogger::setCallbackScreen(&logCallBack)){
+ mexErrMsgTxt("Error initializing mex functions.");
+ }
+ mexIsInitialized=true;
+}