Ejemplo n.º 1
0
void
v_publicDispose(
    v_public o)
{
    assert(C_TYPECHECK(o,v_public));

    if (o == NULL) {
        return;
    }
    switch(v_objectKind(o)) {
    case K_PARTICIPANT:    v_participantDeinit(v_participant(o));       break;
    case K_PUBLISHER:      v_publisherDeinit(v_publisher(o));           break;
    case K_SUBSCRIBER:     v_subscriberDeinit(v_subscriber(o));         break;
    case K_WRITER:         v_writerDeinit(v_writer(o));                 break;
    case K_DATAREADER:     v_dataReaderDeinit(v_dataReader(o));         break;
    case K_DELIVERYSERVICE:v_deliveryServiceDeinit(v_deliveryService(o)); break;
    case K_NETWORKREADER:  v_networkReaderDeinit(v_networkReader(o));   break;
    case K_READER:         v_readerDeinit(v_reader(o));                 break;
    case K_GROUPQUEUE:     v_groupQueueDeinit(v_groupQueue(o));         break;
    case K_TOPIC:          v_topicDeinit(v_topic(o));                   break;
    case K_ENTITY:                                                      break;
    case K_DOMAIN:         v_partitionDeinit(v_partition(o));           break;
    case K_GROUP:          v_groupDeinit(v_group(o));                   break;
    case K_SERVICEMANAGER: /* Is never freed! */                        break;
    case K_SPLICED:        v_splicedDeinit(v_spliced(o));               break;
    case K_NETWORKING:
    case K_DURABILITY:
    case K_CMSOAP:
    case K_SERVICE:        v_serviceDeinit(v_service(o));               break;
    case K_SERVICESTATE:   /* Is never freed! */                        break;
    case K_CONFIGURATION:                                               break;
    case K_QUERY:
        OS_REPORT(OS_ERROR, "v_publicDispose failure", 
                  0, "deinit of abstract class K_QUERY");
    break;
    case K_DATAREADERQUERY: 
        v_dataReaderQueryDeinit(v_dataReaderQuery(o));
    break;
    case K_DATAVIEWQUERY: 
        v_dataViewQueryDeinit(v_dataViewQuery(o));
    break;
    case K_DATAVIEW:       v_dataViewDeinit(v_dataView(o));             break;
    case K_WAITSET:        v_waitsetDeinit(v_waitset(o));               break;
    case K_WRITERINSTANCE:
        v_writerInstanceDeinit(v_writerInstance(o));
    break;
    case K_DATAREADERINSTANCE:
        v_dataReaderInstanceDeinit(v_dataReaderInstance(o));
    break;
    case K_DATAVIEWINSTANCE:
        v_dataViewInstanceDeinit(v_dataViewInstance(o));
    break;
    default:
        OS_REPORT_1(OS_ERROR,"v_publicDispose failed",0,
                    "illegal entity kind (%d) specified",v_objectKind(o));
        assert(FALSE);
    break;
    }
    c_free(o);
}
Ejemplo n.º 2
0
v_dataViewSample
v_dataViewSampleNew(
    v_dataViewInstance instance,
    v_readerSample masterSample)
{
    v_dataView dataView;
    v_dataViewSample sample;

    assert(instance != NULL);
    assert(masterSample != NULL);
    assert(C_TYPECHECK(masterSample,v_readerSample));

    dataView = v_dataView(instance->dataView);
#ifdef _EXTENT_
    sample = v_dataViewSample(c_extentCreate(dataView->sampleExtent));
#else
    sample = v_dataViewSample(c_new(dataView->sampleType));
#endif
    if (sample) {
        v_readerSample(sample)->instance = (c_voidp)instance;
        v_readerSample(sample)->sampleState = 0;
        v_dataViewSampleList(sample)->next = NULL;
        v_dataViewSampleList(sample)->prev = NULL;
        sample->prev = NULL;
        v_dataViewSampleTemplate(sample)->sample = c_keep(masterSample);
    } else {
        OS_REPORT(OS_ERROR,
                  "v_dataViewSampleNew",0,
                  "Failed to allocate v_dataViewSample.");
    }
    return sample;
}
Ejemplo n.º 3
0
void
v_dataViewInstanceRemove(
    v_dataViewInstance instance)
{
    v_dataViewInstance found;

    assert(C_TYPECHECK(instance,v_dataViewInstance));


    if (instance->sampleCount == 0) {
        CHECK_ZERO_INSTANCE(instance);
        found = c_remove(v_dataView(instance->dataView)->instances,instance,NULL,NULL);
        assert(found == instance);
        instance->dataView  = NULL;
        v_publicFree(v_public(instance));
        c_free(instance);
    } else {
        CHECK_INSTANCE(instance);
    }
}
Ejemplo n.º 4
0
v_query
v_queryNew (
    v_collection source,
    const c_char *name,
    q_expr predicate,
    c_value params[])
{
    v_query q;
    v_dataReader reader;
    v_dataView readerView;

    assert(C_TYPECHECK(source,v_collection));

    q = NULL;

    switch(v_objectKind(source)) {
    case K_DATAREADER:
        reader = v_dataReader(source);
        q = v_query(v_dataReaderQueryNew(
                        reader,
                        name,
                        predicate,
                        params));
    break;
    case K_DATAVIEW:
        readerView = v_dataView(source);
        q = v_query(v_dataViewQueryNew(
                        readerView,
                        name,
                        predicate,
                        params));
    break;
    default:
        OS_REPORT_1(OS_ERROR,
                    "v_queryNew failed",0,
                    "illegal source kind (%d) specified",
                    v_objectKind(source));
    }
    return q;
}
Ejemplo n.º 5
0
void
v_dataViewInstanceRemove(
    v_dataViewInstance instance)
{
    v_dataView dataView;
    v_dataViewInstance found;

    assert(C_TYPECHECK(instance,v_dataViewInstance));

    if (instance->sampleCount == 0) {
        CHECK_ZERO_INSTANCE(instance);
        if (v_objectKind (instance) == K_DATAVIEWINSTANCE) {
            dataView = v_dataView(v_instanceEntity(instance));
            found = c_remove(dataView->instances,instance,NULL,NULL);
            assert(found == instance);
            OS_UNUSED_ARG(found);
            v_publicFree(v_public(instance));
            c_free(instance);
        }
    } else {
        CHECK_INSTANCE(instance);
    }
}
Ejemplo n.º 6
0
u_instanceHandle
u_instanceHandleFix(
    u_instanceHandle _this,
    v_collection reader)
{
    u_instanceHandleTranslator translator;
    struct v_publicationInfo *data;
    v_topic topic;
    v_message message;
    v_public instance;

    translator.handle = _this;
    if (translator.lid.lifecycleId & HANDLE_GLOBAL_MASK) {
        /* Is a GID therefore fix handle by lookup. */
        while (v_objectKind(v_entity(reader)) == K_QUERY ||
               v_objectKind(v_entity(reader)) == K_DATAREADERQUERY ||
               v_objectKind(v_entity(reader)) == K_DATAVIEWQUERY) {
            /* If the entity derives from a query entity it can be cast to a v_query */
            reader = v_querySource(v_query(reader));
        }
        while (v_objectKind(v_entity(reader)) == K_DATAVIEW) {
            reader = v_collection(v_dataViewGetReader(v_dataView(reader)));
        }
        topic = v_dataReaderGetTopic(v_dataReader(reader));
        message = v_topicMessageNew(topic);
        data = (c_voidp)C_DISPLACE(message, v_topicDataOffset(topic));
        data->key = u_instanceHandleToGID(_this);
        instance = (v_public)v_dataReaderLookupInstance(v_dataReader(reader),
                                                        message);
        translator.handle = u_instanceHandleNew(instance);
        c_free(instance);
        c_free(topic);
        c_free(message);
    }
    return translator.handle;
}
Ejemplo n.º 7
0
v_writeResult
v_dataViewInstanceWrite (
    v_dataViewInstance instance,
    v_readerSample sample)
{
    v_dataViewSample viewSample;
    v_dataViewSample *prev;
    v_dataViewSample next;

    assert(C_TYPECHECK(instance,v_dataViewInstance));
    assert(C_TYPECHECK(sample,v_readerSample));

    CHECK_INSTANCE(instance);

    viewSample = v_dataViewSampleNew(instance,sample);
    if (viewSample) {
        viewSample->next = NULL;

        prev = &v_dataViewInstanceTemplate(instance)->sample;
        next = NULL;

        while (*prev) {
            next = *prev;
            prev = &(*prev)->prev;
        }
        *prev = viewSample;
        viewSample->next = next;

        v_readerSampleAddViewSample(sample,viewSample);
        instance->sampleCount++;
        assert(c_refCount(viewSample) == 1);
        v_dataViewNotifyDataAvailable(v_dataView(instance->dataView), viewSample);
    }
    CHECK_INSTANCE(instance);
    return V_WRITE_SUCCESS;
}