Codebase list libgdf / ac0e65e
Import upstream version 0.1.3+git20210707.1.39e9cfb Debian Janitor 2 years ago
23 changed file(s) with 408 addition(s) and 74 deletion(s). Raw diff Collapse all Expand all
0 name: CMake
1
2 on:
3 push:
4 branches: [ master ]
5 pull_request:
6 branches: [ master ]
7
8 env:
9 # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
10 BUILD_TYPE: Release
11
12 jobs:
13 build:
14 # The CMake configure and build commands are platform agnostic and should work equally
15 # well on Windows or Mac. You can convert this to a matrix build if you need
16 # cross-platform coverage.
17 # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
18 runs-on: ubuntu-latest
19
20 steps:
21 - uses: actions/checkout@v2
22
23 - name: Install Dependencies
24 run: sudo apt-get update && sudo apt-get install -yq libboost-all-dev
25
26 - name: Configure CMake
27 # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
28 # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
29 run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTING=yes
30
31 - name: Build
32 # Build your program with the given configuration
33 run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
34
35 - name: Test
36 working-directory: ${{github.workspace}}/build
37 # Execute tests defined by the CMake configuration.
38 # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
39 run: ctest -C ${{env.BUILD_TYPE}}
40
0
1 os: linux
2 arch:
3 - amd64
4 - ppc64le
5 language: cpp
6
7 compiler:
8 - gcc
9 - clang
10
11 before_install:
12 - sudo apt-get update -qq
13 - sudo apt-get install libboost-all-dev
14
15 script:
16 - mkdir build
17 - cd build
18 - cmake .. -DBUILD_TESTING=yes
19 - make
20 - make test
1919
2020 # Make sure the version is in sync with
2121 # libgdf/include/GDF/Version.h
22 set(GDF_VERSION "0.1.3")
22 set(GDF_VERSION "0.1.4")
2323
2424 # shared library API versioning (soversion) -- NOT the same as the release version
2525 # it follows first number
+0
-29
README less more
0 #
1 # This file is part of libGDF.
2 #
3 # libGDF is free software: you can redistribute it and/or modify
4 # it under the terms of the GNU Lesser General Public License as
5 # published by the Free Software Foundation, either version 3 of
6 # the License, or (at your option) any later version.
7 #
8 # libGDF is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public License
14 # along with libGDF. If not, see <http://www.gnu.org/licenses/>.
15 #
16 # Copyright 2010 Martin Billinger
17
18
19 A. Build Instructions (out of source build)
20
21 replace $GDF_ROOT with the (relative or absolute) path to the source
22 tree (e.g. ~/SVN/GDF/trunk).
23
24 > mkdir build
25 > cd build
26 > cmake $GDF_ROOT
27 > make
28 > make check
0 [![Build Status](https://travis-ci.org/mbillingr/libgdf.svg?branch=master)](https://travis-ci.com/mbillingr/libgdf)
1 [![CMake](https://github.com/mbillingr/libgdf/actions/workflows/cmake.yml/badge.svg)](https://github.com/mbillingr/libgdf/actions/workflows/cmake.yml)
2
3 libGDF
4 ======
5
6 C++ implementation of GDF - "a general dataformat for biosignals" version V2.20.
7
8 Obtaining libGDF
9 ----------------
10
11 Use the following command to fetch the sources:
12
13 git clone https://github.com/kazemakase/libgdf.git libgdf
14
15 Dependencies
16 ------------
17 Required: boost
18
19 Build Instructions
20 ------------------
21
22 The preferred method is to perform an out-of-source build.
23 Replace `$GDF_ROOT` with the (relative or absolute) path to the source
24 tree (e.g. ~/repositories/libgdf).
25
26 mkdir build
27 cd build
28 cmake $GDF_ROOT -DBUILD_TESTING=yes
29 make
30 make test
00
11
2 Development Head
2 Development Head (0.1.4)
33 ===================
44
55 Version 0.1.3
99 epoch=
1010 pkgdesc="C++ implementation of GDF, the general dataformat for biosignals"
1111 arch=('i686' 'x86_64')
12 url="http://sourceforge.net/projects/libgdf/"
12 url="http://github.com/kazemakase/libgdf/"
1313 license=('LGPL')
1414 groups=()
1515 depends=(boost-libs)
2727 noextract=()
2828 md5sums=() #generate with 'makepkg -g'
2929
30 _gitroot='git://libgdf.git.sourceforge.net/gitroot/libgdf/libgdf'
30 _gitroot='https://github.com/kazemakase/libgdf.git'
3131 _gitname='libgdf'
3232
3333 build() {
3030 /// using the flag 0x8000 which marks the type of mode 1 stop events
3131 /// @throws general if events could not be converted
3232 std::vector<Mode3Event> convertMode1EventsIntoMode3Events (std::vector<Mode1Event>
33 const& mode_1_events)
34 throw (exception::general);
33 const& mode_1_events);
3534 }
3635
3736 #endif
124124 inline size_t getNumFullRecords( ) const { return m_num_full; }
125125
126126 /// Get number of partially filled records currently in the list.
127 inline size_t getNumPartialRecords( ) const { return m_records.size( ); }
127 inline size_t getNumPartialRecords( ) const { return m_num_recs; }
128128
129129 /// Returns reference to channel specified by channel_idx
130130 /** If channel does not exist gdf::nonexistent_channel_access::nonexistent_channel_access is thrown.
144144 PointerPool<Record> *m_pool;
145145 std::list< Record* > m_records;
146146 std::list< Record* > m_records_full;
147 size_t m_num_full;
147 size_t m_num_full, m_num_recs;
148148 std::vector< std::list< Record* >::iterator > m_channelhead;
149149 std::list<RecordFullHandler*> m_recfull_callbacks;
150150 };
3535 {
3636 public:
3737 /// Constructor
38 TagField( uint8 tag );
38 TagField( uint8 tag=0 );
3939
4040 /// Destructor
4141 virtual ~TagField( );
2020
2121 #include "Exceptions.h"
2222 #include <boost/cstdint.hpp>
23 #include <boost/detail/endian.hpp>
23 #include <boost/predef/other/endian.h>
2424 #include <iostream>
2525
2626 namespace gdf
7373 template<typename T>
7474 void writeLittleEndian( std::ostream &out, T item )
7575 {
76 #if defined(BOOST_LITTLE_ENDIAN)
76 #if BOOST_ENDIAN_LITTLE_BYTE
7777 out.write( reinterpret_cast<const char*>(&item), sizeof(item) );
78 #elif defined(BOOST_BIG_ENDIAN)
78 #elif BOOST_ENDIAN_BIG_BYTE
7979 const char* p = reinterpret_cast<const char*>(&item) + sizeof(item)-1;
8080 for( size_t i=0; i<sizeof(item); i++ )
8181 out.write( p--, 1 );
8787 template<typename T>
8888 void readLittleEndian( std::istream &in, T &item )
8989 {
90 #if defined(BOOST_LITTLE_ENDIAN)
90 #if BOOST_ENDIAN_LITTLE_BYTE
9191 in.read( reinterpret_cast<char*>(&item), sizeof(item) );
92 #elif defined(BOOST_BIG_ENDIAN)
92 #elif BOOST_ENDIAN_BIG_BYTE
9393 char* p = reinterpret_cast<char*>(&item) + sizeof(item)-1;
9494 for( size_t i=0; i<sizeof(item); i++ )
9595 in.read( p--, 1 );
2020
2121 // Current library version
2222 // Must be the same as in the top level CMakeLists.txt
23 #define GDF_VERSION "0.1.3"
23 #define GDF_VERSION "0.1.4"
2424
2525
2626 #endif
3333
3434 //-------------------------------------------------------------------------
3535 vector<Mode3Event> convertMode1EventsIntoMode3Events (vector<Mode1Event> const& mode_1_events)
36 throw (exception::general)
3736 {
3837 vector<Mode3Event> mode_3_events;
3938
195195 {
196196 desc = "";
197197 int i =0;
198 while( value[pos+i] != 0 && (pos+i < tagfieldlength)) {
198 while( (pos + i < tagfieldlength) && value[pos+i] != 0 ) {
199199 desc.push_back(value[pos+i]);
200200 i++;
201201 }
1717
1818 #include "GDF/EventHeader.h"
1919 #include "GDF/Exceptions.h"
20 #include <math.h>
2021 #include <algorithm>
2122 #include <iostream>
2223 #include <sstream>
2222 #include <boost/numeric/conversion/cast.hpp>
2323 #include <list>
2424 #include <string>
25 //#include <iostream>
26
27 const double epsilon_d = 1e-15;
28 const double epsilon_f = 1e-15;
29 const double epsilon_i = 1;
3025
3126
3227 namespace gdf
402397 hdr.getTagHeader_readonly( ).toStream( out );
403398 uint16 header3LenBlocks = mh->get_header_length() - (1+ns);
404399 assert( out.tellp() == std::streampos(256+256*ns+256*header3LenBlocks));
400 (void)header3LenBlocks; // To prevent -Werror=unused-variable in a release build.
405401
406402 return out;
407403 }
416412 MainHeader *mh = &hdr.m_mainhdr;
417413 mh->version_id.fromstream( in );
418414 int gdf_version_int = mh->getGdfVersionInt();
415 #ifdef ALLOW_GDF_V_251
416 if (gdf_version_int < 210 || gdf_version_int > 251)
417 #else
419418 if (gdf_version_int < 210 || gdf_version_int > 220)
419 #endif
420420 throw exception::incompatible_gdf_version (mh->get_version_id ());
421
421422 mh->patient_id.fromstream( in );
422423 mh->reserved_1.fromstream( in );
423424 mh->patient_drugs.fromstream( in );
483484 {
484485 case 0:
485486 break;
487 #ifdef ALLOW_GDF_V_251
488 default:
489 evd.fromTagField(tagfield);
490 taghdr.setEventDescriptor(evd);
491 break;
492 #else
486493 case 1:
487494 evd.fromTagField(tagfield);
488495 taghdr.setEventDescriptor(evd);
490497 default:
491498 throw exception::feature_not_implemented("Only tag==1 is supported in this build");
492499 break;
500 #endif
493501 }
494502 }
495503 taghdr.setLength();
103103 {
104104 delete m_record_cache[i];
105105 m_record_cache[i] = NULL;
106 m_record_changed[i] = NULL;
106 m_record_changed[i] = false;
107107 }
108108 }
109109 }
6666 {
6767 size_t samplesize = datatype_size( m_header.getSignalHeader_readonly( i ).get_datatype( ) );
6868 m_record_length += samplesize * m_header.getSignalHeader_readonly( i ).get_samples_per_record( );
69
69 #ifdef ALLOW_GDF_V_251
70 double fs = m_header.getSignalHeader( i ).get_samples_per_record( );
71 #else
7072 double fs = m_header.getSignalHeader( i ).get_samples_per_record( ) * m_header.getMainHeader_readonly().get_datarecord_duration(1) / m_header.getMainHeader_readonly().get_datarecord_duration(0);
73 #endif
7174 m_header.getSignalHeader( i ).set_samplerate( boost::numeric_cast<uint32>(fs) );
7275 }
7376
144147 }
145148
146149 buffer.resize( signal_indices.size() );
147
150 #ifdef ALLOW_GDF_V_251
151 double record_rate = 1;
152 #else
148153 double record_rate = m_header.getMainHeader_readonly().get_datarecord_duration(1) / m_header.getMainHeader_readonly().get_datarecord_duration(0);
154 #endif
149155 size_t record = boost::numeric_cast<size_t>( floor( start_time * record_rate ) );
150156
151157
5858 m_records.clear( );
5959 m_records_full.clear( );
6060
61 m_num_recs = 0;
6162 m_num_full = 0;
6263 }
6364
9697 //std::cout << "Record Full" << std::endl;
9798 m_records_full.push_back( m_records.front() );
9899 m_records.pop_front( );
100 m_num_recs--;
99101 m_num_full++;
100102
101103 // Sparse channels do not need m_channelhead[i] mechanism, but the mechanism
193195 Record *r = m_pool->pop( );
194196 r->clear( );
195197 m_records.push_back( r );
198 m_num_recs++;
196199 std::list< Record* >::iterator it = m_records.end( );
197200 it--;
198201 return it;
229232
230233 if( m_channelhead[channel_idx] == m_records.end() )
231234 {
232 if( m_records.size() > 0 )
235 if( m_num_recs > 0 )
233236 {
234237 if( m_records.back()->getChannel(channel_idx)->getFree( ) == 0 )
235 {
236 // Create a new record in m_records and inform all
237 // channels that are pointing beyond the end m_records.
238
239 // capture the iter value that flags m_channelhead's that have no free space
240 std::list< Record* >::iterator end_iter = m_records.end();
241 // get a clean record from m_pool, enlist it on m_records, and return an iterator
242 std::list< Record* >::iterator newrec_iter = createNewRecord( );
243 // broadcast the new record among all channels that need it
244 for( size_t i=0; i<m_channelhead.size(); i++ )
245 {
246 if (m_channelhead[i] == end_iter)
247 {
248 m_channelhead[i] = newrec_iter;
249 }
250 }
251 }
238 {
239 // Create a new record in m_records and inform all
240 // channels that are pointing beyond the end m_records.
241
242 // capture the iter value that flags m_channelhead's that have no free space
243 std::list< Record* >::iterator end_iter = m_records.end();
244 // get a clean record from m_pool, enlist it on m_records, and return an iterator
245 std::list< Record* >::iterator newrec_iter = createNewRecord( );
246 // broadcast the new record among all channels that need it
247 for( size_t i=0; i<m_channelhead.size(); i++ )
248 {
249 if (m_channelhead[i] == end_iter)
250 {
251 m_channelhead[i] = newrec_iter;
252 }
253 }
254 }
252255 else
253256 throw exception::corrupt_recordbuffer( "DOOM is upon us!" );
254257 }
5555 gdf::TagField tagfield(0);
5656 tagfield.fromStream(stream);
5757 tag = tagfield.getTagNumber();
58 #ifdef ALLOW_GDF_V_251
59 if (tag == 0)
60 {
61 // Zero tag value indicates end of Header 3. See first row of Table 10 in GDF standard.
62 header3unpaddedsize += 1;
63 }
64 else if (1 <= tag && tag <= 13)
65 {
66 header3unpaddedsize += tagfield.getLength();
67 this->addTagField( tagfield );
68 }
69 else
70 {
71 throw exception::feature_not_implemented("Only tag==1..13 are supported in this build");
72 }
73 #else
5874 switch( tag )
5975 {
6076 case 0:
6985 throw exception::feature_not_implemented("Only tag==1 is supported in this build");
7086 break;
7187 }
88 #endif
7289 }
7390 // consume the padding bytes that make Header 3 a multiple of 256 bytes
7491 size_t ns = hdr.getMainHeader_readonly().get_num_signals( );
184201 //===================================================================================================
185202 //===================================================================================================
186203
187 TagField::TagField( uint8 tag=0 ) : m_tag(tag)
204 TagField::TagField( uint8 tag ) : m_tag(tag)
188205 {
189206 ;
190207 }
232249 for( size_t i=0; i<taglength; i++ )
233250 stream.read( reinterpret_cast<char*>(&m_value[i+4]), 1 );
234251 }
235 }
252 }
253
1515 #ifndef __COMMANDS_H_INCLUDED__
1616 #define __COMMANDS_H_INCLUDED__
1717
18 #include <map>
1819 #include <stdexcept>
1920 #include <string>
2021 #include "mex.h"
4849 public:
4950 CommandManager( )
5051 {
52 default_cmd = NULL;
5153 }
5254
5355 virtual ~CommandManager( )
5557 std::map< std::string, Command* >::iterator it = commands.begin( );
5658 for( ; it != commands.end(); it++ )
5759 delete it->second;
60 }
61
62 void setDefaultCommand( const std::string cmdstr )
63 {
64 std::map< std::string, Command* >::iterator it = commands.find( toUpper( cmdstr ) );
65 if( it == commands.end() )
66 throw std::invalid_argument( "Invalid command: "+toUpper( cmdstr ) );
67 default_cmd = it->second;
5868 }
5969
6070 void registerCommand( const std::string cmdstr, Command * cmd, size_t nlhs, size_t nrhs )
7181 (*it->second)( nlhs, plhs, nrhs, prhs );
7282 }
7383
84 void execute( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] )
85 {
86 if( !default_cmd )
87 throw std::invalid_argument( "No default command specified." );
88 (*default_cmd)( nlhs, plhs, nrhs, prhs );
89 }
90
7491 static std::string toUpper( const std::string str )
7592 {
7693 std::string out( str );
83100
84101 private:
85102 std::map< std::string, Command* > commands;
103 Command *default_cmd;
86104 };
87105
88106 #endif // COMMANDS_H
3535 target_link_libraries( testRWConsistency ${Boost_LIBRARIES} GDF )
3636 add_test( NAME testRWConsistency COMMAND testRWConsistency )
3737
38 add_executable( testBlit testBlit.cpp )
39 target_link_libraries( testBlit ${Boost_LIBRARIES} GDF )
40 add_test( NAME testBlit COMMAND testBlit )
41
3842 add_executable( testSparseSampling testSparseSampling.cpp )
3943 target_link_libraries( testSparseSampling ${Boost_LIBRARIES} GDF )
4044 add_test( NAME testSparseSampling COMMAND testSparseSampling )
0 //
1 // This file is part of libGDF.
2 //
3 // libGDF is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU Lesser General Public License as
5 // published by the Free Software Foundation, either version 3 of
6 // the License, or (at your option) any later version.
7 //
8 // libGDF is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public License
14 // along with libGDF. If not, see <http://www.gnu.org/licenses/>.
15 //
16 // Copyright 2010, 2013 Martin Billinger, Owen Kelly
17
18
19 #include "config-tests.h"
20
21 #include <GDF/Writer.h>
22 #include <GDF/Reader.h>
23 #include <GDF/TagHeader.h>
24 #include <GDF/EventDescriptor.h>
25
26 #include <iostream>
27 #include <stdio.h>
28 #include <sys/stat.h>
29
30 using namespace std;
31
32 const string testfile = "test.gdf.tmp";
33 const string reffile0 = string(GDF_SOURCE_ROOT)+"/sampledata/MI128.gdf";
34 const string annotfile = string(GDF_SOURCE_ROOT)+"/sampledata/Header3Tag1.gdf";
35 const string alltypesfile = string(GDF_SOURCE_ROOT)+"/sampledata/alltypes.gdf";
36 const string eventcodefile = string(GDF_SOURCE_ROOT)+"/libgdf/eventcodes.txt";
37
38 bool fexist( std::string filename )
39 {
40 std::ifstream f( filename.c_str(), std::ios_base::in );
41 if( f.fail() )
42 return false;
43 f.close( );
44 return true;
45 }
46
47 size_t fsize( std::string filename )
48 {
49 struct stat filestatus;
50 stat( filename.c_str(), &filestatus );
51 return filestatus.st_size;
52 }
53
54 bool fcompare( std::string fileA, std::string fileB )
55 {
56 std::ifstream f1( fileA.c_str(), std::ios_base::in | std::ios_base::binary );
57 std::ifstream f2( fileB.c_str(), std::ios_base::in | std::ios_base::binary );
58
59 bool state = true;
60
61 size_t ofs = 0;
62 while( !( f1.eof() || f2.eof() ) )
63 {
64 signed char a, b;
65 f1 >> a;
66 f2 >> b;
67
68
69 if( abs(a-b) > 1 ) // tolerate a difference of 1 due to rounding errors in digitial -> physical -> digital conversion
70 {
71 cout << ofs << " : " << (int)a << " ... " << (int)b << endl;
72 state = false;
73 }
74
75 ofs++;
76
77 }
78 return state;
79 }
80
81 int main( )
82 {
83 std::vector<string> infilelist; // a list of files on which to run tests
84 infilelist.push_back(annotfile);
85 infilelist.push_back(alltypesfile);
86 infilelist.push_back(reffile0);
87
88 string reffile;
89
90
91 try
92 {
93 for(size_t file_count=0; file_count < infilelist.size(); file_count++)
94 {
95 reffile = infilelist[file_count]; // file to be tested in this loop iteration
96
97 cout << "Creating Writer instance." << endl;
98 gdf::Writer w;
99
100 cout << "Creating Reader instance." << endl;
101 gdf::Reader r;
102
103 r.enableCache( false );
104
105 cout << "Opening '" << reffile << "' for reading." << endl;
106 r.open( reffile );
107
108 cout << "Copying Header information." << endl;
109 w.getMainHeader( ).copyFrom( r.getMainHeader_readonly() );
110 w.getHeaderAccess().setRecordDuration( r.getMainHeader_readonly().get_datarecord_duration( 0 ), r.getMainHeader_readonly().get_datarecord_duration( 1 ) );
111 for( size_t m=0; m<w.getMainHeader_readonly().get_num_signals(); m++ )
112 {
113 w.createSignal( m, true );
114 w.getSignalHeader( m ).copyFrom( r.getSignalHeader_readonly( m ) );
115 }
116
117 w.setEventMode( r.getEventHeader()->getMode() );
118 w.setEventSamplingRate( r.getEventHeader()->getSamplingRate() );
119 // Copy GDF header 3 including user-specific event description table
120 gdf::TagHeader ath = r.getHeaderAccess_readonly().getTagHeader_readonly();
121 w.getHeaderAccess().getTagHeader().copyFrom( ath );
122
123 cout << "Opening '" << testfile << "' for writing." << endl;
124 w.open( testfile, gdf::writer_ev_memory | gdf::writer_overwrite );
125
126 cout << "Copying data .... ";
127
128 //size_t num_recs = boost::numeric_cast<size_t>( r.getMainHeader_readonly( ).get_num_datarecords( ) );
129 //for( size_t n=0; n<num_recs; n++ )
130 //{
131 // gdf::Record *rec = w.acquireRecord( );
132 // r.readRecord( n, rec );
133 // w.addRecord( rec );
134 //}
135
136 std::vector< std::vector< double > > buffer;
137 r.getSignals(buffer);
138
139 for( size_t ch=0; ch<buffer.size(); ch++)
140 {
141 cout << ch << endl;
142 w.blitSamplesPhys(ch, buffer[ch]);
143 }
144
145 cout << "OK" << endl;
146
147 cout << "Copying events .... ";
148 gdf::EventHeader* ev_header = r.getEventHeader();
149 unsigned int num_events = ev_header->getNumEvents();
150 switch( ev_header->getMode() )
151 {
152 default: throw(std::runtime_error("ERROR -- Invalid event mode!"));
153 case 1: {
154 gdf::Mode1Event ev;
155 for(unsigned int m = 0; m < num_events; m++)
156 {
157 ev_header->getEvent(m, ev);
158 w.addEvent(ev);
159 }
160 } break;
161 case 3: {
162 gdf::Mode3Event ev;
163 double sample_physical_value;
164 double sample_time_sec;
165
166 // Copy all event from source file to target file.
167 // Mode 1 and 3 events are copied.
168 // Sparse samples are extracted to (time,phys) then stored again.
169 for(unsigned int mm = 0; mm < num_events; mm++)
170 {
171 ev_header->getEvent(mm, ev);
172 if( ev.type != 0x7fff ) {
173 w.addEvent(ev);
174 } else {
175 r.eventToSample(sample_time_sec, sample_physical_value, ev);
176 // At this point we have successfully decoded a sparse sample
177 // (sample_time_sec, sample_physical_value) .
178 w.sampleToEvent( sample_time_sec, sample_physical_value, ev.channel, ev );
179 // At this point we have successfully encoded a sparse sample into an event.
180 // Now write the event to file.
181 w.addEvent( ev );
182 }
183 }
184 } break;
185 }
186
187 cout << "OK" << endl;
188
189 w.close( );
190 cout << "Comparing files .... ";
191 if( !fcompare( reffile, testfile ) )
192 {
193 cout << "Failed." << endl;
194 return 1;
195 }
196 cout << "OK" << endl;
197
198 cout << "Removing " << testfile << endl << endl;
199 remove( testfile.c_str() );
200 }
201 return 0; // test succeeded
202 }
203 catch( std::exception &e )
204 {
205 std::cout << "Caught Exception: " << e.what( ) << endl;
206 }
207 catch( ... )
208 {
209 std::cout << "Caught Unknown Exception." << endl;
210 }
211
212 return 1; // test failed
213 }