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 | * |
---|
22 | * \param gc the associated garbage collector |
---|
23 | * \param inputSlotsCount the number of input slots |
---|
24 | * \param engine the filter engine |
---|
25 | */ |
---|
26 | CFilter(CGarbageCollector& gc, size_t inputSlotsCount, IFilterEngine* engine); |
---|
27 | |
---|
28 | StdString virtual GetName(void); |
---|
29 | |
---|
30 | /*! |
---|
31 | * Sets the trigger for a specific input slot. |
---|
32 | * |
---|
33 | * \param inputSlot the input slot number |
---|
34 | * \param trigger the corresponding trigger |
---|
35 | */ |
---|
36 | void virtual setInputTrigger(size_t inputSlot, COutputPin* trigger); |
---|
37 | |
---|
38 | /*! |
---|
39 | * Triggers the filter for the specified timestamp. |
---|
40 | * |
---|
41 | * \param timestamp the timestamp for which we are triggering the filter |
---|
42 | */ |
---|
43 | void virtual trigger(Time timestamp); |
---|
44 | |
---|
45 | /*! |
---|
46 | * Tests if the filter can be triggered. |
---|
47 | * |
---|
48 | * \return true if the filter can be triggered |
---|
49 | */ |
---|
50 | bool virtual canBeTriggered() const; |
---|
51 | |
---|
52 | /*! |
---|
53 | * Tests if the filter must auto-trigger. |
---|
54 | * |
---|
55 | * \return true if the filter must auto-trigger |
---|
56 | */ |
---|
57 | bool virtual mustAutoTrigger() const; |
---|
58 | |
---|
59 | /*! |
---|
60 | * Tests whether data is expected for the specified date. |
---|
61 | * |
---|
62 | * \param date the date associated to the data |
---|
63 | */ |
---|
64 | bool virtual isDataExpected(const CDate& date) const; |
---|
65 | |
---|
66 | |
---|
67 | |
---|
68 | |
---|
69 | int filterID; |
---|
70 | StdString expression; |
---|
71 | |
---|
72 | protected: |
---|
73 | IFilterEngine* engine; //!< The filter engine, might be the filter itself |
---|
74 | size_t inputSlotCount; //!< Number of slot on filter |
---|
75 | |
---|
76 | /*! |
---|
77 | * Generic implementation of the input pin notification function, processes |
---|
78 | * the data using the filter engine and passes the resulting packet (if any) |
---|
79 | * to the downstreams filters. |
---|
80 | * |
---|
81 | * \param data a vector of packets corresponding to each slot |
---|
82 | */ |
---|
83 | void virtual onInputReady(std::vector<CDataPacketPtr> data); |
---|
84 | }; // class CFilter |
---|
85 | } // namespace xios |
---|
86 | |
---|
87 | #endif //__XIOS_CFilter__ |
---|