source: XIOS/dev/dev_olga/src/filter/store_filter.hpp @ 1158

Last change on this file since 1158 was 1158, checked in by oabramkina, 7 years ago

Two server levels: merging with trunk r1137.
There are bugs.

File size: 2.7 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       */
25      CStoreFilter(CGarbageCollector& gc, CContext* context, CGrid* grid);
26
27      /*!
28       * Accesses the filter storage and retuns the packet corresponding
29       * to the specified timestamp. If there is no packet available for
30       * the specified timestamp, the function waits until the data is
31       * received or a timeout occurs.
32       *
33       * \param timestamp the timestamp of the requested packet
34       * \return a pointer to a read-only packet
35       */
36      CConstDataPacketPtr getPacket(Time timestamp);
37
38      /*!
39       * Accesses the filter storage and retuns the data corresponding
40       * to the specified timestamp. If there is no data available for
41       * the specified timestamp, the function waits until the data is
42       * received or a timeout occurs.
43       *
44       * \param timestamp the timestamp of the requested data
45       * \param data the array where the data is to be copied
46       * \return the status code associated with the data
47       */
48      template <int N>
49      CDataPacket::StatusCode getData(Time timestamp, CArray<double, N>& data);
50
51      /*!
52       * Tests whether data is expected for the specified date.
53       *
54       * \param date the date associated to the data
55       */
56      bool virtual isDataExpected(const CDate& date) const;
57
58      /*!
59       * Removes all pending packets which are older than the specified timestamp.
60       *
61       * \param timestamp the timestamp used for invalidation
62       */
63      void virtual invalidate(Time timestamp);
64
65    protected:
66      /*!
67       * Stores the packet for later access.
68       *
69       * \param data a vector of packets corresponding to each slot
70       */
71      void virtual onInputReady(std::vector<CDataPacketPtr> data);
72
73    private:
74      CGarbageCollector& gc; //!< The garbage collector associated to the filter
75      CContext* context; //!< The context to which the data belongs
76      CGrid* grid; //!< The grid attached to the data the filter can accept
77      std::map<Time, CDataPacketPtr> packets; //<! The stored packets
78  }; // class CStoreFilter
79} // namespace xios
80
81#endif //__XIOS_CStoreFilter__
Note: See TracBrowser for help on using the repository browser.