source: XIOS/trunk/src/filter/output_pin.hpp @ 1704

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

Introducing the new graph functionality. Attribute build_workflow_graph=.TRUE. is used in the field definition section in the xml file to enable the workflow graph of the field and other fields referecing to it. A more detailed document will be available soon on the graph fuctionality.

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