Esempio n. 1
0
_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;

}
Esempio n. 2
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;
}
Esempio n. 3
0
gapi_returnCode_t
_DataReaderViewFree (
    _DataReaderView dataReaderView)
{
    gapi_returnCode_t result = GAPI_RETCODE_OK;
    u_dataView v;
    assert(dataReaderView);
    
    u_queryFree(dataReaderView->uQuery);
    
    gapi_loanRegistry_free(dataReaderView->loanRegistry);

    v = U_DATAREADERVIEW_GET(dataReaderView);
    _EntityDispose (_Entity(dataReaderView));
    u_dataViewFree(v);

    return result;
}
Esempio n. 4
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;
}