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

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

Intermeadiate version for merging with new server functionalities.

File size: 2.5 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       * Removes all pending packets which are older than the specified timestamp.
53       *
54       * \param timestamp the timestamp used for invalidation
55       */
56      void virtual invalidate(Time timestamp);
57
58    protected:
59      /*!
60       * Stores the packet for later access.
61       *
62       * \param data a vector of packets corresponding to each slot
63       */
64      void virtual onInputReady(std::vector<CDataPacketPtr> data);
65
66    private:
67      CGarbageCollector& gc; //!< The garbage collector associated to the filter
68      CContext* context; //!< The context to which the data belongs
69      CGrid* grid; //!< The grid attached to the data the filter can accept
70      std::map<Time, CDataPacketPtr> packets; //<! The stored packets
71  }; // class CStoreFilter
72} // namespace xios
73
74#endif //__XIOS_CStoreFilter__
Note: See TracBrowser for help on using the repository browser.