DATRW++ library: seismic data I/O with multiple formats
isffstream.cc
Go to the documentation of this file.
1 /*! \file isffstream.cc
2  * \brief read sff data (implementation)
3  *
4  * ----------------------------------------------------------------------------
5  *
6  * \author Thomas Forbriger
7  * \date 30/03/2004
8  *
9  * read sff data (implementation)
10  *
11  * ----
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25  * ----
26  *
27  * Copyright (c) 2004 by Thomas Forbriger (BFO Schiltach)
28  *
29  * REVISIONS and CHANGES
30  * - 30/03/2004 V1.0 Thomas Forbriger
31  * - 12/06/2004 V1.1 provides DEBUG output
32  * - 29/06/2007 V1.2 read SRCE line prior to file FREE block
33  * - 03/07/2007 V1.3 read FREE block prior to file SRCE line
34  * order of elements in file header should not
35  * be defined by the order of the code characters
36  * since reading functions in libsffxx do not
37  * respect this order. libstuff always writes the FREE
38  * block first in sff_WOpenFS
39  * - 23/11/2010 V1.4 introduced static member data
40  * - 18/11/2016 V1.5 use debug flag in base class
41  *
42  * ============================================================================
43  */
44 #define DATRW_ISFF_CC_VERSION \
45  "DATRW_ISFF_CC V1.5"
46 
47 #include <datrwxx/sff.h>
48 #include <sffxx.h>
49 
50 namespace datrw {
51 
52  const std::ios_base::openmode isffstream::openmode=std::ios_base::in;
53 
54  //@{
55  /*! \brief Format properties
56  * \ingroup group_sff
57  */
58  const bool sff::isbinary=false;
59  const char* const sff::streamID="sff";
60  //@}
61 
62  /*----------------------------------------------------------------------*/
63 
64  isffstream::isffstream(std::istream& is, const bool& debug):
65  Tbase(is, true, true, true, debug)
66  {
67  ::sff::FileHeader fileheader(Mis, debug);
68  if (fileheader.hasfree()) { this->setfilefree(fileheader.free()); }
69  if (fileheader.hassrce()) { this->setsrce(fileheader.srce()); }
70  }
71 
72  /*----------------------------------------------------------------------*/
73 
75  {
76  this->newtrace();
77  if (Mdebug)
78  {
79  std::cerr
80  << "DEBUG (isffstream::dseries): read waveform"
81  << std::endl;
82  }
83  ::sff::InputWaveform<Tdseries> waveform(Mis);
84  this->settraceheader(waveform.header());
85  if (Mdebug)
86  { std::cerr << "DEBUG (isffstream::dseries): done" << std::endl; }
87  return(waveform.series());
88  }
89 
90  /*----------------------------------------------------------------------*/
91 
93  {
94  this->newtrace();
95  if (Mdebug)
96  {
97  std::cerr
98  << "DEBUG (isffstream::fseries): read waveform"
99  << std::endl;
100  }
101  ::sff::InputWaveform<Tfseries> waveform(Mis);
102  this->settraceheader(waveform.header());
103  if (Mdebug)
104  { std::cerr << "DEBUG (isffstream::fseries): done" << std::endl; }
105  return(waveform.series());
106  }
107 
108  /*----------------------------------------------------------------------*/
109 
111  {
112  this->newtrace();
113  if (Mdebug)
114  {
115  std::cerr
116  << "DEBUG (isffstream::iseries): read waveform"
117  << std::endl;
118  }
119  ::sff::InputWaveform<Tiseries> waveform(Mis);
120  this->settraceheader(waveform.header());
121  if (Mdebug)
122  { std::cerr << "DEBUG (isffstream::iseries): done" << std::endl; }
123  return(waveform.series());
124  }
125 
126  /*----------------------------------------------------------------------*/
127 
129  {
130  this->newtrace();
131  if (Mdebug)
132  {
133  std::cerr
134  << "DEBUG (isffstream::skipseries): skipped waveform"
135  << std::endl;
136  }
137  ::sff::SkipWaveform skip(Mis);
138  if (Mdebug)
139  { std::cerr << "DEBUG (isffstream::skipseries): done" << std::endl; }
140  this->settraceheader(skip.header());
141  }
142 
143  /*----------------------------------------------------------------------*/
144 
145  void isffstream::settraceheader(const ::sff::TraceHeader& header)
146  {
147  this->setwid2(header.wid2());
148  if (header.hasfree()) { this->settracefree(header.free()); }
149  if (header.hasinfo()) { this->setinfo(header.info()); }
150  if (header.last()) { this->setlast(); }
151  }
152 
153 } // namespace datrw
154 
155 /* ----- END OF isffstream.cc ----- */
void setinfo(const sff::INFO &info)
Definition: datread.cc:121
aff::Series< float > Tfseries
Definition: types.h:46
void setfilefree(const sff::FREE &free)
Definition: datread.cc:97
void setsrce(const sff::SRCE &srce)
Definition: datread.cc:129
const char *const streamID
Format properties.
Definition: isffstream.cc:59
read sff data (prototypes)
void settraceheader(const ::sff::TraceHeader &header)
Definition: isffstream.cc:145
aff::Series< double > Tdseries
Definition: types.h:45
std::istream & Mis
Definition: datread.h:126
void setwid2(const sff::WID2 &wid2)
Definition: datread.cc:113
bool debug()
indicate debug mode
Definition: datread.h:116
Root namespace of library.
Definition: aalibdatrwxx.cc:16
virtual Tdseries dseries()
Definition: isffstream.cc:74
void settracefree(const sff::FREE &free)
Definition: datread.cc:105
aff::Series< int > Tiseries
Definition: types.h:47
static const std::ios_base::openmode openmode
Definition: sff.h:87
virtual Tfseries fseries()
Definition: isffstream.cc:92
virtual Tiseries iseries()
Definition: isffstream.cc:110
const bool isbinary
Format properties.
Definition: isffstream.cc:58
virtual void skipseries()
Definition: isffstream.cc:128
isffstream(std::istream &is, const bool &debug=false)
Definition: isffstream.cc:64