Commit 90ff3a93 authored by thomas.forbriger's avatar thomas.forbriger
Browse files

libdatrwxx [FEATURE][WP]: provide debug flag in base class

A common debug flag for all stream classes now is provided in the base classes
idatstream and odatstream. The debug member data is removed from all specific
input and output stream classes. This way we guarantee that any class which
can be referred to through ianystream and oanystream provides a debug flag.
This is necessary to allow input and output operators for example to check
whether the stream is in debug mode. This way generic operators or functions
can print a debug messages.

Recompiled test cases and full Seitosh repository to make sure that modified
interface operates properly in existing code.
parent 87e6f3ea
......@@ -15,7 +15,7 @@
namespace datrw {
const char* const libversion="libdatrwxx (version 2016-07-05)";
const char* const libversion="libdatrwxx (version 2016-11-18)";
} // namespace datrw
......
......@@ -30,6 +30,7 @@
* REVISIONS and CHANGES
* - 11/04/2006 V1.0 Thomas Forbriger
* - 23/08/2012 V1.1 output stream supports modifiers
* - 18/11/2016 V1.2 use debug flag in base class
*
* ============================================================================
*/
......@@ -38,7 +39,7 @@
#ifndef DATRW_ASCII_H_VERSION
#define DATRW_ASCII_H_VERSION \
"DATRW_ASCII_H V1.1"
"DATRW_ASCII_H V1.2"
#include<datrwxx/datread.h>
#include<datrwxx/datwrite.h>
......@@ -78,7 +79,6 @@ namespace datrw {
private:
void settraceheader();
void readheader();
bool Mdebug;
bool Mnonfatal;
std::string Mmodifier; //!< format modifier
std::string Mcurrentline;
......@@ -118,7 +118,6 @@ namespace datrw {
virtual void writetrace(const Tiseries::Tcoc& series);
private:
void writetraceheader(const unsigned int& n, const char* type);
bool Mdebug; //!< produce debug output if true
unsigned int Mprecision; //!< floating point format precision
}; // class oasciistream
......
......@@ -35,11 +35,12 @@
* - 08/07/2016 V1.2 thof:
* - make correct use of new DATRW_report_assert
* - make correct use of new DATRW_nonfatal_assert
* - 18/11/2016 V1.3 use debug flag in base class
*
* ============================================================================
*/
#define DATRW_IASCIISTREAM_CC_VERSION \
"DATRW_IASCIISTREAM_CC V1.2"
"DATRW_IASCIISTREAM_CC V1.3"
#include<iomanip>
#include<vector>
......@@ -60,7 +61,7 @@ namespace datrw {
iasciistream::iasciistream(std::istream& is,
const std::string& modifier,
const bool& debug):
Tbase(is, true, true, true), Mdebug(debug), Mmodifier(modifier)
Tbase(is, true, true, true, debug), Mmodifier(modifier)
{
// format modifiers must be used here to set defaults
datrw::Subformat subformat(Mmodifier);
......
......@@ -30,11 +30,12 @@
* REVISIONS and CHANGES
* - 18/10/2011 V1.0 Thomas Forbriger
* - 23/08/2012 V1.1 support format modifiers
* - 18/11/2016 V1.2 use debug flag in base class
*
* ============================================================================
*/
#define DATRW_OASCIISTREAM_CC_VERSION \
"DATRW_OASCIISTREAM_CC V1.1"
"DATRW_OASCIISTREAM_CC V1.2"
#include<datrwxx/ascii.h>
#include<datrwxx/debug.h>
......@@ -56,8 +57,7 @@ namespace datrw {
oasciistream::oasciistream(std::ostream& os,
const std::string& modifier,
const bool& debug):
Tbase(os, Fall, true, true, true, true),
Mdebug(debug)
Tbase(os, Fall, true, true, true, true, debug)
{
DATRW_debug(Mdebug, "oasciistream::oasciistream",
"new instance established");
......
......@@ -29,6 +29,7 @@
*
* REVISIONS and CHANGES
* - 24/02/2010 V1.0 Thomas Forbriger
* - 18/11/2016 V1.1 use debug flag in base class
*
* ============================================================================
*/
......@@ -37,7 +38,7 @@
#ifndef DATRW_BINARY_H_VERSION
#define DATRW_BINARY_H_VERSION \
"DATRW_BINARY_H V1.0 "
"DATRW_BINARY_H V1.1"
#include<datrwxx/datread.h>
#include<datrwxx/datwrite.h>
......@@ -116,7 +117,6 @@ namespace datrw {
void readflags();
void setnsamples(const unsigned int& nsamples);
binary::ibinstream Mibs;
bool Mdebug;
short Mversion;
char Mnextflags; //!< flags for next trace
}; // class ibinarystream
......@@ -145,7 +145,6 @@ namespace datrw {
private:
void writetraceheader(const binary::Eflags&,
const unsigned int& nsamples);
bool Mdebug;
binary::obinstream Mobs;
}; // class obinarystream
......
......@@ -29,11 +29,12 @@
*
* REVISIONS and CHANGES
* - 18/10/2011 V1.0 Thomas Forbriger
* - 18/11/2016 V1.1 use debug flag in base class
*
* ============================================================================
*/
#define DATRW_IBINARYSTREAM_CC_VERSION \
"DATRW_IBINARYSTREAM_CC V1.0 "
"DATRW_IBINARYSTREAM_CC V1.1"
#include<datrwxx/binary.h>
#include<datrwxx/error.h>
......@@ -49,9 +50,8 @@ namespace datrw {
ibinarystream::ibinarystream(std::istream& is,
const bool& debug):
Tbase(is, true, true, true),
Mibs(is, ::datrw::binary::magic, debug),
Mdebug(debug)
Tbase(is, true, true, true, debug),
Mibs(is, ::datrw::binary::magic, debug)
{
char flags;
Mibs >> Mversion;
......
......@@ -29,11 +29,12 @@
*
* REVISIONS and CHANGES
* - 18/10/2011 V1.0 Thomas Forbriger
* - 18/11/2016 V1.1 use debug flag in base class
*
* ============================================================================
*/
#define DATRW_OBINARYSTREAM_CC_VERSION \
"DATRW_OBINARYSTREAM_CC V1.0 "
"DATRW_OBINARYSTREAM_CC V1.1"
#include<datrwxx/binary.h>
#include<datrwxx/debug.h>
......@@ -46,8 +47,7 @@ namespace datrw {
/*----------------------------------------------------------------------*/
obinarystream::obinarystream(std::ostream& os, const bool& debug):
Tbase(os, Fall, true, true, true, true),
Mdebug(debug),
Tbase(os, Fall, true, true, true, true, debug),
Mobs(os, ::datrw::binary::magic, Mdebug)
//Mobs(os, ::datrw::binary::magic, debug)
{
......
......@@ -29,11 +29,12 @@
* REVISIONS and CHANGES
* - 30/03/2004 V1.0 Thomas Forbriger
* - 17/09/2004 V1.1 make most fields private
* - 18/11/2016 V1.2 provide debug flag in base class
*
* ============================================================================
*/
#define DATRW_DATRW_CC_VERSION \
"DATRW_DATRW_CC V1.1 "
"DATRW_DATRW_CC V1.2"
#include <datrwxx/datread.h>
......@@ -49,8 +50,9 @@ namespace datrw {
idatstream::idatstream(std::istream& is,
const bool& providesd,
const bool& providesf,
const bool& providesi)
: Mis(is), Mwid2set(false), Msrceset(false), Minfoset(false),
const bool& providesi,
const bool& debug)
: Mis(is), Mdebug(debug), Mwid2set(false), Msrceset(false), Minfoset(false),
Mtracefreeset(false), Mfilefreeset(false), Mlast(false),
Mprovidesd(providesd), Mprovidesf(providesf), Mprovidesi(providesi)
{
......
......@@ -34,6 +34,7 @@
* anything about Mis state
* - 23/11/2010 V1.4 introduced isbinary flag
* - 29/07/2011 V1.5 support property query
* - 18/11/2016 V1.6 provide debug flag in base class
*
* ============================================================================
*/
......@@ -42,7 +43,7 @@
#ifndef DATRW_DATREAD_H_VERSION
#define DATRW_DATREAD_H_VERSION \
"DATRW_DATREAD_H V1.5"
"DATRW_DATREAD_H V1.6"
#include<iostream>
#include<sffxx.h>
......@@ -110,11 +111,17 @@ namespace datrw {
//! print some info about data conversion.
static void help(std::ostream& os=std::cout,
const char* name="idatsream");
//! indicate debug mode
bool debug() { return Mdebug; }
//! set debug mode
void debug(const bool& debug) { Mdebug=debug; }
protected:
// member functions
idatstream(std::istream& is,
const bool& providesd=false,
const bool& providesf=false,
const bool& providesi=false);
const bool& providesi=false,
const bool& debug=false);
std::istream& Mis;
void setfilefree(const sff::FREE& free);
void settracefree(const sff::FREE& free);
......@@ -123,6 +130,8 @@ namespace datrw {
void setinfo(const sff::INFO& info);
void setlast();
void newtrace();
// member data
bool Mdebug;
private:
sff::WID2 Mwid2;
sff::SRCE Msrce;
......
......@@ -32,11 +32,12 @@
* - 01/04/2011 V1.1 do not clear Mhassrce upon writing the file header
* - 07/06/2011 V1.2 promise constness of series samples
* - 08/07/2016 V1.3 make correct use of new DATRW_report_assert
* - 18/11/2016 V1.4 provide debug flag in base class
*
* ============================================================================
*/
#define DATRW_DATWRITE_CC_VERSION \
"DATRW_DATWRITE_CC V1.3"
"DATRW_DATWRITE_CC V1.4"
#include<fstream>
#include <datrwxx/datwrite.h>
......@@ -85,9 +86,10 @@ namespace datrw {
const bool& handlesfilefree,
const bool& handlestracefree,
const bool& handlessrce,
const bool& handlesinfo)
: Mos(os), Mwid2set(false), Msrceset(false), Minfoset(false),
Mfreeset(false), Mheaderflushed(false),
const bool& handlesinfo,
const bool& debug)
: Mos(os), Mdebug(debug), Mwid2set(false), Msrceset(false),
Minfoset(false), Mfreeset(false), Mheaderflushed(false),
Mhandlestracefree(handlestracefree),
Mhandlesfilefree(handlesfilefree),
Mhandlesinfo(handlesinfo),
......
......@@ -31,6 +31,7 @@
* - 11/04/2006 V1.0 Thomas Forbriger
* - 07/06/2011 V1.1 promise constness of series samples
* - 29/07/2011 V1.2 support property query
* - 18/11/2016 V1.3 provide debug flag in base class
*
* ============================================================================
*/
......@@ -39,7 +40,7 @@
#ifndef DATRW_DATWRITE_H_VERSION
#define DATRW_DATWRITE_H_VERSION \
"DATRW_DATWRITE_H V1.2"
"DATRW_DATWRITE_H V1.3"
#include<string>
#include<iostream>
......@@ -139,6 +140,11 @@ namespace datrw {
//! print some info about data conversion.
static void help(std::ostream& os=std::cout,
const char* name="idatsream");
//! indicate debug mode
bool debug() { return Mdebug; }
//! set debug mode
void debug(const bool& debug) { Mdebug=debug; }
protected:
//! constructor is protected: do not create an instance of this class
odatstream(std::ostream& os,
......@@ -146,7 +152,8 @@ namespace datrw {
const bool& handlesfilefree=false,
const bool& handlestracefree=false,
const bool& handlessrce=false,
const bool& handlesinfo=false);
const bool& handlesinfo=false,
const bool& debug=false);
//! write double data
virtual void writetrace(const Tdseries::Tcoc& series) { DATRW_illegal; }
//! write single precision float data
......@@ -185,6 +192,9 @@ namespace datrw {
//! output stream to be used by this class
std::ostream& Mos;
//! global debug flag
bool Mdebug;
private:
bool Mwid2set, Msrceset, Minfoset, Mfreeset;
bool Mheaderflushed;
......
......@@ -34,6 +34,7 @@
* - 22/07/2014 V1.4 thof: support new format modifier: estimateNframes
* - 05/07/2016 V1.5 thof: provide consistency check control flags
* - 12/07/2016 V1.6 thof: provide usec consistency check
* - 18/11/2016 V1.7 use debug flag in base class
*
* ============================================================================
*/
......@@ -42,7 +43,7 @@
#ifndef DATRW_MSEED_H_VERSION
#define DATRW_MSEED_H_VERSION \
"DATRW_MSEED_H V1.6"
"DATRW_MSEED_H V1.7"
#include<datrwxx/datread.h>
......@@ -177,8 +178,6 @@ namespace datrw {
Tiseries read(const bool& skipdata=false);
//! data read ahead
datrw::mseed::Record Mrecord;
//! debugging mode
bool Mdebug;
std::string Mmodifier; //!< format modifier
bool Mdumpascii; //!< dump ASCII data if true
double Mttolerance; //!< timing tolerance in microseconds
......
......@@ -38,11 +38,12 @@
* - 05/07/2016 V1.7 thof: evaluate format modifiers to adjust
* consistency checks
* - 12/07/2016 V1.8 thof: provide usec consistency check
* - 18/11/2016 V1.9 use debug flag in base class
*
* ============================================================================
*/
#define DATRW_IMSEEDSTREAM_CC_VERSION \
"DATRW_IMSEEDSTREAM_CC V1.8"
"DATRW_IMSEEDSTREAM_CC V1.9"
#include <datrwxx/util.h>
#include <datrwxx/mseed.h>
......@@ -89,7 +90,7 @@ namespace datrw {
imseedstream::imseedstream(std::istream& is,
const std::string& modifier,
const bool& debug):
Tbase(is, true, true, true), Mdebug(debug), Mmodifier(modifier),
Tbase(is, true, true, true, debug), Mmodifier(modifier),
Mdumpascii(false), Mchecks(true, true)
{
datrw::Subformat subformat(Mmodifier);
......
......@@ -47,11 +47,12 @@
* - 19/11/2011 V1.17 provide binary input
* - 05/12/2011 V1.18 itsoftstream takes format modifiers
* - 21/01/2012 V1.19 prepared isustream to take modifiers
* - 18/11/2016 V1.20 set debug mode in base class
*
* ============================================================================
*/
#define DATRW_READANY_CC_VERSION \
"DATRW_READANY_CC V1.19"
"DATRW_READANY_CC V1.20"
#include <datrwxx/readany.h>
#include <datrwxx/sff.h>
......@@ -177,7 +178,7 @@ namespace datrw {
else if (Mformat==Fsff)
{
DATRW_expect_no_modifier(Mformat,modifiers);
Mis=new isffstream(is, debug);
Mis=new isffstream(is);
}
else if (Mformat==Fhpmo)
{
......@@ -186,12 +187,12 @@ namespace datrw {
}
else if (Mformat==Fmseed)
{
Mis=new imseedstream(is, modifiers, debug);
Mis=new imseedstream(is, modifiers);
}
else if (Mformat==Fsac)
{
DATRW_expect_no_modifier(Mformat,modifiers);
Mis=new isacstream(is, debug);
Mis=new isacstream(is);
}
else if (Mformat==Fgse)
{
......@@ -209,27 +210,28 @@ namespace datrw {
}
else if (Mformat==Fsu)
{
Mis=new isustream(is, modifiers, debug);
Mis=new isustream(is, modifiers);
}
else if (Mformat==Fseife)
{
Mis=new iseifestream(is, modifiers, debug);
Mis=new iseifestream(is, modifiers);
}
else if (Mformat==Fthiesdl1)
{
Mis=new ithiesdl1stream(is, modifiers, debug);
Mis=new ithiesdl1stream(is, modifiers);
}
else if (Mformat==Fascii)
{
Mis=new iasciistream(is, modifiers, debug);
Mis=new iasciistream(is, modifiers);
}
else if (Mformat==Fbinary)
{
DATRW_expect_no_modifier(Mformat,modifiers);
Mis=new ibinarystream(is, debug);
Mis=new ibinarystream(is);
}
else
{ DATRW_abort("ERROR (ianystream): unknown format!"); }
Mis->debug(debug);
}
/*----------------------------------------------------------------------*/
......
......@@ -30,6 +30,7 @@
* - 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
* - 18/11/2016 V1.3 use debug flag in base class
*
* ============================================================================
*/
......@@ -38,7 +39,7 @@
#ifndef DATRW_SAC_H_VERSION
#define DATRW_SAC_H_VERSION \
"DATRW_SAC_H V1.2"
"DATRW_SAC_H V1.3"
#include<datrwxx/datread.h>
......@@ -70,7 +71,6 @@ namespace datrw {
static const std::ios_base::openmode openmode;
private:
void readheader();
bool Mdebug;
}; // class isacstream
} // namespace datrw
......
......@@ -30,11 +30,12 @@
* - 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
* - 18/11/2016 V1.3 use debug flag in base class
*
* ============================================================================
*/
#define DATRW_ISACSTREAM_CC_VERSION \
"DATRW_ISACSTREAM_CC V1.2"
"DATRW_ISACSTREAM_CC V1.3"
#include <string>
#include <sstream>
......@@ -60,7 +61,7 @@ namespace datrw {
/*----------------------------------------------------------------------*/
isacstream::isacstream(std::istream& is, const bool& debug):
Tbase(is, true, true, true), Mdebug(debug)
Tbase(is, true, true, true, debug)
{ }
/*----------------------------------------------------------------------*/
......
......@@ -28,6 +28,7 @@
*
* REVISIONS and CHANGES
* - 30/11/2010 V1.0 Thomas Forbriger
* - 18/11/2016 V1.1 use debug flag in base class
*
* ============================================================================
*/
......@@ -36,7 +37,7 @@
#ifndef DATRW_SEIFE_H_VERSION
#define DATRW_SEIFE_H_VERSION \
"DATRW_SEIFE_H V1.0 "
"DATRW_SEIFE_H V1.1"
#include<datrwxx/datread.h>
#include<datrwxx/datwrite.h>
......@@ -75,7 +76,6 @@ namespace datrw {
static const std::ios_base::openmode openmode;
private:
void settraceheader();
bool Mdebug;
std::string Mmodifier; //!< format modifier
}; // class iseifestream
......@@ -100,7 +100,6 @@ namespace datrw {
virtual void writetrace(const Tfseries::Tcoc& series);
private:
void writetraceheader(const unsigned int& n);
bool Mdebug; //!< produce debug output if true
bool Mtracewritten; //!< true, if a trace has be written
std::string Mmodifier; //!< format modifier
}; // class oseifestream
......
......@@ -28,11 +28,12 @@
*
* REVISIONS and CHANGES
* - 30/11/2010 V1.0 Thomas Forbriger
* - 18/11/2016 V1.1 use debug flag in base class
*
* ============================================================================
*/
#define DATRW_ISEIFESTREAM_CC_VERSION \
"DATRW_ISEIFESTREAM_CC V1.0 "
"DATRW_ISEIFESTREAM_CC V1.1"
#include <datrwxx/seife.h>
#include <datrwxx/seifeio.h>
......@@ -49,7 +50,7 @@ namespace datrw {
iseifestream::iseifestream(std::istream& is,
const std::string& modifier,
const bool& debug):
Tbase(is, true, true, false), Mdebug(debug), Mmodifier(modifier)
Tbase(is, true, true, false, debug), Mmodifier(modifier)
{
} // iseifestream::iseifestream
......
......@@ -29,11 +29,12 @@
* REVISIONS and CHANGES
* - 30/11/2010 V1.0 Thomas Forbriger
* - 08/07/2016 V1.1 make correct use of new DATRW_report_assert
* - 18/11/2016 V1.2 use debug flag in base class
*
* ============================================================================
*/
#define DATRW_OSEIFESTREAM_CC_VERSION \
"DATRW_OSEIFESTREAM_CC V1.1"
"DATRW_OSEIFESTREAM_CC V1.2"
#include <datrwxx/seife.h>
#include <datrwxx/seifeio.h>
......@@ -51,8 +52,8 @@ namespace datrw {
oseifestream::oseifestream(std::ostream& os,
const std::string& modifier,
const bool& debug):
Tbase(os, Fdouble, false, true, false, false),
Mdebug(debug), Mtracewritten(false), Mmodifier(modifier)
Tbase(os, Fdouble, false, true, false, false, debug),
Mtracewritten(false), Mmodifier(modifier)
{
DATRW_debug(Mdebug, "oseifestream::oseifestream",
"new instance established");
......
......@@ -32,6 +32,7 @@
* - 23/11/2010 V1.2 introduced static member data
* - 07/06/2011 V1.3 promise constness of series samples
* - 21/11/2011 V1.4 introduce format modifiers
* - 18/11/2016 V1.5 use debug flag in base class
*
* ============================================================================
*/
......@@ -40,7 +41,7 @@
#ifndef DATRW_SFF_H_VERSION
#define DATRW_SFF_H_VERSION \
"DATRW_SFF_H V1.4"
"DATRW_SFF_H V1.5"
#include<sffxx.h>
#include<datrwxx/datread.h>
......@@ -85,7 +86,6 @@ namespace datrw {
static const std::ios_base::openmode openmode;
private:
void settraceheader(const ::sff::TraceHeader& header);
bool Mdebug;
}; // class isffstream
/*======================================================================*/
......@@ -115,8 +115,6 @@ namespace datrw {
*/
void flushwaitingtrace(const bool& last=false);
protected:
bool Mdebug;
private:
bool Mwid2iswaiting, Mfreeiswaiting, Minfoiswaiting;
::sff::WID2 Mwid2waiting;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment