source: XIOS/dev/branch_yushan_merged/src/filter/store_filter.hpp @ 1205

Last change on this file since 1205 was 1205, checked in by yushan, 7 years ago

branch merged with trunk @1200

File size: 3.1 KB
Line 
1#ifndef __XIOS_CStoreFilter__
2#define __XIOS_CStoreFilter__
3
4#include "input_pin.hpp"
5
6namespace 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      /*!
18       * Constructs the filter with one input slot and an associated
19       * garbage collector for the specified grid and context.
20       *
21       * \param gc the garbage collector associated with this input pin
22       * \param context the context to which the data belongs
23       * \param grid the grid to which the data is attached
24       * \param detectMissingValues whether missing values should be detected
25       * \param missingValue the value to use to replace missing values
26       */
27      CStoreFilter(CGarbageCollector& gc, CContext* context, CGrid* grid,
28                   bool detectMissingValues = false, double missingValue = 0.0);
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
54      /*!
55       * Tests whether data is expected for the specified date.
56       *
57       * \param date the date associated to the data
58       */
59      bool virtual isDataExpected(const CDate& date) const;
60
61      /*!
62       * Removes all pending packets which are older than the specified timestamp.
63       *
64       * \param timestamp the timestamp used for invalidation
65       */
66      void virtual invalidate(Time timestamp);
67
68    protected:
69      /*!
70       * Stores the packet for later access.
71       *
72       * \param data a vector of packets corresponding to each slot
73       */
74      void virtual onInputReady(std::vector<CDataPacketPtr> data);
75
76    private:
77      CGarbageCollector& gc; //!< The garbage collector associated to the filter
78      CContext* context; //!< The context to which the data belongs
79      CGrid* grid; //!< The grid attached to the data the filter can accept
80      const bool detectMissingValues; //!< Whether missing values should be detected
81      const double missingValue; //!< The value to use to replace missing values
82      std::map<Time, CDataPacketPtr> packets; //<! The stored packets
83  }; // class CStoreFilter
84} // namespace xios
85
86#endif //__XIOS_CStoreFilter__
Note: See TracBrowser for help on using the repository browser.