source: XIOS/dev/dev_trunk_omp/src/filter/store_filter.hpp @ 1677

Last change on this file since 1677 was 1677, checked in by yushan, 5 years ago

MARK: Dynamic workflow graph developement. Branch up to date with trunk @1663.

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