DDS::ReturnCode_t RecorderImpl::set_qos( const DDS::SubscriberQos & subscriber_qos, const DDS::DataReaderQos & qos) { OPENDDS_NO_OBJECT_MODEL_PROFILE_COMPATIBILITY_CHECK(subscriber_qos, DDS::RETCODE_UNSUPPORTED); if (Qos_Helper::valid(subscriber_qos) && Qos_Helper::consistent(subscriber_qos)) { if (subqos_ != subscriber_qos) { // for the not changeable qos, it can be changed before enable if (!Qos_Helper::changeable(subqos_, subscriber_qos) && enabled_ == true) { return DDS::RETCODE_IMMUTABLE_POLICY; } else { subqos_ = subscriber_qos; } } } else { return DDS::RETCODE_INCONSISTENT_POLICY; } OPENDDS_NO_OWNERSHIP_KIND_EXCLUSIVE_COMPATIBILITY_CHECK(qos, DDS::RETCODE_UNSUPPORTED); OPENDDS_NO_OWNERSHIP_PROFILE_COMPATIBILITY_CHECK(qos, DDS::RETCODE_UNSUPPORTED); OPENDDS_NO_DURABILITY_KIND_TRANSIENT_PERSISTENT_COMPATIBILITY_CHECK(qos, DDS::RETCODE_UNSUPPORTED); if (Qos_Helper::valid(qos) && Qos_Helper::consistent(qos)) { if (qos_ == qos) return DDS::RETCODE_OK; if (!Qos_Helper::changeable(qos_, qos) && this->is_enabled()) { return DDS::RETCODE_IMMUTABLE_POLICY; } else { Discovery_rch disco = TheServiceParticipant->get_discovery(domain_id_); const bool status = disco->update_subscription_qos( this->participant_servant_->get_domain_id(), this->participant_servant_->get_id(), this->subscription_id_, qos, subscriber_qos); if (!status) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) RecorderImpl::set_qos, ") ACE_TEXT("qos not updated. \n")), DDS::RETCODE_ERROR); } } qos_ = qos; subqos_ = subscriber_qos; return DDS::RETCODE_OK; } else { return DDS::RETCODE_INCONSISTENT_POLICY; } }
DDS::ReturnCode_t PublisherImpl::set_qos(const DDS::PublisherQos & qos) { OPENDDS_NO_OBJECT_MODEL_PROFILE_COMPATIBILITY_CHECK(qos, DDS::RETCODE_UNSUPPORTED); if (Qos_Helper::valid(qos) && Qos_Helper::consistent(qos)) { if (qos_ == qos) return DDS::RETCODE_OK; // for the not changeable qos, it can be changed before enable if (!Qos_Helper::changeable(qos_, qos) && enabled_ == true) { return DDS::RETCODE_IMMUTABLE_POLICY; } else { qos_ = qos; DwIdToQosMap idToQosMap; { ACE_GUARD_RETURN(ACE_Recursive_Thread_Mutex, guard, this->pi_lock_, DDS::RETCODE_ERROR); for (PublicationMap::iterator iter = publication_map_.begin(); iter != publication_map_.end(); ++iter) { DDS::DataWriterQos qos; iter->second->get_qos(qos); RepoId id = iter->second->get_publication_id(); std::pair<DwIdToQosMap::iterator, bool> pair = idToQosMap.insert(DwIdToQosMap::value_type(id, qos)); if (pair.second == false) { GuidConverter converter(id); ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ") ACE_TEXT("PublisherImpl::set_qos: ") ACE_TEXT("insert id %C to DwIdToQosMap ") ACE_TEXT("failed.\n"), OPENDDS_STRING(converter).c_str()), DDS::RETCODE_ERROR); } } } DwIdToQosMap::iterator iter = idToQosMap.begin(); while (iter != idToQosMap.end()) { Discovery_rch disco = TheServiceParticipant->get_discovery(this->domain_id_); const bool status = disco->update_publication_qos( participant_->get_domain_id(), participant_->get_id(), iter->first, iter->second, this->qos_); if (!status) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) PublisherImpl::set_qos, ") ACE_TEXT("failed. \n")), DDS::RETCODE_ERROR); } ++iter; } } return DDS::RETCODE_OK; } else { return DDS::RETCODE_INCONSISTENT_POLICY; } }