diff options
author | Daniel M. Pelt <D.M.Pelt@cwi.nl> | 2015-03-13 17:12:42 +0100 |
---|---|---|
committer | Daniel M. Pelt <D.M.Pelt@cwi.nl> | 2015-03-13 17:12:42 +0100 |
commit | f21700e00e81538d5510973a51b8ae97fb4a24dd (patch) | |
tree | d1dcd07f2a29243e279fe2915c5db7814e99ea13 /matlab/mex/mexInitFunctions.cpp | |
parent | e4614cf09b90cc9a0e38d370bb090a11f3877b33 (diff) | |
download | astra-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.cpp | 24 |
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; +} |