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