sfftsfileread.h 2.94 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*! \file sfftsfileread.h
 * \brief define ts::sff::File<C>::read function (implementation)
 * 
 * ----------------------------------------------------------------------------
 * 
 * \author Thomas Forbriger
 * \date 02/04/2019
 * 
 * define ts::sff::File<C>::read function (implementation)
 * 
 * Copyright (c) 2019 by Thomas Forbriger (BFO Schiltach) 
 * 
 * ----
 * libtsioxx is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version. 
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 * ----
 *
28
29
30
31
 *  The code in this file must be kept in its own header file, because this
 *  compilation units has to load inputoperators.h which in turn loads
 *  sfftsfile.h
 *
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
 * REVISIONS and CHANGES 
 *  - 02/04/2019   V1.0   Thomas Forbriger
 * 
 * ============================================================================
 */

// include guard
#ifndef TSIO_SFFTSFILEREAD_H_VERSION

#define TSIO_SFFTSFILEREAD_H_VERSION \
  "TSIO_SFFTSFILEREAD_H   2019/04/02"

#include<tsioxx/sfftsfile.h>
#include<tsioxx/inputoperators.h>

namespace ts {

  namespace sff {

    /*======================================================================*/
    // member functions
    
    /*! \brief Read a complete file with all traces.
     */
    template<class C>
    inline void File<C>::read(datrw::idatstream& is, const bool& verbose)
    {
      Trangelist rl;
      this->read(is, rl, verbose);
    } // File<C>::read
    
    /*----------------------------------------------------------------------*/

    
    /*! \brief Read a data file an extract selected traces.
     */
    template<class C>
      inline void File<C>::read(datrw::idatstream& is, 
                                const Trangelist& rl,
                                const bool& verbose)
    {
      is >> this->fileheader;
      int itrace=0;
      while (is.good())
      {
        ++itrace;
        if ((rl.size()==0) || rl.contains(itrace))
        {
          if (verbose)
          { std::cout << "  * read trace #" << itrace << std::endl; }
          Ttimeseries timeseries;
          is >> timeseries;
          timeseries.settraceindex(itrace);
          this->push_back(timeseries);
        }
        else
        {
          if (verbose)
          { std::cout << "    skip trace #" << itrace << std::endl; }
          is.skipseries();
        }
      }
    } // File<C>::read

  } // namespace sff

} // namespace ts

#endif // TSIO_SFFTSFILEREAD_H_VERSION (includeguard)

/* ----- END OF sfftsfileread.h ----- */