sfftimeseries.h 5.26 KB
Newer Older
1
2
/*! \file sfftimeseries.h
 * \brief libtsxx TimeSeries class template with SFF trace header (prototypes)
thomas.forbriger's avatar
thomas.forbriger committed
3
4
5
 * 
 * ----------------------------------------------------------------------------
 * 
6
 * $Id: $
thomas.forbriger's avatar
thomas.forbriger committed
7
 * \author Thomas Forbriger
8
9
 * \since 18/07/2005
 * \date 30/01/2014
thomas.forbriger's avatar
thomas.forbriger committed
10
 * 
11
 * libtsxx TimeSeries class template with SFF trace header (prototypes)
thomas.forbriger's avatar
thomas.forbriger committed
12
 * 
13
 * Copyright (c) 2005-2007, 2012, 2014 by Thomas Forbriger (BFO Schiltach) 
thomas.forbriger's avatar
thomas.forbriger committed
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 *
 * ----
 * This program 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, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 * ----
30
 *
thomas.forbriger's avatar
thomas.forbriger committed
31
 * REVISIONS and CHANGES 
32
33
 *  - 30/01/2014   V1.0   Thomas Forbriger (thof):
 *                        copied from sffheaders.h
thomas.forbriger's avatar
thomas.forbriger committed
34
35
36
37
38
 * 
 * ============================================================================
 */

// include guard
39
#ifndef TSIO_SFFTIMESERIES_H_VERSION
thomas.forbriger's avatar
thomas.forbriger committed
40

41
42
43
44
#define TSIO_SFFTIMESERIES_H_VERSION \
  "TF_SFFTIMESERIES_H   2014/01/30"
#define TSIO_SFFTIMESERIES_H_CVSID \
  "$Id: $"
thomas.forbriger's avatar
thomas.forbriger committed
45
46
47
48

#include<sffxx.h>
#include<tsxx/tsxx.h>

49
50
/*! \brief SFF Timeseries I/O.
 *
51
 * \defgroup group_sffheaders SFF Timeseries I/O
52
 *
53
 * This interface is presented in sffheaders.h
54
 *
55
56
57
58
 * This module provides three submodules:
 *   - \ref subgroup_sffheaders_classes
 *   - \ref subgroup_sffheaders_datrwxx
 *   - \ref subgroup_sffheaders_sffxx
59
60
 */

61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*! \brief A set of classes to handle complete files
 *
 * \defgroup subgroup_sffheaders_classes A set of classes to handle complete files
 * \ingroup group_sffheaders
 *
 * As a basis for time series processing, it provides the class template
 * SFFTimeSeries which inherits from ts::TimeSeries and this way is a fully
 * qualified TimeSeries class in terms of libtsxx.
 * SFFTimeSeries can be passed directly for filter modules and other modules
 * in libtsxx.
 * In contrast to the basic TimeSeries class definitions in libtsxx,
 * SFFTimeSeries is equipped with an SFF TraceHeader.
 *
 * By combining several SFFTimeSeries objects to a TraceVector, a set of
 * traces can be stored and passed along.
 * A TraceVector together with a FileHeader builds a data File.
 *
 * @{
 */

81
82
83
namespace ts {

  namespace sff {
thomas.forbriger's avatar
thomas.forbriger committed
84
85
86

    /*----------------------------------------------------------------------*/

87
88
    /*! \brief hold information for a complete SFF trace header
     * \ingroup group_sffheaders_classes
89
     */
thomas.forbriger's avatar
thomas.forbriger committed
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
    class TraceHeader {
      public:
        TraceHeader(): Mhasfree(false), Mhasinfo(false) { }
        void info(const ::sff::INFO& s);
        void free(const ::sff::FREE& f);
        void wid2(const ::sff::WID2& w) { Mwid2=w; }
        void append(const ::sff::FREE& f);
        ::sff::FREE free() const { return Mfree; }
        ::sff::INFO info() const { return Minfo; }
        ::sff::WID2 wid2() const { return Mwid2; }
        bool hasfree() const { return Mhasfree; }
        bool hasinfo() const { return Mhasinfo; }
        void read(std::istream& is, const bool& verbose=false);
      private:
        ::sff::FREE Mfree;
        ::sff::INFO Minfo;
        ::sff::WID2 Mwid2;
        bool Mhasfree;
        bool Mhasinfo;
    }; // class TraceHeader

    /*----------------------------------------------------------------------*/

113
114
    /*! \brief hold a full SFF trace and provide conversion
     * \ingroup group_sffheaders_classes
115
     */
thomas.forbriger's avatar
thomas.forbriger committed
116
117
118
119
120
121
122
123
124
125
126
127
128
    template<class C>
      class SFFTimeSeries: 
      public ts::TimeSeries<C,ts::sff::TraceHeader> {
        public:
          typedef ts::TimeSeries<C,ts::sff::TraceHeader> Tbase;
          typedef typename Tbase::Tvalue Tvalue;
          typedef ts::TimeSeries<C,::sff::WID2> Twid2timeseries;
          typedef ts::TimeSeries<C,ts::DTHeader<Tvalue> > Tdttimeseries;
          typedef typename Tbase::Tseries Tseries;
          typedef typename Tbase::Theader Theader;
          typedef typename Tbase::Tcoc Tcoc;
          typedef typename Tbase::Ttimeseries Ttimeseries;
          typedef typename Tbase::Tconsttimeseries Tconsttimeseries;
thomas.forbriger's avatar
thomas.forbriger committed
129
130
          SFFTimeSeries(): Tbase(), Mtraceindex(-1) { }
          SFFTimeSeries(const Tseries& s): Tbase(s), Mtraceindex(-1) { }
thomas.forbriger's avatar
thomas.forbriger committed
131
          void read(std::istream& is, const bool& verbose=false);
thomas.forbriger's avatar
thomas.forbriger committed
132
133
          int traceindex() const { return Mtraceindex; }
          void settraceindex(int ti) { Mtraceindex=ti; }
thomas.forbriger's avatar
thomas.forbriger committed
134
          operator Twid2timeseries() const
thomas.forbriger's avatar
thomas.forbriger committed
135
          { return Twid2timeseries(this->series(), this->header.wid2()); }
thomas.forbriger's avatar
thomas.forbriger committed
136
          operator Tdttimeseries() const
thomas.forbriger's avatar
thomas.forbriger committed
137
          { return Tdttimeseries(this->series(), this->header.wid2().dt); }
thomas.forbriger's avatar
thomas.forbriger committed
138
          int Mtraceindex; //!< trace index in data file
thomas.forbriger's avatar
thomas.forbriger committed
139
140
141
142
      }; // class SFFTimeSeries

    /*----------------------------------------------------------------------*/

143
144
145
146
/*!
 * @}
 */

thomas.forbriger's avatar
thomas.forbriger committed
147
  } // namespace sff
148
149
150
} // namespace ts
    
#endif // TSIO_SFFTIMESERIES_H_VERSION (includeguard)
thomas.forbriger's avatar
thomas.forbriger committed
151

152
/* ----- END OF sfftimeseries.h ----- */