示例#1
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;
}
示例#2
0
/**************************************************************
 * Protected functions
 **************************************************************/
v_qos
u_qosNew(
    v_qos tmpl)
{
    v_qos q;
    
    q = NULL;
    if (tmpl != NULL) {
        switch (tmpl->kind) {
        case V_PARTITION_QOS:
            q = (v_qos)u_partitionQosNew((v_partitionQos)tmpl);
        break;
        case V_PARTICIPANT_QOS:
            q = (v_qos)u_participantQosNew((v_participantQos)tmpl);
        break;
        case V_TOPIC_QOS:
            q = (v_qos)u_topicQosNew((v_topicQos)tmpl);
        break;
        case V_WRITER_QOS:
            q = (v_qos)u_writerQosNew((v_writerQos)tmpl);
        break;
        case V_READER_QOS:
            q = (v_qos)u_readerQosNew((v_readerQos)tmpl);
        break;
        case V_PUBLISHER_QOS:
            q = (v_qos)u_publisherQosNew((v_publisherQos)tmpl);
        break;
        case V_SUBSCRIBER_QOS:
            q = (v_qos)u_subscriberQosNew((v_subscriberQos)tmpl);
        break;
        case V_DATAVIEW_QOS:
            q = (v_qos)u_dataViewQosNew((v_dataViewQos)tmpl);
        break;
        default:
            OS_REPORT_1(OS_ERROR, "u_qosNew", 0, "unsupported qos %d", tmpl->kind);
        break;
        }
    }

    return q;
}
示例#3
0
_DataWriter
_DataWriterNew (
    const _Topic topic,
    const _TypeSupport typesupport,
    const gapi_dataWriterQos *qos,
    const struct gapi_dataWriterListener *a_listener,
    const gapi_statusMask mask,
    const _Publisher publisher)
{
    _DataWriter newDataWriter;
    v_writerQos writerQos;
    u_writer uWriter;
    _TypeSupport typeSupport = (_TypeSupport)typesupport;
    char dataWriterId[256];
    gapi_string topicName;

    newDataWriter = _DataWriterAlloc();

    if ( newDataWriter != NULL ) {
        _EntityInit(_Entity(newDataWriter),
                    _Entity(publisher));

        newDataWriter->topic = topic;
        if ( a_listener ) {
            newDataWriter->listener = *a_listener;
        }
        writerQos = u_writerQosNew(NULL);
        if ( (writerQos != NULL) ) {
            if ( !copyWriterQosIn(qos, writerQos) ) {
                u_writerQosFree (writerQos);
                _EntityDispose(_Entity(newDataWriter));
                newDataWriter = NULL;
            }
        } else {
            _EntityDispose(_Entity(newDataWriter));
            newDataWriter = NULL;
        }
    }

    if ( newDataWriter != NULL ) {
        u_writerCopy copy_action;

        newDataWriter->copy_in    = _TypeSupportCopyIn(typeSupport);
        newDataWriter->copy_out   = _TypeSupportCopyOut(typeSupport);
        newDataWriter->copy_cache = _TypeSupportCopyCache(typeSupport);

        copy_action = _TypeSupportGetWriterCopy(typeSupport);
        if (!copy_action) {
            copy_action = _DataWriterCopy;
        }

        topicName = _TopicDescriptionGetName (_TopicDescription(topic));
        if (topicName) {
            snprintf (dataWriterId,
                      sizeof (dataWriterId),
                      "%sWriter", topicName);
            gapi_free (topicName);
        } else {
            snprintf (dataWriterId,
                      sizeof (dataWriterId),
                      "dataWriter");
        }
        uWriter = u_writerNew(_PublisherUpublisher(publisher),
                              dataWriterId,
                              _TopicUtopic(topic),
                              copy_action,
                              writerQos,
                              FALSE);
        if ( uWriter != NULL ) {
            U_WRITER_SET(newDataWriter, uWriter);
        } else {
            _EntityDispose(_Entity(newDataWriter));
            newDataWriter = NULL;
        }
        u_writerQosFree(writerQos);
    }

    if ( newDataWriter != NULL ) {
        _Status status;

        status = _StatusNew(_Entity(newDataWriter),
                            STATUS_KIND_DATAWRITER,
                            (struct gapi_listener *)a_listener, mask);
        _EntityStatus(newDataWriter) = status;
        if (status) {
            _TopicDescriptionIncUse(_TopicDescription(topic));
        } else {
            u_writerFree(uWriter);
            _EntityDispose(_Entity(newDataWriter));
            newDataWriter = NULL;
        }
    }

    return newDataWriter;
}