source: XIOS/trunk/src/filter/filter.cpp @ 1006

Last change on this file since 1006 was 1006, checked in by rlacroix, 7 years ago

The workflow is now triggered when using xios_recv_field for fields in read mode received from the servers.

Previously the workflow was triggered upon receiving the data which could cause deadlocks since there are no garanties that clients are receiving data at the same time.

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