/*     ReturnCode_t
 *     delete_readcondition(
 *         in ReadCondition a_condition);
 */
gapi_returnCode_t
gapi_dataReaderView_delete_readcondition (
    gapi_dataReaderView _this,
    const gapi_readCondition a_condition)
{
    gapi_returnCode_t result = GAPI_RETCODE_OK;
    _DataReaderView datareaderview;
    _ReadCondition readCondition = NULL;
    c_bool contains;

    if (_this && a_condition) {
        datareaderview = gapi_dataReaderViewClaim(_this, &result);
        if (datareaderview != NULL) {
            readCondition = gapi_readConditionClaim(a_condition, NULL);
            if (readCondition != NULL ) {
                contains = u_readerContainsQuery(U_READER_GET(datareaderview),
                                                 U_QUERY_GET(readCondition));
                if (contains) {
                    _ReadConditionFree(readCondition);
                } else {
                    result = GAPI_RETCODE_PRECONDITION_NOT_MET;
                    _EntityRelease(readCondition);
                }
            } else {
                result = GAPI_RETCODE_ALREADY_DELETED;
            }
            _EntityRelease(datareaderview);
        } else {
            result = GAPI_RETCODE_ALREADY_DELETED;
        }
    } else {
        result = GAPI_RETCODE_BAD_PARAMETER;
    }
    return result;
}
gapi_returnCode_t
gapi_fooDataReaderView_return_loan (
    gapi_fooDataReaderView _this,
    void               *data_buffer,
    void               *info_buffer)
{
    _DataReaderView datareaderview;
    gapi_returnCode_t result = GAPI_RETCODE_OK;

    datareaderview = gapi_dataReaderViewClaim(_this, &result);

    if (datareaderview == NULL) {
        return result;
    } else if (data_buffer == NULL || info_buffer == NULL) {
        result = GAPI_RETCODE_BAD_PARAMETER;
    } else {
        result = gapi_loanRegistry_deregister(datareaderview->loanRegistry,
                                              data_buffer,
                                              info_buffer);
    }

    _EntityRelease(datareaderview);

    return result;
}
/* InstanceHandle_t
 * lookup_instance(
 *     in Data instance);
 */
gapi_instanceHandle_t
gapi_fooDataReaderView_lookup_instance (
    gapi_fooDataReaderView _this,
    const gapi_foo *instance_data)
{
    _DataReaderView datareaderview;
    gapi_instanceHandle_t handle = GAPI_HANDLE_NIL;

    datareaderview = gapi_dataReaderViewClaim(_this, NULL);
    if ( datareaderview && instance_data ) {
        readerViewCopyInInfo rData;
        u_result uResult;

        rData.reader = datareaderview->datareader;
        rData.data = (void *)instance_data;

        uResult = u_dataViewLookupInstance(
                      U_DATAREADERVIEW_GET(datareaderview),
                      &rData,
                      _DataReaderViewCopyIn,
                      &handle);
    }
    _EntityRelease(datareaderview);

    return handle;
}
/*     ReturnCode_t
 *     delete_contained_entities();
 */
