Commit a442c00d authored by thomas.forbriger's avatar thomas.forbriger
Browse files

libtsxx, libdatrwxx [MERGE]: merge fix_sigfit into master

When compiling sigfit, the overloaded function resolution algorithm selected
the wrong output operator for ts::TimSeries objects. An output operator for
writing instances of this object type to datrw::oanystream was missing.

For this reason the overloaded output operator for aff::Series type objects to
datrw::oanystream was selected by casting ts::TimeSeries to its public base
class type aff::Series.

Solved the problem by providing additional output and input operators in
libtsxx and access to the debug flag in ianystream and oanystream in
libdatrwxx.
parents 27683b2a 2d74e07f
......@@ -39,6 +39,7 @@
* support property query
* - 07/09/2011 V1.9 more string type format ID support: openmode
* - 29/11/2011 V1.10 present complete idatstream interface
* - 13/04/2018 V1.11 provide access to debug flag if output stream
*
* ============================================================================
*/
......@@ -47,7 +48,7 @@
#ifndef DATRW_READANY_H_VERSION
#define DATRW_READANY_H_VERSION \
"DATRW_READANY_H V1.10"
"DATRW_READANY_H V1.11"
#include<string>
#include<datrwxx/datread.h>
......@@ -111,6 +112,10 @@ namespace datrw {
Properties ANYDELEGATE( properties )
static std::ios_base::openmode openmode(const Eformat& format);
static std::ios_base::openmode openmode(const std::string& format);
//! indicate debug mode
bool debug() { return this->idatstream().debug(); }
//! set debug mode
void debug(const bool& debug) { this->idatstream().debug(debug); }
private:
//! \brief actually open stream (to be called by constructor)
void open(std::istream& os, std::string format,
......
......@@ -33,6 +33,7 @@
* - 29/07/2011 V1.3 added constructor which accepts format modifiers
* support property query
* - 07/09/2011 V1.4 more string type format ID support: openmode
* - 13/04/2018 V1.5 provide access to debug flag if output stream
*
* ============================================================================
*/
......@@ -41,7 +42,7 @@
#ifndef DATRW_WRITEANY_H_VERSION
#define DATRW_WRITEANY_H_VERSION \
"DATRW_WRITEANY_H V1.4"
"DATRW_WRITEANY_H V1.5"
#include<string>
#include<datrwxx/datwrite.h>
......@@ -94,6 +95,10 @@ namespace datrw {
Edatatype ANYDELEGATE( seriestype )
static std::ios_base::openmode openmode(const Eformat& format);
static std::ios_base::openmode openmode(const std::string& format);
//! indicate debug mode
bool debug() { return this->odatstream().debug(); }
//! set debug mode
void debug(const bool& debug) { this->odatstream().debug(debug); }
private:
//! \brief actually open stream (to be called by constructor)
void open(std::ostream& os, std::string format,
......
......@@ -27,6 +27,8 @@
*
* REVISIONS and CHANGES
* - 22/11/2016 V1.0 Thomas Forbriger
* - 13/04/2018 V1.1 provide input and output operator for
* ianystream and oanystream too
*
* ============================================================================
*/
......@@ -35,15 +37,34 @@
#ifndef TSXX_WID2TSIO_H_VERSION
#define TSXX_WID2TSIO_H_VERSION \
"TSXX_WID2TSIO_H V1.0"
"TSXX_WID2TSIO_H V1.1"
#include<tsxx/wid2timeseries.h>
#include<datrwxx/datread.h>
#include<datrwxx/datwrite.h>
#include<datrwxx/readany.h>
#include<datrwxx/writeany.h>
#include<tsxx/debug.h>
namespace ts {
/*! output operator template for time series with WID2 header
*/
template<class C>
datrw::oanystream& operator<<(datrw::oanystream& os,
TimeSeries<C, sff::WID2>& s)
{
TSXX_debug(os.debug(),
"datrw::oanystream& operator>>(datrw::oanystream& os,\n"
" TimeSeries<C, sff::WID2>& s)",
TSXX_value(s.header.line()));
os << s.header;
typename TimeSeries<C, sff::WID2>::Tseries series(s);
os << series;
return(os);
} // datrw::oanystream& operator<<(datrw::oanystream& os,
// TimeSeries<C, sff::WID2>& s)
/* ---------------------------------------------------------------------- */
/*! output operator template for time series with WID2 header
*/
template<class C>
......@@ -62,7 +83,27 @@ namespace ts {
// TimeSeries<C, sff::WID2>& s)
/* ---------------------------------------------------------------------- */
/*! input operator template for time series with WID2 header
*/
template<class C>
datrw::ianystream& operator>>(datrw::ianystream& is,
TimeSeries<C, sff::WID2>& s)
{
typename TimeSeries<C, sff::WID2>::Tseries series;
is >> series;
s=series;
is >> s.header;
TSXX_debug(is.debug(),
"datrw::ianystream& operator>>(datrw::ianystream& is,\n"
" TimeSeries<C, sff::WID2>& s)",
TSXX_value(s.header.line()));
return(is);
} // datrw::ianystream& operator>>(datrw::ianystream& is,
// TimeSeries<C, sff::WID2>& s)
/* ---------------------------------------------------------------------- */
/*! input operator template for time series with WID2 header
*/
template<class C>
......
......@@ -43,11 +43,12 @@
* - 20/02/2012 V1.7 read and write any file format (damb)
* trace selecttion requires skip trace (thof)
* - 22/11/2016 V1.8 make use of new output facilities in libtsxx
* - 13/04/2018 V1.9
*
* ============================================================================
*/
#define SIGFIT_VERSION \
"SIGFIT V1.8 fit signal by trial-signals"
"SIGFIT V1.9 fit signal by trial-signals"
#include <fstream>
#include <iostream>
......@@ -59,6 +60,7 @@
#include <tfxx/rangelist.h>
#include <tfxx/rangestring.h>
#include <tfxx/error.h>
#include <tfxx/misc.h>
#include <datrwxx/readany.h>
#include <datrwxx/writeany.h>
#include <tsxx/tsxx.h>
......@@ -82,7 +84,7 @@ using std::endl;
// structure to store commandline options
struct Options {
bool verbose;
bool verbose, debug;
double Tdate;
bool truncate;
std::string residualname;
......@@ -143,7 +145,7 @@ int main(int iargc, char* argv[])
char usage_text[]=
{
SIGFIT_VERSION "\n"
"usage: sigfit [-v] [-Tdate v] [-truncate]" "\n"
"usage: sigfit [-v] [-DEBUG] [-Tdate v] [-truncate]" "\n"
" [-Sramp[=v]] [-Sconst[=v]] [-Sexp[=v]]" "\n"
" [-residual f]" "\n"
" [-searchrange[=r]] [-equalsearch] [-skip n]" "\n"
......@@ -242,6 +244,8 @@ int main(int iargc, char* argv[])
{"itype",arg_yes,"sff"},
// 12: output file format
{"otype",arg_yes,"sff"},
// 13: produce debug output
{"DEBUG",arg_no,"-"},
{NULL}
};
......@@ -296,6 +300,7 @@ int main(int iargc, char* argv[])
opt.tcexp=cmdline.double_arg(10);
opt.itype=cmdline.string_arg(11);
opt.otype=cmdline.string_arg(12);
opt.debug=cmdline.optset(13);
/*----------------------------------------------------------------------*/
......@@ -642,7 +647,7 @@ int main(int iargc, char* argv[])
}
std::ofstream ofs(opt.residualname.c_str(),
datrw::oanystream::openmode(opt.otype));
datrw::oanystream os(ofs, opt.otype);
datrw::oanystream os(ofs, opt.otype, opt.debug);
if (os.handlesfilefree())
{
sff::FREE residualFileFree;
......@@ -654,8 +659,17 @@ int main(int iargc, char* argv[])
}
os << residualFileFree;
}
TFXX_debug(opt.debug, "main()", "write trace signal\n " <<
TFXX_value(signal.header.channel) << "\n " <<
TFXX_value(signal.header.date.timestring()));
os << signal;
TFXX_debug(opt.debug, "main()", "write trace synthetics\n " <<
TFXX_value(synthetics.header.channel) << "\n " <<
TFXX_value(synthetics.header.date.timestring()));
os << synthetics;
TFXX_debug(opt.debug, "main()", "write trace residual\n " <<
TFXX_value(residual.header.channel) << "\n " <<
TFXX_value(residual.header.date.timestring()));
os << residual;
for (Tbundlevec::const_iterator i=bundlevec.begin();
i!=bundlevec.end(); i++)
......
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