source: XIOS/trunk/src/filter/filter.hpp @ 1358

Last change on this file since 1358 was 1358, checked in by rlacroix, 6 years ago

Support reentrant workflows and workflows with temporal integration for fields read from files.

File size: 2.3 KB
Line 
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
8namespace 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      /*!
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
50      /*!
51       * Tests if the filter must auto-trigger.
52       *
53       * \return true if the filter must auto-trigger
54       */
55      bool virtual mustAutoTrigger() const;
56
57      /*!
58       * Tests whether data is expected for the specified date.
59       *
60       * \param date the date associated to the data
61       */
62      bool virtual isDataExpected(const CDate& date) const;
63
64    protected:
65      IFilterEngine* engine; //!< The filter engine, might be the filter itself
66      size_t inputSlotCount; //!< Number of slot on filter
67
68      /*!
69       * Generic implementation of the input pin notification function, processes
70       * the data using the filter engine and passes the resulting packet (if any)
71       * to the downstreams filters.
72       *
73       * \param data a vector of packets corresponding to each slot
74       */
75      void virtual onInputReady(std::vector<CDataPacketPtr> data);
76  }; // class CFilter
77} // namespace xios
78
79#endif //__XIOS_CFilter__
Note: See TracBrowser for help on using the repository browser.