Commit 32668e29 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

base class moved to filterbase

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.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 1812
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 17807dfb
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.9 2005-07-05 08:21:22 tforb Exp $
# $Id: Makefile,v 1.10 2005-07-05 11:05:25 tforb Exp $
#
# Copyright (c) 2003 by Thomas Forbriger (BFO Schiltach)
#
......@@ -12,7 +12,7 @@
# ============================================================================
HEADERS=$(shell find . -name \*.h)
LIBSRC=tsxx.cc filter.cc seifexx.cc seifeclass.cc
LIBSRC=tsxx.cc filter.cc seifexx.cc seifeclass.cc filterbase.cc
INCINSTALLPATH=$(LOCINCLUDEDIR)/tsxx
LIBINSTALLPATH=$(LOCLIBDIR)
......
/*! \file filter.cc
* \brief interface to call a variety of filters (implementation)
* \brief some time series filter classes (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: filter.cc,v 1.3 2005-07-05 10:51:43 tforb Exp $
* $Id: filter.cc,v 1.4 2005-07-05 11:05:25 tforb Exp $
* \author Thomas Forbriger
* \date 30/06/2005
* \date 05/07/2005
*
* interface to call a variety of filters (implementation)
* some time series filter classes (implementation)
*
* Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 30/06/2005 V1.0 Thomas Forbriger
* - 05/07/2005 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_FILTER_CC_VERSION \
"TF_FILTER_CC V1.0 "
#define TF_FILTER_CC_CVSID \
"$Id: filter.cc,v 1.3 2005-07-05 10:51:43 tforb Exp $"
"$Id: filter.cc,v 1.4 2005-07-05 11:05:25 tforb Exp $"
#include<iostream>
#include <tsxx/filter.h>
#include <filter.h>
namespace ts {
namespace tf {
namespace filter {
Ttimeseries FilterCollection::operator()(const Ttimeseries& s) const
{
Tfilterlist::const_iterator i=this->Tfilterlist::begin();
while (i!=this->Tfilterlist::end())
{ (*i)->operator()(s); }
return s;
}
void Exception::report() const {
this->Tbase::report();
}
void UnknownFilterException::report() const {
this->Tbase::report();
std::cerr << "requested filter type: \"" << Mfilter << "\""
<< std::endl;
}
} // namespace filter
} // namespace ts
}
/* ----- END OF filter.cc ----- */
/*! \file filter.h
* \brief interface to call a variety of filters (prototypes)
* \brief some time series filter classes (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: filter.h,v 1.6 2005-07-05 10:51:43 tforb Exp $
* $Id: filter.h,v 1.7 2005-07-05 11:05:25 tforb Exp $
* \author Thomas Forbriger
* \date 30/06/2005
* \date 05/07/2005
*
* interface to call a variety of filters (prototypes)
* some time series filter classes (prototypes)
*
* Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 30/06/2005 V1.0 Thomas Forbriger
* - 05/07/2005 V1.0 Thomas Forbriger
*
* ============================================================================
*/
......@@ -23,122 +23,11 @@
#define TF_FILTER_H_VERSION \
"TF_FILTER_H V1.0 "
#define TF_FILTER_H_CVSID \
"$Id: filter.h,v 1.6 2005-07-05 10:51:43 tforb Exp $"
"$Id: filter.h,v 1.7 2005-07-05 11:05:25 tforb Exp $"
#include<list>
#include<string>
#include<tsxx/tsxx.h>
#include<tfxx/handle.h>
#include<tfxx/error.h>
namespace tf {
namespace ts {
namespace filter {
//! we always work in double precision
typedef double Tvalue;
/*! simple header
*/
struct DTHeader {
DTHeader(const Tvalue& sdt): dt(sdt) { }
//! sampling interval
Tvalue dt;
}; // DTHeader
//! the way we use time series
typedef ts::TimeSeries<aff::Series<Tvalue>, DTHeader> Ttimeseries;
/*! base class for any filter
*
* Filters derived from that class will have the following properties:
*
* - They will not change the number of samples
* - They will not change the sampling interval
* - They do neither need the time of first sample nor will they alter it
*/
class BasicFilter {
public:
//! type of sample values
typedef double Tvalue;
//! type of series container
typedef ts::filter::Ttimeseries Ttimeseries;
typedef Ttimeseries::Tseries Tseries;
typedef Ttimeseries::Theader Theader;
virtual ~BasicFilter();
virtual Ttimeseries operator()(const Ttimeseries& s) const =0;
Ttimeseries operator()(const Tseries& s, const Tvalue& dt) const
{ return this->operator()(Ttimeseries(s, Theader(dt))); }
template <class H>
Ttimeseries operator()(const ts::TimeSeries<Tseries, H>& s) const
{ return this->operator()(Ttimeseries(s, Theader(s.header.dt))); }
protected:
//! Do not allow to use the baseclass alone
BasicFilter();
}; // class BasicFilter
//! handle to pass filters
typedef tfxx::Handle<BasicFilter> Tfilterhandle;
/*! filter collection
*/
class FilterCollection: public std::list<Tfilterhandle> {
public:
typedef ts::filter::Tfilterhandle Tfilterhandle;
typedef Tfilterhandle::Tobject Tfilter;
typedef std::list<Tfilterhandle> Tfilterlist;
typedef Tfilterlist Tbase;
typedef Ttimeseries::Tseries Tseries;
typedef Ttimeseries::Theader Theader;
Ttimeseries operator()(const Ttimeseries& s) const;
Ttimeseries operator()(const Tseries& s, const Tvalue& dt) const
{ return this->operator()(Ttimeseries(s, Theader(dt))); }
template <class H>
Ttimeseries operator()(const ts::TimeSeries<Tseries, H>& s) const
{ return this->operator()(Ttimeseries(s, Theader(s.header.dt))); }
}; // class FilterCollection
//! no-operation filter
class Noop: public BasicFilter {
public:
Ttimeseries operator()(const Ttimeseries& s) const { return s; }
}; // class Noop
//! exception class
class Exception: public tfxx::error::Exception {
public:
typedef tfxx::error::Exception Tbase;
Exception(const char* message,
const char* file,
const int& line,
const char* condition):
Tbase(message, file, line, condition)
{ this->Tbase::dont_report_on_construct(); }
virtual void report() const;
}; // class Exception
//! unknown filter exception
class UnknownFilterException: public Exception {
public:
typedef Exception Tbase;
UnknownFilterException(const char* message,
const char* file,
const int& line,
const std::string& filter):
Tbase(message, file, line, "filter type is unknown"),
Mfilter(filter) { }
virtual ~UnknownFilterException() { }
virtual void report() const;
private:
std::string Mfilter;
}; // UnknownFilterException
} // namespace filter
} // namespace ts
#define TSXX_UnknownFilterAbort(M, F) \
throw( ts::filter::UnknownFilterException ( M , __FILE__, __LINE__, F ))
}
#endif // TF_FILTER_H_VERSION (includeguard)
......
/*! \file filterbase.cc
* \brief base class for all filter classes (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: filterbase.cc,v 1.1 2005-07-05 11:05:26 tforb Exp $
* \author Thomas Forbriger
* \date 05/07/2005
*
* base class for all filter classes (implementation)
*
* Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 05/07/2005 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_FILTERBASE_CC_VERSION \
"TF_FILTERBASE_CC V1.0 "
#define TF_FILTERBASE_CC_CVSID \
"$Id: filterbase.cc,v 1.1 2005-07-05 11:05:26 tforb Exp $"
#include <filterbase.h>
namespace tf {
}
/*! \file filter.cc
* \brief interface to call a variety of filters (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: filterbase.cc,v 1.1 2005-07-05 11:05:26 tforb Exp $
* \author Thomas Forbriger
* \date 30/06/2005
*
* interface to call a variety of filters (implementation)
*
* Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 30/06/2005 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define TF_FILTER_CC_VERSION \
"TF_FILTER_CC V1.0 "
#define TF_FILTER_CC_CVSID \
"$Id: filterbase.cc,v 1.1 2005-07-05 11:05:26 tforb Exp $"
#include<iostream>
#include <tsxx/filter.h>
namespace ts {
namespace filter {
Ttimeseries FilterCollection::operator()(const Ttimeseries& s) const
{
Tfilterlist::const_iterator i=this->Tfilterlist::begin();
while (i!=this->Tfilterlist::end())
{ (*i)->operator()(s); }
return s;
}
void Exception::report() const {
this->Tbase::report();
}
void UnknownFilterException::report() const {
this->Tbase::report();
std::cerr << "requested filter type: \"" << Mfilter << "\""
<< std::endl;
}
} // namespace filter
} // namespace ts
/* ----- END OF filter.cc ----- */
/* ----- END OF filterbase.cc ----- */
/*! \file filterbase.h
* \brief base class for all filter classes (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: filterbase.h,v 1.1 2005-07-05 11:05:26 tforb Exp $
* \author Thomas Forbriger
* \date 05/07/2005
*
* base class for all filter classes (prototypes)
*
* Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 05/07/2005 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef TF_FILTERBASE_H_VERSION
#define TF_FILTERBASE_H_VERSION \
"TF_FILTERBASE_H V1.0 "
#define TF_FILTERBASE_H_CVSID \
"$Id: filterbase.h,v 1.1 2005-07-05 11:05:26 tforb Exp $"
namespace tf {
}
#endif // TF_FILTERBASE_H_VERSION (includeguard)
/*! \file filter.h
* \brief interface to call a variety of filters (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: filterbase.h,v 1.1 2005-07-05 11:05:26 tforb Exp $
* \author Thomas Forbriger
* \date 30/06/2005
*
* interface to call a variety of filters (prototypes)
*
* Copyright (c) 2005 by Thomas Forbriger (BFO Schiltach)
*
* REVISIONS and CHANGES
* - 30/06/2005 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef TF_FILTER_H_VERSION
#define TF_FILTER_H_VERSION \
"TF_FILTER_H V1.0 "
#define TF_FILTER_H_CVSID \
"$Id: filterbase.h,v 1.1 2005-07-05 11:05:26 tforb Exp $"
#include<list>
#include<string>
#include<tsxx/tsxx.h>
#include<tfxx/handle.h>
#include<tfxx/error.h>
namespace ts {
namespace filter {
//! we always work in double precision
typedef double Tvalue;
/*! simple header
*/
struct DTHeader {
DTHeader(const Tvalue& sdt): dt(sdt) { }
//! sampling interval
Tvalue dt;
}; // DTHeader
//! the way we use time series
typedef ts::TimeSeries<aff::Series<Tvalue>, DTHeader> Ttimeseries;
/*! base class for any filter
*
* Filters derived from that class will have the following properties:
*
* - They will not change the number of samples
* - They will not change the sampling interval
* - They do neither need the time of first sample nor will they alter it
*/
class BasicFilter {
public:
//! type of sample values
typedef double Tvalue;
//! type of series container
typedef ts::filter::Ttimeseries Ttimeseries;
typedef Ttimeseries::Tseries Tseries;
typedef Ttimeseries::Theader Theader;
virtual ~BasicFilter();
virtual Ttimeseries operator()(const Ttimeseries& s) const =0;
Ttimeseries operator()(const Tseries& s, const Tvalue& dt) const
{ return this->operator()(Ttimeseries(s, Theader(dt))); }
template <class H>
Ttimeseries operator()(const ts::TimeSeries<Tseries, H>& s) const
{ return this->operator()(Ttimeseries(s, Theader(s.header.dt))); }
protected:
//! Do not allow to use the baseclass alone
BasicFilter();
}; // class BasicFilter
//! handle to pass filters
typedef tfxx::Handle<BasicFilter> Tfilterhandle;
/*! filter collection
*/
class FilterCollection: public std::list<Tfilterhandle> {
public:
typedef ts::filter::Tfilterhandle Tfilterhandle;
typedef Tfilterhandle::Tobject Tfilter;
typedef std::list<Tfilterhandle> Tfilterlist;
typedef Tfilterlist Tbase;
typedef Ttimeseries::Tseries Tseries;
typedef Ttimeseries::Theader Theader;
Ttimeseries operator()(const Ttimeseries& s) const;
Ttimeseries operator()(const Tseries& s, const Tvalue& dt) const
{ return this->operator()(Ttimeseries(s, Theader(dt))); }
template <class H>
Ttimeseries operator()(const ts::TimeSeries<Tseries, H>& s) const
{ return this->operator()(Ttimeseries(s, Theader(s.header.dt))); }
}; // class FilterCollection
//! no-operation filter
class Noop: public BasicFilter {
public:
Ttimeseries operator()(const Ttimeseries& s) const { return s; }
}; // class Noop
//! exception class
class Exception: public tfxx::error::Exception {
public:
typedef tfxx::error::Exception Tbase;
Exception(const char* message,
const char* file,
const int& line,
const char* condition):
Tbase(message, file, line, condition)
{ this->Tbase::dont_report_on_construct(); }
virtual void report() const;
}; // class Exception
//! unknown filter exception
class UnknownFilterException: public Exception {
public:
typedef Exception Tbase;
UnknownFilterException(const char* message,
const char* file,
const int& line,
const std::string& filter):
Tbase(message, file, line, "filter type is unknown"),
Mfilter(filter) { }
virtual ~UnknownFilterException() { }
virtual void report() const;
private:
std::string Mfilter;
}; // UnknownFilterException
} // namespace filter
} // namespace ts
#define TSXX_UnknownFilterAbort(M, F) \
throw( ts::filter::UnknownFilterException ( M , __FILE__, __LINE__, F ))
#endif // TF_FILTER_H_VERSION (includeguard)
/* ----- END OF filter.h ----- */
/* ----- END OF filterbase.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