gapi_returnCode_t gapi_subscriber_set_default_datareader_qos ( gapi_subscriber _this, const gapi_dataReaderQos *qos) { gapi_returnCode_t result = GAPI_RETCODE_OK; _Subscriber subscriber = (_Subscriber)_this; gapi_context context; GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_SET_DEFAULT_DATAREADER_QOS); subscriber = gapi_subscriberClaim(_this, &result); if (result == GAPI_RETCODE_OK) { if (qos == GAPI_SUBSCRIBER_QOS_DEFAULT) { qos = &gapi_dataReaderQosDefault; } result = gapi_dataReaderQosIsConsistent(qos, &context); if (result == GAPI_RETCODE_OK) { gapi_dataReaderQosCopy (qos, &subscriber->_defDataReaderQos); } _EntityRelease(subscriber); } return result; }
gapi_returnCode_t gapi_dataReader_set_qos ( gapi_dataReader _this, const gapi_dataReaderQos *qos) { gapi_returnCode_t result = GAPI_RETCODE_OK; u_result uResult; _DataReader dataReader; v_readerQos dataReaderQos; gapi_context context; GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_SET_QOS); dataReader = gapi_dataReaderClaim(_this, &result); if ( dataReader ) { if ( qos ) { result = gapi_dataReaderQosIsConsistent(qos, &context); } else { result = GAPI_RETCODE_BAD_PARAMETER; } } if (( result == GAPI_RETCODE_OK ) && (_EntityEnabled(dataReader))){ gapi_dataReaderQos * existing_qos = gapi_dataReaderQos__alloc(); result = gapi_dataReaderQosCheckMutability(qos, _DataReaderGetQos(dataReader, existing_qos), &context); gapi_free(existing_qos); } if ( result == GAPI_RETCODE_OK ) { dataReaderQos = u_readerQosNew(NULL); if (dataReaderQos) { if ( gapi_kernelReaderQosCopyIn(qos, dataReaderQos) ) { uResult = u_entitySetQoS(_EntityUEntity(dataReader), (v_qos)(dataReaderQos) ); result = kernelResultToApiResult(uResult); u_readerQosFree(dataReaderQos); } else { result = GAPI_RETCODE_OUT_OF_RESOURCES; } } else { result = GAPI_RETCODE_OUT_OF_RESOURCES; } } _EntityRelease(dataReader); return result; }
gapi_dataReader gapi_subscriber_create_datareader ( gapi_subscriber _this, const gapi_topicDescription a_topic, const gapi_dataReaderQos *qos, const struct gapi_dataReaderListener *a_listener, const gapi_statusMask mask) { _Subscriber subscriber; _DataReader datareader = NULL; gapi_dataReader result = NULL; _TopicDescription topicDescription = NULL; gapi_dataReaderQos *readerQos; gapi_context context; gapi_topicQos* topicQos; GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_CREATE_DATAREADER); subscriber = gapi_subscriberClaim(_this, NULL); if ( subscriber ) { if ( !subscriber->builtin ) { topicDescription = _TopicDescriptionFromHandle(a_topic); } } if ( topicDescription ) { if ( qos == GAPI_DATAREADER_QOS_DEFAULT ) { readerQos = &subscriber->_defDataReaderQos; } else if ( qos == GAPI_DATAREADER_QOS_USE_TOPIC_QOS ) { _Topic topic = NULL; switch(_ObjectGetKind(_Object(topicDescription))) { case OBJECT_KIND_TOPIC: topic = _Topic(topicDescription); break; case OBJECT_KIND_CONTENTFILTEREDTOPIC: topic = _ContentFilteredTopicGetRelatedTopic(_ContentFilteredTopic(topicDescription)); break; default: topic = NULL; break; } if ( topic ) { topicQos = gapi_topicQos__alloc(); readerQos = gapi_dataReaderQos__alloc(); gapi_dataReaderQosCopy(&subscriber->_defDataReaderQos, readerQos); _TopicGetQos(topic, topicQos); gapi_mergeTopicQosWithDataReaderQos(topicQos,readerQos); gapi_free(topicQos); } else { readerQos = (gapi_dataReaderQos *)qos; } } else { readerQos = (gapi_dataReaderQos *)qos; } if ( gapi_dataReaderQosIsConsistent(readerQos, &context) == GAPI_RETCODE_OK ) { gapi_char *typeName; gapi_char *topicName; _DomainParticipant participant; _TypeSupport typeSupport; /* find topic with the participant for consistency */ typeName = _TopicDescriptionGetTypeName(topicDescription); topicName = _TopicDescriptionGetName(topicDescription); participant = _EntityParticipant(_Entity(subscriber)); /* find type support for the data type to find * data reader create function. */ typeSupport = _DomainParticipantFindType(participant, typeName); if(typeSupport) { /* if create function is NULL, take default from data reader */ datareader = _DataReaderNew(topicDescription, typeSupport, readerQos, a_listener, mask, subscriber); if ( datareader ) { _ENTITY_REGISTER_OBJECT(_Entity(subscriber), (_Object)datareader); } }else{ OS_REPORT_1(OS_WARNING, "gapi_subscriber_create_datareader", 0, "TypeSupport %s not found !", typeName); } gapi_free(typeName); gapi_free(topicName); } if (qos == GAPI_DATAREADER_QOS_USE_TOPIC_QOS) { gapi_free(readerQos); } } _EntityRelease(subscriber); if ( datareader ) { gapi_object statusHandle; statusHandle = _EntityHandle(_Entity(datareader)->status); result = (gapi_dataReader)_EntityRelease(datareader); } return result; }