gapi_returnCode_t gapi_publisher_set_qos ( gapi_publisher _this, const gapi_publisherQos *qos) { gapi_returnCode_t result = GAPI_RETCODE_OK; u_result uResult; _Publisher publisher; v_publisherQos publisherQos; gapi_context context; gapi_publisherQos *existing_qos; GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_SET_QOS); publisher = gapi_publisherClaim(_this, &result); if ( publisher && qos ) { result = gapi_publisherQosIsConsistent(qos, &context); } else { result = GAPI_RETCODE_BAD_PARAMETER; } if ((result == GAPI_RETCODE_OK ) && (_EntityEnabled(publisher))) { existing_qos = gapi_publisherQos__alloc(); uResult = _PublisherGetQos(publisher, existing_qos); result = kernelResultToApiResult(uResult); if(result == GAPI_RETCODE_OK) { result = gapi_publisherQosCheckMutability( qos, existing_qos, &context); } gapi_free(existing_qos); } if ( result == GAPI_RETCODE_OK ) { publisherQos = u_publisherQosNew(NULL); if (publisherQos) { if ( copyPublisherQosIn(qos, publisherQos) ) { uResult = u_entitySetQoS(_EntityUEntity(publisher), (v_qos)(publisherQos) ); result = kernelResultToApiResult(uResult); u_publisherQosFree(publisherQos); } else { result = GAPI_RETCODE_OUT_OF_RESOURCES; } } else { result = GAPI_RETCODE_OUT_OF_RESOURCES; } } _EntityRelease(publisher); return result; }
void PublisherQosDelegate::defaults() { /* Get default QoS from userlayer and copy result. */ u_publisherQos qos = u_publisherQosNew(NULL); if (!qos) { ISOCPP_THROW_EXCEPTION(ISOCPP_OUT_OF_RESOURCES_ERROR, "Could not create internal QoS."); } this->u_qos(qos); u_publisherQosFree(qos); }
u_publisherQos PublisherQosDelegate::u_qos() const { u_publisherQos qos = u_publisherQosNew(NULL); if (!qos) { ISOCPP_THROW_EXCEPTION(ISOCPP_OUT_OF_RESOURCES_ERROR, "Could not create internal QoS."); } qos->presentation = presentation_ .delegate().v_policyI(); qos->partition = partition_ .delegate().v_policyI(); qos->groupData = gdata_ .delegate().v_policyI(); qos->entityFactory = factory_policy_ .delegate().v_policyI(); return qos; }
/************************************************************** * Protected functions **************************************************************/ v_qos u_qosNew( v_qos tmpl) { v_qos q; q = NULL; if (tmpl != NULL) { switch (tmpl->kind) { case V_PARTITION_QOS: q = (v_qos)u_partitionQosNew((v_partitionQos)tmpl); break; case V_PARTICIPANT_QOS: q = (v_qos)u_participantQosNew((v_participantQos)tmpl); break; case V_TOPIC_QOS: q = (v_qos)u_topicQosNew((v_topicQos)tmpl); break; case V_WRITER_QOS: q = (v_qos)u_writerQosNew((v_writerQos)tmpl); break; case V_READER_QOS: q = (v_qos)u_readerQosNew((v_readerQos)tmpl); break; case V_PUBLISHER_QOS: q = (v_qos)u_publisherQosNew((v_publisherQos)tmpl); break; case V_SUBSCRIBER_QOS: q = (v_qos)u_subscriberQosNew((v_subscriberQos)tmpl); break; case V_DATAVIEW_QOS: q = (v_qos)u_dataViewQosNew((v_dataViewQos)tmpl); break; default: OS_REPORT_1(OS_ERROR, "u_qosNew", 0, "unsupported qos %d", tmpl->kind); break; } } return q; }
_Publisher _PublisherNew ( u_participant uParticipant, const gapi_publisherQos *qos, const struct gapi_publisherListener *a_listener, const gapi_statusMask mask, const _DomainParticipant participant) { v_publisherQos publisherQos; _Publisher newPublisher; assert(uParticipant); assert(qos); assert(participant); newPublisher = _PublisherAlloc(); if ( newPublisher ) { _EntityInit (_Entity(newPublisher), _Entity(participant)); gapi_dataWriterQosCopy (&gapi_dataWriterQosDefault, &newPublisher->_defDataWriterQos); if ( a_listener ) { newPublisher->_Listener = *a_listener; } } if ( newPublisher ) { publisherQos = u_publisherQosNew(NULL); if ( publisherQos ) { if ( !copyPublisherQosIn(qos, publisherQos)) { _EntityDispose(_Entity(newPublisher)); newPublisher = NULL; } } else { _EntityDispose(_Entity(newPublisher)); newPublisher = NULL; } } if ( newPublisher ) { u_publisher uPublisher; uPublisher = u_publisherNew (uParticipant, "publisher", publisherQos, FALSE); u_publisherQosFree(publisherQos); if ( uPublisher ) { U_PUBLISHER_SET(newPublisher, uPublisher); } else { _EntityDispose(_Entity(newPublisher)); newPublisher = NULL; } } if ( newPublisher ) { _Status status; status = _StatusNew(_Entity(newPublisher), STATUS_KIND_PUBLISHER, (struct gapi_listener *)a_listener, mask); if (status) { _EntityStatus(newPublisher) = status; if ( qos->partition.name._length == 0 ) { /* * behaviour of the kernel in case of an empty sequence * is that it is related to none of the partitions, * while DCPS expects it to be conected to all partitions. * Therefore this has to be done seperately. */ u_publisherPublish (U_PUBLISHER_GET(newPublisher), ""); } } else { u_publisherFree(U_PUBLISHER_GET(newPublisher)); _EntityDispose(_Entity(newPublisher)); newPublisher = NULL; } } return newPublisher; }