gapi_returnCode_t gapi_publisher_set_default_datawriter_qos ( gapi_publisher _this, const gapi_dataWriterQos *qos) { gapi_returnCode_t result = GAPI_RETCODE_OK; _Publisher publisher; gapi_context context; GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_SET_DEFAULT_DATAWRITER_QOS); publisher = gapi_publisherClaim(_this, &result); if (result == GAPI_RETCODE_OK) { if (qos == GAPI_DATAWRITER_QOS_DEFAULT) { qos = &gapi_dataWriterQosDefault; } result = gapi_dataWriterQosIsConsistent(qos, &context); if (result == GAPI_RETCODE_OK) { gapi_dataWriterQosCopy (qos, &publisher->_defDataWriterQos); } _EntityRelease(publisher); } return result; }
/* ReturnCode_t * set_qos( * in DataWriterQos qos); * * Function will operate independent of the enable flag */ gapi_returnCode_t gapi_dataWriter_set_qos ( gapi_dataWriter _this, const gapi_dataWriterQos *qos) { gapi_returnCode_t result = GAPI_RETCODE_OK; u_result uResult; _DataWriter dataWriter; v_writerQos dataWriterQos; gapi_context context; GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_SET_QOS); dataWriter = gapi_dataWriterClaim(_this, &result); if ( dataWriter != NULL ) { result = gapi_dataWriterQosIsConsistent(qos, &context); } else { result = GAPI_RETCODE_BAD_PARAMETER; } if (( result == GAPI_RETCODE_OK ) && (_EntityEnabled(dataWriter))) { gapi_dataWriterQos *existing_qos = gapi_dataWriterQos__alloc(); result = gapi_dataWriterQosCheckMutability(qos, _DataWriterGetQos(dataWriter, existing_qos), &context); gapi_free(existing_qos); } if ( result == GAPI_RETCODE_OK ) { dataWriterQos = u_writerQosNew(NULL); if (dataWriterQos) { if ( copyWriterQosIn(qos, dataWriterQos) ) { uResult = u_entitySetQoS(_EntityUEntity(dataWriter), (v_qos)(dataWriterQos) ); result = kernelResultToApiResult(uResult); u_writerQosFree(dataWriterQos); } else { result = GAPI_RETCODE_OUT_OF_RESOURCES; } } else { result = GAPI_RETCODE_OUT_OF_RESOURCES; } } _EntityRelease(dataWriter); return result; }
gapi_dataWriter gapi_publisher_create_datawriter ( gapi_publisher _this, const gapi_topic a_topic, const gapi_dataWriterQos *qos, const struct gapi_dataWriterListener *a_listener, const gapi_statusMask mask) { _Publisher publisher; _DataWriter datawriter = NULL; gapi_dataWriter result = NULL; _Topic topic = NULL; gapi_dataWriterQos *writerQos; gapi_context context; gapi_topicQos* topicQos; gapi_returnCode_t rc; GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_CREATE_DATAWRITER); publisher = gapi_publisherClaim(_this, NULL); if ( publisher ) { topic = _TopicFromHandle(a_topic); } if ( topic ) { if ( qos == GAPI_DATAWRITER_QOS_DEFAULT ) { writerQos = &publisher->_defDataWriterQos; } else if ( qos == GAPI_DATAWRITER_QOS_USE_TOPIC_QOS ) { topicQos = gapi_topicQos__alloc(); writerQos = gapi_dataWriterQos__alloc(); gapi_dataWriterQosCopy(&publisher->_defDataWriterQos, writerQos); _TopicGetQos(topic, topicQos); gapi_mergeTopicQosWithDataWriterQos(topicQos,writerQos); gapi_free(topicQos); } else { writerQos = (gapi_dataWriterQos *)qos; } rc = gapi_dataWriterQosIsConsistent(writerQos, &context); if ( rc == GAPI_RETCODE_OK ) { gapi_char *typeName; gapi_char *topicName; _DomainParticipant participant; _TypeSupport typeSupport = NULL; /* find topic with the participant for consistency */ typeName = _TopicGetTypeName(topic); topicName = _TopicGetName(topic); participant = _EntityParticipant(_Entity(publisher)); /* find type support for the data type to find data writer create function */ typeSupport = _DomainParticipantFindType(participant, typeName); if(typeSupport) { /* if create function is NULL, take default from data writer */ datawriter = _DataWriterNew(topic, typeSupport, writerQos, a_listener, mask, publisher); if ( datawriter ) { _ENTITY_REGISTER_OBJECT(_Entity(publisher), (_Object)datawriter); } }else{ OS_REPORT_1(OS_WARNING, "gapi_publisher_create_datawriter", 0, "TypeSupport %s not found !", typeName); } gapi_free(typeName); gapi_free(topicName); } if (qos == GAPI_DATAWRITER_QOS_USE_TOPIC_QOS) { gapi_free(writerQos); } } _EntityRelease(publisher); if ( datawriter ) { gapi_object statusHandle; statusHandle = _EntityHandle(_Entity(datawriter)->status); result = (gapi_dataWriter)_EntityRelease(datawriter); } return result; }