Line data Source code
1 : /* 2 : * 3 : * 4 : * Distributed under the OpenDDS License. 5 : * See: http://www.opendds.org/license.html 6 : */ 7 : 8 : #ifndef OPENDDS_DCPS_TRANSPORT_FRAMEWORK_TRANSPORTSENDCONTROLELEMENT_H 9 : #define OPENDDS_DCPS_TRANSPORT_FRAMEWORK_TRANSPORTSENDCONTROLELEMENT_H 10 : 11 : #include "dds/DCPS/dcps_export.h" 12 : #include "dds/DCPS/GuidUtils.h" 13 : #include "dds/DCPS/DataSampleHeader.h" 14 : #include "TransportDefs.h" 15 : #include "TransportQueueElement.h" 16 : #include "ace/Synch_Traits.h" 17 : 18 : ACE_BEGIN_VERSIONED_NAMESPACE_DECL 19 : class ACE_Message_Block; 20 : ACE_END_VERSIONED_NAMESPACE_DECL 21 : 22 : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 23 : 24 : namespace OpenDDS { 25 : namespace DCPS { 26 : 27 : class TransportSendListener; 28 : class TransportSendControlElement; 29 : class DataSampleElement; 30 : 31 : typedef Cached_Allocator_With_Overflow<TransportSendControlElement, ACE_SYNCH_NULL_MUTEX> 32 : TransportSendControlElementAllocator; 33 : 34 : class OpenDDS_Dcps_Export TransportSendControlElement : public TransportQueueElement { 35 : public: 36 : 37 : TransportSendControlElement(int initial_count, 38 : const GUID_t& publisher_id, 39 : TransportSendListener* listener, 40 : const DataSampleHeader& header, 41 : Message_Block_Ptr msg_block); 42 : 43 : TransportSendControlElement(int initial_count, 44 : const DataSampleElement* dcps_elem); 45 : 46 : virtual ~TransportSendControlElement(); 47 : 48 : /// Overridden to always return true for Send Control elements. 49 : virtual bool requires_exclusive_packet() const; 50 : 51 : /// Accessor for the publisher id. 52 : virtual GUID_t publication_id() const; 53 : 54 : virtual ACE_Message_Block* duplicate_msg() const; 55 : 56 : /// Accessor for the ACE_Message_Block 57 : virtual const ACE_Message_Block* msg() const; 58 : 59 0 : const DataSampleHeader& header() const { return header_; } 60 : // Only allow const access to the header. Modifying the header 61 : // would require remarshaling. 62 : //DataSampleHeader& header() { return header_; } 63 : 64 0 : const TransportSendListener* listener() const { return listener_; } 65 : 66 : virtual const ACE_Message_Block* msg_payload() const; 67 : 68 : virtual SequenceNumber sequence() const; 69 : 70 : /// Is the element a "control" sample from the specified pub_id? 71 : virtual bool is_control(GUID_t pub_id) const; 72 : virtual bool owned_by_transport (); 73 : 74 0 : virtual bool is_request_ack() const { return header_.message_id_ == REQUEST_ACK; } 75 : 76 0 : virtual bool is_last_fragment() const { return !header_.more_fragments(); } 77 : 78 : protected: 79 : 80 : virtual void release_element(bool dropped_by_transport); 81 : 82 : private: 83 : 84 : /// The publisher of the control message 85 : GUID_t publisher_id_; 86 : 87 : /// The TransportSendListener object to call back upon. 88 : TransportSendListener* listener_; 89 : 90 : /// The OpenDDS DCPS header for this control message 91 : DataSampleHeader header_; 92 : 93 : /// The control message. 94 : Message_Block_Ptr msg_; 95 : 96 : /// If constructed from a DataSampleElement, keep it around for release 97 : const DataSampleElement* const dcps_elem_; 98 : }; 99 : 100 : } // namespace DCPS 101 : } // namespace OpenDDS 102 : 103 : OPENDDS_END_VERSIONED_NAMESPACE_DECL 104 : 105 : #if defined (__ACE_INLINE__) 106 : #include "TransportSendControlElement.inl" 107 : #endif /* __ACE_INLINE__ */ 108 : 109 : #endif /* OPENDDS_DCPS_TRANSPORTSENDCONTROLELEMENT_H */