Example #1
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;
}
Example #2
0
gapi_returnCode_t
gapi_fooDataWriter_writedispose_w_timestamp (
    gapi_fooDataWriter _this,
    const gapi_foo *instance_data,
    const gapi_instanceHandle_t handle,
    const gapi_time_t *source_timestamp)
{
    gapi_returnCode_t result = GAPI_RETCODE_BAD_PARAMETER;
    _DataWriter datawriter;
    writerInfo data;
    c_time timestamp;
    u_result r;

    if ( instance_data != NULL ) {
        result = kernelCopyInTime(source_timestamp, &timestamp);
        if ( result == GAPI_RETCODE_OK ) {
            datawriter = gapi_dataWriterReadClaim(_this, &result);
            if ( datawriter != NULL ) {
                data.writer = datawriter;
                data.data = (void *)instance_data;

                r = u_writerWriteDispose (U_WRITER_GET(datawriter),
                                          &data,
                                          timestamp,
                                          handle);
                _EntityReadRelease(datawriter);
                result = kernelResultToApiResult(r);
            }
        }
    }

    return result;
}
Example #3
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;
}
Example #4
0
gapi_returnCode_t
_DataReaderGetKeyValue (
    _DataReader _this,
    void        *instance,
    const gapi_instanceHandle_t handle)
{
    gapi_returnCode_t result;
    u_dataReader reader;
    u_result uResult;

    PREPEND_COPYOUTCACHE(_this->copy_cache, instance, NULL);

    reader = U_DATAREADER_GET(_this);
    uResult = u_dataReaderCopyKeysFromInstanceHandle(reader,
                    (u_instanceHandle)handle,
                    (u_readerAction)_this->copy_out,
                    instance);
    result = kernelResultToApiResult(uResult);

    /* The OpenSplice user-layer may have detected that the instance has been deleted (expired),
     * but the DDS Spec. requires a PRECONDITION_NOT_MET result code if the instance handle is not registered
     */
    if (result == GAPI_RETCODE_ALREADY_DELETED) {
        result = GAPI_RETCODE_PRECONDITION_NOT_MET;
    }

    REMOVE_COPYOUTCACHE(_this->copy_cache, instance);

    return result;
}
Example #5
0
gapi_returnCode_t
_DataWriterUnregisterInstance (
    _DataWriter _this,
    const void *instanceData,
    const gapi_instanceHandle_t handle,
    c_time timestamp)
{
    gapi_returnCode_t result = GAPI_RETCODE_OK;
    u_writer w;
    u_result uResult;
    writerInfo wData;
    writerInfo *pData = NULL;

    w = U_WRITER_GET(_this);
    if ( instanceData ) {
        wData.writer = _this;
        wData.data = (void *)instanceData;
        pData = &wData;
    }
    uResult = u_writerUnregisterInstance(w,
                                         pData,
                                         timestamp,
                                         (u_instanceHandle)handle);
    result = kernelResultToApiResult(uResult);
    return result;
}
Example #6
0
gapi_returnCode_t
gapi_dataReader_wait_for_historical_data (
    gapi_dataReader _this,
    const gapi_duration_t *max_wait)
{
    gapi_returnCode_t result = GAPI_RETCODE_OK;
    _DataReader datareader;
    c_time  c_time_max_wait;
    u_result  uResult;

    datareader = gapi_dataReaderClaim(_this, &result);

    if (datareader) {
        if ( !max_wait || !gapi_validDuration(max_wait)) {
            result = GAPI_RETCODE_BAD_PARAMETER;
        } else if (!_EntityEnabled(datareader)) {
            result = GAPI_RETCODE_NOT_ENABLED;
        } else {
            kernelCopyInDuration(max_wait, &c_time_max_wait);

            uResult = u_dataReaderWaitForHistoricalData(
                          U_DATAREADER_GET(datareader),
                          c_time_max_wait);
            result = kernelResultToApiResult(uResult);
        }
        _EntityRelease(datareader);
    }
    return result;
}
Example #7
0
gapi_returnCode_t
gapi_fooDataWriter_writedispose (
    gapi_fooDataWriter _this,
    const gapi_foo *instance_data,
    const gapi_instanceHandle_t handle)
{
    gapi_returnCode_t result = GAPI_RETCODE_BAD_PARAMETER;
    _DataWriter datawriter;
    writerInfo data;
    u_result r;

    if ( instance_data != NULL ) {
        datawriter = gapi_dataWriterReadClaim(_this, &result);
        if ( datawriter != NULL ) {
            data.writer = datawriter;
            data.data = (void *)instance_data;

            r = u_writerWriteDispose(U_WRITER_GET(datawriter),
                                     &data,
                                     C_TIME_INVALID,
                                     handle);
            _EntityReadRelease(datawriter);
            result = kernelResultToApiResult(r);
        }
    }


    return result;
}
Example #8
0
static gapi_returnCode_t
_DataReader_set_notread_threshold (
    _DataReader _this,
    gapi_long threshold)
{
    u_result uResult;
    uResult = u_dataReaderSetNotReadThreshold(
                  U_READER_GET(_this),
                  threshold);
    return kernelResultToApiResult(uResult);
}
Example #9
0
static gapi_returnCode_t
_DataWriter_get_matched_subscriptions (
    _DataWriter _this,
    gapi_instanceHandleSeq *subscription_handles)
{
    u_result uResult;
    uResult = u_writerGetMatchedSubscriptions(
                  U_WRITER_GET(_this),
                  copy_matched_subscription,
                  subscription_handles);
    return kernelResultToApiResult(uResult);
}
Example #10
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;
}
Example #11
0
static gapi_returnCode_t
_DataReader_get_matched_publications (
    _DataReader _this,
    gapi_instanceHandleSeq *publication_handles)
{
    u_result uResult;
    uResult = u_readerGetMatchedPublications(
                  U_READER_GET(_this),
                  copy_matched_publication,
                  publication_handles);
    return kernelResultToApiResult(uResult);
}
Example #12
0
static gapi_returnCode_t
_DataReader_get_requested_deadline_missed_status (
    _DataReader _this,
    gapi_requestedDeadlineMissedStatus *status)
{
    u_result uResult;
    uResult = u_readerGetDeadlineMissedStatus(
                  u_reader(U_DATAREADER_GET(_this)),
                  TRUE,
                  copy_deadline_missed_status,
                  status);
    return kernelResultToApiResult(uResult);
}
Example #13
0
static gapi_returnCode_t
_DataReader_get_sample_rejected_status (
    _DataReader _this,
    gapi_sampleRejectedStatus *status)
{
    u_result uResult;
    uResult = u_readerGetSampleRejectedStatus(
                  u_reader(U_DATAREADER_GET(_this)),
                  TRUE,
                  copy_sample_rejected_status,
                  status);
    return kernelResultToApiResult(uResult);
}
Example #14
0
static gapi_returnCode_t
_DataReader_get_subscription_matched_status (
    _DataReader _this,
    gapi_subscriptionMatchedStatus *status)
{
    u_result uResult;
    uResult = u_readerGetSubscriptionMatchStatus(
                  u_reader(U_DATAREADER_GET(_this)),
                  TRUE,
                  copy_subscription_matched_status,
                  status);
    return kernelResultToApiResult(uResult);
}
Example #15
0
static gapi_returnCode_t
_DataReader_get_requested_incompatible_qos_status (
    _DataReader _this,
    gapi_requestedIncompatibleQosStatus *status)
{
    u_result uResult;
    uResult = u_readerGetIncompatibleQosStatus(
                  u_reader(U_DATAREADER_GET(_this)),
                  TRUE,
                  copy_incompatible_qos_status,
                  status);
    return kernelResultToApiResult(uResult);
}
Example #16
0
static gapi_returnCode_t
_DataReader_get_liveliness_changed_status (
    _DataReader _this,
    gapi_livelinessChangedStatus *status)
{
    u_result uResult;
    uResult = u_readerGetLivelinessChangedStatus(
                  u_reader(U_DATAREADER_GET(_this)),
                  TRUE,
                  copy_liveliness_changed_status,
                  status);
    return kernelResultToApiResult(uResult);
}
Example #17
0
static gapi_returnCode_t
_DataWriter_get_offered_incompatible_qos_status (
    _DataWriter _this,
    gapi_offeredIncompatibleQosStatus *status)
{
    u_result uResult;
    uResult = u_writerGetIncompatibleQosStatus(
                  U_WRITER_GET(_this),
                  TRUE,
                  copy_IncompatibleQosStatus,
                  status);
    return kernelResultToApiResult(uResult);
}
Example #18
0
static gapi_returnCode_t
_DataWriter_get_publication_matched_status (
    _DataWriter _this,
    gapi_publicationMatchedStatus *status)
{
    u_result uResult;
    uResult = u_writerGetPublicationMatchStatus(
                  U_WRITER_GET(_this),
                  TRUE,
                  copy_publication_matched_status,
                  status);
    return kernelResultToApiResult(uResult);
}
Example #19
0
static gapi_returnCode_t
_DataWriter_get_liveliness_lost_status (
    _DataWriter _this,
    gapi_livelinessLostStatus *status)
{
    u_result uResult;
    uResult = u_writerGetLivelinessLostStatus(
                  U_WRITER_GET(_this),
                  TRUE,
                  copy_liveliness_lost_status,
                  status);

    return kernelResultToApiResult(uResult);
}
Example #20
0
static gapi_returnCode_t
_DataReader_get_matched_publication_data (
    _DataReader _this,
    gapi_publicationBuiltinTopicData *publication_data,
    const gapi_instanceHandle_t publication_handle)
{
    u_result uResult;
    uResult = u_readerGetMatchedPublicationData(
                  U_READER_GET(_this),
                  publication_handle,
                  gapi_publicationBuiltinTopicData__copyOut,
                  publication_data);
    return kernelResultToApiResult(uResult);
}
Example #21
0
static gapi_returnCode_t
_DataWriter_get_offered_deadline_missed_status (
    _DataWriter _this,
    gapi_offeredDeadlineMissedStatus *status)
{
    u_result uResult;
    uResult = u_writerGetDeadlineMissedStatus(
                  U_WRITER_GET(_this),
                  TRUE,
                  copy_deadline_missed_status,
                  status);

    return kernelResultToApiResult(uResult);
}
Example #22
0
static gapi_returnCode_t
_DataWriter_get_matched_subscription_data (
	    _DataWriter _this,
	    gapi_subscriptionBuiltinTopicData *subscription_data,
	    const gapi_instanceHandle_t subscription_handle)
{
    u_result uResult;
    uResult = u_writerGetMatchedSubscriptionData(
                  U_WRITER_GET(_this),
                  subscription_handle,
                  gapi_subscriptionBuiltinTopicData__copyOut,
                  subscription_data);
    return kernelResultToApiResult(uResult);
}
/*     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;
}
Example #24
0
gapi_returnCode_t
gapi_publisher_get_qos (
    gapi_publisher _this,
    gapi_publisherQos *qos)
{
    _Publisher publisher;
    gapi_returnCode_t result;
    u_result uResult;

    publisher = gapi_publisherClaim(_this, &result);
    if ( publisher && qos ) {
        uResult = _PublisherGetQos(publisher, qos);
        result = kernelResultToApiResult(uResult);
    }

    _EntityRelease(publisher);
    return result ;
}
Example #25
0
gapi_returnCode_t
gapi_publisher_end_coherent_changes (
    gapi_publisher _this)
{
    _Publisher publisher;
    gapi_returnCode_t result = GAPI_RETCODE_BAD_PARAMETER;
    u_result uResult;

    publisher  = gapi_publisherClaim(_this, &result);

    if ( publisher != NULL ) {
        if ( _EntityEnabled(publisher)) {
            uResult = u_publisherCoherentEnd(U_PUBLISHER_GET(publisher));
            result = kernelResultToApiResult(uResult);
        } else {
            result = GAPI_RETCODE_NOT_ENABLED;
        }
    }
    _EntityRelease(publisher);

    return result;
}
Example #26
0
gapi_returnCode_t
_DataWriterGetKeyValue (
    _DataWriter  _this,
    void        *instance,
    const gapi_instanceHandle_t handle)
{
    gapi_returnCode_t result;
    u_writer w;
    u_result          uResult;

    PREPEND_COPYOUTCACHE(_this->copy_cache,instance, NULL);

    w = U_WRITER_GET(_this);
    uResult = u_writerCopyKeysFromInstanceHandle(w,
                                       (u_instanceHandle)handle,
                                       (u_writerAction)_this->copy_out,
                                       instance);
    result = kernelResultToApiResult(uResult);

    REMOVE_COPYOUTCACHE(_this->copy_cache,instance);

    return result;
}
Example #27
0
/*     ReturnCode_t
 *     assert_liveliness();
 */
