DDS_DataReaderQos * DDS_DataReaderQos__alloc ( void ) { return (DDS_DataReaderQos *) gapi_dataReaderQos__alloc (); }
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; }
/** * Class: org_opensplice_dds_dcps_SubscriberImpl * Method: jniSetDefaultDatareaderQos * Signature: (LDDS/DataReaderQos;)I */ JNIEXPORT jint JNICALL SAJ_FUNCTION(jniSetDefaultDatareaderQos)( JNIEnv *env, jobject jsubscriber, jobject jqos) { gapi_dataReaderQos* qos; gapi_subscriber subscriber; saj_returnCode rc; jint result; result = (jint)GAPI_RETCODE_ERROR; qos = gapi_dataReaderQos__alloc(); rc = saj_DataReaderQosCopyIn(env, jqos, qos); if (rc == SAJ_RETCODE_OK){ subscriber = (gapi_subscriber)saj_read_gapi_address(env, jsubscriber); result = (jint)gapi_subscriber_set_default_datareader_qos(subscriber, qos); } gapi_free(qos); return result; }
/** * Class: org_opensplice_dds_dcps_SubscriberImpl * Method: jniGetDefaultDatareaderQos * Signature: (LDDS/DataReaderQosHolder;)V */ JNIEXPORT jint JNICALL SAJ_FUNCTION(jniGetDefaultDatareaderQos)( JNIEnv *env, jobject jsubscriber, jobject jqosHolder) { saj_returnCode rc; jobject jqos; gapi_subscriber subscriber; gapi_returnCode_t result; gapi_dataReaderQos *qos; jqos = NULL; rc = SAJ_RETCODE_ERROR; if(jqosHolder != NULL){ qos = gapi_dataReaderQos__alloc(); subscriber = (gapi_subscriber)saj_read_gapi_address(env, jsubscriber); result = gapi_subscriber_get_default_datareader_qos(subscriber, qos); if(result == GAPI_RETCODE_OK){ rc = saj_DataReaderQosCopyOut(env, qos, &jqos); gapi_free(qos); if (rc == SAJ_RETCODE_OK){ (*env)->SetObjectField(env, jqosHolder, GET_CACHED(dataReaderQosHolder_value_fid), jqos); } else { result = GAPI_RETCODE_ERROR; } } } else { result = GAPI_RETCODE_BAD_PARAMETER; } return (jint)result; }
/** * Class: org_opensplice_dds_dcps_SubscriberImpl * Method: jniCopyFromTopicQos * Signature: (LDDS/DataReaderQosHolder;LDDS/TopicQos;)I */ JNIEXPORT jint JNICALL SAJ_FUNCTION(jniCopyFromTopicQos)( JNIEnv *env, jobject jsubscriber, jobject jqosHolder, jobject jtopicQos) { saj_returnCode rc; gapi_returnCode_t grc; jobject jqos, oldQos; gapi_subscriber subscriber; gapi_dataReaderQos *qos; gapi_topicQos *topicQos; jint result; oldQos = NULL; if(jqosHolder != NULL){ result = (jint)GAPI_RETCODE_ERROR; rc = SAJ_RETCODE_ERROR; if ((*env)->IsSameObject (env, jtopicQos, GET_CACHED(TOPIC_QOS_DEFAULT)) == JNI_TRUE) { topicQos = (gapi_topicQos *)GAPI_TOPIC_QOS_DEFAULT; rc = SAJ_RETCODE_OK; } else { topicQos = gapi_topicQos__alloc (); rc = saj_TopicQosCopyIn(env, jtopicQos, topicQos); } if(rc == SAJ_RETCODE_OK){ oldQos = (*env)->GetObjectField(env, jqosHolder, GET_CACHED(dataReaderQosHolder_value_fid)); qos = gapi_dataReaderQos__alloc(); if(oldQos){ rc = saj_DataReaderQosCopyIn(env, oldQos, qos); if(rc != SAJ_RETCODE_OK) { gapi_free(qos); qos = NULL; } } } else { qos = NULL; } subscriber = (gapi_subscriber)saj_read_gapi_address(env, jsubscriber); grc = gapi_subscriber_copy_from_topic_qos(subscriber, qos, topicQos); result = (jint)grc; if(grc == GAPI_RETCODE_OK){ if(oldQos){ jqos = oldQos; } else { jqos = NULL; } rc = saj_DataReaderQosCopyOut(env, qos, &jqos); if(rc == SAJ_RETCODE_OK){ (*env)->SetObjectField(env, jqosHolder, GET_CACHED(dataReaderQosHolder_value_fid), jqos); } } if(qos) { gapi_free(qos); } gapi_free(topicQos); } else { result = (jint)GAPI_RETCODE_BAD_PARAMETER; } return result; }
/** * Class: org_opensplice_dds_dcps_SubscriberImpl * Method: jniCreateDatareader * Signature: (LDDS/TopicDescription;LDDS/DataReaderQos;LDDS/DataReaderListener;)LDDS/DataReader; */ JNIEXPORT jobject JNICALL SAJ_FUNCTION(jniCreateDatareader)( JNIEnv *env, jobject jsubscriber, jobject jdescription, jobject jqos, jobject jlistener, jint jmask) { jobject jreader; jobject jtypeSupport; gapi_subscriber subscriber; gapi_dataReader reader; gapi_dataReaderQos* readerQos; gapi_domainParticipant participant; gapi_typeSupport typeSupport; gapi_string typeName; gapi_topicDescription description; struct gapi_dataReaderListener *listener; gapi_char* dataReaderClassName; gapi_char* signature; saj_returnCode rc; listener = NULL; jreader = NULL; reader = GAPI_OBJECT_NIL; subscriber = (gapi_subscriber) saj_read_gapi_address(env, jsubscriber); participant = gapi_subscriber_get_participant(subscriber); description = (gapi_topicDescription) saj_read_gapi_address(env, jdescription); typeName = gapi_topicDescription_get_type_name(description); typeSupport = gapi_domainParticipant_get_typesupport(participant, (const gapi_char*) typeName); gapi_free(typeName); jtypeSupport = saj_read_java_address((gapi_object)typeSupport); rc = saj_LookupTypeSupportDataReader(env, jtypeSupport, &dataReaderClassName); if(rc == SAJ_RETCODE_OK){ if ((*env)->IsSameObject (env, jqos, GET_CACHED(DATAREADER_QOS_DEFAULT)) == JNI_TRUE) { readerQos = (gapi_dataReaderQos *)GAPI_DATAREADER_QOS_DEFAULT; rc = SAJ_RETCODE_OK; } else if ((*env)->IsSameObject (env, jqos, GET_CACHED(DATAREADER_QOS_USE_TOPIC_QOS)) == JNI_TRUE) { readerQos = (gapi_dataReaderQos *)GAPI_DATAREADER_QOS_USE_TOPIC_QOS; rc = SAJ_RETCODE_OK; } else { readerQos = gapi_dataReaderQos__alloc(); rc = saj_DataReaderQosCopyIn(env, jqos, readerQos); } if(rc == SAJ_RETCODE_OK){ listener = saj_dataReaderListenerNew(env, jlistener); reader = gapi_subscriber_create_datareader(subscriber, description, readerQos, listener, (gapi_statusMask)jmask); if (reader != GAPI_OBJECT_NIL){ rc = saj_LookupTypeSupportConstructorSignature(env, jtypeSupport, &signature); if(rc == SAJ_RETCODE_OK){ gapi_subscriberQos *sqos = gapi_subscriberQos__alloc(); rc = saj_construct_typed_java_object(env, dataReaderClassName, (PA_ADDRCAST)reader, &jreader, signature, jtypeSupport); gapi_free(signature); if(listener != NULL){ saj_write_java_listener_address(env, reader, listener->listener_data); } if(sqos){ if(gapi_subscriber_get_qos(subscriber, sqos) == GAPI_RETCODE_OK){ if(sqos->entity_factory.autoenable_created_entities) { gapi_entity_enable(reader); } } gapi_free(sqos); } } } else if(listener != NULL){ saj_listenerDataFree(env, saj_listenerData(listener->listener_data)); } } if ((readerQos != (gapi_dataReaderQos *)GAPI_DATAREADER_QOS_DEFAULT) && (readerQos != (gapi_dataReaderQos *)GAPI_DATAREADER_QOS_USE_TOPIC_QOS)) { gapi_free(readerQos); } gapi_free(dataReaderClassName); } return jreader; }
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; }