TS++ library: time series library
filterbase.h
Go to the documentation of this file.
1 
36 // include guard
37 #ifndef TF_FILTERBASE_H_VERSION
38 
39 #define TF_FILTERBASE_H_VERSION \
40  "TF_FILTERBASE_H V1.1"
41 
42 #include<list>
43 #include<string>
44 #include<tsxx/dttimeseries.h>
45 #include<tfxx/handle.h>
46 #include<tfxx/error.h>
47 
48 namespace ts {
49 
50  namespace filter {
51 
53  typedef double Tvalue;
54 
57 
71  class BasicFilter {
72  public:
74  typedef double Tvalue;
79  virtual ~BasicFilter();
80  virtual Ttimeseries operator()(const Ttimeseries& s,
81  const bool& debug=false) const =0;
82  Ttimeseries operator()(const Tseries& s, const Tvalue& dt) const
83  { return this->operator()(Ttimeseries(s, Theader(dt))); }
84  template <class H>
86  { return this->operator()(Ttimeseries(s, Theader(s.header.dt))); }
87  protected:
89  BasicFilter();
90  }; // class BasicFilter
91 
93  typedef tfxx::Handle<BasicFilter> Tfilterhandle;
94 
97  class FilterCollection: public std::list<Tfilterhandle> {
98  public:
100  typedef Tfilterhandle::Tobject Tfilter;
101  typedef std::list<Tfilterhandle> Tfilterlist;
106  const bool& debug=false) const;
107  Ttimeseries operator()(const Tseries& s, const Tvalue& dt) const
108  { return this->operator()(Ttimeseries(s, Theader(dt))); }
109  template <class H>
111  { return this->operator()(Ttimeseries(s, Theader(s.header.dt))); }
112  }; // class FilterCollection
113 
115  class Noop: public BasicFilter {
116  public:
118  const bool& debug=false) const { return s; }
119  }; // class Noop
120 
122  class Exception: public tfxx::error::Exception {
123  public:
124  typedef tfxx::error::Exception Tbase;
125  Exception(const char* message,
126  const char* file,
127  const int& line,
128  const char* condition):
129  Tbase(message, file, line, condition) { }
130  virtual void report() const;
131  }; // class Exception
132 
135  public:
136  typedef Exception Tbase;
137  UnknownFilterException(const char* message,
138  const char* file,
139  const int& line,
140  const std::string& filter):
141  Tbase(message, file, line, "filter type is unknown"),
142  Mfilter(filter) { }
144  virtual void report() const;
145  private:
146  std::string Mfilter;
147  }; // UnknownFilterException
148 
149  } // namespace filter
150 
151 } // namespace ts
152 
153 #define TSXX_UnknownFilterAbort(M, F) \
154  throw( ts::filter::UnknownFilterException ( M , __FILE__, __LINE__, F ))
155 
156 #endif // TF_FILTERBASE_H_VERSION (includeguard)
157 
158 /* ----- END OF filterbase.h ----- */
tfxx::Handle< BasicFilter > Tfilterhandle
handle to pass filters
Definition: filterbase.h:93
Ttimeseries::Theader Theader
Definition: filterbase.h:78
ts::filter::Tfilterhandle Tfilterhandle
Definition: filterbase.h:99
ts::filter::Ttimeseries Ttimeseries
type of series container
Definition: filterbase.h:76
Ttimeseries::Tseries Tseries
Definition: filterbase.h:103
Ttimeseries::Theader Theader
Definition: filterbase.h:104
BasicFilter()
Do not allow to use the baseclass alone.
Definition: filterbase.cc:76
Ttimeseries::Tvalue Tvalue
we always work in double precision
Definition: filter.cc:83
Ttimeseries operator()(const ts::TimeSeries< Tseries, H > &s) const
Definition: filterbase.h:110
unknown filter exception
Definition: filterbase.h:134
Ttimeseries::Tseries Tseries
Definition: filterbase.h:77
time series with basic sampling interval header (prototypes)
Tfilterhandle::Tobject Tfilter
Definition: filterbase.h:100
virtual void report() const
Definition: filterbase.cc:69
std::list< Tfilterhandle > Tfilterlist
Definition: filterbase.h:101
Structure to hold the data samples of a series together with header information to form a time series...
Definition: tsxx.h:83
Ttimeseries operator()(const Tseries &s, const Tvalue &dt) const
Definition: filterbase.h:82
ts::TDtimeseries Ttimeseries
use double precision time series
Definition: filterbase.h:56
All stuff in this library will be placed within namespace ts.
Definition: anyfilter.cc:43
UnknownFilterException(const char *message, const char *file, const int &line, const std::string &filter)
Definition: filterbase.h:137
Theader header
data header fields
Definition: tsxx.h:134
Ttimeseries operator()(const ts::TimeSeries< Tseries, H > &s) const
Definition: filterbase.h:85
virtual Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const =0
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
Definition: filterbase.h:117
Ttimeseries operator()(const Tseries &s, const Tvalue &dt) const
Definition: filterbase.h:107
virtual void report() const
Definition: filterbase.cc:65
Exception(const char *message, const char *file, const int &line, const char *condition)
Definition: filterbase.h:125
tfxx::error::Exception Tbase
Definition: filterbase.h:124
no-operation filter
Definition: filterbase.h:115
exception class
Definition: filterbase.h:122
double Tvalue
type of sample values
Definition: filterbase.h:74
Ttimeseries operator()(const Ttimeseries &s, const bool &debug=false) const
Definition: filterbase.cc:48