DATRW++ library: seismic data I/O with multiple formats
sff.h
Go to the documentation of this file.
1 /*! \file sff.h
2  * \brief read sff data (prototypes)
3  *
4  * ----------------------------------------------------------------------------
5  *
6  * \author Thomas Forbriger
7  * \date 30/03/2004
8  *
9  * read sff 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  * - 12/06/2007 V1.1 added DEBUG member data
32  * - 23/11/2010 V1.2 introduced static member data
33  * - 07/06/2011 V1.3 promise constness of series samples
34  * - 21/11/2011 V1.4 introduce format modifiers
35  * - 18/11/2016 V1.5 use debug flag in base class
36  * - 22/11/2016 V1.6 set default for format modifiers
37  *
38  * ============================================================================
39  */
40 
41 // include guard
42 #ifndef DATRW_SFF_H_VERSION
43 
44 #define DATRW_SFF_H_VERSION \
45  "DATRW_SFF_H V1.6"
46 
47 #include<sffxx.h>
48 #include<datrwxx/datread.h>
49 #include<datrwxx/datwrite.h>
50 #include<datrwxx/reservoir.h>
51 
52 namespace datrw {
53 
54  /*! \brief Format specific modules for SFF data
55  *
56  * \ingroup group_sff
57  */
58  namespace sff {
59 
60  extern const bool isbinary;
61  extern const char* const streamID;
62 
63  } // namespace sff
64 
65  /*----------------------------------------------------------------------*/
66 
67  /*! \brief I/O module for SFF
68  *
69  * \defgroup group_sff I/O module for SFF
70  */
71 
72  /*! \brief class to read SFF data
73  *
74  * \ingroup group_sff
75  */
76  class isffstream: public idatstream {
77  public:
78  typedef idatstream Tbase;
79  isffstream(std::istream& is, const bool& debug=false);
80  virtual ~isffstream() { }
81  virtual Tdseries dseries();
82  virtual Tfseries fseries();
83  virtual Tiseries iseries();
84  virtual void skipseries();
85  static void help(std::ostream& os=std::cout)
86  { Tbase::help(os, "isffstream"); }
87  static const std::ios_base::openmode openmode;
88  private:
89  void settraceheader(const ::sff::TraceHeader& header);
90  }; // class isffstream
91 
92 /*======================================================================*/
93 
94  /*! \brief class to write SFF data
95  *
96  * \ingroup group_sff
97  */
98  class osffstream: public odatstream {
99  public:
100  typedef odatstream Tbase;
101  osffstream(std::ostream& os, const std::string& modifier="",
102  const bool& debug=false);
103  inline virtual ~osffstream()
104  { this->flushwaitingtrace(true); }
105  static void help(std::ostream& os=std::cout);
106  static const std::ios_base::openmode openmode;
107  protected:
108  virtual void writefileheader();
109  virtual void writetrace(const Tdseries::Tcoc& series);
110  virtual void writetrace(const Tfseries::Tcoc& series);
111  virtual void writetrace(const Tiseries::Tcoc& series);
112  private:
113  /*! flush waiting trace data
114  * \PARAM last true if no other trace will be written,
115  * i.e. only set to true when called from destructor
116  */
117  void flushwaitingtrace(const bool& last=false);
118 
119  private:
121  ::sff::WID2 Mwid2waiting;
122  ::sff::FREE Mfreewaiting;
123  ::sff::INFO Minfowaiting;
125 
126  protected:
127  ::sff::Enormmode Mnormmode;
128  }; // class osffstream
129 
130  /*----------------------------------------------------------------------*/
131 
132  /*! \brief class to write GSE data
133  *
134  * \ingroup group_sff
135  */
136  class ogsestream: public osffstream {
137  public:
138  typedef osffstream Tbase;
139  ogsestream(std::ostream& os, const bool& debug=false);
140  inline virtual ~ogsestream() { }
141  static void help(std::ostream& os=std::cout);
142  /*
143  protected:
144  virtual void writetrace(const Tdseries& series)
145  { DATRW_abort("ogsestream cannot write doubles"); }
146  virtual void writetrace(const Tfseries& series)
147  { DATRW_abort("ogsestream cannot write floats"); }
148  */
149  }; // class ogsestream
150 
151 } // namespace datrw
152 
153 #endif // DATRW_SFF_H_VERSION (includeguard)
154 
155 /* ----- END OF sff.h ----- */
bool Minfoiswaiting
Definition: sff.h:120
aff::Series< float > Tfseries
Definition: types.h:46
::sff::WID2 Mwid2waiting
Definition: sff.h:121
bool Mfreeiswaiting
Definition: sff.h:120
static void help(std::ostream &os=std::cout, const char *name="idatsream")
print some info about data conversion.
Definition: datread.cc:153
virtual void writefileheader()
actually write the file header
Definition: osffstream.cc:110
const char *const streamID
Format properties.
Definition: isffstream.cc:59
virtual ~ogsestream()
Definition: sff.h:140
virtual void writetrace(const Tdseries::Tcoc &series)
write double data
Definition: osffstream.cc:122
void settraceheader(const ::sff::TraceHeader &header)
Definition: isffstream.cc:145
aff::Series< double > Tdseries
Definition: types.h:45
class to read SFF data
Definition: sff.h:76
static void help(std::ostream &os=std::cout)
Definition: osffstream.cc:79
class to write SFF data
Definition: sff.h:98
::sff::FREE Mfreewaiting
Definition: sff.h:122
::sff::INFO Minfowaiting
Definition: sff.h:123
bool debug()
indicate debug mode
Definition: datwrite.h:145
bool debug()
indicate debug mode
Definition: datread.h:116
Root namespace of library.
Definition: aalibdatrwxx.cc:16
osffstream Tbase
Definition: sff.h:138
osffstream(std::ostream &os, const std::string &modifier="", const bool &debug=false)
Definition: osffstream.cc:56
virtual Tdseries dseries()
Definition: isffstream.cc:74
void flushwaitingtrace(const bool &last=false)
Definition: osffstream.cc:152
virtual ~isffstream()
Definition: sff.h:80
idatstream Tbase
Definition: sff.h:78
static const std::ios_base::openmode openmode
Definition: sff.h:106
aff::Series< int > Tiseries
Definition: types.h:47
::sff::Enormmode Mnormmode
Definition: sff.h:127
static const std::ios_base::openmode openmode
Definition: sff.h:87
static void help(std::ostream &os=std::cout)
Definition: osffstream.cc:199
static void help(std::ostream &os=std::cout)
Definition: sff.h:85
datrw::util::seriesreservoir Mserieswaiting
Definition: sff.h:124
bool Mwid2iswaiting
Definition: sff.h:120
virtual Tfseries fseries()
Definition: isffstream.cc:92
series reservoir (prototypes)
virtual Tiseries iseries()
Definition: isffstream.cc:110
odatstream Tbase
Definition: sff.h:100
class to write GSE data
Definition: sff.h:136
const bool isbinary
Format properties.
Definition: isffstream.cc:58
virtual void skipseries()
Definition: isffstream.cc:128
ogsestream(std::ostream &os, const bool &debug=false)
Definition: osffstream.cc:188
generic interface definition (prototypes)
virtual ~osffstream()
Definition: sff.h:103
isffstream(std::istream &is, const bool &debug=false)
Definition: isffstream.cc:64