source: XIOS/trunk/src/filter/temporal_filter.hpp @ 827

Last change on this file since 827 was 643, checked in by rlacroix, 9 years ago

Use the filter infrastructure to handle the temporal operations.

Add a temporal filter to do so.

File size: 2.6 KB
Line 
1#ifndef __XIOS_CTemporalFilter__
2#define __XIOS_CTemporalFilter__
3
4#include "filter.hpp"
5#include <boost/smart_ptr/scoped_ptr.hpp>
6#include "functor.hpp"
7#include "array_new.hpp"
8
9namespace xios
10{
11  /*!
12   * A generic temporal filter with one input slot wrapping any type of temporal operation.
13   */
14  class CTemporalFilter : public CFilter, public IFilterEngine
15  {
16    public:
17      /*!
18       * Constructs a temporal filter wrapping the specified temporal operation.
19       *
20       * \param gc the associated garbage collector
21       * \param opId the string identifying the temporal operation
22       * \param initDate the origin of time
23       * \param samplingFreq the sampling frequency, i.e. the frequency at which the input data will be used
24       * \param samplingOffset the sampling offset, i.e. the offset after which the input data will be used
25       * \param opFreq the operation frequency, i.e. the frequency at which the output data will be computed
26       * \param ignoreMissingValue true if and only if the missing value must be ignored
27                                   when doing the operation
28       * \param missingValue the missing value
29       */
30      CTemporalFilter(CGarbageCollector& gc, const std::string& opId,
31                      const CDate& initDate, const CDuration samplingFreq, const CDuration samplingOffset, const CDuration opFreq,
32                      bool ignoreMissingValue = false, double missingValue = 0.0);
33
34      /*!
35       * Applies the temporal operation to the input data and returns the result when it is ready.
36       *
37       * \param data a vector of packets corresponding to each slot (one in this case)
38       * \return the result of the temporal operation or null if it is not ready yet
39       */
40      CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data);
41
42    private:
43      boost::scoped_ptr<func::CFunctor> functor; //!< The functor corresponding to the temporal operation
44      CArray<double, 1> tmpData; //!< The array of data used for temporary storage
45      const CDuration samplingFreq; //!< The sampling frequency, i.e. the frequency at which the input data will be used
46      const CDuration opFreq; //!< The operation frequency, i.e. the frequency at which the output data will be computed
47      CDate nextSamplingDate; //!< The date of the next sampling
48      CDate nextOperationDate; //!< The date of the next operation
49      bool isFirstOperation; //!< True before the first operation was been computed
50      bool isOnceOperation; //!< True if the operation should be computed just once
51  }; // class CTemporalFilter
52} // namespace xios
53
54#endif //__XIOS_CTemporalFilter__
Note: See TracBrowser for help on using the repository browser.