Ejemplo n.º 1
0
/*     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;
}
Ejemplo n.º 2
0
gapi_returnCode_t
gapi_dataReader_delete_contained_entities (
    gapi_dataReader _this)
{
    gapi_object handle;
    gapi_returnCode_t result = GAPI_RETCODE_OK;
    _DataReader datareader;
    gapi_context context;
    _Condition condition = NULL;
    _DataReaderView view = NULL;
    c_iter entities;
    u_entity e;
    u_result ur;

    GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_DELETE_CONTAINED_ENTITIES);

    datareader = gapi_dataReaderClaim(_this, &result);

    if ( datareader != NULL ) {
        if (!gapi_loanRegistry_is_empty(datareader->loanRegistry)) {
            result = GAPI_RETCODE_PRECONDITION_NOT_MET;
        } else {
            entities = u_readerLookupQueries(U_READER_GET(datareader));
            e = c_iterTakeFirst(entities);
            while (e) {
                condition = u_entityGetUserData(e);
                if (condition) {
                    _ObjectReadClaimNotBusy(_Object(condition));
                    _ConditionFree(condition);
                } else {
                    assert(condition);
                    result = GAPI_RETCODE_BAD_PARAMETER;
                }
                e = c_iterTakeFirst(entities);
            }
            c_iterFree(entities);

            entities = u_dataReaderLookupViews(U_DATAREADER_GET(datareader));
            e = c_iterTakeFirst(entities);
            while (e) {
                handle = u_entityGetUserData(e);
                view = _DataReaderView(gapi_conditionClaimNB(handle,&result));
                if (view) {
                    _DataReaderViewFree(view);
                } else {
                    ur = u_dataViewFree(u_dataView(e));
                    if (ur == U_RESULT_OK) {
                        result = GAPI_RETCODE_OK;
                    } else {
                        result = GAPI_RETCODE_BAD_PARAMETER;
                    }
                }
                e = c_iterTakeFirst(entities);
            }
            c_iterFree(entities);
        }
        _EntityRelease(datareader);
    } else {
        result = GAPI_RETCODE_BAD_PARAMETER;
    }
    return result;
}