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