TransportSendControlElement.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "DCPS/DdsDcps_pch.h"
00009 #include "TransportSendControlElement.h"
00010 #include "TransportSendListener.h"
00011 #include "dds/DCPS/transport/framework/EntryExit.h"
00012
00013 #if !defined (__ACE_INLINE__)
00014 #include "TransportSendControlElement.inl"
00015 #endif
00016
00017 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00018
00019 namespace OpenDDS {
00020 namespace DCPS {
00021
00022
00023 TransportSendControlElement::TransportSendControlElement(int initial_count,
00024 const RepoId& publisher_id,
00025 TransportSendListener* listener,
00026 const DataSampleHeader& header,
00027 Message_Block_Ptr msg_block)
00028 : TransportQueueElement(initial_count),
00029 publisher_id_(publisher_id),
00030 listener_(listener),
00031 header_(header),
00032 msg_(msg_block.release()),
00033 dcps_elem_(0)
00034 {
00035 DBG_ENTRY_LVL("TransportSendControlElement","TransportSendControlElement",6);
00036 }
00037
00038
00039 TransportSendControlElement::TransportSendControlElement(int initial_count,
00040 const DataSampleElement* dcps_elem)
00041 : TransportQueueElement(initial_count)
00042 , publisher_id_(dcps_elem->get_pub_id())
00043 , listener_(dcps_elem->get_send_listener())
00044 , header_(dcps_elem->get_header())
00045 , dcps_elem_(dcps_elem)
00046 {
00047 DBG_ENTRY_LVL("TransportSendControlElement", "TransportSendControlElement", 6);
00048 }
00049
00050 TransportSendControlElement::~TransportSendControlElement()
00051 {
00052 DBG_ENTRY_LVL("TransportSendControlElement","~TransportSendControlElement",6);
00053 }
00054
00055 bool
00056 TransportSendControlElement::requires_exclusive_packet() const
00057 {
00058 DBG_ENTRY_LVL("TransportSendControlElement","requires_exclusive_packet",6);
00059 return true;
00060 }
00061
00062 namespace
00063 {
00064 void handle_message(const bool dropped,
00065 const Message_Block_Ptr& msg,
00066 TransportSendListener* const listener,
00067 const bool dropped_by_transport)
00068 {
00069 if (dropped) {
00070 listener->control_dropped(msg, dropped_by_transport);
00071 } else {
00072 listener->control_delivered(msg);
00073 }
00074 }
00075
00076 void handle_message(const bool dropped,
00077 const DataSampleElement* elem,
00078 const bool dropped_by_transport)
00079 {
00080 TransportSendListener* const listener = elem->get_send_listener();
00081 if (dropped) {
00082 listener->data_dropped(elem, dropped_by_transport);
00083 } else {
00084 listener->data_delivered(elem);
00085 }
00086 }
00087 }
00088
00089 void
00090 TransportSendControlElement::release_element(bool dropped_by_transport)
00091 {
00092 ACE_UNUSED_ARG(dropped_by_transport);
00093
00094 DBG_ENTRY_LVL("TransportSendControlElement","release_element",6);
00095
00096
00097 const bool dropped = this->was_dropped();
00098
00099 Message_Block_Ptr msg(this->msg_.release());
00100
00101 TransportSendListener* const listener = this->listener_;
00102 const DataSampleElement* dcps_elem = dcps_elem_;
00103
00104
00105 delete this;
00106
00107
00108
00109 if (dcps_elem) {
00110 handle_message(dropped, dcps_elem, dropped_by_transport);
00111 } else {
00112 handle_message(dropped, msg, listener, dropped_by_transport);
00113 }
00114 }
00115
00116 RepoId
00117 TransportSendControlElement::publication_id() const
00118 {
00119 DBG_ENTRY_LVL("TransportSendControlElement","publication_id",6);
00120 return this->publisher_id_;
00121 }
00122
00123 const ACE_Message_Block*
00124 TransportSendControlElement::msg() const
00125 {
00126 DBG_ENTRY_LVL("TransportSendControlElement","msg",6);
00127 if (dcps_elem_)
00128 return dcps_elem_->get_sample();
00129 return this->msg_.get();
00130 }
00131
00132 const ACE_Message_Block*
00133 TransportSendControlElement::msg_payload() const
00134 {
00135 DBG_ENTRY_LVL("TransportSendControlElement", "msg_payload", 6);
00136 return this->msg()->cont();
00137 }
00138
00139 bool
00140 TransportSendControlElement::is_control(RepoId pub_id) const
00141 {
00142 return (pub_id == this->publisher_id_);
00143 }
00144
00145 }
00146 }
00147
00148 OPENDDS_END_VERSIONED_NAMESPACE_DECL