#include "store_filter.hpp" #include "context.hpp" #include "grid.hpp" #include "timer.hpp" namespace xios { CStoreFilter::CStoreFilter(CGarbageCollector& gc, CContext* context, CGrid* grid, bool detectMissingValues /*= false*/, double missingValue /*= 0.0*/) : CInputPin(gc, 1) , gc(gc) , context(context) , grid(grid) , detectMissingValues(detectMissingValues) , missingValue(missingValue) { if (!context) ERROR("CStoreFilter::CStoreFilter(CContext* context, CGrid* grid)", "Impossible to construct a store filter without providing a context."); if (!grid) ERROR("CStoreFilter::CStoreFilter(CContext* context, CGrid* grid)", "Impossible to construct a store filter without providing a grid."); } CConstDataPacketPtr CStoreFilter::getPacket(Time timestamp) { CTimer timer("CStoreFilter::getPacket"); CConstDataPacketPtr packet; const double timeout = CXios::recvFieldTimeout; do { if (canBeTriggered()) trigger(timestamp); timer.resume(); std::map::const_iterator it = packets.find(timestamp); if (it != packets.end()) packet = it->second; else // if the packet is not available yet, check if it can be received context->checkBuffersAndListen(); timer.suspend(); } while (!packet && timer.getCumulatedTime() < timeout); if (!packet) { std::map::const_iterator it ; info(0)<<"Impossible to get the packet with timestamp = " << timestamp<first<<" "; info(0)<