[637] | 1 | #ifndef __XIOS_COutputPin__ |
---|
| 2 | #define __XIOS_COutputPin__ |
---|
| 3 | |
---|
[1006] | 4 | #include "garbage_collector.hpp" |
---|
[637] | 5 | #include "input_pin.hpp" |
---|
| 6 | |
---|
| 7 | namespace xios |
---|
| 8 | { |
---|
| 9 | /*! |
---|
| 10 | * An output pin handles the connections with downstream filters. |
---|
| 11 | */ |
---|
[1006] | 12 | class COutputPin : public InvalidableObject |
---|
[637] | 13 | { |
---|
| 14 | public: |
---|
| 15 | /*! |
---|
[1006] | 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 | /*! |
---|
[637] | 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 | |
---|
[1006] | 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 | * Removes all pending packets which are older than the specified timestamp. |
---|
| 49 | * |
---|
| 50 | * \param timestamp the timestamp used for invalidation |
---|
| 51 | */ |
---|
| 52 | void virtual invalidate(Time timestamp); |
---|
| 53 | |
---|
[637] | 54 | protected: |
---|
| 55 | /*! |
---|
[1006] | 56 | * Function triggered when a packet is ready to be delivered. |
---|
| 57 | * |
---|
| 58 | * \param packet the packet ready for output |
---|
| 59 | */ |
---|
| 60 | void onOutputReady(CDataPacketPtr packet); |
---|
| 61 | |
---|
| 62 | /*! |
---|
| 63 | * Informs the downstream pins that this output pin should be triggered. |
---|
| 64 | */ |
---|
| 65 | void setOutputTriggers(); |
---|
| 66 | |
---|
| 67 | private: |
---|
| 68 | /*! |
---|
[637] | 69 | * Delivers an output packet to the downstreams filter. |
---|
| 70 | * |
---|
| 71 | * \param packet the packet to output |
---|
| 72 | */ |
---|
| 73 | void deliverOuput(CDataPacketPtr packet); |
---|
| 74 | |
---|
[1006] | 75 | CGarbageCollector& gc; //!< The garbage collector associated to the output pin |
---|
| 76 | |
---|
| 77 | //!< Whether the ouput should be triggered manually |
---|
| 78 | bool manualTrigger; |
---|
| 79 | |
---|
[637] | 80 | //!< The list of connected filters and the corresponding slot numbers |
---|
| 81 | std::vector<std::pair<boost::shared_ptr<CInputPin>, size_t> > outputs; |
---|
[1006] | 82 | |
---|
| 83 | //! Output buffer, store the packets until the output is triggered |
---|
| 84 | std::map<Time, CDataPacketPtr> outputPackets; |
---|
[637] | 85 | }; // class COutputPin |
---|
| 86 | } // namespace xios |
---|
| 87 | |
---|
| 88 | #endif //__XIOS_COutputPin__ |
---|