/************************************************************** * constructor/destructor **************************************************************/ v_publisherQos u_publisherQosNew( v_publisherQos tmpl) { u_result result; v_publisherQos q; q = os_malloc(sizeof(C_STRUCT(v_publisherQos))); if (q != NULL) { if (tmpl != NULL) { *q = *tmpl; q->groupData.size = tmpl->groupData.size; if (tmpl->groupData.size > 0) { q->groupData.value = os_malloc(tmpl->groupData.size); memcpy(q->groupData.value,tmpl->groupData.value,tmpl->groupData.size); } else { q->groupData.value = NULL; } if (tmpl->partition != NULL) { q->partition = os_strdup(tmpl->partition); } else { q->partition = NULL; } } else { result = u_publisherQosInit(q); if (result != U_RESULT_OK) { u_publisherQosFree(q); q = NULL; } } } return q; }
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); }
void PublisherDelegate::qos(const dds::pub::qos::PublisherQos& pqos) { org::opensplice::core::ScopedObjectLock scopedLock(*this); u_publisherQos uQos; u_result uResult; pqos.delegate().check(); uQos = pqos.delegate().u_qos(); if (!uQos) { ISOCPP_THROW_EXCEPTION(ISOCPP_ERROR, "Could not convert publisher qos."); } uResult = u_publisherSetQos(u_publisher(this->userHandle), uQos); u_publisherQosFree(uQos); ISOCPP_U_RESULT_CHECK_AND_THROW(uResult, "Could not set publisher qos."); this->qos_ = pqos; }
u_result _PublisherGetQos ( _Publisher _this, gapi_publisherQos *qos) { v_publisherQos publisherQos; u_publisher uPublisher; u_result result; assert(_this); uPublisher = U_PUBLISHER_GET(_this); result = u_entityQoS(u_entity(uPublisher), (v_qos*)&publisherQos); if ( result == U_RESULT_OK ) { copyPublisherQosOut(publisherQos, qos); u_publisherQosFree(publisherQos); } return result; }
PublisherDelegate::PublisherDelegate(const dds::domain::DomainParticipant& dp, const dds::pub::qos::PublisherQos& qos, dds::pub::PublisherListener* listener, const dds::core::status::StatusMask& event_mask) : dp_(dp), qos_(qos), default_dwqos_() { ISOCPP_REPORT_STACK_DDS_BEGIN(dp); u_publisher uPub; u_participant uPar; u_publisherQos uQos; uPar = u_participant(this->dp_.delegate()->get_user_handle()); if (!uPar) { ISOCPP_THROW_EXCEPTION(ISOCPP_ERROR, "Could not get publisher participant."); } qos.delegate().check(); uQos = qos.delegate().u_qos(); if (!uQos) { ISOCPP_THROW_EXCEPTION(ISOCPP_ERROR, "Could not convert publisher QoS."); } std::string name = this->dp_.delegate()->create_child_name("publisher"); uPub = u_publisherNew(uPar, name.c_str(), uQos, false); u_publisherQosFree (uQos); if (!uPub) { ISOCPP_THROW_EXCEPTION(ISOCPP_ERROR, "Could not create publisher."); } /* ObjectDelegate class will free the userlayer object in its destructor. */ this->userHandle = u_object(uPub); this->listener_set((void*)listener, event_mask); set_domain_id(dp.delegate()->get_domain_id()); }
_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; }