Пример #1
0
u_result
u_readerTakeNextInstance(
    u_reader r,
    u_instanceHandle h,
    u_readerAction action,
    c_voidp actionArg)
{
    u_result result;

    switch (u_entity(r)->kind) {
    case U_READER:
        result = u_dataReaderTakeNextInstance(u_dataReader(r), h, action, actionArg);
    break;
    case U_DATAVIEW:
        result = u_dataViewTakeNextInstance(u_dataView(r), h, action, actionArg);
    break;
    case U_QUERY:
        result = u_queryTakeNextInstance(u_query(r), h, action, actionArg);
    break;
    default:
        result = U_RESULT_ILL_PARAM;
    break;
    }
    return result;
}
Пример #2
0
_ReadCondition
_ReadConditionNew(
    const gapi_sampleStateMask sample_states,
    const gapi_viewStateMask view_states,
    const gapi_instanceStateMask instance_states,
    _DataReader datareader,
    _DataReaderView datareaderview)
{
    _ReadCondition _this;
    u_reader      uReader;
    u_dataView    uDataView;
    q_expr        predicate;


    /* The datareader and the datareaderview (should) share
     * a baseclass and therefore it is not necessary to have
     * both a datareader and a datareaderview as properties.
     * At run-time the right owner can be determined
     */
    _this = _ReadConditionAlloc();
    if ( _this != NULL ) {
        if (datareaderview != NULL) {
          _ConditionInit(_Condition(_this),
                         _Entity(datareaderview),
                         _ReadConditionGetTriggerValue);
        } else {
          _ConditionInit(_Condition(_this),
                         _Entity(datareader),
                         _ReadConditionGetTriggerValue);
        }
        _this->dataReader = datareader;
        _this->dataReaderView = datareaderview;
        _this->readerMask.sampleStateMask = sample_states;
        _this->readerMask.viewStateMask = view_states;
        _this->readerMask.instanceStateMask = instance_states;

        predicate = q_parse("1=1");
        if (datareaderview) {
            uDataView = u_dataView(_DataReaderViewUreaderView(datareaderview));
            if ( predicate != NULL ) {
                _this->uQuery = u_queryNew(u_reader(uDataView), NULL, predicate, NULL);
            }
        } else {
            uReader = u_reader(_DataReaderUreader(datareader));
            if ( predicate != NULL ) {
                _this->uQuery = u_queryNew(uReader, NULL, predicate, NULL);
            }
        }
        q_dispose(predicate);
        if (_this->uQuery != NULL) {
            u_entitySetUserData(u_entity(_this->uQuery),_this);
            _Condition(_this)->uEntity = u_entity(_this->uQuery);
        } else {
            _ConditionDispose(_Condition(_this));
            _this = NULL;
        }
    }

    return _this;
}
Пример #3
0
static gapi_boolean
initViewQuery (
    _DataReaderView dataReaderView)
{
    gapi_boolean result = FALSE;
    gapi_expression expr;
    u_dataView uReaderView;
    
    dataReaderView->reader_mask.sampleStateMask   = (c_long)0;
    dataReaderView->reader_mask.viewStateMask     = (c_long)0;
    dataReaderView->reader_mask.instanceStateMask = (c_long)0;
    
    uReaderView = u_dataView(U_DATAREADERVIEW_GET(dataReaderView));
    expr = gapi_createReadExpression(u_entity(uReaderView),
                                     &dataReaderView->reader_mask);
    if ( expr != NULL ) {
        dataReaderView->uQuery = gapi_expressionCreateQuery(expr,
                                                            u_reader(uReaderView),
                                                            NULL,
                                                            NULL);
        gapi_expressionFree(expr);
        if ( dataReaderView->uQuery ) {
            result = TRUE;
        }
    }
    return result;
}
Пример #4
0
u_result
u_subscriberDeleteContainedEntities (
    u_subscriber _this)
{
    u_result result;
    u_reader reader;
    c_iter list;

    if (_this != NULL) {
        result = u_entityLock(u_entity(_this));
        if (result == U_RESULT_OK) {
            list = _this->readers;
            _this->readers = NULL;
            /* Unlock here because following code will take this lock. */
            u_entityUnlock(u_entity(_this));
            reader = c_iterTakeFirst(list);
            while (reader) {
                switch (u_entityKind(u_entity(reader))) {
                case U_READER:
                    result = u_dataReaderDeleteContainedEntities(u_dataReader(reader));
                    result = u_dataReaderFree(u_dataReader(reader));
                break;
                case U_GROUPQUEUE:
                    result = u_groupQueueFree(u_groupQueue(reader));
                break;
                case U_DATAVIEW:
                    result = u_dataViewFree(u_dataView(reader));
                break;
                case U_NETWORKREADER:
                    result = u_networkReaderFree(u_networkReader(reader));
                break;
                default:
                    OS_REPORT_2(OS_WARNING,
                                "u_subscriberDeleteContainedEntities",0,
                                "invalid object type: "
                                "For Subscriber = 0x%x, found Reader type = %s.",
                                _this, u_kindImage(u_entityKind(u_entity(reader))));
                    assert(0);
                break;
                }
                u_entityDereference(u_entity(_this));
                reader = c_iterTakeFirst(list);
            }
            c_iterFree(list);
        } else {
            OS_REPORT_2(OS_WARNING,
                        "u_subscriberDeleteContainedEntities",0,
                        "Operation u_entityLock failed: "
                        "Subscriber = 0x%x, result = %s.",
                        _this, u_resultImage(result));
        }
    } else {
        OS_REPORT(OS_WARNING,
                  "u_subscriberDeleteContainedEntities",0,
                  "Invalid Subscriber <NULL>.");
        result = U_RESULT_ILL_PARAM;
    }
    return result;
}
Пример #5
0
gapi_dataReaderViewQos *
_DataReaderViewGetQos (
    _DataReaderView dataReaderView,
    gapi_dataReaderViewQos * qos)
{
    v_dataViewQos dataViewQos;
    u_dataView uDataView;
    
    assert(dataReaderView);

    uDataView = u_dataView(U_DATAREADERVIEW_GET(dataReaderView));
        
    if ( u_entityQoS(u_entity(uDataView), (v_qos*)&dataViewQos) == U_RESULT_OK ) {
        copyReaderViewQosOut(dataViewQos,  qos);
        u_dataViewQosFree(dataViewQos);
    }

    return qos;
}
Пример #6
0
u_result
u_readerRead(
    u_reader r,
    u_readerAction action,
    c_voidp actionArg)
{
    u_result result;
    switch (u_entity(r)->kind) {
    case U_READER:
        result = u_dataReaderRead(u_dataReader(r), action, actionArg);
    break;
    case U_DATAVIEW:
        result = u_dataViewRead(u_dataView(r), action, actionArg);
    break;
    case U_QUERY:
        result = u_queryRead(u_query(r), action, actionArg);
    break;
    default:
        result = U_RESULT_ILL_PARAM;
    break;
    }
    return result;
}
Пример #7
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;
}
Пример #8
0
_QueryCondition
_QueryConditionNew(
    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,
    _DataReader datareader,
    _DataReaderView datareaderview)
{
    _QueryCondition _this;
    u_reader      uReader;
    u_dataView    uDataView;


    /* Allocate QueryCondition */
    _this = _QueryConditionAlloc();
    if (_this != NULL) {
        /* Initialise QueryCondition */
        if (datareaderview != NULL) {
          _ConditionInit(_Condition(_this),
                         _Entity(datareaderview),
                         _ReadConditionGetTriggerValue);
        } else {
          _ConditionInit(_Condition(_this),
                         _Entity(datareader),
                         _ReadConditionGetTriggerValue);
        }
        _this->_parent.dataReader = datareader;
        _this->_parent.dataReaderView = datareaderview;
        _this->_parent.readerMask.sampleStateMask = sample_states;
        _this->_parent.readerMask.viewStateMask = view_states;
        _this->_parent.readerMask.instanceStateMask = instance_states;
        _this->query_expression = gapi_string_dup(query_expression);
        _this->query_parameters = gapi_stringSeq_dup(query_parameters);

        uReader = u_reader(_DataReaderUreader(datareader));

        _this->expression =
            gapi_createQueryExpression(u_entity(uReader),
                                       _this->query_expression);
        if (_this->expression) {
            if (datareaderview) {
                uDataView = u_dataView(_DataReaderViewUreaderView(datareaderview));
                _this->_parent.uQuery = gapi_expressionCreateQuery(
                                                _this->expression,
                                                 u_reader(uDataView),
                                                 NULL,
                                                 _this->query_parameters);
            } else {
                uReader = u_reader(_DataReaderUreader(datareader));
                _this->_parent.uQuery = gapi_expressionCreateQuery(
                                                _this->expression,
                                                 uReader,
                                                 NULL,
                                                 _this->query_parameters);
            }


            if (_this->_parent.uQuery) {
                /* Success: fill UserData and mark as valid */
                u_entitySetUserData(u_entity(_this->_parent.uQuery),_this);
                _Condition(_this)->uEntity = u_entity(_this->_parent.uQuery);
            } else {
                gapi_free(_this->query_expression);
                gapi_free(_this->query_parameters);
                gapi_expressionFree(_this->expression);
                _ConditionDispose(_Condition(_this));
                _this = NULL;
            }
        } else {
            gapi_free(_this->query_expression);
            gapi_free(_this->query_parameters);
            _ConditionDispose(_Condition(_this));
            _this = NULL;
        }
    }

    return _this;
}