Line data Source code
1 : /* 2 : * 3 : * 4 : * Distributed under the OpenDDS License. 5 : * See: http://www.opendds.org/license.html 6 : */ 7 : 8 : #include "DCPS/DdsDcps_pch.h" //Only the _pch include should start with DCPS/ 9 : 10 : #ifndef DDS_HAS_MINIMUM_BIT 11 : 12 : #include "BitPubListenerImpl.h" 13 : #include "DomainParticipantImpl.h" 14 : #include "GuidConverter.h" 15 : #include "Discovery.h" 16 : #include "Service_Participant.h" 17 : #include "BuiltInTopicUtils.h" 18 : #include "dds/DdsDcpsCoreTypeSupportImpl.h" 19 : 20 : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL 21 : 22 : namespace OpenDDS { 23 : namespace DCPS { 24 : 25 0 : BitPubListenerImpl::BitPubListenerImpl(DomainParticipantImpl* partipant) 26 0 : : partipant_ (partipant) 27 : { 28 0 : } 29 : 30 0 : BitPubListenerImpl::~BitPubListenerImpl() 31 : { 32 0 : } 33 : 34 0 : void BitPubListenerImpl::on_data_available(DDS::DataReader_ptr reader) 35 : { 36 : try { 37 : ::DDS::PublicationBuiltinTopicDataDataReader_var bit_dr = 38 0 : ::DDS::PublicationBuiltinTopicDataDataReader::_narrow(reader); 39 : 40 0 : if (CORBA::is_nil(bit_dr.in())) { 41 0 : ACE_ERROR((LM_ERROR, 42 : ACE_TEXT("(%P|%t) ERROR: BitPubListenerImpl::on_data_available ") 43 : ACE_TEXT("_narrow failed!\n"))); 44 0 : return; 45 : } 46 : 47 0 : ::DDS::PublicationBuiltinTopicData data; 48 : DDS::SampleInfo si; 49 : DDS::ReturnCode_t status; 50 : 51 : do { 52 0 : status = bit_dr->take_next_sample(data, si); 53 : 54 0 : if (status == DDS::RETCODE_OK) { 55 0 : if (si.valid_data) { 56 : #ifndef OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE 57 0 : const GUID_t pub_id = bit_key_to_guid(data.key); 58 0 : CORBA::Long const ownership_strength = data.ownership_strength.value; 59 0 : this->partipant_->update_ownership_strength(pub_id, ownership_strength); 60 0 : if (DCPS_debug_level > 4) { 61 0 : ACE_DEBUG((LM_DEBUG, 62 : ACE_TEXT("(%P|%t) BitPubListenerImpl::on_data_available: %X ") 63 : ACE_TEXT("reset ownership strength %d for writer %C.\n"), 64 : this, ownership_strength, LogGuid(pub_id).c_str())); 65 : } 66 : #endif 67 : } 68 0 : else if (si.instance_state != DDS::NOT_ALIVE_DISPOSED_INSTANCE_STATE 69 0 : && si.instance_state != DDS::NOT_ALIVE_NO_WRITERS_INSTANCE_STATE) { 70 0 : ACE_ERROR((LM_ERROR, 71 : ACE_TEXT("(%P|%t) ERROR: BitPubListenerImpl::on_data_available:") 72 : ACE_TEXT(" unknown instance state: %d\n"), 73 : si.instance_state)); 74 : } 75 0 : } else if (status != DDS::RETCODE_NO_DATA) { 76 0 : ACE_ERROR((LM_ERROR, 77 : ACE_TEXT("(%P|%t) ERROR: BitPubListenerImpl::on_data_available:") 78 : ACE_TEXT(" unexpected status: %d\n"), 79 : status)); 80 : } 81 0 : } while (status == DDS::RETCODE_OK); 82 : 83 0 : } catch (const CORBA::Exception& e) { 84 0 : e._tao_print_exception("Exception caught in BitPubListenerImpl::on_data_available():"); 85 0 : } 86 : } 87 : 88 0 : void BitPubListenerImpl::on_requested_deadline_missed( 89 : DDS::DataReader_ptr, 90 : const DDS::RequestedDeadlineMissedStatus &) 91 : { 92 0 : } 93 : 94 0 : void BitPubListenerImpl::on_requested_incompatible_qos( 95 : DDS::DataReader_ptr, 96 : const DDS::RequestedIncompatibleQosStatus &) 97 : { 98 0 : } 99 : 100 0 : void BitPubListenerImpl::on_liveliness_changed( 101 : DDS::DataReader_ptr, 102 : const DDS::LivelinessChangedStatus &) 103 : { 104 0 : } 105 : 106 0 : void BitPubListenerImpl::on_subscription_matched( 107 : DDS::DataReader_ptr, 108 : const DDS::SubscriptionMatchedStatus &) 109 : { 110 0 : } 111 : 112 0 : void BitPubListenerImpl::on_sample_rejected( 113 : DDS::DataReader_ptr, 114 : const DDS::SampleRejectedStatus&) 115 : { 116 0 : } 117 : 118 0 : void BitPubListenerImpl::on_sample_lost( 119 : DDS::DataReader_ptr, 120 : const DDS::SampleLostStatus&) 121 : { 122 0 : } 123 : 124 : } // namespace DCPS 125 : } // namespace OpenDDS 126 : 127 : OPENDDS_END_VERSIONED_NAMESPACE_DECL 128 : 129 : #endif // DDS_HAS_MINIMUM_BIT