Пример #1
0
/**
 * Class:     org_opensplice_dds_dcps_PublisherImpl
 * Method:    jniGetDefaultDatawriterQos
 * Signature: (LDDS/DataWriterQosHolder;)V
 */
JNIEXPORT jint JNICALL
SAJ_FUNCTION(jniGetDefaultDatawriterQos)(
    JNIEnv *env,
    jobject jpublisher,
    jobject jqosHolder)
{
    saj_returnCode rc;
    gapi_returnCode_t result;
    jobject jqos;
    gapi_publisher publisher;
    gapi_dataWriterQos *qos;
    
    jqos = NULL;
    
    if(jqosHolder != NULL){
        qos = gapi_dataWriterQos__alloc();
        publisher = (gapi_publisher)saj_read_gapi_address(env, jpublisher);
        result = gapi_publisher_get_default_datawriter_qos(publisher, qos); 
        
        if(result == GAPI_RETCODE_OK){
            rc = saj_DataWriterQosCopyOut(env, qos, &jqos);
            gapi_free(qos);
        
            if (rc == SAJ_RETCODE_OK){
                (*env)->SetObjectField(env, jqosHolder, 
                                       GET_CACHED(dataWriterQosHolder_value_fid), jqos);
            } else {
                result = GAPI_RETCODE_ERROR;
            }
        }
    } else {
        result = GAPI_RETCODE_BAD_PARAMETER;
    }
    return (jint)result;
}
Пример #2
0
DDS_DataWriterQos *
DDS_DataWriterQos__alloc (
    void
)
{
    return (DDS_DataWriterQos *)
           gapi_dataWriterQos__alloc ();

}
Пример #3
0
/*     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;
}
Пример #4
0
/**
 * Class:     org_opensplice_dds_dcps_PublisherImpl
 * Method:    jniSetDefaultDatawriterQos
 * Signature: (LDDS/DataWriterQos;)I
 */
JNIEXPORT jint JNICALL
SAJ_FUNCTION(jniSetDefaultDatawriterQos)(
    JNIEnv *env,
    jobject jpublisher,
    jobject jqos)
{
    gapi_dataWriterQos* qos;
    gapi_publisher publisher;
    saj_returnCode rc;
    jint result;
    
    result = (jint)GAPI_RETCODE_ERROR;
    qos = gapi_dataWriterQos__alloc();
    rc = saj_DataWriterQosCopyIn(env, jqos, qos);
    
    if (rc == SAJ_RETCODE_OK){
        publisher = (gapi_publisher)saj_read_gapi_address(env, jpublisher);
        result = (jint)gapi_publisher_set_default_datawriter_qos(publisher, qos);
    }
    gapi_free(qos);
    
    return result;
}
Пример #5
0
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;
}
Пример #6
0
/**
 * Class:     org_opensplice_dds_dcps_PublisherImpl
 * Method:    jniCopyFromTopicQos
 * Signature: (LDDS/DataWriterQosHolder;LDDS/TopicQos;)I
 */
JNIEXPORT jint JNICALL
SAJ_FUNCTION(jniCopyFromTopicQos)(
    JNIEnv *env,
    jobject jpublisher,
    jobject jqosHolder,
    jobject jtopicQos)
{
    saj_returnCode rc;
    gapi_returnCode_t grc;
    jobject jqos, oldQos;
    gapi_publisher publisher;
    gapi_dataWriterQos *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(dataWriterQosHolder_value_fid));
            qos = gapi_dataWriterQos__alloc();
            
            if(oldQos){
                rc = saj_DataWriterQosCopyIn(env, oldQos, qos);
                
                if(rc != SAJ_RETCODE_OK) {
                    gapi_free(qos);
                    qos = NULL;
                }
            }
        } else {
            qos = NULL;
        }
        publisher = (gapi_publisher)saj_read_gapi_address(env, jpublisher);
        grc = gapi_publisher_copy_from_topic_qos(publisher, qos, topicQos);
        result = (jint)grc;
        
        if(grc == GAPI_RETCODE_OK){
            if(oldQos){
                jqos = oldQos;
            } else {
                jqos = NULL;
            }
            rc = saj_DataWriterQosCopyOut(env, qos, &jqos);
            
            if(rc == SAJ_RETCODE_OK){
                (*env)->SetObjectField(env, jqosHolder, 
                                  GET_CACHED(dataWriterQosHolder_value_fid), jqos);
            }
        }
        if(qos) {
            gapi_free(qos);
        }
        gapi_free(topicQos);
    } else {
        result = (jint)GAPI_RETCODE_BAD_PARAMETER;
    }
    return result;
}
Пример #7
0
/**
 * Class:     org_opensplice_dds_dcps_PublisherImpl
 * Method:    jniCreateDatawriter
 * Signature: (LDDS/Topic;LDDS/DataWriterQos;LDDS/DataWriterListener;)LDDS/DataWriter;
 */
