source: XIOS/trunk/src/filter/store_filter.hpp @ 638

Last change on this file since 638 was 638, checked in by rlacroix, 9 years ago

Add a source filter and two terminal filters.

File size: 2.1 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 for the specified grid
19       * and context.
20       *
21       * \param context the context to which the data belongs
22       * \param grid the grid to which the data is attached
23       */
24      CStoreFilter(CContext* context, CGrid* grid);
25
26      /*!
27       * Accesses the filter storage and retuns the packet corresponding
28       * to the specified timestamp. If there is no packet available for
29       * the specified timestamp, the function waits until the data is
30       * received or a timeout occurs.
31       *
32       * \param timestamp the timestamp of the requested packet
33       * \return a pointer to a read-only packet
34       */
35      CConstDataPacketPtr getPacket(Time timestamp);
36
37      /*!
38       * Accesses the filter storage and retuns the data corresponding
39       * to the specified timestamp. If there is no data available for
40       * the specified timestamp, the function waits until the data is
41       * received or a timeout occurs.
42       *
43       * \param timestamp the timestamp of the requested data
44       * \param data the array where the data is to be copied
45       * \return the status code associated with the data
46       */
47      template <int N>
48      CDataPacket::StatusCode getData(Time timestamp, CArray<double, N>& data);
49
50    protected:
51      /*!
52       * Stores the packet for later access.
53       *
54       * \param data a vector of packets corresponding to each slot
55       */
56      void virtual onInputReady(std::vector<CDataPacketPtr> data);
57
58    private:
59      CContext* context; //!< The context to which the data belongs
60      CGrid* grid; //!< The grid attached to the data the filter can accept
61      std::map<Time, CDataPacketPtr> packets; //<! The stored packets
62  }; // class CStoreFilter
63} // namespace xios
64
65#endif //__XIOS_CStoreFilter__
Note: See TracBrowser for help on using the repository browser.