source: XIOS/dev/dev_trunk_omp/src/filter/output_pin.hpp @ 1677

Last change on this file since 1677 was 1677, checked in by yushan, 5 years ago

MARK: Dynamic workflow graph developement. Branch up to date with trunk @1663.

File size: 3.4 KB
Line 
1#ifndef __XIOS_COutputPin__
2#define __XIOS_COutputPin__
3
4#include "garbage_collector.hpp"
5#include "input_pin.hpp"
6
7namespace xios
8{
9  class CInputPin;
10  class CFilter;
11  /*!
12   * An output pin handles the connections with downstream filters.
13   */
14  class COutputPin : public InvalidableObject
15  {
16    public:
17      StdString output_field_id;
18      int tag;
19
20      std::vector< std::shared_ptr<COutputPin> > parent_filters;
21
22      /*!
23       * Constructs an ouput pin with manual or automatic trigger
24       * and an associated garbage collector.
25       *
26       * \param gc the garbage collector associated with this ouput pin
27       * \param slotsCount the number of slots
28       * \param buildWorkflowGraph indicates whether data will be visualized
29       */
30      COutputPin(CGarbageCollector& gc, bool manualTrigger = false, bool buildWorkflowGraph = false);
31
32      StdString virtual GetName(void);
33     
34      /*!
35       * Connects to a specific slot of the input pin of a downstream filter.
36       * Note that the output pin holds a reference on the downstream filter.
37       *
38       * \param inputPin the input pin to connect
39       * \param inputSlot the input slot number
40       */
41      void connectOutput(std::shared_ptr<CInputPin> inputPin, size_t inputSlot);
42
43      /*!
44       * Triggers the output of any buffered packet for the specified timestamp.
45       *
46       * \param timestamp the timestamp for which we are triggering the output
47       */
48      void virtual trigger(Time timestamp);
49
50      /*!
51       * Tests if the pin can be triggered.
52       *
53       * \return true if the pin can be triggered
54       */
55      bool virtual canBeTriggered() const;
56
57      /*!
58       * Tests if the pin must auto-trigger.
59       *
60       * \return true if the pin must auto-trigger
61       */
62      bool virtual mustAutoTrigger() const;
63
64      /*!
65       * Tests whether data is expected for the specified date.
66       *
67       * \param date the date associated to the data
68       */
69      bool virtual isDataExpected(const CDate& date) const;
70
71      /*!
72       * Removes all pending packets which are older than the specified timestamp.
73       *
74       * \param timestamp the timestamp used for invalidation
75       */
76      void virtual invalidate(Time timestamp);
77
78      void virtual setParentFiltersTag();
79
80
81    protected:
82      /*!
83       * Function triggered when a packet is ready to be delivered.
84       *
85       * \param packet the packet ready for output
86       */
87      void onOutputReady(CDataPacketPtr packet);
88
89      /*!
90       * Informs the downstream pins that this output pin should be triggered.
91       */
92      void setOutputTriggers();
93
94    private:
95      /*!
96       * Delivers an output packet to the downstreams filter.
97       *
98       * \param packet the packet to output
99       */
100      void deliverOuput(CDataPacketPtr packet);
101
102      CGarbageCollector& gc; //!< The garbage collector associated to the output pin
103
104      //!< Whether the ouput should be triggered manually
105      bool manualTrigger;
106
107      //!< The list of connected filters and the corresponding slot numbers
108      std::vector<std::pair<std::shared_ptr<CInputPin>, size_t> > outputs;
109
110      //! Output buffer, store the packets until the output is triggered
111      std::map<Time, CDataPacketPtr> outputPackets;
112
113      //! Indicates whether the workflow will be visualized
114      bool buildWorkflowGraph;
115
116
117  }; // class COutputPin
118} // namespace xios
119
120#endif //__XIOS_COutputPin__
Note: See TracBrowser for help on using the repository browser.