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 namespace OpenDDS {
00018 namespace DCPS {
00019
00020 TransportSendControlElement::~TransportSendControlElement()
00021 {
00022 DBG_ENTRY_LVL("TransportSendControlElement","~TransportSendControlElement",6);
00023 }
00024
00025 bool
00026 TransportSendControlElement::requires_exclusive_packet() const
00027 {
00028 DBG_ENTRY_LVL("TransportSendControlElement","requires_exclusive_packet",6);
00029 return true;
00030 }
00031
00032 namespace
00033 {
00034 void handle_message(const bool dropped,
00035 ACE_Message_Block* const msg,
00036 TransportSendListener* const listener,
00037 const bool dropped_by_transport)
00038 {
00039 if (dropped) {
00040 listener->control_dropped(msg, dropped_by_transport);
00041 } else {
00042 listener->control_delivered(msg);
00043 }
00044 }
00045
00046 void handle_message(const bool dropped,
00047 const DataSampleElement* const elem,
00048 const bool dropped_by_transport)
00049 {
00050 TransportSendListener* const listener = elem->get_send_listener();
00051 if (dropped) {
00052 listener->data_dropped(elem, dropped_by_transport);
00053 } else {
00054 listener->data_delivered(elem);
00055 }
00056 }
00057 }
00058
00059 void
00060 TransportSendControlElement::release_element(bool dropped_by_transport)
00061 {
00062 ACE_UNUSED_ARG(dropped_by_transport);
00063
00064 DBG_ENTRY_LVL("TransportSendControlElement","release_element",6);
00065
00066
00067 const bool dropped = this->was_dropped();
00068 ACE_Message_Block* const msg = this->msg_;
00069 TransportSendListener* const listener = this->listener_;
00070 const DataSampleElement* const dcps_elem = dcps_elem_;
00071
00072 if (allocator_) {
00073 ACE_DES_FREE(this, allocator_->free, TransportSendControlElement);
00074 }
00075
00076
00077 if (dcps_elem) {
00078 handle_message(dropped, dcps_elem, dropped_by_transport);
00079 } else {
00080 handle_message(dropped, msg, listener, dropped_by_transport);
00081 }
00082 }
00083
00084 RepoId
00085 TransportSendControlElement::publication_id() const
00086 {
00087 DBG_ENTRY_LVL("TransportSendControlElement","publication_id",6);
00088 return this->publisher_id_;
00089 }
00090
00091 const ACE_Message_Block*
00092 TransportSendControlElement::msg() const
00093 {
00094 DBG_ENTRY_LVL("TransportSendControlElement","msg",6);
00095 return this->msg_;
00096 }
00097
00098 const ACE_Message_Block*
00099 TransportSendControlElement::msg_payload() const
00100 {
00101 DBG_ENTRY_LVL("TransportSendControlElement", "msg_payload", 6);
00102 return this->msg_->cont();
00103 }
00104
00105 bool
00106 TransportSendControlElement::is_control(RepoId pub_id) const
00107 {
00108 return (pub_id == this->publisher_id_);
00109 }
00110
00111 }
00112 }