[637] | 1 | #ifndef __XIOS_CFilter__ |
---|
| 2 | #define __XIOS_CFilter__ |
---|
| 3 | |
---|
| 4 | #include "input_pin.hpp" |
---|
| 5 | #include "output_pin.hpp" |
---|
| 6 | #include "filter_engine.hpp" |
---|
| 7 | |
---|
| 8 | namespace xios |
---|
| 9 | { |
---|
| 10 | /*! |
---|
| 11 | * A generic filter with an input pin and an output pin. |
---|
| 12 | * A filter can delegate the internal work to an engine |
---|
| 13 | * which may be shared by multiple filter instances. |
---|
| 14 | */ |
---|
| 15 | class CFilter : public CInputPin, public COutputPin |
---|
| 16 | { |
---|
| 17 | public: |
---|
| 18 | /*! |
---|
| 19 | * Constructs a filter with the specified number of input slots |
---|
| 20 | * and the specified engine. |
---|
| 21 | * |
---|
[639] | 22 | * \param gc the associated garbage collector |
---|
[637] | 23 | * \param inputSlotsCount the number of input slots |
---|
| 24 | * \param engine the filter engine |
---|
| 25 | */ |
---|
[639] | 26 | CFilter(CGarbageCollector& gc, size_t inputSlotsCount, IFilterEngine* engine); |
---|
[637] | 27 | |
---|
[1021] | 28 | /*! |
---|
| 29 | * Sets the trigger for a specific input slot. |
---|
| 30 | * |
---|
| 31 | * \param inputSlot the input slot number |
---|
| 32 | * \param trigger the corresponding trigger |
---|
| 33 | */ |
---|
| 34 | void virtual setInputTrigger(size_t inputSlot, COutputPin* trigger); |
---|
| 35 | |
---|
| 36 | /*! |
---|
| 37 | * Triggers the filter for the specified timestamp. |
---|
| 38 | * |
---|
| 39 | * \param timestamp the timestamp for which we are triggering the filter |
---|
| 40 | */ |
---|
| 41 | void virtual trigger(Time timestamp); |
---|
| 42 | |
---|
| 43 | /*! |
---|
| 44 | * Tests if the filter can be triggered. |
---|
| 45 | * |
---|
| 46 | * \return true if the filter can be triggered |
---|
| 47 | */ |
---|
| 48 | bool virtual canBeTriggered() const; |
---|
| 49 | |
---|
[1158] | 50 | /*! |
---|
| 51 | * Tests whether data is expected for the specified date. |
---|
| 52 | * |
---|
| 53 | * \param date the date associated to the data |
---|
| 54 | */ |
---|
| 55 | bool virtual isDataExpected(const CDate& date) const; |
---|
| 56 | |
---|
[637] | 57 | protected: |
---|
| 58 | IFilterEngine* engine; //!< The filter engine, might be the filter itself |
---|
[827] | 59 | size_t inputSlotCount; //!< Number of slot on filter |
---|
[637] | 60 | |
---|
| 61 | /*! |
---|
| 62 | * Generic implementation of the input pin notification function, processes |
---|
| 63 | * the data using the filter engine and passes the resulting packet (if any) |
---|
| 64 | * to the downstreams filters. |
---|
| 65 | * |
---|
| 66 | * \param data a vector of packets corresponding to each slot |
---|
| 67 | */ |
---|
| 68 | void virtual onInputReady(std::vector<CDataPacketPtr> data); |
---|
| 69 | }; // class CFilter |
---|
| 70 | } // namespace xios |
---|
| 71 | |
---|
| 72 | #endif //__XIOS_CFilter__ |
---|