gapi_returnCode_t
gapi_dataReaderView_delete_contained_entities (
    gapi_dataReaderView _this)
{
    gapi_returnCode_t result = GAPI_RETCODE_OK;
    _DataReaderView datareaderview;
    gapi_context context;
    _Condition condition = NULL;
    c_iter entities;
    u_entity e;
    u_result ur;

    GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_DELETE_CONTAINED_ENTITIES);

    if ( _this != NULL ) {
        datareaderview = gapi_dataReaderViewClaim(_this, &result);
        if ( datareaderview != NULL ) {
            if (!gapi_loanRegistry_is_empty(datareaderview->loanRegistry)) {
                result = GAPI_RETCODE_PRECONDITION_NOT_MET;
            } else {
                entities = u_readerLookupQueries(U_READER_GET(datareaderview));
                e = c_iterTakeFirst(entities);
                while (e) {
                    condition = u_entityGetUserData(e);
                    if (condition) {
                        _ObjectReadClaimNotBusy(_Object(condition));
                        _ConditionFree(condition);
                    } else {
                        if (e == u_entity(datareaderview->uQuery)) {
                            datareaderview->uQuery = NULL;
                            ur = u_queryFree(u_query(e));
                            if (ur == U_RESULT_OK) {
                                result = GAPI_RETCODE_OK;
                            } else {
                                result = GAPI_RETCODE_BAD_PARAMETER;
                            }
                        } else {
                            assert(condition);
                            result = GAPI_RETCODE_BAD_PARAMETER;
                        }
                    }
                    e = c_iterTakeFirst(entities);
                }
                c_iterFree(entities);
            }
            _EntityRelease(datareaderview);
        } else {
            result = GAPI_RETCODE_ALREADY_DELETED;
        }
    } else {
        result = GAPI_RETCODE_BAD_PARAMETER;
    }

    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;
}
/*     void
 *     get_qos(
 *         inout DataReaderViewQos qos);
 *
 * Function will operate indepenedent of the enable flag
 */
gapi_returnCode_t
gapi_dataReaderView_get_qos (
    gapi_dataReaderView _this,
    gapi_dataReaderViewQos *qos)
{
    _DataReaderView dataReaderView;
    gapi_returnCode_t result;
    
    dataReaderView = gapi_dataReaderViewClaim(_this, &result);
    if ( dataReaderView && qos ) {
        _DataReaderViewGetQos(dataReaderView, qos);
    }

    _EntityRelease(dataReaderView);
    return result;
}
/*     DataReader
 *     get_datareader();
 */
gapi_dataReader
gapi_dataReaderView_get_datareader(
    gapi_dataReaderView _this)
{
    _DataReader datareader = NULL;
    _DataReaderView dataReaderView;

    dataReaderView = gapi_dataReaderViewClaim(_this, NULL);

    if ( dataReaderView != NULL ) { 
        datareader = _DataReaderViewDataReader(dataReaderView);
    }

    _EntityRelease(dataReaderView);
    
    return (gapi_dataReader)_EntityRelease(datareader);
}
/*     ReadCondition
 *     create_readcondition(
 *         in SampleStateMask sample_states,
 *         in ViewStateMask view_states,
 *         in InstanceStateMask instance_states);
 */
