Esempio n. 1
0
v_networkReader
v_networkReaderNew(
    v_subscriber subscriber,
    const c_char *name,
    v_readerQos qos,
    c_bool ignoreReliabilityQoS)
{
    /* Note: currently, no qos-es are supported. Everything is redirected
     *       to the defaultQueue */

    v_kernel kernel;
    v_networkReader reader;
    v_readerQos q;
    v_statistics s;
    c_type queueType;
    c_long i;

    assert(C_TYPECHECK(subscriber,v_subscriber));

    /* Creation */
    kernel = v_objectKernel(subscriber);
    q = v_readerQosNew(kernel,qos);
    if (q != NULL) {
        reader = v_networkReader(v_objectNew(kernel,K_NETWORKREADER));
        s = v_statistics(v_networkReaderStatisticsNew(kernel));

        /* Initialization of parent */
        v_readerInit(v_reader(reader), name, subscriber, q, s, TRUE);
        c_free(q); /* ref now in v_reader(queue)->qos */

        /* This function only ever called once per network instance so no
         * need to store queueType as static variable.  Look up as needed (once)
         */
        queueType = c_resolve(c_getBase(subscriber),"kernelModule::v_networkQueue");
        /* Initialization of self */
        reader->queues = NULL;
        reader->queues = c_arrayNew(queueType, NW_MAX_NOF_QUEUES);
        reader->nofQueues = 0;
        reader->defaultQueue = NULL;
        reader->remoteActivity = FALSE;
        reader->ignoreReliabilityQoS = ignoreReliabilityQoS;
        reader->queueCache = c_arrayNew(queueType, 2*NW_MAX_QUEUE_CACHE_PRIO);
        for( i= 0; i < 2*NW_MAX_QUEUE_CACHE_PRIO; i++) {
            reader->queueCache[i] = NULL;
        }
        c_free(queueType);
        /* Add to subscriber */
        v_subscriberAddReader(subscriber,v_reader(reader));
    } else {
        OS_REPORT(OS_ERROR, "v_networkReaderNew", 0,
            "NetworkReader not created: inconsistent qos");
        reader = NULL;
    }

    return reader;
}
Esempio n. 2
0
void
v_groupStreamInit(
    v_groupStream stream,
    const c_char *name,
    v_subscriber subscriber,
    v_readerQos qos)
{
    v_kernel kernel;

    assert(C_TYPECHECK(stream, v_groupStream));
    assert(C_TYPECHECK(subscriber, v_subscriber));

    kernel = v_objectKernel(subscriber);

    stream->groups = c_setNew(v_kernelType(kernel,K_GROUP));
    v_readerInit(v_reader(stream),name,subscriber,qos,NULL,TRUE);
    v_subscriberAddReader(subscriber,v_reader(stream));
}
Esempio n. 3
0
void
v_groupStreamInit(
    v_groupStream stream,
    const c_char *name,
    v_subscriber subscriber,
    v_readerQos qos,
    v_statistics rs,
    c_iter expr)
{
    v_kernel kernel;

    assert(C_TYPECHECK(stream, v_groupStream));
    assert(C_TYPECHECK(subscriber, v_subscriber));

    kernel = v_objectKernel(subscriber);

    stream->groups = c_setNew(v_kernelType(kernel,K_GROUP));
    stream->expr = c_listNew(c_resolve(c_getBase(stream), "::c_string"));
    c_iterWalk(expr, fillExprList, stream->expr);

    v_readerInit(v_reader(stream),name,subscriber,qos,rs,TRUE);
    v_subscriberAddReader(subscriber,v_reader(stream));
}
Esempio n. 4
0
v_deliveryService
v_deliveryServiceNew (
    v_subscriber subscriber,
    const c_char *name)
{
    v_kernel kernel;
    v_deliveryService _this;
    v_readerQos q;
    v_topic topic;
    c_base base;
    c_type type;
    v_entry entry, found;

    assert(C_TYPECHECK(subscriber,v_subscriber));
    base = c_getBase(subscriber);
    kernel = v_objectKernel(subscriber);
    topic = v_lookupTopic (kernel, V_DELIVERYINFO_NAME);
    /* ES, dds1576: Before creating the ackreader we have to verify that read
     * access to the topic is allowed. We can accomplish this by checking the
     * access mode of the topic.
     */
    if(!topic)
    {
        OS_REPORT(OS_ERROR, "v_deliveryServiceNew",0,
                  "DeliveryService not created: "
                  "Could not locate topic with name DCPS_Delivery.");
        return NULL;
    }
    if(v_topicAccessMode(topic) == V_ACCESS_MODE_READ ||
       v_topicAccessMode(topic) == V_ACCESS_MODE_READ_WRITE)
    {
        q = v_readerQosNew(kernel,NULL);
        if (q == NULL) {
            OS_REPORT(OS_ERROR, "v_deliveryServiceNew", 0,
                      "DeliveryService not created: inconsistent qos");
            return NULL;
        }
        _this = v_deliveryService(v_objectNew(kernel,K_DELIVERYSERVICE));

        type = c_resolve(base, "kernelModule::v_deliveryGuard");
        _this->guards = c_tableNew(type, "writerGID.localId");
        c_free(type);

        type = c_resolve(base, "kernelModule::v_subscriptionInfoTemplate");
        _this->subscriptions = c_tableNew(type, "userData.key.systemId,userData.key.localId");
        c_free(type);
        q->userKey.enable = TRUE;
        q->userKey.expression = NULL;
        v_readerInit(v_reader(_this),name, subscriber,q, NULL, TRUE);

        c_free(q);

        entry = v_entry(v_deliveryServiceEntryNew(_this,topic));
        found = v_readerAddEntry(v_reader(_this),v_entry(entry));
        c_free(entry);
        c_free(found);

        v_deliveryServiceEnable(_this);
    } else
    {
        OS_REPORT_1(OS_ERROR, "v_deliveryServiceNew", 0,
                    "Creation of DeliveryService <%s> failed. Topic DCPS_Delivery."
                    "does not have read access rights.", name);
        _this = NULL;
    }
    return _this;
}
Esempio n. 5
0
v_networkReader
v_networkReaderNew(
    v_subscriber subscriber,
    const c_char *name,
    v_readerQos qos,
    c_bool ignoreReliabilityQoS)
{
    /* Note: currently, no qos-es are supported. Everything is redirected
     *       to the defaultQueue
     */

    v_kernel kernel;
    v_networkReader reader = NULL;
    v_result r;
    v_readerQos q;
    c_type queueType;
    c_long i;

    assert(C_TYPECHECK(subscriber,v_subscriber));

    /* Creation */
    kernel = v_objectKernel(subscriber);
    if (v_readerQosCheck(qos) == V_RESULT_OK) {
        q = v_readerQosNew(kernel,qos);

        if (q != NULL) {
            reader = v_networkReader(v_objectNew(kernel,K_NETWORKREADER));
            reader->statistics = v_networkReaderStatisticsNew(kernel);

            /* Initialization of parent */
            v_readerInit(v_reader(reader), name, subscriber, q);
            (void)v_entityEnable(v_entity(reader));

            c_free(q); /* ref now in v_reader(queue)->qos */

            /* This function only ever called once per network instance so no
             * need to store queueType as static variable.  Look up as needed (once)
             */
            queueType = c_resolve(c_getBase(subscriber),"kernelModuleI::v_networkQueue");
            /* Initialization of self */
            reader->queues = NULL;
            reader->queues = c_arrayNew_s(queueType, NW_MAX_NOF_QUEUES);
            if (!reader->queues) {
                OS_REPORT(OS_ERROR, "v_networkReaderNew", V_RESULT_OUT_OF_MEMORY,
                    "Creation of NetworkReader <%s> failed: cannot create queues",
                    name);
                goto err_alloc_queues;
            }
            reader->nofQueues = 0;
            reader->defaultQueue = NULL;
            reader->remoteActivity = FALSE;
            reader->ignoreReliabilityQoS = ignoreReliabilityQoS;
            reader->queueCache = c_arrayNew_s(queueType, 2*NW_MAX_QUEUE_CACHE_PRIO);
            if (!reader->queueCache) {
                OS_REPORT(OS_ERROR, "v_networkReaderNew", V_RESULT_OUT_OF_MEMORY,
                     "Creation of NetworkReader <%s> failed: cannot create queue cache",
                     name);
                goto err_alloc_cache;
            }
            for( i= 0; i < 2*NW_MAX_QUEUE_CACHE_PRIO; i++) {
                reader->queueCache[i] = NULL;
            }
            c_free(queueType);
            /* Add to subscriber */
            r = v_subscriberAddReader(subscriber,v_reader(reader));
            if (r != V_RESULT_OK) {
                OS_REPORT(OS_ERROR, "v_networkReaderNew", r,
                          "Creation of NetworkReader <%s> failed: cannot add reader to subscriber",
                          name);
                goto err_add_reader;
            }
        } else {
            OS_REPORT(OS_ERROR, "v_networkReaderNew", V_RESULT_OUT_OF_MEMORY,
                "Creation of NetworkReader <%s> failed: cannot create reader QoS",
                name);
            reader = NULL;
        }
    }

    return reader;

err_add_reader:
err_alloc_cache:
err_alloc_queues:
    c_free(queueType);
    c_free(reader);
    return NULL;
}