readany.cc 5.51 KB
Newer Older
1
2
3
4
5
/*! \file readany.cc
 * \brief read any type (implementation)
 * 
 * ----------------------------------------------------------------------------
 * 
6
 * $Id: readany.cc,v 1.18 2010-05-03 11:07:45 tforb Exp $
7
8
9
10
 * \author Thomas Forbriger
 * \date 06/04/2004
 * 
 * read any type (implementation)
thomas.forbriger's avatar
thomas.forbriger committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 *
 * ----
 * 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
 * ----
27
28
29
30
31
 * 
 * Copyright (c) 2004 by Thomas Forbriger (BFO Schiltach) 
 * 
 * REVISIONS and CHANGES 
 *  - 06/04/2004   V1.0   Thomas Forbriger
32
 *  - 16/09/2004   V1.1   activate isffstream
thomas.forbriger's avatar
thomas.forbriger committed
33
 *  - 23/12/2004   V1.2   activate ihpmostream
thomas.forbriger's avatar
thomas.forbriger committed
34
 *  - 29/06/2007   V1.3   added SAC binary format
thomas.forbriger's avatar
thomas.forbriger committed
35
 *  - 19/09/2007   V1.4   added raw GSE format
36
 *  - 12/11/2009   V1.5   added TSOFT format
37
 *  - 03/05/2010   V1.6   sac provides debugging
38
39
40
41
 * 
 * ============================================================================
 */
#define DATREAD_READANY_CC_VERSION \
42
  "DATREAD_READANY_CC   V1.6"
43
#define DATREAD_READANY_CC_CVSID \
44
  "$Id: readany.cc,v 1.18 2010-05-03 11:07:45 tforb Exp $"
45
46

#include <datreadxx/readany.h>
47
#include<datreadxx/sff.h>
thomas.forbriger's avatar
thomas.forbriger committed
48
#include<datreadxx/pdas.h>
thomas.forbriger's avatar
thomas.forbriger committed
49
#include<datreadxx/hpmo.h>
thomas.forbriger's avatar
thomas.forbriger committed
50
#include<datreadxx/mseed.h>
51
#include<datreadxx/bonjer.h>
thomas.forbriger's avatar
thomas.forbriger committed
52
#include<datreadxx/sac.h>
thomas.forbriger's avatar
thomas.forbriger committed
53
#include<datreadxx/gse.h>
54
#include<datreadxx/tsoft.h>
55
56
57
58
#include <datreadxx/error.h>

namespace datread {

thomas.forbriger's avatar
thomas.forbriger committed
59
60
  ianystream::ianystream(std::istream& is, const Eformat& format,
                         const bool& debug):
61
62
    Mformat(format)
  {
thomas.forbriger's avatar
thomas.forbriger committed
63
64
    if (Mformat==Fbonjer) { Mis=new ibonjerstream(is); }
    else if (Mformat==Fpdas) { Mis=new ipdasstream(is); }
thomas.forbriger's avatar
thomas.forbriger committed
65
    else if (Mformat==Fsff) { Mis=new isffstream(is, debug); }
thomas.forbriger's avatar
thomas.forbriger committed
66
    else if (Mformat==Fhpmo) { Mis=new ihpmostream(is); }
thomas.forbriger's avatar
thomas.forbriger committed
67
    else if (Mformat==Fmseed) { Mis=new imseedstream(is, debug); }
68
    else if (Mformat==Fsac) { Mis=new isacstream(is, debug); }
thomas.forbriger's avatar
thomas.forbriger committed
69
    else if (Mformat==Fgse) { Mis=new igsestream(is); }
70
    else if (Mformat==Ftsoft) { Mis=new itsoftstream(is); }
71
    else 
thomas.forbriger's avatar
thomas.forbriger committed
72
    { DATREAD_abort("ERROR (ianystream): unknown format!"); }
73
74
75
76
77
78
79
80
81
  }

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

  ianystream::~ianystream()
  {
    delete Mis;
  }

82
83
84
85
86
87
88
89
90
91
92
93
  /*======================================================================*/
  // functions
  
