示例#1
0
gapi_returnCode_t
gapi_dataWriter_wait_for_acknowledgments (
	gapi_dataWriter _this,
    const gapi_duration_t *max_wait
    )
{
	_DataWriter datawriter;
	u_result uResult;
	gapi_returnCode_t result;
	c_time timeout;

	datawriter = gapi_dataWriterClaim(_this, NULL);

	if ( datawriter != NULL ) {
		kernelCopyInDuration(max_wait, &timeout);
		uResult = u_writerWaitForAcknowledgments(
					u_writer(_EntityUEntity(datawriter)),
					timeout);
		result = kernelResultToApiResult(uResult);
	} else {
		result = GAPI_RETCODE_BAD_PARAMETER;
	}
	_EntityRelease(datawriter);

	return result;
}
_DataReaderView
_DataReaderViewNew (
    const gapi_dataReaderViewQos * qos,
    const _DataReader datareader)
{
    _DataReaderView _this;
    v_dataViewQos ViewQos;
    u_dataView uReaderView;
    _TypeSupport typeSupport;

    _this = _DataReaderViewAlloc();
        
    if ( _this != NULL ) {
        _EntityInit(_Entity(_this),
                          _Entity(datareader));
         
        typeSupport = _TopicDescriptionGetTypeSupport(datareader->topicDescription);

        assert(typeSupport);
        _this->datareader = datareader;
        ViewQos = u_dataViewQosNew(NULL);
        if ( ViewQos != NULL ) {
            if ( !copyReaderViewQosIn(qos, ViewQos) ) { 
                u_dataViewQosFree(ViewQos);
                _EntityDispose(_Entity(_this));
                _this = NULL;
            }
        } else {
            _EntityDispose(_Entity(_this));
            _this = NULL;
        }
    }

    if ( _this != NULL ) {
        uReaderView = u_dataViewNew(u_dataReader(_EntityUEntity (datareader)),
                                    "dataReaderView",
                                    ViewQos);
        if ( uReaderView ) {
            U_DATAREADERVIEW_SET(_this, uReaderView);
        } else {
            _EntityDispose(_Entity(_this));
            _this = NULL;
        }
        u_dataViewQosFree(ViewQos);
    }

    if ( _this != NULL ) {
        if ( !initViewQuery(_this) ) {
            u_dataViewFree(uReaderView);
            _EntityDispose(_Entity(_this));
            _this = NULL;
        }
    }
    if ( _this != NULL ) {
        _EntityStatus(_this) = _Entity(datareader)->status;
    }       

    return _this;

}
示例#3
0
gapi_returnCode_t
gapi_publisher_set_qos (
    gapi_publisher _this,
    const gapi_publisherQos *qos)
{
    gapi_returnCode_t result = GAPI_RETCODE_OK;
    u_result uResult;
    _Publisher publisher;
    v_publisherQos publisherQos;
    gapi_context context;
    gapi_publisherQos *existing_qos;

    GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_SET_QOS);

    publisher = gapi_publisherClaim(_this, &result);

    if ( publisher && qos ) {
        result = gapi_publisherQosIsConsistent(qos, &context);
    } else {
        result = GAPI_RETCODE_BAD_PARAMETER;
    }

    if ((result == GAPI_RETCODE_OK ) && (_EntityEnabled(publisher))) {
        existing_qos = gapi_publisherQos__alloc();
        uResult = _PublisherGetQos(publisher, existing_qos);
        result = kernelResultToApiResult(uResult);
        if(result == GAPI_RETCODE_OK)
        {
            result = gapi_publisherQosCheckMutability(
                     qos,
                     existing_qos,
                     &context);
        }
        gapi_free(existing_qos);
    }

    if ( result == GAPI_RETCODE_OK ) {
        publisherQos = u_publisherQosNew(NULL);
        if (publisherQos) {
            if ( copyPublisherQosIn(qos, publisherQos) ) {
                uResult = u_entitySetQoS(_EntityUEntity(publisher),
                                         (v_qos)(publisherQos) );
                result = kernelResultToApiResult(uResult);
                u_publisherQosFree(publisherQos);
            } else {
                result = GAPI_RETCODE_OUT_OF_RESOURCES;
            }
        } else {
            result = GAPI_RETCODE_OUT_OF_RESOURCES;
        }
    }

    _EntityRelease(publisher);

    return result;
}
示例#4
0
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;
}
/*     ReturnCode_t
 *     set_qos(
 *         in DataReaderViewQos qos);
 *
 * Function will operate indepenedent of the enable flag
 */
gapi_returnCode_t
gapi_dataReaderView_set_qos (
    gapi_dataReaderView _this,
    const gapi_dataReaderViewQos *qos)
{
    gapi_returnCode_t result = GAPI_RETCODE_OK;
    u_result uResult;
    _DataReaderView dataReaderView;
    v_dataViewQos dataReaderViewQos;
    gapi_context context;

    GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_SET_QOS);
    
    dataReaderView = gapi_dataReaderViewClaim(_this, &result);

    if (dataReaderView != NULL) {
        if ( dataReaderView && qos) {
           result = gapi_dataReaderViewQosIsConsistent(qos, &context);
        } else {
            result = GAPI_RETCODE_BAD_PARAMETER;
        }
        
        if ( result == GAPI_RETCODE_OK ) {
            gapi_dataReaderViewQos * existing_qos = gapi_dataReaderViewQos__alloc();

            result = gapi_dataReaderViewQosCheckMutability(qos, _DataReaderViewGetQos(dataReaderView, existing_qos), &context);
            gapi_free(existing_qos);
        }
    
        if ( result == GAPI_RETCODE_OK ) {
            dataReaderViewQos = u_dataViewQosNew(NULL);
            if (dataReaderViewQos) {
                if ( copyReaderViewQosIn(qos, dataReaderViewQos) ) {
                    uResult = u_entitySetQoS(_EntityUEntity(dataReaderView),(v_qos)(dataReaderViewQos) );
                    result = kernelResultToApiResult(uResult);
                } else {
                    result = GAPI_RETCODE_OUT_OF_RESOURCES;
                }
                u_dataViewQosFree(dataReaderViewQos);
            } else {
                result = GAPI_RETCODE_OUT_OF_RESOURCES;
            }
        }

        _EntityRelease(dataReaderView);
    }

    return result;
}