JNIEXPORT jobject JNICALL
SAJ_FUNCTION(jniCreateDatawriter)(
    JNIEnv *env, 
    jobject jpublisher,
    jobject jtopic,
    jobject jqos,
    jobject jlistener,
    jint jmask)
{
    jobject jwriter;
    gapi_publisher publisher;
    gapi_dataWriter writer;
    gapi_dataWriterQos* writerQos;
    gapi_topic topic;
    gapi_domainParticipant participant;
    gapi_typeSupport typeSupport;
    const struct gapi_dataWriterListener *listener;
    gapi_char* dataWriterClassName;
    saj_returnCode rc;
    gapi_string typeName;
    gapi_char* signature;
    jobject jtypeSupport;
    
    jwriter = NULL;
    listener = NULL;
    writer = GAPI_OBJECT_NIL;
    
    publisher = (gapi_publisher) saj_read_gapi_address(env, jpublisher);
    participant = gapi_publisher_get_participant(publisher);
    topic = (gapi_topic) saj_read_gapi_address(env, jtopic);
    
    typeName = gapi_topicDescription_get_type_name((gapi_topicDescription)topic);
    typeSupport = gapi_domainParticipant_get_typesupport(participant, (const gapi_char*) typeName);
    gapi_free(typeName);
                                                
    jtypeSupport = saj_read_java_address((gapi_object)typeSupport);
    rc = saj_LookupTypeSupportDataWriter(env, jtypeSupport, &dataWriterClassName);
    
    if(rc == SAJ_RETCODE_OK){
        if ((*env)->IsSameObject (env, jqos, GET_CACHED(DATAWRITER_QOS_DEFAULT)) == JNI_TRUE) {
            writerQos = (gapi_dataWriterQos *)GAPI_DATAWRITER_QOS_DEFAULT;
            rc = SAJ_RETCODE_OK;
        } else if ((*env)->IsSameObject (env, jqos, GET_CACHED(DATAWRITER_QOS_USE_TOPIC_QOS)) == JNI_TRUE) {
            writerQos = (gapi_dataWriterQos *)GAPI_DATAWRITER_QOS_USE_TOPIC_QOS;
            rc = SAJ_RETCODE_OK;
        } else {
            writerQos = gapi_dataWriterQos__alloc();
            rc = saj_DataWriterQosCopyIn(env, jqos, writerQos);
	}
        
        if(rc == SAJ_RETCODE_OK){
            listener = saj_dataWriterListenerNew(env, jlistener);
            writer = gapi_publisher_create_datawriter(publisher, topic, writerQos, 
                                                                        listener, (gapi_statusMask)jmask);
                    
            if (writer != GAPI_OBJECT_NIL){
                rc = saj_LookupTypeSupportConstructorSignature(env, jtypeSupport, &signature);
                
                if(rc == SAJ_RETCODE_OK){
                    gapi_publisherQos *pqos = gapi_publisherQos__alloc();
                    rc = saj_construct_typed_java_object(env, 
                                                        dataWriterClassName, 
                                                        (PA_ADDRCAST)writer, 
                                                        &jwriter, signature,
                                                        jtypeSupport);

                    gapi_free(signature);
                    
                    if(listener != NULL){
                        saj_write_java_listener_address(env, writer, listener->listener_data);
                    }

                    if(pqos){
                        if(gapi_publisher_get_qos(publisher, pqos) == GAPI_RETCODE_OK){
                            if(pqos->entity_factory.autoenable_created_entities) {
                                gapi_entity_enable(writer);
                            }
                        }
                        gapi_free(pqos);
                    }

                }
            } else if(listener != NULL){
                saj_listenerDataFree(env, saj_listenerData(listener->listener_data));
            }
        }
        if ((writerQos != (gapi_dataWriterQos *)GAPI_DATAWRITER_QOS_DEFAULT) &&
	    (writerQos != (gapi_dataWriterQos *)GAPI_DATAWRITER_QOS_USE_TOPIC_QOS)) {
	    gapi_free(writerQos);
	}
        gapi_free(dataWriterClassName);
    } 
    return jwriter;
}