source: XIOS/dev/XIOS_DEV_CMIP6/src/filter/store_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: 3.3 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 if the filter must auto-trigger.
56       *
57       * \return true if the filter must auto-trigger
58       */
59      bool virtual mustAutoTrigger() const;
60
61      /*!
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      /*!
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
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:
84      CGarbageCollector& gc; //!< The garbage collector associated to the filter
85      CContext* context; //!< The context to which the data belongs
86      CGrid* grid; //!< The grid attached to the data the filter can accept
87      const bool detectMissingValues; //!< Whether missing values should be detected
88      const double missingValue; //!< The value to use to replace missing values
89      std::map<Time, CDataPacketPtr> packets; //<! The stored packets
90  }; // class CStoreFilter
91} // namespace xios
92
93#endif //__XIOS_CStoreFilter__
Note: See TracBrowser for help on using the repository browser.