[638] | 1 | #ifndef __XIOS_CStoreFilter__ |
---|
| 2 | #define __XIOS_CStoreFilter__ |
---|
| 3 | |
---|
| 4 | #include "input_pin.hpp" |
---|
[1677] | 5 | #include "workflow_graph.hpp" |
---|
[638] | 6 | |
---|
[1677] | 7 | |
---|
[638] | 8 | namespace xios |
---|
| 9 | { |
---|
| 10 | class CContext; |
---|
| 11 | class CGrid; |
---|
[1679] | 12 | class CField; |
---|
[638] | 13 | |
---|
| 14 | /*! |
---|
| 15 | * A terminal filter which stores all the packets it receives. |
---|
| 16 | */ |
---|
| 17 | class CStoreFilter : public CInputPin |
---|
| 18 | { |
---|
| 19 | public: |
---|
| 20 | /*! |
---|
[639] | 21 | * Constructs the filter with one input slot and an associated |
---|
| 22 | * garbage collector for the specified grid and context. |
---|
[638] | 23 | * |
---|
[639] | 24 | * \param gc the garbage collector associated with this input pin |
---|
[638] | 25 | * \param context the context to which the data belongs |
---|
| 26 | * \param grid the grid to which the data is attached |
---|
[1201] | 27 | * \param detectMissingValues whether missing values should be detected |
---|
| 28 | * \param missingValue the value to use to replace missing values |
---|
[638] | 29 | */ |
---|
[1201] | 30 | CStoreFilter(CGarbageCollector& gc, CContext* context, CGrid* grid, |
---|
| 31 | bool detectMissingValues = false, double missingValue = 0.0); |
---|
[638] | 32 | |
---|
| 33 | /*! |
---|
| 34 | * Accesses the filter storage and retuns the packet corresponding |
---|
| 35 | * to the specified timestamp. If there is no packet available for |
---|
| 36 | * the specified timestamp, the function waits until the data is |
---|
| 37 | * received or a timeout occurs. |
---|
| 38 | * |
---|
| 39 | * \param timestamp the timestamp of the requested packet |
---|
| 40 | * \return a pointer to a read-only packet |
---|
| 41 | */ |
---|
| 42 | CConstDataPacketPtr getPacket(Time timestamp); |
---|
| 43 | |
---|
| 44 | /*! |
---|
| 45 | * Accesses the filter storage and retuns the data corresponding |
---|
| 46 | * to the specified timestamp. If there is no data available for |
---|
| 47 | * the specified timestamp, the function waits until the data is |
---|
| 48 | * received or a timeout occurs. |
---|
| 49 | * |
---|
| 50 | * \param timestamp the timestamp of the requested data |
---|
| 51 | * \param data the array where the data is to be copied |
---|
| 52 | * \return the status code associated with the data |
---|
| 53 | */ |
---|
| 54 | template <int N> |
---|
| 55 | CDataPacket::StatusCode getData(Time timestamp, CArray<double, N>& data); |
---|
| 56 | |
---|
[639] | 57 | /*! |
---|
[1358] | 58 | * Tests if the filter must auto-trigger. |
---|
| 59 | * |
---|
| 60 | * \return true if the filter must auto-trigger |
---|
| 61 | */ |
---|
| 62 | bool virtual mustAutoTrigger() const; |
---|
| 63 | |
---|
| 64 | /*! |
---|
[1158] | 65 | * Tests whether data is expected for the specified date. |
---|
| 66 | * |
---|
| 67 | * \param date the date associated to the data |
---|
| 68 | */ |
---|
| 69 | bool virtual isDataExpected(const CDate& date) const; |
---|
| 70 | |
---|
| 71 | /*! |
---|
[639] | 72 | * Removes all pending packets which are older than the specified timestamp. |
---|
| 73 | * |
---|
| 74 | * \param timestamp the timestamp used for invalidation |
---|
| 75 | */ |
---|
| 76 | void virtual invalidate(Time timestamp); |
---|
| 77 | |
---|
[1677] | 78 | int filterID; |
---|
| 79 | int tag; |
---|
[1679] | 80 | Time start_graph; |
---|
| 81 | Time end_graph; |
---|
| 82 | CField *field; |
---|
[1681] | 83 | int distance; |
---|
[1668] | 84 | |
---|
[1677] | 85 | |
---|
[638] | 86 | protected: |
---|
| 87 | /*! |
---|
| 88 | * Stores the packet for later access. |
---|
| 89 | * |
---|
| 90 | * \param data a vector of packets corresponding to each slot |
---|
| 91 | */ |
---|
| 92 | void virtual onInputReady(std::vector<CDataPacketPtr> data); |
---|
[1681] | 93 | void virtual buildGraph(std::vector<CDataPacketPtr> data); |
---|
[638] | 94 | |
---|
| 95 | private: |
---|
[1021] | 96 | CGarbageCollector& gc; //!< The garbage collector associated to the filter |
---|
[638] | 97 | CContext* context; //!< The context to which the data belongs |
---|
| 98 | CGrid* grid; //!< The grid attached to the data the filter can accept |
---|
[1201] | 99 | const bool detectMissingValues; //!< Whether missing values should be detected |
---|
| 100 | const double missingValue; //!< The value to use to replace missing values |
---|
[638] | 101 | std::map<Time, CDataPacketPtr> packets; //<! The stored packets |
---|
| 102 | }; // class CStoreFilter |
---|
| 103 | } // namespace xios |
---|
| 104 | |
---|
| 105 | #endif //__XIOS_CStoreFilter__ |
---|