[637] | 1 | #include "filter.hpp" |
---|
| 2 | |
---|
| 3 | namespace xios |
---|
| 4 | { |
---|
[1653] | 5 | CFilter::CFilter(CGarbageCollector& gc, size_t inputSlotsCount, IFilterEngine* engine, bool buildWorkflowGraph /*= false*/) |
---|
[639] | 6 | : CInputPin(gc, inputSlotsCount) |
---|
[1653] | 7 | , COutputPin(gc, false, buildWorkflowGraph) |
---|
[637] | 8 | , engine(engine) |
---|
[827] | 9 | , inputSlotCount(inputSlotCount) |
---|
[637] | 10 | { /* Nothing to do */ } |
---|
| 11 | |
---|
[1653] | 12 | StdString CFilter::GetName(void) { return StdString("Filter"); } |
---|
| 13 | |
---|
[637] | 14 | void CFilter::onInputReady(std::vector<CDataPacketPtr> data) |
---|
| 15 | { |
---|
| 16 | CDataPacketPtr outputPacket = engine->apply(data); |
---|
| 17 | if (outputPacket) |
---|
[1021] | 18 | onOutputReady(outputPacket); |
---|
[637] | 19 | } |
---|
[1021] | 20 | |
---|
| 21 | void CFilter::setInputTrigger(size_t inputSlot, COutputPin* trigger) |
---|
| 22 | { |
---|
| 23 | // Was the filter already triggerable? If not, we need to inform |
---|
| 24 | // all downstream filters. |
---|
| 25 | bool wasTriggerable = canBeTriggered(); |
---|
| 26 | |
---|
| 27 | CInputPin::setInputTrigger(inputSlot, trigger); |
---|
| 28 | |
---|
| 29 | if (!wasTriggerable) |
---|
| 30 | setOutputTriggers(); |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | void CFilter::trigger(Time timestamp) |
---|
| 34 | { |
---|
| 35 | CInputPin::trigger(timestamp); |
---|
| 36 | |
---|
| 37 | COutputPin::trigger(timestamp); |
---|
| 38 | } |
---|
| 39 | |
---|
| 40 | bool CFilter::canBeTriggered() const |
---|
| 41 | { |
---|
| 42 | return (CInputPin::canBeTriggered() || COutputPin::canBeTriggered()); |
---|
| 43 | } |
---|
[1158] | 44 | |
---|
[1358] | 45 | bool CFilter::mustAutoTrigger() const |
---|
| 46 | { |
---|
| 47 | return COutputPin::mustAutoTrigger(); |
---|
| 48 | } |
---|
| 49 | |
---|
[1158] | 50 | bool CFilter::isDataExpected(const CDate& date) const |
---|
| 51 | { |
---|
| 52 | return COutputPin::isDataExpected(date); |
---|
| 53 | } |
---|
[637] | 54 | } // namespace xios |
---|