Marsyas
0.6.0-alpha
|
00001 /* 00002 ** Copyright (C) 1998-2006 George Tzanetakis <gtzan@cs.uvic.ca> 00003 ** 00004 ** This program is free software; you can redistribute it and/or modify 00005 ** it under the terms of the GNU General Public License as published by 00006 ** the Free Software Foundation; either version 2 of the License, or 00007 ** (at your option) any later version. 00008 ** 00009 ** This program is distributed in the hope that it will be useful, 00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 ** GNU General Public License for more details. 00013 ** 00014 ** You should have received a copy of the GNU General Public License 00015 ** along with this program; if not, write to the Free Software 00016 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 */ 00018 00033 #ifdef MARSYAS_MATLAB 00034 00035 #if !defined(__MATLABENGINE_H__) 00036 #define __MATLABENGINE_H__ 00037 00038 #include <string> 00039 #include <sstream> 00040 #include <vector> 00041 00042 #include <marsyas/realvec.h> 00043 #include <marsyas/common_header.h> 00044 00045 #include "engine.h" //$(MATLAB)\extern\include 00046 00047 //starting from MATLAB R2006b (version 7.3.0) 00048 //mwSize and mwIndex are defined and must be used. 00049 //However, these typedefs are not defined in previous 00050 //MATLAB versions and must be defined 00051 #if MX_API_VER <= 0x07020000 /* Version 7.2.0 */ 00052 typedef int mwSize; 00053 typedef int mwIndex; 00054 #endif 00055 00056 namespace Marsyas 00057 { 00058 00059 class realvec; 00060 00061 class marsyas_EXPORT MATLABengine 00062 { 00063 private: 00064 Engine *engine_; 00065 static MATLABengine *instance_; 00066 // char *buffer_; 00067 MATLABengine(); 00068 00069 public: 00070 virtual ~MATLABengine(); 00071 00072 static MATLABengine *getMatlabEng(); 00073 void closeMatlabEng(); 00074 void evalString(const std::ostringstream& oss); 00075 00076 //------------------------------------------------ 00077 // setters 00078 //------------------------------------------------ 00079 void putVariable(const std::string value, std::string MATLABname); 00080 void putVariable(const long *const value, unsigned int size, std::string MATLABname); 00081 void putVariable(const float *const value, unsigned int size, std::string MATLABname); 00082 void putVariable(const double *const value, unsigned int size, std::string MATLABname); 00083 00084 void putVariable(mrs_natural value, std::string MATLABname);//OK 00085 void putVariable(mrs_real value, std::string MATLABname);//OK 00086 void putVariable(mrs_complex value, std::string MATLABname);//OK 00087 00088 void putVariable(realvec value, std::string MATLABname);//OK 00089 00090 void putVariable(std::vector<mrs_natural> value, std::string MATLABname); 00091 void putVariable(std::vector<mrs_real> value, std::string MATLABname); 00092 void putVariable(std::vector<mrs_complex> value, std::string MATLABname); 00093 00094 //------------------------------------------------ 00095 // getters 00096 //------------------------------------------------ 00097 int getVariable(std::string MATLABname, mrs_natural& value);//OK 00098 int getVariable(std::string MATLABname, mrs_real& value);//OK 00099 int getVariable(std::string MATLABname, mrs_complex& value);//OK 00100 00101 int getVariable(std::string MATLABname, realvec& value);//OK 00102 00103 int getVariable(std::string MATLABname, std::vector<mrs_natural> &value); 00104 int getVariable(std::string MATLABname, std::vector<mrs_real> &value); 00105 int getVariable(std::string MATLABname, std::vector<mrs_complex> &value); 00106 }; 00107 00108 } //namespace Marsyas 00109 00110 #endif //__MATLABENGINE_H__ 00111 00112 #endif //_MATLAB_ENGINE 00113 00114