[med-svn] [SCM] aghermann branch, master, updated. 99b1d5a023eee9df74b0e0d6f894516fc79435ad

Andrei Zavada johnhommer at gmail.com
Sun Jul 7 23:04:02 UTC 2013


The following commit has been merged in the master branch:
commit 5c9a408766068fd85b81839fd46775a5bdf35dc9
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Tue Jun 25 20:22:01 2013 +0300

    WIP

diff --git a/src/libsigfile/edf.hh b/src/libsigfile/edf.hh
index a8ba074..d1ec3d6 100644
--- a/src/libsigfile/edf.hh
+++ b/src/libsigfile/edf.hh
@@ -81,11 +81,11 @@ class CEDFFile
 	// open existing
 	CEDFFile (const string& fname, int flags = 0);
 	// create new
-	CEDFFile (const string& fname, TSubtype subtype_, int flags,
-		  const list<pair<SChannel, size_t>>& channels,
+	CEDFFile (const string& fname, TSubtype, int flags,
+		  const list<pair<SChannel, size_t>>&,
 		  size_t data_record_size = 1,
 		  size_t n_data_records = 0);
-	CEDFFile (CEDFFile&& rv);
+	CEDFFile (CEDFFile&&);
       // dtor
        ~CEDFFile ();
 
diff --git a/src/libsigfile/source-base.hh b/src/libsigfile/source-base.hh
index a0d77e8..80a9c90 100644
--- a/src/libsigfile/source-base.hh
+++ b/src/libsigfile/source-base.hh
@@ -390,14 +390,8 @@ class CSource {
 	get_real_original_signal_range( int) const = 0;
 
 	virtual pair<TFloat, TFloat>
-	get_max_original_signal_range( int) const = 0;
-
-	virtual pair<TFloat, TFloat>
 	get_real_filtered_signal_range( int) const = 0;
 
-	virtual pair<TFloat, TFloat>
-	get_max_filtered_signal_range( int) const = 0;
-
       // export
 	virtual int
 	export_original( int, const string& fname) const = 0;
diff --git a/src/libsigfile/source.cc b/src/libsigfile/source.cc
index e68b6b0..5d5d278 100644
--- a/src/libsigfile/source.cc
+++ b/src/libsigfile/source.cc
@@ -11,28 +11,38 @@
 
 
 #include "source.hh"
+#include "edf.hh"
+#include "tsv.hh"
 
 using namespace std;
 
-sigfile::CTypedSource::
+using sigfile::CSource;
+using sigfile::CTypedSource;
+using sigfile::CTSVFile;
+using sigfile::CEDFFile;
+
+
+CTypedSource::
 CTypedSource (const string& fname,
 	      const size_t pagesize,
 	      const int flags)
       : CHypnogram (pagesize)
 {
 	switch ( _type = source_file_type(fname) ) {
-	case TType::bin:
-		throw invalid_argument ("Source type 'bin' not yet supported");
 	case TType::ascii:
-		throw invalid_argument ("Source type 'ascii' not yet supported");
+		_obj = new CTSVFile( fname, flags);
+		break;
 	case TType::edf:
 		_obj = new CEDFFile( fname, flags);
 		break;
+
+	case TType::bin:
+		throw invalid_argument ("Source type 'bin' not supported");
 	case TType::unrecognised:
 		throw invalid_argument ("Unrecognised source type");
 	}
 
-	if ( flags | ~no_ancillary_files ) {
+	if ( flags | ~CSource::no_ancillary_files ) {
 		// CHypnogram::
 		CHypnogram::load( sigfile::make_fname_hypnogram(fname, pagesize));
 		size_t scorable_pages = ceil( _obj->recording_time() / pagesize);
@@ -48,33 +58,36 @@ CTypedSource (const string& fname,
 
 
 
-sigfile::CTypedSource::
+CTypedSource::
 CTypedSource (CTypedSource&& rv)
       : CHypnogram (move(rv))
 {
 	switch ( _type = rv._type ) {
-	case TType::bin:
-		throw invalid_argument ("Source type 'bin' not yet supported");
 	case TType::ascii:
-		throw invalid_argument ("Source type 'ascii' not yet supported");
+		_obj = new CTSVFile( move(*static_cast<CTSVFile*>(rv._obj)));
+		break;
 	case TType::edf:
-		_obj = new CEDFFile( move(*(CEDFFile*)rv._obj));
+		_obj = new CEDFFile( move(*static_cast<CEDFFile*>(rv._obj)));
 		break;
+
+	case TType::bin:
+		throw invalid_argument ("Source type 'bin' not yet supported");
 	case TType::unrecognised:
 		throw invalid_argument ("Unrecognised source type");
 	default:
 		throw invalid_argument ("Bad source type");
 	}
+
 	delete rv._obj;
 	rv._obj = nullptr;
 }
 
 
-sigfile::CTypedSource::
+CTypedSource::
 ~CTypedSource ()
 {
 	if ( _obj ) {
-		if ( not (_obj->_flags & no_ancillary_files) )
+		if ( not (_obj->_flags & CSource::no_ancillary_files) )
 			CHypnogram::save( make_fname_hypnogram());
 		delete _obj;
 	}
@@ -82,12 +95,19 @@ sigfile::CTypedSource::
 
 
 
-sigfile::CTypedSource::TType
-sigfile::CTypedSource::
+CTypedSource::TType
+CTypedSource::
 source_file_type( const string& fname)
 {
-	if ( fname.size() > 4 && strcasecmp( &fname[fname.size()-4], ".edf") == 0 )
+	if ( fname.size() > 4 &&
+	     strcasecmp( &fname[fname.size()-4], ".edf") == 0 )
 		return TType::edf;
+
+	if ( fname.size() > 4 &&
+	     (strcasecmp( &fname[fname.size()-4], ".tsv") == 0 ||
+	      strcasecmp( &fname[fname.size()-4], ".csv") == 0 ) )
+		return TType::ascii;
+
 	return TType::unrecognised;
 }
 
diff --git a/src/libsigfile/source.hh b/src/libsigfile/source.hh
index 191fb9f..a160cae 100644
--- a/src/libsigfile/source.hh
+++ b/src/libsigfile/source.hh
@@ -13,8 +13,6 @@
 #define AGH_SIGFILE_SOURCE_H_
 
 #include "source-base.hh"
-#include "edf.hh"
-//#include "other.hh"
 #include "page.hh"
 
 #if HAVE_CONFIG_H && !defined(VERSION)
diff --git a/src/libsigfile/tsv.hh b/src/libsigfile/tsv.hh
index 9152c47..850de99 100644
--- a/src/libsigfile/tsv.hh
+++ b/src/libsigfile/tsv.hh
@@ -67,22 +67,19 @@ class CTSVFile
 		{ return subtype_s( _subtype); }
 
       // ctor
-	CTSVFile( const CTSVFile&)
+	CTSVFile (const CTSVFile&)
 	      : CSource("")
 		{
 			throw invalid_argument("nono");
 		}
-	enum TFlags {
-		no_field_consistency_check	= 1<<5,
-	};
 	// open existing
 	CTSVFile (const string& fname, int flags = 0);
 	// create new
 	CTSVFile (const string& fname, TSubtype, int flags,
-		  const list<pair<SChannel, size_t>>& channels,
-		  size_t data_record_size = 1,
-		  size_t n_data_records = 0);
-	CTSVFile (CTSVFile&& rv);
+		  const list<SChannel>&,
+		  const size_t samplerate_,
+		  const double recording_time_);
+	CTSVFile (CTSVFile&&);
       // dtor
        ~CTSVFile ();
 

-- 
Sleep experiment manager



More information about the debian-med-commit mailing list