DATRW++ library: seismic data I/O with multiple formats
itfasciistream.cc
Go to the documentation of this file.
1 /*! \file itfasciistream.cc
2  * \brief read Thomas Forbrigers ASCII data (implementation)
3  *
4  * ----------------------------------------------------------------------------
5  *
6  * \author Daniel Armbruster
7  * \date 05/10/2010
8  *
9  * Purpose: read Thomas Forbrigers ASCII data (implementation)
10  *
11  * ----
12  * This file is part of libdatrwxx.
13  *
14  * libdatrwxx is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation, either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * libdatrwxx is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with libdatrwxx. If not, see <http://www.gnu.org/licenses/>.
26  * ----
27  *
28  * Copyright (c) 2010 by Daniel Armbruster
29  *
30  * REVISIONS and CHANGES
31  * - 05/10/2010 V0.1 Daniel Armbruster
32  * - 23/11/2010 V1.1 Thomas Forbriger: introduced static member data
33  *
34  * ============================================================================
35  */
36 
37 #define DATRW_TFASCII_CC_VERSION \
38  "DATRW_TFASCII_CC V1.1"
39 
40 #include <datrwxx/tfascii.h>
41 #include <datrwxx/error.h>
42 #include <datrwxx/util.h>
43 
44 namespace datrw {
45 
46  const std::ios_base::openmode itfasciistream::openmode=std::ios_base::in;
47 
48  //@{
49  /*! \brief Format properties
50  * \ingroup group_tfascii
51  */
52  const bool tfascii::isbinary=false;
53  const char* const tfascii::streamID="tfascii";
54  //@}
55 
56  /*----------------------------------------------------------------------*/
57  // constructor
58  itfasciistream::itfasciistream(std::istream& is, const bool& verbose)
59  : Tbase(is, true, true, true), Mverbose(verbose)
60  {
62  } // function itfasciistream::itfasciistream
63 
64  /*----------------------------------------------------------------------*/
65  // destructor
67  { }
68 
69  /*----------------------------------------------------------------------*/
70  void itfasciistream::help(std::ostream& os)
71  { datrw::tfascii::help(os); }
72 
73  /*----------------------------------------------------------------------*/
74  // implicit virtual functions
75 
77  {
79  return (util::readasciidouble<Tdseries>(Mis, this->wid2().nsamples,
81  } // function itfasciistream::dseries
82 
83  /*----------------------------------------------------------------------*/
85  {
87  return (util::readasciidouble<Tfseries>(Mis, this->wid2().nsamples,
89  } // function itfasciistream::fseries
90 
91  /*----------------------------------------------------------------------*/
93  {
95  return (util::readasciidouble<Tiseries>(Mis, this->wid2().nsamples,
97  } // function itfasciistream::iseries
98 
99  /*----------------------------------------------------------------------*/
100  // private functions
103  get_verbose());
104  if (fileheader.hasfilefree)
105  {
106  this->setfilefree(fileheader.filefree);
107  }
108  if (fileheader.hassrce)
109  {
110  this->setsrce(fileheader.srce);
111  }
112  } // function itfasciistream::set_fileheader
113 
114  /*----------------------------------------------------------------------*/
116  {
118  get_verbose());
119  this->newtrace();
120  this->setwid2(traceheader.wid2);
121  if(traceheader.hastracefree)
122  {
123  this->settracefree(traceheader.tracefree);
124  }
125  if (traceheader.hasinfo)
126  {
127  this->setinfo(traceheader.info);
128  }
129  this->setlast();
130  } // function itfasciistream::set_traceheader
131 
132  /*----------------------------------------------------------------------*/
134  {
135  return Mverbose;
136  } // function itfasciistream::get_verbose
137 
138 } // namespace datrw
139 
140 
141 /* ----- END OF itfasciistream.cc ----- */
FileHeader readfileheader(std::istream &is, const bool &verbose)
read the complete fileheader
Definition: readtfascii.cc:78
read Thomas Forbrigers ASCII data (prototypes)
holds the traceheader data
Definition: readtfascii.h:106
void setinfo(const sff::INFO &info)
Definition: datread.cc:121
aff::Series< float > Tfseries
Definition: types.h:46
const char *const streamname
name of the stream
Definition: readtfascii.cc:75
virtual Tdseries dseries()
to read the data as double
sff::WID2 wid2() const
Definition: datread.h:111
void setfilefree(const sff::FREE &free)
Definition: datread.cc:97
TraceHeader readtraceheader(std::istream &is, const bool &verbose)
read the complete traceheader
Definition: readtfascii.cc:165
itfasciistream(std::istream &is, const bool &verbose=false)
constructor
void setsrce(const sff::SRCE &srce)
Definition: datread.cc:129
const bool Mverbose
for verbose output
Definition: tfascii.h:100
aff::Series< double > Tdseries
Definition: types.h:45
void set_fileheader()
set the file header data
virtual Tfseries fseries()
to read the data as float
const int nsamples
number of samples per minute block and channel
Definition: hpmodata.h:51
exception class declaration for libdatrwxx (prototypes)
std::istream & Mis
Definition: datread.h:126
const char *const streamID
Format properties.
void setwid2(const sff::WID2 &wid2)
Definition: datread.cc:113
bool get_verbose() const
member function
Root namespace of library.
Definition: aalibdatrwxx.cc:16
utilities used by more than one type of data reader (prototypes)
void settracefree(const sff::FREE &free)
Definition: datread.cc:105
const bool isbinary
Format properties.
static const std::ios_base::openmode openmode
Definition: tfascii.h:97
aff::Series< int > Tiseries
Definition: types.h:47
holds the fileheader data
Definition: readtfascii.h:98
static void help(std::ostream &os=std::cout)
print some info about data conversion
void help(std::ostream &os)
function to print online help
Definition: readtfascii.cc:287
virtual Tiseries iseries()
to read the data as integer
void set_traceheader()
set the trace header data
virtual ~itfasciistream()
destructor