[637] | 1 | #ifndef __XIOS_COutputPin__ |
---|
| 2 | #define __XIOS_COutputPin__ |
---|
| 3 | |
---|
[1021] | 4 | #include "garbage_collector.hpp" |
---|
[637] | 5 | #include "input_pin.hpp" |
---|
[1704] | 6 | #include "duration.hpp" |
---|
[637] | 7 | |
---|
| 8 | namespace xios |
---|
| 9 | { |
---|
[1704] | 10 | class CField; |
---|
| 11 | class CInputPin; |
---|
| 12 | class CFilter; |
---|
| 13 | class CDuration; |
---|
[637] | 14 | /*! |
---|
| 15 | * An output pin handles the connections with downstream filters. |
---|
| 16 | */ |
---|
[1021] | 17 | class COutputPin : public InvalidableObject |
---|
[637] | 18 | { |
---|
| 19 | public: |
---|
[1868] | 20 | int tag = 0; |
---|
| 21 | Time start_graph = 0; |
---|
| 22 | Time end_graph = 0; |
---|
| 23 | CField *field = nullptr; |
---|
| 24 | int distance = 0; |
---|
[1704] | 25 | |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | std::vector< std::shared_ptr<COutputPin> > parent_filters; |
---|
| 29 | |
---|
[637] | 30 | /*! |
---|
[1021] | 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 | |
---|
[1704] | 39 | StdString virtual GetName(void); |
---|
| 40 | |
---|
[1021] | 41 | /*! |
---|
[637] | 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 | */ |
---|
[1542] | 48 | void connectOutput(std::shared_ptr<CInputPin> inputPin, size_t inputSlot); |
---|
[637] | 49 | |
---|
[1021] | 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 | /*! |
---|
[1358] | 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 | /*! |
---|
[1158] | 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 | /*! |
---|
[1021] | 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 | |
---|
[1704] | 85 | void virtual setParentFiltersTag(); |
---|
| 86 | |
---|
| 87 | |
---|
[637] | 88 | protected: |
---|
| 89 | /*! |
---|
[1021] | 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 | /*! |
---|
[637] | 103 | * Delivers an output packet to the downstreams filter. |
---|
| 104 | * |
---|
| 105 | * \param packet the packet to output |
---|
| 106 | */ |
---|
| 107 | void deliverOuput(CDataPacketPtr packet); |
---|
| 108 | |
---|
[1021] | 109 | CGarbageCollector& gc; //!< The garbage collector associated to the output pin |
---|
| 110 | |
---|
| 111 | //!< Whether the ouput should be triggered manually |
---|
| 112 | bool manualTrigger; |
---|
| 113 | |
---|
[637] | 114 | //!< The list of connected filters and the corresponding slot numbers |
---|
[1542] | 115 | std::vector<std::pair<std::shared_ptr<CInputPin>, size_t> > outputs; |
---|
[1021] | 116 | |
---|
| 117 | //! Output buffer, store the packets until the output is triggered |
---|
| 118 | std::map<Time, CDataPacketPtr> outputPackets; |
---|
[637] | 119 | }; // class COutputPin |
---|
| 120 | } // namespace xios |
---|
| 121 | |
---|
| 122 | #endif //__XIOS_COutputPin__ |
---|