Changeset 1122
- Timestamp:
- 05/05/17 08:58:36 (8 years ago)
- Location:
- XIOS/trunk/src/filter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/trunk/src/filter/temporal_filter.cpp
r1121 r1122 5 5 namespace xios 6 6 { 7 static func::CFunctor* createFunctor(const std::string& opId, bool ignoreMissingValue, double missingValue, CArray<double, 1>& tmpData); 8 7 9 CTemporalFilter::CTemporalFilter(CGarbageCollector& gc, const std::string& opId, 8 10 const CDate& initDate, const CDuration samplingFreq, const CDuration samplingOffset, const CDuration opFreq, 9 11 bool ignoreMissingValue /*= false*/, double missingValue /*= 0.0*/) 10 12 : CFilter(gc, 1, this) 13 , functor(createFunctor(opId, ignoreMissingValue, missingValue, tmpData)) 11 14 , samplingFreq(samplingFreq) 12 15 , opFreq(opFreq) … … 14 17 , nextOperationDate(initDate + samplingOffset + opFreq) 15 18 , isFirstOperation(true) 19 , isOnceOperation(functor->timeType() == func::CFunctor::once) 16 20 { 17 double defaultValue = ignoreMissingValue ? std::numeric_limits<double>::quiet_NaN() : missingValue;18 19 #define DECLARE_FUNCTOR(MType, mtype) \20 if (opId.compare(#mtype) == 0) \21 { \22 if (ignoreMissingValue) \23 { \24 functor.reset(new func::C##MType(tmpData, defaultValue)); \25 } \26 else \27 { \28 functor.reset(new func::C##MType(tmpData)); \29 } \30 }31 32 #include "functor_type.conf"33 34 if (!functor)35 ERROR("CTemporalFilter::CTemporalFilter(CGarbageCollector& gc, const std::string& opId, ...)",36 << "\"" << opId << "\" is not a valid operation.");37 38 isOnceOperation = (functor->timeType() == func::CFunctor::once);39 21 } 40 22 … … 80 62 return isOnceOperation ? isFirstOperation : (date >= nextSamplingDate || date + samplingFreq > nextOperationDate); 81 63 } 64 65 static func::CFunctor* createFunctor(const std::string& opId, bool ignoreMissingValue, double missingValue, CArray<double, 1>& tmpData) 66 { 67 func::CFunctor* functor = NULL; 68 69 double defaultValue = ignoreMissingValue ? std::numeric_limits<double>::quiet_NaN() : missingValue; 70 71 #define DECLARE_FUNCTOR(MType, mtype) \ 72 if (opId.compare(#mtype) == 0) \ 73 { \ 74 if (ignoreMissingValue) \ 75 { \ 76 functor = new func::C##MType(tmpData, defaultValue); \ 77 } \ 78 else \ 79 { \ 80 functor = new func::C##MType(tmpData); \ 81 } \ 82 } 83 84 #include "functor_type.conf" 85 86 if (!functor) 87 ERROR("createFunctor(const std::string& opId, ...)", 88 << "\"" << opId << "\" is not a valid operation."); 89 90 return functor; 91 } 82 92 } // namespace xios -
XIOS/trunk/src/filter/temporal_filter.hpp
r1119 r1122 48 48 49 49 private: 50 boost::scoped_ptr<func::CFunctor> functor; //!< The functor corresponding to the temporal operation50 const boost::scoped_ptr<func::CFunctor> functor; //!< The functor corresponding to the temporal operation 51 51 CArray<double, 1> tmpData; //!< The array of data used for temporary storage 52 52 const CDuration samplingFreq; //!< The sampling frequency, i.e. the frequency at which the input data will be used … … 55 55 CDate nextOperationDate; //!< The date of the next operation 56 56 bool isFirstOperation; //!< True before the first operation was been computed 57 bool isOnceOperation; //!< True if the operation should be computed just once57 const bool isOnceOperation; //!< True if the operation should be computed just once 58 58 }; // class CTemporalFilter 59 59 } // namespace xios
Note: See TracChangeset
for help on using the changeset viewer.