From d86ffb3a506c3ae7f809c6a26e22df98ddf37549 Mon Sep 17 00:00:00 2001 From: Sean Stangl Date: Wed, 9 Apr 2014 12:39:03 -0700 Subject: [PATCH] Store EDFSignal memory in a linear vector. Signed-off-by: Mark Watkins --- .../SleepLib/loader_plugins/resmed_loader.cpp | 57 ++++++++++--------- .../SleepLib/loader_plugins/resmed_loader.h | 2 +- 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp b/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp index 10a44dc0..98c57600 100644 --- a/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp +++ b/sleepyhead/SleepLib/loader_plugins/resmed_loader.cpp @@ -71,10 +71,9 @@ EDFParser::EDFParser(QString name) } EDFParser::~EDFParser() { - QVector::iterator s; + QVector::iterator s; for (s=edfsignals.begin();s!=edfsignals.end();s++) { - if ((*s)->data) delete [] (*s)->data; - delete *s; + if ((*s).data) delete [] (*s).data; } if (buffer) delete [] buffer; } @@ -162,35 +161,37 @@ bool EDFParser::Parse() // this could be loaded quicker by transducer_type[signal] etc.. - for (int i=0;idata=NULL; - edfsignals[i]->label=Read(16); - lookup[edfsignals[i]->label]=signal; + // Initialize fixed-size signal list. + edfsignals.resize(num_signals); + + for (int i = 0; i < num_signals; i++) { + EDFSignal &signal = edfsignals[i]; + signal.data = NULL; + signal.label = Read(16); + lookup[signal.label] = &signal; // Safe: edfsignals won't move. } - for (int i=0;itransducer_type=Read(80); + for (int i=0;iphysical_dimension=Read(8); - for (int i=0;iphysical_minimum=Read(8).toDouble(&ok); - for (int i=0;iphysical_maximum=Read(8).toDouble(&ok); - for (int i=0;idigital_minimum=Read(8).toDouble(&ok); + for (int i=0;iprefiltering=Read(80); - for (int i=0;inr=Read(8).toLong(&ok); - for (int i=0;ireserved=Read(32); + for (int i=0;ilabel << endl; - EDFSignal & sig=*edfsignals[i]; + EDFSignal &sig = edfsignals[i]; long recs=sig.nr * num_data_records; if (num_data_records<0) @@ -201,7 +202,7 @@ bool EDFParser::Parse() for (int x=0;xAddEventList(CPAP_Apnea,EVL_Event); for (int s=0;snr*edf.GetNumDataRecords()*2; + recs=edf.edfsignals[s].nr*edf.GetNumDataRecords()*2; - data=(char *)edf.edfsignals[s]->data; + data=(char *)edf.edfsignals[s].data; pos=0; tt=edf.startdate; sess->updateFirst(tt); @@ -1854,7 +1855,7 @@ bool ResmedLoader::LoadBRP(Session *sess,EDFParser &edf) sess->updateLast(edf.startdate+duration); for (int s=0;slabel; + qDebug() << "Unobserved ResMed BRP Signal " << es.label; continue; } double rate=double(duration)/double(recs); @@ -2021,7 +2022,7 @@ bool ResmedLoader::LoadSAD(Session *sess,EDFParser &edf) sess->updateLast(edf.startdate+duration); for (int s=0;slabel; + qDebug() << "Unobserved ResMed SAD Signal " << es.label; continue; } bool hasdata=false; @@ -2074,7 +2075,7 @@ bool ResmedLoader::LoadPLD(Session *sess,EDFParser &edf) ChannelID code; for (int s=0;s edfsignals; + QVector edfsignals; //! \brief An by-name indexed into the EDFSignal data QHash lookup;