DATRW++ library: seismic data I/O with multiple formats
datread.h
Go to the documentation of this file.
1 /*! \file datrw.h
2  * \brief abstract base class to read seismic data (prototypes)
3  *
4  * ----------------------------------------------------------------------------
5  *
6  * \author Thomas Forbriger
7  * \date 30/03/2004
8  *
9  * abstract base class to read seismic data (prototypes)
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  * - 21/04/2004 V1.1 some improvements - provide definition of use
32  * - 17/09/2004 V1.2 make most fields private
33  * - 23/12/2004 V1.3 user of datstream::good() does not want to know
34  * anything about Mis state
35  * - 23/11/2010 V1.4 introduced isbinary flag
36  * - 29/07/2011 V1.5 support property query
37  * - 18/11/2016 V1.6 provide debug flag in base class
38  * do not define input operators inline
39  *
40  * ============================================================================
41  */
42 
43 // include guard
44 #ifndef DATRW_DATREAD_H_VERSION
45 
46 #define DATRW_DATREAD_H_VERSION \
47  "DATRW_DATREAD_H V1.6"
48 
49 #include<iostream>
50 #include<sffxx.h>
51 #include<aff/series.h>
52 #include<datrwxx/error.h>
53 #include<datrwxx/properties.h>
54 #include<datrwxx/types.h>
55 
56 namespace datrw {
57 
58  /*! input stream to read seismic data (abstract base)
59  *
60  * The concept is based on SFF data contents and we will make use of SFF
61  * structures.
62  *
63  * \note
64  * The convention is that a call to dseries(), fseries(), iseries() or
65  * skipseries() will scan the next trace in the input file and will fill all
66  * header structures. While dseries(), fseries() and iseries() return
67  * samples, skipseries() simply discards them. Thus use the time series
68  * input operator first for each trace. Read out header information
69  * afterwards.
70  *
71  * \note
72  * For this reason only the member functions dseries(), fseries(), iseries()
73  * and skipseries() have to be virtual. They are responsible for filling the
74  * header data structures with appropriate values upon scanning/reading a
75  * time series.
76  *
77  * \note
78  * All derived classes are expected to provide static members
79  * openmode and isbinary
80  */
81  class idatstream {
82  public:
83  virtual ~idatstream() { }
87  virtual void skipseries() { DATRW_illegal; }
88  bool hasfree() const;
89  bool hassrce() const { return(Msrceset); }
90  bool hasinfo() const { return(Minfoset); }
91  bool providesd() const { return(Mprovidesd); }
92  bool providesf() const { return(Mprovidesf); }
93  bool providesi() const { return(Mprovidesi); }
94  bool last() const { return(Mlast); }
95  bool good() const { return(!Mlast); }
96  Properties properties() const;
97  /*! return FREE block
98  *
99  * if no WID2 ist set (prior to reading first trace)
100  * the file FREE block is returned
101  *
102  * after reading the first trace, the trace FREE block is returned.
103  *
104  * This mechanism is required to provide easy to use input operators,
105  * that cannot distinguish between file FREE blocks and trace FREE
106  * blocks from just looking at their arguments.
107  */
108  sff::FREE free() const;
109  sff::SRCE srce() const { return(Msrce); }
110  sff::INFO info() const { return(Minfo); }
111  sff::WID2 wid2() const { return(Mwid2); }
112  //! print some info about data conversion.
113  static void help(std::ostream& os=std::cout,
114  const char* name="idatsream");
115  //! indicate debug mode
116  bool debug() { return Mdebug; }
117  //! set debug mode
118  void debug(const bool& debug) { Mdebug=debug; }
119  protected:
120  // member functions
121  idatstream(std::istream& is,
122  const bool& providesd=false,
123  const bool& providesf=false,
124  const bool& providesi=false,
125  const bool& debug=false);
126  std::istream& Mis;
127  void setfilefree(const sff::FREE& free);
128  void settracefree(const sff::FREE& free);
129  void setwid2(const sff::WID2& wid2);
130  void setsrce(const sff::SRCE& srce);
131  void setinfo(const sff::INFO& info);
132  void setlast();
133  void newtrace();
134  // member data
135  bool Mdebug;
136  private:
137  sff::WID2 Mwid2;
138  sff::SRCE Msrce;
139  sff::INFO Minfo;
140  sff::FREE Mtracefree;
141  sff::FREE Mfilefree;
143  bool Mlast;
145  }; // class idatstream
146 
147  /*----------------------------------------------------------------------*/
148 
149  idatstream& operator>>(idatstream& is, sff::WID2& wid2);
150 
151  idatstream& operator>>(idatstream& is, sff::SRCE& srce);
152 
153  idatstream& operator>>(idatstream& is, sff::INFO& info);
154 
155  idatstream& operator>>(idatstream& is, sff::FREE& free);
156 
157  idatstream& operator>>(idatstream& is, Tdseries& series);
158 
159  idatstream& operator>>(idatstream& is, Tfseries& series);
160 
161  idatstream& operator>>(idatstream& is, Tiseries& series);
162 
163 } // namespace datrw
164 
165 #endif // DATRW_DATREAD_H_VERSION (includeguard)
166 
167 /* ----- END OF datrw.h ----- */
Properties properties() const
sff::FREE Mfilefree
Definition: datread.h:141
internal data types (prototypes)
bool Mtracefreeset
Definition: datread.h:142
properties base class.
Definition: properties.h:58
sff::INFO Minfo
Definition: datread.h:139
void setinfo(const sff::INFO &info)
Definition: datread.cc:121
aff::Series< float > Tfseries
Definition: types.h:46
sff::WID2 wid2() const
Definition: datread.h:111
void setfilefree(const sff::FREE &free)
Definition: datread.cc:97
sff::WID2 Mwid2
Definition: datread.h:137
static void help(std::ostream &os=std::cout, const char *name="idatsream")
print some info about data conversion.
Definition: datread.cc:153
virtual void skipseries()
Definition: datread.h:87
void setsrce(const sff::SRCE &srce)
Definition: datread.cc:129
bool good() const
Definition: datread.h:95
aff::Series< double > Tdseries
Definition: types.h:45
virtual Tiseries iseries()
Definition: datread.h:86
exception class declaration for libdatrwxx (prototypes)
bool hasfree() const
Definition: datread.cc:72
std::istream & Mis
Definition: datread.h:126
bool last() const
Definition: datread.h:94
bool hassrce() const
Definition: datread.h:89
void setwid2(const sff::WID2 &wid2)
Definition: datread.cc:113
void debug(const bool &debug)
set debug mode
Definition: datread.h:118
bool debug()
indicate debug mode
Definition: datread.h:116
sff::INFO info() const
Definition: datread.h:110
idatstream(std::istream &is, const bool &providesd=false, const bool &providesf=false, const bool &providesi=false, const bool &debug=false)
Definition: datread.cc:55
Root namespace of library.
Definition: aalibdatrwxx.cc:16
bool providesi() const
Definition: datread.h:93
sff::SRCE srce() const
Definition: datread.h:109
sff::FREE free() const
Definition: datread.cc:79
sff::FREE Mtracefree
Definition: datread.h:140
virtual Tdseries dseries()
Definition: datread.h:84
void settracefree(const sff::FREE &free)
Definition: datread.cc:105
describe data properties (prototypes)
sff::SRCE Msrce
Definition: datread.h:138
aff::Series< int > Tiseries
Definition: types.h:47
bool providesd() const
Definition: datread.h:91
bool providesf() const
Definition: datread.h:92
bool hasinfo() const
Definition: datread.h:90
virtual Tfseries fseries()
Definition: datread.h:85
#define DATRW_illegal
Definition: error.h:108
idatstream & operator>>(idatstream &is, sff::WID2 &wid2)
Definition: datread.cc:161
virtual ~idatstream()
Definition: datread.h:83