gapi_readCondition
gapi_dataReaderView_create_readcondition (
    gapi_dataReaderView _this,
    const gapi_sampleStateMask sample_states,
    const gapi_viewStateMask view_states,
    const gapi_instanceStateMask instance_states)
{
    _DataReaderView datareaderview;
    _ReadCondition readCondition = NULL;

    datareaderview = gapi_dataReaderViewClaim(_this, NULL);

    if ( datareaderview && _EntityEnabled(datareaderview) && 
         gapi_stateMasksValid(sample_states, view_states, instance_states) ) {

        _DataReader datareader;

        datareader = _DataReaderViewDataReader(datareaderview);
        readCondition = _ReadConditionNew ( sample_states,
                                            view_states,
                                            instance_states, 
                                            datareader,
                                            datareaderview);
        _EntityRelease(datareader);
        if ( readCondition != NULL ) {
            gapi_deleteEntityAction deleteAction;
            void *actionArg;
            
            if ( _ObjectGetDeleteAction(_Object(readCondition),
                                        &deleteAction, &actionArg) ) {
                _ObjectSetDeleteAction(_Object(readCondition),
                                       deleteAction,
                                       actionArg);
            }
            
            _ENTITY_REGISTER_OBJECT(_Entity(datareaderview),
                                    (_Object)readCondition);
        }
    }

    _EntityRelease(datareaderview);

    return (gapi_readCondition)_EntityRelease(readCondition);
}
Exemple #9
0
gapi_returnCode_t
gapi_dataReader_delete_view (
    gapi_dataReader _this,
    gapi_dataReaderView a_view)
{
    gapi_returnCode_t result = GAPI_RETCODE_OK;
    _DataReader datareader;
    _DataReaderView view = NULL;
    c_bool contains;

    gapi_context context;

    GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_DELETE_DATAREADER);

    datareader = gapi_dataReaderClaim(_this, &result);

    if ( datareader != NULL ) {
        view = gapi_dataReaderViewClaim(a_view, NULL);
        if ( view != NULL ) {
            contains = u_dataReaderContainsView(U_DATAREADER_GET(datareader),
                                                U_DATAREADERVIEW_GET(view));
            if (contains) {
                if (_DataReaderViewPrepareDelete(view,&context)) {
                    _DataReaderViewFree(view);
                    view = NULL;
                } else {
                    result = GAPI_RETCODE_PRECONDITION_NOT_MET;
                }
            } else {
                result = GAPI_RETCODE_PRECONDITION_NOT_MET;
            }
            _EntityRelease(view);
        } else {
            result = GAPI_RETCODE_BAD_PARAMETER;
        }
        _EntityRelease(datareader);
    } else {
        result = GAPI_RETCODE_ALREADY_DELETED;
    }
    return result;
}
gapi_boolean
gapi_fooDataReaderView_is_loan (
    gapi_fooDataReaderView _this,
    void               *data_buffer,
    void               *info_buffer)
{
    _DataReaderView datareaderview;
    gapi_boolean result = FALSE;

    datareaderview = gapi_dataReaderViewClaim(_this, NULL);
    if ( datareaderview ) {
        if ( data_buffer && info_buffer ) {
            result = gapi_loanRegistry_is_loan(datareaderview->loanRegistry,
                                               data_buffer,
                                               info_buffer);
        }
    }
    _EntityRelease(datareaderview);

    return result;
}
/*     QueryCondition
 *     create_querycondition(
 *         in SampleStateMask sample_states,
 *         in ViewStateMask view_states,
 *         in InstanceStateMask instance_states,
 *         in string query_expression,
 *         in StringSeq query_parameters);
 */
gapi_queryCondition
gapi_dataReaderView_create_querycondition (
    gapi_dataReaderView _this,
    const gapi_sampleStateMask sample_states,
    const gapi_viewStateMask view_states,
    const gapi_instanceStateMask instance_states,
    const gapi_char *query_expression,
    const gapi_stringSeq *query_parameters)
{
    _DataReaderView datareaderview;
    _QueryCondition queryCondition = NULL;
    
    datareaderview = gapi_dataReaderViewClaim(_this, NULL);

    if ( datareaderview && _EntityEnabled(datareaderview) &&
         query_expression && gapi_sequence_is_valid(query_parameters) &&
         gapi_stateMasksValid(sample_states, view_states, instance_states) ) {

        _DataReader datareader;

        datareader = _DataReaderViewDataReader(datareaderview);
        queryCondition = _QueryConditionNew(sample_states,
                                            view_states,
                                            instance_states,
                                            query_expression,
                                            query_parameters,
                                            datareader,
                                            datareaderview);
        _EntityRelease(datareader);
        if ( queryCondition != NULL ) {
            _ENTITY_REGISTER_OBJECT(_Entity(datareaderview),
                                    (_Object)queryCondition);
        }
    }

    _EntityRelease(datareaderview);
    
    return (gapi_queryCondition)_EntityRelease(queryCondition);
}
gapi_statusMask
gapi_dataReaderView_get_status_changes(
    gapi_dataReaderView _this) 
{
    gapi_statusMask result = GAPI_STATUS_KIND_NULL;
    _DataReaderView dataReaderView;
    _DataReader dataReader;

    dataReaderView = gapi_dataReaderViewClaim(_this, NULL);

    if ( dataReaderView != NULL ) { 
        dataReader = _DataReaderViewDataReader(dataReaderView);

        if (dataReader != NULL) {
            result = _StatusGetCurrentStatus(_Entity(dataReader)->status);
            _EntityRelease(dataReader);
        }
 
        _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;
}
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;
}