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

[WP][API][!!!][FIX] (nocs): remove advanced file i/o from libtsxx

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.

Removed advanceѕtime series input/output as presented in sffheaders.cc and
sffheaders.h and moved those files to a new library. These files strongly
depended on code in libtfxx which is undesired. The bilateral relationship
between libtfxx and libtsxx is most appropriately be resolved by introducing a
new library which depends on both, libtsxx and libtfxx.

After making libtsxx independent of libtfxx I was unable to make libtfxx
compile. This is due to libtfx file types being reimplemented in libtsxx
necessarily.

Side-effects:
- the modification started here, will change the library interfaces expected
  by time series filter and plot programs
parent c73d11b4
This is a legacy version of the repository. It may be incomplete as well as
inconsistent. See README.history for details. For the old stock of the
repository copyright and licence conditions apply as specified for versions
commited after 2015-03-01. Use recent versions as a base for new development.
The legacy version is only stored to keep a record of history.
......@@ -78,7 +78,7 @@ $(call CHECKVARS,TF_BROWSER TF_WWWBASEDIR)
HEADERS=$(shell find . -name \*.h)
LIBSRC=tsxx.cc filter.cc seifexx.cc seifeclass.cc \
anyfilter.cc filterbase.cc ipo.cc ipolin.cc sffheaders.cc random.cc \
anyfilter.cc filterbase.cc ipo.cc ipolin.cc random.cc \
dropcontainer.cc firfilters.cc tapers.cc ovtaper.cc
INCINSTALLPATH=$(LOCINCLUDEDIR)/tsxx
......@@ -92,7 +92,6 @@ README=$(shell find . -name README)
# the frame of doxygen documentation is palced in text files
DOXYTXT=$(shell find . -name doxygen\*.txt)
#
# general part
# ------------
......
/*! \file range.h
* \brief deal with number ranges
*
* ----------------------------------------------------------------------------
*
* $Id$
* \author Thomas Forbriger
* \date 09/06/2002
*
* deal with number ranges
*
* Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
*
* ----
* 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
* ----
*
* REVISIONS and CHANGES
* - 09/06/2002 V1.0 Thomas Forbriger
* - 27/11/2002 V1.1 copied and modified from libcontxx sources
* - 27/04/2009 V1.2 added range stepper
* - 25/01/2014 V1.3 copied from libtsxx
*
* ============================================================================
*/
// include guard
#ifndef TSXX_RANGE_H_VERSION
#define TSXX_RANGE_H_VERSION \
"TSXX_RANGE_H V1.3"
#define TSXX_RANGE_H_CVSID \
"$Id$"
namespace ts {
/*! \brief A class to deal with numerical ranges
*
* \param T type of value (default=int)
*/
template<class T=int>
class Range {
public:
//! element type
typedef T Tvalue;
//! empty range
Range(): Mfirst(0), Mlast(0) { }
//! range containing exactly one element
Range(const Tvalue& index): Mfirst(index), Mlast(index) { }
//! set range
Range(const Tvalue& first, const Tvalue& last):
Mfirst(first<last ? first:last),
Mlast(last>first ? last:first) { }
//! access start of range
Tvalue& first() { return Mfirst; }
//! access end of range
Tvalue& last() { return Mlast; }
//! read start of range
const Tvalue& first() const { return Mfirst; }
//! read end of range
const Tvalue& last() const { return Mlast; }
//! is this range inside the other
bool isinside(const Range& other) const
{ return ((Mfirst >= other.first()) && (Mlast <= other.last())); }
//! does this range contain the other
bool contains(const Range& other) const
{ return ((Mfirst <= other.first()) && (Mlast >= other.last())); }
//! does this range contain then value v
bool contains(const Tvalue& v) const
{ return ((Mfirst <= v) && (Mlast >= v)); }
//! shrink to smaller of this and the other
Range& shrink(const Range& other)
{
Mfirst=Mfirst>other.first() ? Mfirst:other.first();
Mlast=Mlast<other.last() ? Mlast:other.last();
return *this;
}
//! expand to larger of this and the other
Range& expand(const Range& other)
{
Mfirst=Mfirst<other.first() ? Mfirst:other.first();
Mlast=Mlast>other.last() ? Mlast:other.last();
return *this;
}
//! shift by n
Range& shift(const Tvalue& n)
{ Mfirst+=n; Mlast+=n; return *this; }
//! shift by n
Range& operator+=(const Tvalue& n)
{ return this->shift(n); }
//! shift by -n
Range& operator-=(const Tvalue& n)
{ return this->shift(-n); }
private:
Tvalue Mfirst; //!< start of range.
Tvalue Mlast; //!< end of range.
}; // class Range
/*----------------------------------------------------------------------*/
/*! a class to step through a range
*
* This class is only meaningful for ranges of integer value
*/
template<class T=int>
class RangeStepper {
public:
typedef Range<T> Trange;
typedef typename Trange::Tvalue Tvalue;
RangeStepper(const Trange& range,
const Tvalue& stepsize=1):
Mrange(range), Mstepsize(stepsize), Mcurrent(Mrange.first()) { }
//! \brief return current value
operator Tvalue() const { return(this->current()); }
//! \brief return current value
Tvalue current() const { return(Mcurrent); }
/*! \brief true if stepper is still in range and can return a current
* value
*/
bool valid() const { return(Mcurrent<=Mrange.last()); }
//! \brief true if stepper will still be in range after next advance
bool more() const { return(Mcurrent<=(Mrange.last()-Mstepsize)); }
//! \brief advance to next value and return current value
Tvalue next()
{
if (this->valid()) { Mcurrent += Mstepsize; }
return(this->current());
}
//! \brief advance to next value and return current value
Tvalue operator++() { return(this->next()); }
private:
Trange Mrange;
Tvalue Mstepsize;
Tvalue Mcurrent;
};// class RangeStepper
} // namespace ts
#endif // TSXX_RANGE_H_VERSION (includeguard)
/* ----- END OF range.h ----- */
/*! \file rangelist.h
* \brief handle a list of ranges (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id$
* \author Thomas Forbriger
* \date 30/06/2005
*
* handle a list of ranges (prototypes)
*
* Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach)
*
* ----
* 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
* ----
*
* REVISIONS and CHANGES
* - 30/06/2005 V1.0 Thomas Forbriger
* - 27/04/2009 V1.1 added range list stepper
* - 25/01/2014 V1.2 copied from libtsxx
*
* ============================================================================
*/
// include guard
#ifndef TSXX_RANGELIST_H_VERSION
#define TSXX_RANGELIST_H_VERSION \
"TSXX_RANGELIST_H V1.2"
#define TSXX_RANGELIST_H_CVSID \
"$Id$"
#include<tsxx/range.h>
#include<list>
namespace ts {
template<class T>
class RangeList {
public:
typedef T Tvalue;
typedef ts::Range<Tvalue> Trange;
typedef std::list<Trange> Tlist;
RangeList() { }
RangeList& append(const Trange& r)
{ Mlist.push_back(r); return *this; }
void clear()
{ Mlist.erase(Mlist.begin(), Mlist.end()); }
typename Tlist::size_type size() const { return Mlist.size(); }
bool contains(const Tvalue& v) const
{
bool retval=false;
typename Tlist::const_iterator i=Mlist.begin();
while ((i!=Mlist.end()) && (!retval))
{ retval = i->contains(v); ++i; }
return retval;
}
Tlist list() const { return Mlist; }
private:
Tlist Mlist;
}; // template class RangeList
/*----------------------------------------------------------------------*/
template<class T>
class RangeListStepper {
public:
typedef RangeList<T> Trangelist;
typedef typename Trangelist::Tvalue Tvalue;
typedef typename Trangelist::Tlist Tlist;
typedef RangeStepper<Tvalue> Trangestepper;
RangeListStepper(const Trangelist& rangelist,
const Tvalue& stepsize=1):
Mlist(rangelist.list()), Mstepsize(stepsize),
Miterator(Mlist.begin()),
Mrangestepper(Trangestepper(*Miterator, Mstepsize))
{ }
//! \brief return current value in range list
Tvalue current() const { return(Mrangestepper.current()); }
//! \brief return current value in range list
operator Tvalue() const { return(this->current()); }
/*! \brief true if stepper is still in range and can return a current
* value
*/
bool valid() const
{
return(Mrangestepper.valid() && (Miterator!=Mlist.end()));
}
//! \brief true if stepper is still in range after next step forward
bool more() const
{
bool retval=this->valid();
if (retval && (!Mrangestepper.more()))
{
typename Tlist::const_iterator I=Miterator;
++I;
if (!(I!=Mlist.end())) { retval=false; }
}
return(retval);
}
//! \brief step forward and return current value
Tvalue next()
{
if (this->valid())
{
if (Mrangestepper.more()) { Mrangestepper.next(); }
else {
++Miterator;
if (Miterator != Mlist.end())
{
Mrangestepper=Trangestepper(*Miterator, Mstepsize);
}
}
}
return(this->current());
}
//! \brief step forward and return current value
Tvalue operator++() { return(this->next()); }
private:
Tlist Mlist;
Tvalue Mstepsize;
typename Tlist::const_iterator Miterator;
Trangestepper Mrangestepper;
}; // template class RangeListStepper
}
#endif // TSXX_RANGELIST_H_VERSION (includeguard)
/* ----- END OF rangelist.h ----- */
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