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

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

MARK: Dynamic workflow graph developement. Branch up to date with trunk @1676. Using vis.js

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