source: XIOS/dev/dev_olga/src/filter/output_pin.hpp @ 1158

Last change on this file since 1158 was 1158, checked in by oabramkina, 7 years ago

Two server levels: merging with trunk r1137.
There are bugs.

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