libGDF
GDFHeaderAccess.h
00001 //
00002 // This file is part of libGDF.
00003 //
00004 // libGDF is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU Lesser General Public License as
00006 // published by the Free Software Foundation, either version 3 of
00007 // the License, or (at your option) any later version.
00008 //
00009 // libGDF is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU Lesser General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU Lesser General Public License
00015 // along with libGDF.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // Copyright 2010 Martin Billinger
00018 
00019 #ifndef __GDFHEADERACCESS_H_INCLUDED__
00020 #define __GDFHEADERACCESS_H_INCLUDED__
00021 
00022 #include "GDF/EventHeader.h"
00023 #include "GDF/SignalHeader.h"
00024 #include "GDF/MainHeader.h"
00025 #include "GDF/TagHeader.h"
00026 #include <map>
00027 #include <iostream>
00028 
00029 namespace gdf
00030 {
00031     class GDFHeaderAccess
00032     {
00033     public:
00034 
00036         GDFHeaderAccess( );
00037 
00039         virtual ~GDFHeaderAccess( );
00040 
00042         void clear( );
00043 
00045 
00046         void sanitize( );
00047 
00049 
00051         void setRecordDuration( uint32 num, uint32 den );
00052 
00054         void enableAutoRecordDuration( );
00055 
00056         const MainHeader &getMainHeader_readonly( ) const;
00057         MainHeader &getMainHeader( );
00058 
00059         const SignalHeader &getSignalHeader_readonly( size_t idx ) const;
00060         SignalHeader &getSignalHeader( size_t idx );
00061 
00062         bool createSignal( size_t index, bool throwexc = false );
00063 
00064         size_t getFirstFreeSignalIndex( );
00065 
00066         size_t getNumSignals( ) const;
00067 
00068         void swapSignals( size_t a, size_t b );
00069 
00070         void relocateSignal( size_t src, size_t dst );
00071 
00072         EventHeader &getEventHeader( );
00073 
00074         friend std::ostream& operator<< (std::ostream& out, const GDFHeaderAccess& hdr);
00075         friend std::istream& operator>> (std::istream& in, GDFHeaderAccess& hdr);
00076 
00078         void setLock( bool b) { m_lock = b; }
00079 
00080         // Utility functions
00081 
00082         size_t getNumberOfSamplesInSignal( size_t signal_index ) const;
00083 
00084     private:
00085         MainHeader m_mainhdr;
00086         std::map<uint16,SignalHeader> m_sighdr;
00087         EventHeader m_events;
00088         TagHeader m_taghdr;
00089         uint32 drd_num, drd_den;
00090         bool m_lock;
00091     };
00092 
00094     std::ostream& operator<< (std::ostream& out, const GDFHeaderAccess& hdr);
00095 
00097     std::istream& operator>> (std::istream& in, GDFHeaderAccess& hdr);
00098 }
00099 
00100 #endif
 All Data Structures Functions Variables Friends