[643] | 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 | |
---|
| 9 | namespace 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 | */ |
---|
| 29 | CTemporalFilter(CGarbageCollector& gc, const std::string& opId, |
---|
| 30 | const CDate& initDate, const CDuration samplingFreq, const CDuration samplingOffset, const CDuration opFreq, |
---|
[1440] | 31 | bool ignoreMissingValue = false); |
---|
[643] | 32 | |
---|
[1704] | 33 | inline StdString GetName(void) {return StdString("Temporal filter");}; |
---|
| 34 | |
---|
[643] | 35 | /*! |
---|
| 36 | * Applies the temporal operation to the input data and returns the result when it is ready. |
---|
| 37 | * |
---|
| 38 | * \param data a vector of packets corresponding to each slot (one in this case) |
---|
| 39 | * \return the result of the temporal operation or null if it is not ready yet |
---|
| 40 | */ |
---|
| 41 | CDataPacketPtr virtual apply(std::vector<CDataPacketPtr> data); |
---|
[1704] | 42 | bool virtual buildGraph(std::vector<CDataPacketPtr> data); |
---|
[643] | 43 | |
---|
[1158] | 44 | /*! |
---|
[1358] | 45 | * Tests if the filter must auto-trigger. |
---|
| 46 | * |
---|
| 47 | * \return true if the filter must auto-trigger |
---|
| 48 | */ |
---|
| 49 | bool virtual mustAutoTrigger() const; |
---|
| 50 | |
---|
| 51 | /*! |
---|
[1158] | 52 | * Tests whether data is expected for the specified date. |
---|
| 53 | * |
---|
| 54 | * \param date the date associated to the data |
---|
| 55 | */ |
---|
| 56 | bool virtual isDataExpected(const CDate& date) const; |
---|
[1704] | 57 | std::vector<int > filterIDoutputs; |
---|
| 58 | std::vector<std::pair<int, int> > filterIDoutputs_pair; |
---|
[1158] | 59 | |
---|
[1704] | 60 | StdString temp_op; |
---|
| 61 | |
---|
[643] | 62 | private: |
---|
[1201] | 63 | // Warning the declaration order matters here, double-check the constructor before changing it |
---|
| 64 | CArray<double, 1> tmpData; //!< The array of data used for temporary storage |
---|
[1158] | 65 | const boost::scoped_ptr<func::CFunctor> functor; //!< The functor corresponding to the temporal operation |
---|
[1201] | 66 | const bool isOnceOperation; //!< True if the operation should be computed just once |
---|
| 67 | const bool isInstantOperation; //!< True if the operation is instant |
---|
[643] | 68 | const CDuration samplingFreq; //!< The sampling frequency, i.e. the frequency at which the input data will be used |
---|
[1158] | 69 | const CDuration samplingOffset; //!< The sampling offset, i.e. the offset after which the input data will be used |
---|
[643] | 70 | const CDuration opFreq; //!< The operation frequency, i.e. the frequency at which the output data will be computed |
---|
[1302] | 71 | const CDuration offsetMonth; //!< The month duration of samplingOffset |
---|
| 72 | CDuration offsetAllButMonth; //!< All but the month duration of samplingOffset |
---|
| 73 | const CDate initDate; |
---|
[643] | 74 | CDate nextSamplingDate; //!< The date of the next sampling |
---|
[1302] | 75 | int nbOperationDates; //!< The number of times an operation is performed |
---|
[1473] | 76 | int nbSamplingDates; |
---|
[1302] | 77 | // CDate nextOperationDate; //!< The date of the next operation |
---|
[1285] | 78 | bool isFirstOperation; //!< True before the first operation was been computed |
---|
[643] | 79 | }; // class CTemporalFilter |
---|
| 80 | } // namespace xios |
---|
| 81 | |
---|
| 82 | #endif //__XIOS_CTemporalFilter__ |
---|