source: XIOS3/trunk/src/filter/filter.cpp @ 2628

Last change on this file since 2628 was 2628, checked in by jderouillat, 6 weeks ago

New timers integration/reporting

File size: 1.4 KB
Line 
1#include "filter.hpp"
2#include "timer.hpp"
3
4namespace xios
5{
6  extern CLogType logProfile ;
7  CFilter::CFilter(CGarbageCollector& gc, size_t inputSlotsCount, IFilterEngine* engine)
8    : CInputPin(gc, inputSlotsCount)
9    , COutputPin(gc)
10    , engine(engine)
11    , inputSlotCount(inputSlotCount)
12  { /* Nothing to do */ }
13
14  void CFilter::onInputReady(std::vector<CDataPacketPtr> data)
15  {
16    if (info.isActive(logProfile)) CTimer::get("Applying filters").resume() ;
17    CDataPacketPtr outputPacket = engine->apply(data);
18    if (info.isActive(logProfile)) CTimer::get("Applying filters").suspend() ;
19    if (outputPacket)
20      onOutputReady(outputPacket);
21  }
22
23  void CFilter::setInputTrigger(size_t inputSlot, COutputPin* trigger)
24  {
25    // Was the filter already triggerable? If not, we need to inform
26    // all downstream filters.
27    bool wasTriggerable = canBeTriggered();
28
29    CInputPin::setInputTrigger(inputSlot, trigger);
30
31    if (!wasTriggerable)
32      setOutputTriggers();
33  }
34
35  void CFilter::trigger(Time timestamp)
36  {
37    CInputPin::trigger(timestamp);
38
39    COutputPin::trigger(timestamp);
40  }
41
42  bool CFilter::canBeTriggered() const
43  {
44    return (CInputPin::canBeTriggered() || COutputPin::canBeTriggered());
45  }
46
47  bool CFilter::mustAutoTrigger() const
48  {
49    return COutputPin::mustAutoTrigger();
50  }
51
52  bool CFilter::isDataExpected(const CDate& date) const
53  {
54    return COutputPin::isDataExpected(date);
55  }
56} // namespace xios
Note: See TracBrowser for help on using the repository browser.