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

Last change on this file since 1654 was 1653, checked in by oabramkina, 5 years ago

Developments for visualization of XIOS workflow.

Branch is spawned from trunk r1649.

Boost library is used for producing Graphviz DOT files. Current results: a DOT file representing a static workflow. For a complete proof of concept, DOT files for each timestamp should be generated. The necessary information has been collected by XIOS, it only requires rearranging the information for graphing (changes in classes CWorkflowGraph and CGraphviz).

File size: 3.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       * \param detectMissingValues whether missing values should be detected
25       * \param missingValue the value to use to replace missing values
26       */
27      CStoreFilter(CGarbageCollector& gc, CContext* context, CGrid* grid,
28                   bool detectMissingValues = false, double missingValue = 0.0);
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      /*!
76       * Returns filter's id needed in case of building workflow graph
77       */
78      int getFilterId();
79
80    protected:
81      /*!
82       * Stores the packet for later access.
83       *
84       * \param data a vector of packets corresponding to each slot
85       */
86      void virtual onInputReady(std::vector<CDataPacketPtr> data);
87
88    private:
89      CGarbageCollector& gc;            //!< The garbage collector associated to the filter
90      CContext* context;                //!< The context to which the data belongs
91      CGrid* grid;                      //!< The grid attached to the data the filter can accept
92      const bool detectMissingValues;   //!< Whether missing values should be detected
93      const double missingValue;        //!< The value to use to replace missing values
94      std::map<Time, CDataPacketPtr> packets; //<! The stored packets
95      int filterId;                     //!< Filter's id needed in case of building a workflow
96
97  }; // class CStoreFilter
98} // namespace xios
99
100#endif //__XIOS_CStoreFilter__
Note: See TracBrowser for help on using the repository browser.