Commit 3e857bd2 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

provide format properties through static and external variable

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.
non yet fully implemented


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/branches/libdatrwxx.su
SVN Revision: 3459
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 6d3887b9
......@@ -29,6 +29,7 @@
*
* REVISIONS and CHANGES
* - 30/03/2004 V1.0 Thomas Forbriger
* - 23/11/2010 V1.1 introduced static members
*
* ============================================================================
*/
......@@ -37,7 +38,7 @@
#ifndef DATRW_BONJER_H_VERSION
#define DATRW_BONJER_H_VERSION \
"DATRW_BONJER_H V1.0 "
"DATRW_BONJER_H V1.1"
#define DATRW_BONJER_H_CVSID \
"$Id$"
......@@ -45,6 +46,15 @@
namespace datrw {
namespace bonjer {
extern const bool isbinary;
extern const char* const streamID;
} // namespace bonjer
/*----------------------------------------------------------------------*/
/*! \brief input stream to read seismic data provided by K. Bonjer
*
* \ingroup bonjer
......@@ -64,6 +74,7 @@ namespace datrw {
virtual void skipseries() { readheader(); }
static void help(std::ostream& os=std::cout)
{ Tbase::help(os, "ibonjerstream"); }
static const std::ios_base::openmode openmode;
private:
void readheader();
}; // class ibonjerstream
......
......@@ -30,11 +30,12 @@
* REVISIONS and CHANGES
* - 30/03/2004 V1.0 Thomas Forbriger
* - 31/10/2010 V1.1 pass station value to station header field
* - 23/11/2010 V1.2 introduced static members
*
* ============================================================================
*/
#define DATRW_BONJER_CC_VERSION \
"DATRW_BONJER_CC V1.1"
"DATRW_BONJER_CC V1.2"
#define DATRW_BONJER_CC_CVSID \
"$Id$"
......@@ -43,6 +44,18 @@
namespace datrw {
const std::ios_base::openmode ibonjerstream::openmode=std::ios_base::in;
//@{
/*! \brief Format properties
* \ingroup bonjer
*/
bool bonjer::isbinary=false;
char* const bonjer::streamID="bonjer";
//@}
/*----------------------------------------------------------------------*/
ibonjerstream::ibonjerstream(std::istream& is): Tbase(is, true, true, true)
{ }
......
......@@ -48,7 +48,6 @@ namespace datrw {
* \param providesd \c true, if stream provides \c double type series
* \param providesf \c true, if stream provides \c float type series
* \param providesi \c true, if stream provides \c int type series
* \param isbinary \c true, if input stream should be opened in binary mode
*/
idatstream::idatstream(std::istream& is,
const bool& providesd,
......@@ -57,25 +56,13 @@ namespace datrw {
const bool& isbinary):
Mis(is), Mwid2set(false), Msrceset(false), Minfoset(false),
Mtracefreeset(false), Mfilefreeset(false), Mlast(false),
Mprovidesd(providesd), Mprovidesf(providesf), Mprovidesi(providesi),
Misbinary(isbinary)
Mprovidesd(providesd), Mprovidesf(providesf), Mprovidesi(providesi)
{
DATRW_assert(is.good(), "input stream is not good!");
} // idatstream::idatstream
/*----------------------------------------------------------------------*/
/*! return open mode required for this type of stream
*/
std::ios_base::openmode idatstream::openmode() const
{
std::ios_base::openmode retval=std::ios_base::in;
if (this->isbinary()) { retval |= std::ios_base::binary; }
return(retval);
} // ios_base::openmode openmode() const
/*----------------------------------------------------------------------*/
bool idatstream::hasfree() const
{
if (Mwid2set) { return(Mtracefreeset); } else { return(Mfilefreeset); }
......
......@@ -75,6 +75,10 @@ namespace datrw {
* and skipseries() have to be virtual. They are responsible for filling the
* header data structures with appropriate values upon scanning/reading a
* time series.
*
* \note
* All derived classes are expected to provide static members
* openmode and isbinary
*/
class idatstream {
public:
......@@ -89,8 +93,6 @@ namespace datrw {
bool providesd() const { return(Mprovidesd); }
bool providesf() const { return(Mprovidesf); }
bool providesi() const { return(Mprovidesi); }
bool isbinary() const { return(Misbinary); }
std::ios_base::openmode openmode() const;
bool last() const { return(Mlast); }
bool good() const { return(!Mlast); }
/*! return FREE block
......@@ -115,8 +117,7 @@ namespace datrw {
idatstream(std::istream& is,
const bool& providesd=false,
const bool& providesf=false,
const bool& providesi=false,
const bool& isbinary=false);
const bool& providesi=false);
std::istream& Mis;
void setfilefree(const sff::FREE& free);
void settracefree(const sff::FREE& free);
......@@ -133,7 +134,7 @@ namespace datrw {
sff::FREE Mfilefree;
bool Mwid2set, Msrceset, Minfoset, Mtracefreeset, Mfilefreeset;
bool Mlast;
bool Mprovidesd, Mprovidesf, Mprovidesi, Misbinary;
bool Mprovidesd, Mprovidesf, Mprovidesi;
}; // class idatstream
/*----------------------------------------------------------------------*/
......
......@@ -30,6 +30,7 @@
*
* REVISIONS and CHANGES
* - 19/09/2007 V1.0 Thomas Forbriger
* - 23/11/2010 V1.1 introduced static members
*
* ============================================================================
*/
......@@ -38,7 +39,7 @@
#ifndef TF_GSE_H_VERSION
#define TF_GSE_H_VERSION \
"TF_GSE_H V1.0 "
"TF_GSE_H V1.1"
#define TF_GSE_H_CVSID \
"$Id$"
......@@ -46,6 +47,15 @@
namespace datrw {
namespace gse {
extern const bool isbinary;
extern const char* const streamID;
} // namespace gse
/*----------------------------------------------------------------------*/
/*! \brief class to read raw GSE data
* \ingroup gse
*/
......@@ -59,6 +69,7 @@ namespace datrw {
virtual Tiseries iseries();
virtual void skipseries();
static void help(std::ostream& os=std::cout);
static const std::ios_base::openmode openmode;
private:
void readheader();
}; // class igsestream
......
......@@ -30,11 +30,12 @@
*
* REVISIONS and CHANGES
* - 19/09/2007 V1.0 Thomas Forbriger
* - 23/11/2010 V1.1 introduced static members
*
* ============================================================================
*/
#define TF_GSE_CC_VERSION \
"TF_GSE_CC V1.0 "
"TF_GSE_CC V1.1"
#define TF_GSE_CC_CVSID \
"$Id$"
......@@ -47,6 +48,18 @@
namespace datrw {
const std::ios_base::openmode ibonjerstream::openmode=std::ios_base::in;
//@{
/*! \brief Format properties
* \ingroup bonjer
*/
bool gse::isbinary=false;
char* const gse::streamID="gse";
//@}
/*----------------------------------------------------------------------*/
igsestream::igsestream(std::istream& is): Tbase(is, true, true, true)
{ }
......
......@@ -29,6 +29,7 @@
*
* REVISIONS and CHANGES
* - 31/03/2004 V1.0 Thomas Forbriger
* - 23/11/2010 V1.1 introduced static members
*
* ============================================================================
*/
......@@ -37,7 +38,7 @@
#ifndef DATRW_HPMO_H_VERSION
#define DATRW_HPMO_H_VERSION \
"DATRW_HPMO_H V1.0 "
"DATRW_HPMO_H V1.1"
#define DATRW_HPMO_H_CVSID \
"$Id$"
......@@ -47,6 +48,15 @@
namespace datrw {
namespace hpmo {
extern const bool isbinary;
extern const char* const streamID;
} // namespace hpmo
/*----------------------------------------------------------------------*/
/*! \brief class to read HPMO data
*
* \ingroup hpmo
......@@ -62,6 +72,7 @@ namespace datrw {
virtual void skipseries();
static void help(std::ostream& os=std::cout)
{ Tbase::help(os, "ihpmostream"); }
static const std::ios_base::openmode openmode;
private:
//! read one data file
void read(std::istream& is, const bool& verbose=false);
......
......@@ -7,7 +7,7 @@
* \author Thomas Forbriger
* \date 31/03/2004
*
* provide data from HP Mo (BFO data acquisition system) (implementation)
* provide data from HP-MO (BFO data acquisition system) (implementation)
*
* ----
* This program is free software; you can redistribute it and/or modify
......@@ -29,11 +29,12 @@
*
* REVISIONS and CHANGES
* - 31/03/2004 V1.0 Thomas Forbriger
* - 23/11/2010 V1.1 introduced static members
*
* ============================================================================
*/
#define DATRW_HPMO_CC_VERSION \
"DATRW_HPMO_CC V1.0 "
"DATRW_HPMO_CC V1.1"
#define DATRW_HPMO_CC_CVSID \
"$Id$"
......@@ -47,6 +48,12 @@
namespace datrw {
const std::ios_base::openmode ibonjerstream::openmode=std::ios_base::in;
const bool ibonjerstream::isbinary=false;
const char* const ibonjerstream::streamID="hpmo";
/*----------------------------------------------------------------------*/
ihpmostream::ihpmostream(std::istream& is, const bool& verbose):
Tbase(is, true, true, false),
Mnblocks(0), Mnextblock(0), Mnextchannel(0)
......
......@@ -29,6 +29,7 @@
*
* REVISIONS and CHANGES
* - 15/07/2004 V1.0 Thomas Forbriger
* - 23/11/2010 V1.1 introduced static members
*
* ============================================================================
*/
......@@ -37,7 +38,7 @@
#ifndef TF_MSEED_H_VERSION
#define TF_MSEED_H_VERSION \
"TF_MSEED_H V1.0 "
"TF_MSEED_H V1.1"
#define TF_MSEED_H_CVSID \
"$Id$"
......@@ -45,6 +46,15 @@
namespace datrw {
namespace mseed {
extern const bool isbinary;
extern const char* const streamID;
} // namespace mseed
/*----------------------------------------------------------------------*/
namespace mseed {
/*! structure to hold one MiniSEEDRecord in SFF format
......@@ -64,6 +74,8 @@ namespace datrw {
} // namespace mseed
/*----------------------------------------------------------------------*/
/*! \brief class to read mini-SEED data
*
* \ingroup mseed
......@@ -78,6 +90,7 @@ namespace datrw {
virtual Tiseries iseries();
virtual void skipseries();
static void help(std::ostream& os=std::cout);
static const std::ios_base::openmode openmode;
private:
//! read file
Tiseries read(const bool& skipdata=false);
......
......@@ -32,11 +32,12 @@
* - 24/07/2006 V1.1 reading function was not comparing record start
* time against expected record start time
* - 29/06/2007 V1.2 prefer to use our own functions
* - 23/11/2010 V1.3 introduced static members
*
* ============================================================================
*/
#define TF_MSEED_CC_VERSION \
"TF_MSEED_CC V1.2"
"TF_MSEED_CC V1.3"
#define TF_MSEED_CC_CVSID \
"$Id$"
......@@ -50,6 +51,13 @@
namespace datrw {
const std::ios_base::openmode
ibonjerstream::openmode=std::ios_base::in|std::ios_base::binary;
const bool ibonjerstream::isbinary=true;
const char* const ibonjerstream::streamID="mseed";
/*----------------------------------------------------------------------*/
namespace mseed {
//! read and decode a record to SFF
......@@ -72,7 +80,7 @@ namespace datrw {
} // namespace mseed
imseedstream::imseedstream(std::istream& is, const bool& debug):
Tbase(is, true, true, true, true), Mdebug(debug)
Tbase(is, true, true, true), Mdebug(debug)
{
/* We must always be one record in advance. Data reading will be done by
* concatenating several MiniSEED records. A time series will be
......
......@@ -30,6 +30,7 @@
* REVISIONS and CHANGES
* - 30/03/2004 V1.0 Thomas Forbriger
* - 17/09/2004 V1.1 slightly simplified
* - 23/11/2010 V1.2 introduced static member data
*
* ============================================================================
*/
......@@ -38,7 +39,7 @@
#ifndef DATRW_PDAS_H_VERSION
#define DATRW_PDAS_H_VERSION \
"DATRW_PDAS_H V1.1 "
"DATRW_PDAS_H V1.2"
#define DATRW_PDAS_H_CVSID \
"$Id$"
......@@ -48,6 +49,15 @@
namespace datrw {
namespace pdas {
extern const bool isbinary;
extern const char* const streamID;
} // namespace pdas
/*----------------------------------------------------------------------*/
/*! \brief class to read PDAS data
*
* \ingroup pdas
......@@ -63,6 +73,9 @@ namespace datrw {
virtual Tiseries iseries();
virtual void skipseries();
static void help(std::ostream& os=std::cout);
static const std::ios_base::openmode openmode;
static const bool isbinary;
static const char* const streamID;
private:
void readheader();
// private members
......
......@@ -31,11 +31,12 @@
* - 30/03/2004 V1.0 Thomas Forbriger
* - 17/09/2004 V1.1 slightly simplified
* - 20/10/2004 V1.2 support scaling for floating point output types
* - 23/11/2010 V1.3 introduced static member data
*
* ============================================================================
*/
#define DATRW_PDAS_CC_VERSION \
"DATRW_PDAS_CC V1.2 "
"DATRW_PDAS_CC V1.3"
#define DATRW_PDAS_CC_CVSID \
"$Id$"
......@@ -47,8 +48,15 @@
namespace datrw {
const std::ios_base::openmode
ibonjerstream::openmode=std::ios_base::in|std::ios_base::binary;
const bool ibonjerstream::isbinary=true;
const char* const ibonjerstream::streamID="pdas";
/*----------------------------------------------------------------------*/
ipdasstream::ipdasstream(std::istream& is)
: Tbase(is, true, true, true, true)
: Tbase(is, true, true, true)
{ }
/*----------------------------------------------------------------------*/
......
......@@ -36,11 +36,12 @@
* - 12/11/2009 V1.5 added TSOFT format
* - 03/05/2010 V1.6 sac provides debugging
* - 06/10/2010 V1.7 added ASCII format of T. Forbrigers any2ascii
* - 23/11/2010 V1.8 use static member data
*
* ============================================================================
*/
#define DATRW_READANY_CC_VERSION \
"DATRW_READANY_CC V1.7"
"DATRW_READANY_CC V1.8"
#define DATRW_READANY_CC_CVSID \
"$Id$"
......@@ -58,6 +59,51 @@
namespace datrw {
/*! return whether the specific format is a binary data format
*
* \param format selected data format
* \return \c true, if data format is binary
*/
bool isbinary(const Eformat& format)
{
bool retval=false;
if (Mformat==Fbonjer) { retval=bonjer::isbinary; }
else if (Mformat==Fpdas) { retval=pdas::isbinary; }
else if (Mformat==Fsff) { retval=sff::isbinary; }
else if (Mformat==Fhpmo) { retval=hpmo::isbinary; }
else if (Mformat==Fmseed) { retval=mseed::isbinary; }
else if (Mformat==Fsac) { retval=sac::isbinary; }
else if (Mformat==Fgse) { retval=gse::isbinary; }
else if (Mformat==Ftsoft) { retval=tsoft::isbinary; }
else if (Mformat==Ftfascii) { retval=tfascii::isbinary; }
else
{ DATRW_abort("ERROR (isbinary): unknown format!"); }
return(retval);
} // bool isbinary(const Eformat& format)
/*----------------------------------------------------------------------*/
/*! return appropriate file stream open mode for selected format
*/
std::ios_base::openmode ianystream::openmode(const Eformat& format)
{
std::ios_base::openmode retval;
if (Mformat==Fbonjer) { retval=ibonjerstream::openmode; }
else if (Mformat==Fpdas) { retval=ipdasstream::openmode; }
else if (Mformat==Fsff) { retval=isffstream::openmode; }
else if (Mformat==Fhpmo) { retval=ihpmostream::openmode; }
else if (Mformat==Fmseed) { retval=imseedstream::openmode; }
else if (Mformat==Fsac) { retval=isacstream::openmode; }
else if (Mformat==Fgse) { retval=igsestream::openmode; }
else if (Mformat==Ftsoft) { retval=itsoftstream::openmode; }
else if (Mformat==Ftfascii) { retval=itfasciistream::openmode; }
else
{ DATRW_abort("ERROR (openmode): unknown format!"); }
return(retval);
} // std::ios_base::openmode ianystream::openmode(const Eformat& format)
/*----------------------------------------------------------------------*/
ianystream::ianystream(std::istream& is, const Eformat& format,
const bool& debug):
Mformat(format)
......
......@@ -33,6 +33,7 @@
* - 19/09/2007 V1.2 added raw GSE format
* - 12/11/2009 V1.3 added TSOFT data
* - 06/10/2010 V1.4 added ASCII format of T. Forbrigers any2ascii
* - 23/11/2010 V1.5 use static members
*
* ============================================================================
*/
......@@ -41,7 +42,7 @@
#ifndef DATRW_READANY_H_VERSION
#define DATRW_READANY_H_VERSION \
"DATRW_READANY_H V1.4"
"DATRW_READANY_H V1.5"
#define DATRW_READANY_H_CVSID \
"$Id$"
......@@ -86,9 +87,8 @@ namespace datrw {
bool ANYDELEGATE( providesd )
bool ANYDELEGATE( providesf )
bool ANYDELEGATE( providesi )
bool ANYDELEGATE( isbinary )
std::ios_base::openmode ANYDELEGATE( openmode )
void ANYDELEGATE( skipseries )
static std::ios_base::openmode openmode(const Eformat& format);
private:
ianystream(const ianystream&);
ianystream& operator=(const ianystream&);
......@@ -98,6 +98,8 @@ namespace datrw {
#undef ANYDELEGATE
bool isbinary(const Eformat& format);
// convert identifier from and to string representation
Eformat anyID(const std::string& identifier);
std::string anyID(const Eformat& id);
......
......@@ -30,22 +30,32 @@
* REVISIONS and CHANGES
* - 21/12/2004 V1.0 Thomas Forbriger
* - 03/05/2010 V1.1 sac provides debugging option
* - 23/11/2010 V1.2 introduced static member data
*
* ============================================================================
*/
// include guard
#ifndef TF_SAC_H_VERSION
#ifndef DATRW_SAC_H_VERSION
#define TF_SAC_H_VERSION \
"TF_SAC_H V1.1"
#define TF_SAC_H_CVSID \
#define DATRW_SAC_H_VERSION \
"DATRW_SAC_H V1.2"
#define DATRW_SAC_H_CVSID \
"$Id$"
#include<datrwxx/datread.h>
namespace datrw {
namespace sac {
extern const bool isbinary;
extern const char* const streamID;
} // namespace sac
/*----------------------------------------------------------------------*/
/*! \brief class to read SAC binary data
*
* \ingroup sac
......@@ -60,6 +70,7 @@ namespace datrw {
virtual Tiseries iseries();
virtual void skipseries();
static void help(std::ostream& os=std::cout);
static const std::ios_base::openmode openmode;
private:
void readheader();
bool Mdebug;
......@@ -67,6 +78,6 @@ namespace datrw {
} // namespace datrw
#endif // TF_SAC_H_VERSION (includeguard)
#endif // DATRW_SAC_H_VERSION (includeguard)
/* ----- END OF sac.h ----- */
......@@ -30,11 +30,12 @@
* REVISIONS and CHANGES
* - 21/12/2004 V1.0 Thomas Forbriger
* - 03/05/2010 V1.1 sac provides debugging option
* - 23/11/2010 V1.2 introduced static member data
*
* ============================================================================
*/
#define TF_SAC_CC_VERSION \
"TF_SAC_CC V1.1"
"TF_SAC_CC V1.2"
#define TF_SAC_CC_CVSID \
"$Id$"
......@@ -48,8 +49,15 @@
namespace datrw {
const std::ios_base::openmode
ibonjerstream::openmode=std::ios_base::in|std::ios_base::binary;
<