Changeset 1122 for XIOS/trunk/src/filter/temporal_filter.cpp
- Timestamp:
- 05/05/17 08:58:36 (7 years ago)
- File:
-
- 1 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
Note: See TracChangeset
for help on using the changeset viewer.