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