[med-svn] [SCM] aghermann branch, master, updated. 4b06a66467a52311d413e817136ece62c0e9c24a

andrei zavada jh at johnhommer.com
Sun Jul 21 19:56:31 UTC 2013


The following commit has been merged in the master branch:
commit 40d2e7a25e8638ffaa654d6bfabc7677256a9ecf
Author: andrei zavada <jh at johnhommer.com>
Date:   Mon Jul 15 07:58:30 2013 +0000

    CTSVFile: straighten use of metadata

diff --git a/src/libsigfile/tsv.cc b/src/libsigfile/tsv.cc
index ea43951..b4799ce 100644
--- a/src/libsigfile/tsv.cc
+++ b/src/libsigfile/tsv.cc
@@ -39,9 +39,9 @@ set_start_time( time_t s)
 {
 	char b[9];
 	strftime( b, 9, "%d.%m.%y", localtime(&s));
-	_recording_date.assign( b);
+	metadata["recording_date"].assign( b);
 	strftime( b, 9, "%H.%M.%s", localtime(&s));
-	_recording_time.assign( b);
+	metadata["recording_time"].assign( b);
 
 	return 0;
 }
@@ -120,13 +120,8 @@ CTSVFile::
 CTSVFile (CTSVFile&& rv)
       : CSource (move(rv))
 {
-	swap( _patient_id,   rv._patient_id);
-	swap( _recording_id, rv._recording_id);
-	swap( _recording_date, rv._recording_date);
-	swap( _recording_time, rv._recording_time);
 	swap( _episode,    rv._episode);
 	swap( _session,    rv._session);
-	swap( _comment, rv._comment);
 
 	swap( metadata, rv.metadata);
 
@@ -189,14 +184,15 @@ _parse_header()
 		_status |= (nosession | noepisode);
 		return -1;
 	}
-	_recording_id = metadata["recording_id"];
 
 	if ( metadata.find( "patient_id") == metadata.end() ) {
 		fprintf( stderr, "No patient_id in header\n");
-		_status |= (nosession | noepisode);
+		_status |= CSource::missing_patient_id;;
 		return -1;
 	}
-	_patient_id = metadata["patient_id"];
+
+	if ( metadata.find( "comment") == metadata.end() )
+		;
 
 	if ( metadata.find( "samplerate") == metadata.end() ||
 	     (_samplerate = stoi( metadata["samplerate"])) > 2048 ) {
diff --git a/src/libsigfile/tsv.hh b/src/libsigfile/tsv.hh
index b996238..6f23a2f 100644
--- a/src/libsigfile/tsv.hh
+++ b/src/libsigfile/tsv.hh
@@ -91,11 +91,20 @@ class CTSVFile
 
 	// identification
 	const char* patient_id() const
-		{ return _patient_id.c_str(); }
+		{
+			const auto I = metadata.find("patient_id");
+			return (I == metadata.end()) ? "" : I->c_str();
+		}
 	const char* recording_id() const
-		{ return _recording_id.c_str(); }
+		{
+			const auto I = metadata.find("recording_id");
+			return (I == metadata.end()) ? "" : I->c_str();
+		}
 	const char* comment() const
-		{ return _comment.c_str(); }
+		{
+			const auto I = metadata.find("comment");
+			return (I == metadata.end()) ? "" : I->c_str();
+		}
 	const char* episode() const
 		{ return _episode.c_str(); }
 	const char* session() const
@@ -112,14 +121,20 @@ class CTSVFile
 	// setters
 	int set_patient_id( const string& s)
 		{
-			_patient_id = s;
+			metadata["patient_id"] = s;
 			return 0;
 		}
 	int set_recording_id( const string& s)
 		{
-			_recording_id = s;
+			metadata["recording_id"] = s;
+			return 0;
+		}
+	int set_comment( const string& s)
+		{
+			metadata["comment"] = s;
 			return 0;
 		}
+
 	int set_episode( const string& s) // assigning to _episode or _session directly won't have a lasting effect; think again.
 		{
 			_episode = s;
@@ -130,11 +145,6 @@ class CTSVFile
 			_session = s;
 			return 0;
 		}
-	int set_comment( const string& s)
-		{
-			_comment = s;
-			return 0;
-		}
 
 	int set_start_time( time_t);
 
@@ -335,13 +345,7 @@ class CTSVFile
 	static string explain_status( int);
 
     private:
-      // header... why is it private?
-	string	_patient_id,
-		_recording_id,
-		_recording_date,
-		_recording_time,
-		_comment;
-
+      // header...
 	string	_episode,
 		_session;
 

-- 
Sleep experiment manager



More information about the debian-med-commit mailing list