source: XIOS/dev/dev_ym/XIOS_COUPLING/src/filter/client_to_model_store_filter.hpp @ 1960

Last change on this file since 1960 was 1930, checked in by ymipsl, 4 years ago

Big update on on going work related to data distribution and transfer between clients and servers.
Revisite of the source and store filter using "connectors".

YM

  • Property svn:executable set to *
File size: 3.2 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  class CField ;
11
12  /*!
13   * A terminal filter which stores all the packets it receives.
14   */
15  class CClientToModelStoreFilter : public CInputPin
16  {
17    public:
18      /*!
19       * Constructs the filter with one input slot and an associated
20       * garbage collector for the specified grid and context.
21       *
22       * \param gc the garbage collector associated with this input pin
23       * \param context the context to which the data belongs
24       * \param grid the grid to which the data is attached
25       * \param detectMissingValues whether missing values should be detected
26       * \param missingValue the value to use to replace missing values
27       */
28      CClientToModelStoreFilter(CGarbageCollector& gc, CField* field);
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      bool detectMissingValues_; //!< Whether missing values should be detected
88      double missingValue_; //!< The value to use to replace missing values
89      bool hasMissingValue_ ;
90      std::map<Time, CDataPacketPtr> packets_; //<! The stored packets
91  }; // class CClientToModelStoreFilter
92} // namespace xios
93
94#endif //__XIOS_CStoreFilter__
Note: See TracBrowser for help on using the repository browser.