gapi_returnCode_t
gapi_dataWriter_assert_liveliness (
    gapi_dataWriter _this)
{
    gapi_returnCode_t result;
    u_result uResult;
    _DataWriter datawriter;

    datawriter = gapi_dataWriterClaim(_this, &result);

    if (datawriter != NULL) {
        if (_EntityEnabled(datawriter)) {
            uResult = u_writerAssertLiveliness(U_WRITER_GET(datawriter));
            result = kernelResultToApiResult(uResult);
        } else {
            result=GAPI_RETCODE_NOT_ENABLED;
        }
    }

    _EntityRelease(datawriter);

    return result;
}
Example #28
0
gapi_returnCode_t
gapi_dataReader_wait_for_historical_data_w_condition (
    gapi_dataReader _this,
    const gapi_char *filter_expression,
    const gapi_stringSeq *filter_parameters,
    const gapi_time_t *min_source_timestamp,
    const gapi_time_t *max_source_timestamp,
    const gapi_resourceLimitsQosPolicy *resource_limits,
    const gapi_duration_t *max_wait)
{
    gapi_returnCode_t result;
    _DataReader datareader;
    c_time  c_time_max_wait,
            c_time_min_source_timestamp,
            c_time_max_source_timestamp;
    u_result  uResult;
    c_ulong length, i;
    c_char** params;
    struct v_resourcePolicy resource;

    datareader = gapi_dataReaderClaim(_this, &result);

    if (datareader) {
        if ( !max_wait || !gapi_validDuration(max_wait)) {
            result = GAPI_RETCODE_BAD_PARAMETER;
        } else if (!_EntityEnabled(datareader)) {
            result = GAPI_RETCODE_NOT_ENABLED;
        } else if(filter_parameters && !gapi_stringSeqValid(filter_parameters)){
            result = GAPI_RETCODE_BAD_PARAMETER;
        } else {
            if(filter_parameters){
                length = filter_parameters->_length;
                params = (c_char**)(os_malloc(length*sizeof(c_char*)));

                for(i=0; i<length; i++){
                    params[i] = filter_parameters->_buffer[i];
                }
            } else {
                params = NULL;
                length = 0;
            }
            kernelCopyInDuration(max_wait, &c_time_max_wait);
            if ( (kernelCopyInTime(min_source_timestamp, &c_time_min_source_timestamp) != GAPI_RETCODE_OK) ||
                 (kernelCopyInTime(max_source_timestamp, &c_time_max_source_timestamp) != GAPI_RETCODE_OK) ) {
                result = GAPI_RETCODE_BAD_PARAMETER;
            } else {
                resource.max_samples = resource_limits->max_samples;
                resource.max_instances = resource_limits->max_instances;
                resource.max_samples_per_instance = resource_limits->max_samples_per_instance;

                uResult= u_dataReaderWaitForHistoricalDataWithCondition(
                        U_DATAREADER_GET(datareader),
                        (c_char*)filter_expression,
                        params,
                        length,
                        c_time_min_source_timestamp,
                        c_time_max_source_timestamp,
                        &resource,
                        c_time_max_wait);

                result = kernelResultToApiResult(uResult);
            }
        }
        _EntityRelease(datareader);
    }
    return result;
}
gapi_returnCode_t
gapi_fooDataReaderView_take_next_instance (
    gapi_fooDataReaderView _this,
    void *data_values,
    void *info_data,
    const gapi_long max_samples,
    const gapi_instanceHandle_t a_handle,
    const gapi_sampleStateMask sample_states,
    const gapi_viewStateMask view_states,
    const gapi_instanceStateMask instance_states)
{
    _DataReaderView     datareaderview;
    gapi_returnCode_t   result = GAPI_RETCODE_OK;
    gapi_readerInfo     readerInfo;
    u_reader            reader;
    v_readerSampleSeq   samples;
    v_readerSample      buffer[V_DATAREADERSAMPLESEQ_INITIAL];
    readerViewActionArg arg;
    u_result            uResult;

    assert(data_values);
    assert(info_data);
    assert(max_samples >= -1 );

    datareaderview = gapi_dataReaderViewClaim(_this, &result);

    if (datareaderview == NULL ) {
        return result;
    } else if (!gapi_stateMasksValid(sample_states, view_states, instance_states)) {
        result = GAPI_RETCODE_BAD_PARAMETER;
    } else if (statemasks_unsupported(sample_states,view_states,instance_states)) {
        result = GAPI_RETCODE_UNSUPPORTED;
    } else if (max_samples == 0) {
        result = GAPI_RETCODE_NO_DATA;
    } else {
        reader = u_reader(U_DATAREADERVIEW_GET(datareaderview));
        datareaderview->reader_mask.sampleStateMask = sample_states;
        datareaderview->reader_mask.viewStateMask = view_states;
        datareaderview->reader_mask.instanceStateMask = instance_states;

        readerInfo.max_samples    = (gapi_unsigned_long)max_samples;
        readerInfo.num_samples    = 0U;
        readerInfo.data_buffer    = data_values;
        readerInfo.info_buffer    = info_data;
        readerInfo.alloc_size     = datareaderview->datareader->allocSize;
        readerInfo.alloc_buffer   = datareaderview->datareader->allocBuffer;
        readerInfo.copy_out       = datareaderview->datareader->copy_out;
        readerInfo.copy_cache     = datareaderview->datareader->copy_cache;
        readerInfo.loan_registry  = (void**)&datareaderview->loanRegistry;

        samples._length  = 0;
        samples._maximum = V_DATAREADERSAMPLESEQ_INITIAL;
        samples._buffer  = buffer;
        samples._release = FALSE;

        arg.samples        = &samples;
        arg.max            = (gapi_unsigned_long)max_samples;
        arg.datareaderview = datareaderview;
        arg.readerInfo     = &readerInfo;
        arg.readerCopy     = datareaderview->datareader->readerCopy;
        arg.result         = GAPI_RETCODE_OK;

        uResult = u_readerTakeNextInstance(reader,a_handle,readerActionView,(c_voidp)&arg);
        result = kernelResultToApiResult(uResult);

        if ( result == GAPI_RETCODE_OK ) {
            result = arg.result;
        }
        v_readerSampleSeq_freebuf(&samples);
    }

    _EntityRelease(datareaderview);

    return result;
}
gapi_returnCode_t
gapi_fooDataReaderView_read_next_instance_w_condition (
    gapi_fooDataReaderView _this,
    void *data_values,
    void *info_data,
    const gapi_long max_samples,
    const gapi_instanceHandle_t a_handle,
    const gapi_readCondition a_condition)
{
    _DataReaderView     datareaderview;
    _ReadCondition      readcondition;
    gapi_returnCode_t   result = GAPI_RETCODE_OK;
    gapi_readerInfo     readerInfo;
    u_reader            reader;
    v_readerSampleSeq   samples;
    v_readerSample      buffer[V_DATAREADERSAMPLESEQ_INITIAL];
    readerViewActionArg arg;
    u_result            uResult;

    assert(data_values);
    assert(info_data);
    assert(max_samples >= -1 );

    datareaderview = gapi_dataReaderViewClaim(_this, &result);
    readcondition = _ReadConditionFromHandle(a_condition);

    if (datareaderview == NULL) {
        return result;
    } else if (readcondition == NULL) {
        result = GAPI_RETCODE_BAD_PARAMETER;
    } else if (readcondition->dataReaderView != datareaderview) {
        result = GAPI_RETCODE_PRECONDITION_NOT_MET;
    } else if ( max_samples != 0) {
        reader = u_reader(readcondition->uQuery);
        datareaderview->reader_mask = readcondition->readerMask;
        readerInfo.max_samples    = (gapi_unsigned_long)max_samples;
        readerInfo.num_samples    = 0U;
        readerInfo.data_buffer    = data_values;
        readerInfo.info_buffer    = info_data;
        readerInfo.alloc_size     = datareaderview->datareader->allocSize;
        readerInfo.alloc_buffer   = datareaderview->datareader->allocBuffer;
        readerInfo.copy_out       = datareaderview->datareader->copy_out;
        readerInfo.copy_cache     = datareaderview->datareader->copy_cache;
        readerInfo.loan_registry  = (void**)&datareaderview->loanRegistry;

        samples._length  = 0;
        samples._maximum = V_DATAREADERSAMPLESEQ_INITIAL;
        samples._buffer  = buffer;
        samples._release = FALSE;

        arg.samples        = &samples;
        arg.max            = (gapi_unsigned_long)max_samples;
        arg.datareaderview = datareaderview;
        arg.readerInfo     = &readerInfo;
        arg.readerCopy     = datareaderview->datareader->readerCopy;
        arg.result         = GAPI_RETCODE_OK;

        uResult = u_readerReadNextInstance(reader,a_handle,readerActionView,(c_voidp)&arg);
        result = kernelResultToApiResult(uResult);
        if ( result == GAPI_RETCODE_OK ) {
            result = arg.result;
        }
        v_readerSampleSeq_freebuf(&samples);
    } else {
        datareaderview->datareader->readerCopy(NULL, &readerInfo);
        result = GAPI_RETCODE_NO_DATA;
    }
    _EntityRelease(datareaderview);

    return result;
}