Stimfit 0.12.7
src/libstfio/stfio.h
Go to the documentation of this file.
00001 // This program is free software; you can redistribute it and/or
00002 // modify it under the terms of the GNU General Public License
00003 // as published by the Free Software Foundation; either version 2
00004 // of the License, or (at your option) any later version.
00005 
00006 // This program is distributed in the hope that it will be useful,
00007 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00008 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00009 // GNU General Public License for more details.
00010 
00011 // You should have received a copy of the GNU General Public License
00012 // along with this program; if not, write to the Free Software
00013 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00014 
00024 #ifndef _STFIO_H_
00025 #define _STFIO_H_
00026 
00027 #include <iostream>
00028 #include <boost/function.hpp>
00029 #include <vector>
00030 #include <deque>
00031 #include <map>
00032 #include <string>
00033 #include <cmath>
00034 
00035 #ifdef _MSC_VER
00036 #pragma warning( disable : 4251 )  // Disable warning messages
00037 #pragma warning( disable : 4996 )  // Disable warning messages
00038 #endif
00039 
00041 #if defined(_WINDOWS) && !defined(__MINGW32__)
00042     #ifdef STFIODLL
00043         #define StfioDll __declspec( dllexport )
00044     #else
00045         #define StfioDll __declspec( dllimport )
00046     #endif
00047 #else
00048     #define StfioDll
00049 #endif
00050 
00051 typedef std::vector<double > Vector_double;
00052 typedef std::vector<float > Vector_float;
00053 
00054 #ifdef _MSC_VER
00055     #ifndef NAN
00056         static const unsigned long __nan[2] = {0xffffffff, 0x7fffffff};
00057         #define NAN (*(const float *) __nan)
00058     #endif
00059     StfioDll long int lround(double x);
00060 #endif
00061 
00062 #include "./recording.h"
00063 #include "./channel.h"
00064 #include "./section.h"
00065 
00066 /* class Recording; */
00067 /* class Channel; */
00068 /* class Section; */
00069 
00071 
00074 namespace stfio {
00075 
00080     StfioDll Vector_double vec_scal_plus(const Vector_double& vec, double scalar);
00081 
00082     StfioDll Vector_double vec_scal_minus(const Vector_double& vec, double scalar);
00083 
00084     StfioDll Vector_double vec_scal_mul(const Vector_double& vec, double scalar);
00085 
00086     StfioDll Vector_double vec_scal_div(const Vector_double& vec, double scalar);
00087 
00088     StfioDll Vector_double vec_vec_plus(const Vector_double& vec1, const Vector_double& vec2);
00089 
00090     StfioDll Vector_double vec_vec_minus(const Vector_double& vec1, const Vector_double& vec2);
00091 
00092     StfioDll Vector_double vec_vec_mul(const Vector_double& vec1, const Vector_double& vec2);
00093 
00094     StfioDll Vector_double vec_vec_div(const Vector_double& vec1, const Vector_double& vec2);
00095 
00097 
00100  class StfioDll ProgressInfo {
00101  public:
00103 
00108      ProgressInfo(const std::string& title, const std::string& message, int maximum, bool verbose) {};
00109 
00111 
00116      virtual bool Update(int value, const std::string& newmsg="", bool* skip=NULL) = 0;
00117  };
00118 
00119  
00121 
00123 class StfioDll StdoutProgressInfo : public stfio::ProgressInfo {
00124  public:
00125     StdoutProgressInfo(const std::string& title, const std::string& message, int maximum, bool verbose);
00126     bool Update(int value, const std::string& newmsg="", bool* skip=NULL);
00127  private:
00128     bool verbosity;
00129 };
00130 
00132 struct txtImportSettings {
00133   txtImportSettings() : hLines(1),toSection(true),firstIsTime(true),ncolumns(2),
00134         sr(20),yUnits("mV"),yUnitsCh2("pA"),xUnits("ms") {}
00135 
00136     int hLines;            
00137     bool toSection;        
00138     bool firstIsTime;      
00139     int ncolumns;          
00140     double sr;             
00141     std::string yUnits;    
00142     std::string yUnitsCh2; 
00143     std::string xUnits;    
00144 };
00145 
00147 enum filetype {
00148     atf,    
00149     abf,    
00150     axg,    
00151     ascii,  
00152     cfs,    
00153     igor,   
00154     son,    
00155     hdf5,   
00156     heka,   
00157 #ifdef WITH_BIOSIG
00158     biosig, 
00159 #endif
00160     none    
00161 };
00162 
00163   
00165 
00168 StfioDll stfio::filetype
00169 findType(const std::string& ext);
00170 
00172 
00179 StfioDll bool 
00180 importFile(
00181         const std::string& fName,
00182         stfio::filetype type,
00183         Recording& ReturnData,
00184         const stfio::txtImportSettings& txtImport,
00185         stfio::ProgressInfo& progDlg
00186 );
00187 
00189 
00195 StfioDll bool
00196 exportFile(const std::string& fName, stfio::filetype type, const Recording& Data,
00197            ProgressInfo& progDlg);
00198 
00201 } // end of namespace
00202 
00203 typedef std::vector< std::string        >::iterator       sst_it;      
00204 typedef std::vector< std::string        >::const_iterator c_sst_it;    
00205 typedef std::vector< std::size_t     >::const_iterator c_st_it;     
00206 typedef std::vector< int             >::iterator       int_it;      
00207 typedef std::vector< int             >::const_iterator c_int_it;    
00208 typedef std::vector< Channel         >::iterator       ch_it;       
00209 typedef std::vector< Channel         >::const_iterator c_ch_it;     
00210 typedef std::vector< Section         >::iterator       sec_it;      
00211 typedef std::vector< Section         >::const_iterator c_sec_it;    
00213 #endif