  Eformat anyID(const std::string& id)
  {
    Eformat retval;
    if (id=="pdas") 
    { retval=Fpdas; }
    else if (id=="sff") 
    { retval=Fsff; }
    else if (id=="hpmo") 
    { retval=Fhpmo; }
thomas.forbriger's avatar
thomas.forbriger committed
94
95
    else if (id=="mseed") 
    { retval=Fmseed; }
96
97
    else if (id=="bonjer") 
    { retval=Fbonjer; }
thomas.forbriger's avatar
thomas.forbriger committed
98
99
    else if (id=="sac") 
    { retval=Fsac; }
thomas.forbriger's avatar
thomas.forbriger committed
100
101
    else if (id=="gse") 
    { retval=Fgse; }
102
103
    else if (id=="tsoft") 
    { retval=Ftsoft; }
104
105
106
107
108
109
110
111
112
113
114
115
    else { DATREAD_abort("unknown data type identifier!"); } 
    return(retval);
  }
  // Eformat anyID(const std::string& identifier)
  
  std::string anyID(const Eformat& id)
  {
    std::string retval="NSP";
    switch(id) {
    case Fpdas:   retval="pdas"; break;
    case Fsff:    retval="sff"; break;
    case Fhpmo:   retval="hpmo"; break;
thomas.forbriger's avatar
thomas.forbriger committed
116
    case Fmseed:  retval="mseed"; break;
117
    case Fbonjer: retval="bonjer"; break;
thomas.forbriger's avatar
thomas.forbriger committed
118
    case Fsac:    retval="sac"; break;
thomas.forbriger's avatar
thomas.forbriger committed
119
    case Fgse:    retval="gse"; break;
120
    case Ftsoft:  retval="tsoft"; break;
121
122
123
124
125
126
    default: DATREAD_abort("unknown data type ID#!");
    }
    return(retval);
  }
  // std::string anyID(const Eformat& id)
    
thomas.forbriger's avatar
thomas.forbriger committed
127
128
129
130
  /*----------------------------------------------------------------------*/

  void supported_data_types(std::ostream& os)
  {
thomas.forbriger's avatar
thomas.forbriger committed
131
132
    os << "data formats supported by ianystream:" << std::endl;
    os << "  sff:     Stuttgart File Format" << std::endl;
thomas.forbriger's avatar
thomas.forbriger committed
133
134
    os << "  hpmo:    HP-MO data format defined by W. Grossmann (BFO)" 
      << std::endl;
thomas.forbriger's avatar
thomas.forbriger committed
135
    os << "  pdas:    PDAS100 (i.e. DaDisp)" << std::endl;
thomas.forbriger's avatar
thomas.forbriger committed
136
    os << "  mseed:   MiniSEED (SeisComP, EDL, etc.)" << std::endl;
thomas.forbriger's avatar
thomas.forbriger committed
137
138
    os << "  bonjer:  K2 ASCII data format (defined by K. Bonjer?)" 
      << std::endl;
thomas.forbriger's avatar
thomas.forbriger committed
139
    os << "  sac:     SAC binary format" << std::endl;
thomas.forbriger's avatar
thomas.forbriger committed
140
    os << "  gse:     raw GSE format" << std::endl;
141
    os << "  tsoft:   TSOFT format" << std::endl;
thomas.forbriger's avatar
thomas.forbriger committed
142
    os << DATREAD_READANY_CC_CVSID << std::endl;
thomas.forbriger's avatar
thomas.forbriger committed
143
144
  }

thomas.forbriger's avatar
thomas.forbriger committed
145
146
147
148
149
150
151
152
  /*----------------------------------------------------------------------*/

  void online_help(std::ostream& os)
  {
    os << std::endl
      << "Online help obtained from data extraction facilities:"
      << std::endl;
    os << "SFF data: "; isffstream::help(os);
153
    os << std::endl;
thomas.forbriger's avatar
thomas.forbriger committed
154
    os << "HPMO data: "; ihpmostream::help(os);
155
    os << std::endl;
thomas.forbriger's avatar
thomas.forbriger committed
156
    os << "MiniSEED data: "; imseedstream::help(os);
157
    os << std::endl;
thomas.forbriger's avatar
thomas.forbriger committed
158
    os << "PDAS data: "; ipdasstream::help(os);
159
    os << std::endl;
thomas.forbriger's avatar
thomas.forbriger committed
160
    os << "Bonjer data: "; ibonjerstream::help(os);
161
    os << std::endl;
thomas.forbriger's avatar
thomas.forbriger committed
162
    os << "SAC data: "; isacstream::help(os);
163
    os << std::endl;
thomas.forbriger's avatar
thomas.forbriger committed
164
    os << "GSE data: "; igsestream::help(os);
165
    os << std::endl;
166
    os << "TSOFT data: "; itsoftstream::help(os);
thomas.forbriger's avatar
thomas.forbriger committed
167
168
  }

169
170
171
} // namespace datread

/* ----- END OF readany.cc ----- */