Example #1
0
gapi_returnCode_t
_PublisherFree (
    _Publisher _this)
{
    gapi_returnCode_t result = GAPI_RETCODE_OK;
    _Status status;
    u_publisher p;

    assert(_this);

    status = _EntityStatus(_this);
    _StatusSetListener(status, NULL, 0);

    _EntityClaim(status);
    _StatusDeinit(status);

    gapi_dataWriterQos_free(&_this->_defDataWriterQos);

    p = U_PUBLISHER_GET(_this);
    _EntityDispose (_Entity(_this));
    if (u_publisherFree(p) != U_RESULT_OK) {
        result = GAPI_RETCODE_ERROR;
    }

    return result;
}
Example #2
0
gapi_returnCode_t
gapi_publisher_set_listener (
    gapi_publisher _this,
    const struct gapi_publisherListener *a_listener,
    const gapi_statusMask mask)
{
    gapi_returnCode_t result = GAPI_RETCODE_OK;
    _Publisher publisher;

    publisher  = gapi_publisherClaim(_this, &result);

    if ( publisher != NULL ) {
        _Status status;

        if ( a_listener ) {
            publisher->_Listener = *a_listener;
        } else {
            memset(&publisher->_Listener, 0, sizeof(publisher->_Listener));
        }

        status = _EntityStatus(publisher);
        if ( _StatusSetListener(status,
                                (struct gapi_listener *)a_listener,
                                mask) )
        {
            result = GAPI_RETCODE_OK;
        }
    }
    _EntityRelease(publisher);

    return result;
}
_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;

}
Example #4
0
gapi_returnCode_t
_SubscriberFree (
    _Subscriber subscriber)
{
    gapi_returnCode_t result = GAPI_RETCODE_OK;
    _Status status;
    u_subscriber s;

    assert(subscriber);

    status = _EntityStatus(subscriber);
    _StatusSetListener(status, NULL, 0);

    _EntityClaim(status);
    _StatusDeinit(status);

    gapi_dataReaderQos_free(&subscriber->_defDataReaderQos);

    s = U_SUBSCRIBER_GET(subscriber);
    _EntityDispose(_Entity(subscriber));
    if (u_subscriberFree(s) != U_RESULT_OK) {
        result = GAPI_RETCODE_ERROR;
    }

    return result;
}
Example #5
0
gapi_returnCode_t
gapi_subscriber_set_listener (
    gapi_subscriber _this,
    const struct gapi_subscriberListener *a_listener,
    const gapi_statusMask mask)
{
    gapi_returnCode_t result = GAPI_RETCODE_OK;
    _Subscriber subscriber = (_Subscriber)_this;

    subscriber = gapi_subscriberClaim(_this, &result);

    if ( (subscriber != NULL) ) {
        _Status status;

        if ( a_listener ) {
            subscriber->_Listener = *a_listener;
        } else {
            memset(&subscriber->_Listener, 0, sizeof(subscriber->_Listener));
        }

        status = _EntityStatus(subscriber);
        if ( _StatusSetListener(status,
                                (struct gapi_listener *)a_listener,
                                mask) )
        {
            result = GAPI_RETCODE_OK;
        }
        _EntityRelease(subscriber);
    }
    return result;
}
Example #6
0
/*     ReturnCode_t
 *     set_listener(
 *         in DataWriterListener a_listener,
 *         in StatusMask mask);
 */
gapi_returnCode_t
gapi_dataWriter_set_listener (
    gapi_dataWriter _this,
    const struct gapi_dataWriterListener *a_listener,
    const gapi_statusMask mask)
{
    gapi_returnCode_t result = GAPI_RETCODE_ERROR;
    _DataWriter datawriter;

    datawriter = gapi_dataWriterClaim(_this, &result);

    if ( datawriter != NULL ) {
        _Status status;

        if ( a_listener ) {
            datawriter->listener = *a_listener;
        } else {
            memset(&datawriter->listener, 0, sizeof(datawriter->listener));
        }

        status = _EntityStatus(datawriter);
        if ( _StatusSetListener(status,
                                (struct gapi_listener *)a_listener,
                                mask) )
        {
            result = GAPI_RETCODE_OK;
        }
    }

    _EntityRelease(datawriter);

    return result;
}
Example #7
0
void
_SubscriberNotifyListener(
    _Subscriber _this,
    gapi_statusMask triggerMask)
{
    gapi_object source;
    _Status status;

    if ( _this && (triggerMask & GAPI_DATA_ON_READERS_STATUS) ) {
        status = _EntityStatus(_this);
        source = _EntityHandle(_this);
        _StatusNotifyDataOnReaders(status, source);
    }
}
Example #8
0
void
_BuiltinSubscriberFree (
    _Subscriber subscriber)
{
    _Status status;

    assert(subscriber != NULL);

    status = _EntityStatus(subscriber);
    _StatusSetListener(status, NULL, 0);

    _EntityClaim(status);
    _StatusDeinit(status);

    u_subscriberFree(U_SUBSCRIBER_GET(subscriber));

    _EntityDispose(_Entity(subscriber));
}
Example #9
0
gapi_returnCode_t
_DataReaderFree (
    _DataReader _this)
{
    gapi_returnCode_t result = GAPI_RETCODE_OK;
    _Status status;
    u_dataReader r;

    assert(_this);

    /* The following refCount checking and destruction mechanism is not
     * bullet proof and may cause leakage.
     * This is a temporary situation during GAPI redesign and should be
     * resolved when the GAPI redesign is finished.
     */
    r = U_DATAREADER_GET(_this);
    _TopicDescriptionDecUse(_this->topicDescription);

    status = _EntityStatus(_this);

    _StatusSetListener(status, NULL, 0);

    _EntityClaim(status);
    _StatusDeinit(status);

    gapi_loanRegistry_free(_this->loanRegistry);

    /* Following the user layer reader object is deleted after the entity
     * dispose because it will otherwise lead to a double free of the user
     * layer reader.
     * This is caused by the status condition which is attached to an exiting
     * waitset and the fact that a status condition's user object is the user
     * layer reader.
     * This is a hack but besides of that the destruction of the user entity
     * should be part of the entity dispose method.
     * For now this works.
     */
    _EntityDispose(_Entity(_this));
    u_dataReaderFree(r);

    return result;
}
Example #10
0
gapi_returnCode_t
_DataWriterFree (
    _DataWriter _this)
{
    gapi_returnCode_t result = GAPI_RETCODE_OK;
    _Status status;
    u_writer w;

    assert(_this);

    status = _EntityStatus(_this);
    _TopicDescriptionDecUse(_TopicDescription(_this->topic));

    _StatusSetListener(status, NULL, 0);

    _EntityClaim(status);
    _StatusDeinit(status);

    w = U_WRITER_GET(_this);
    _EntityDispose (_Entity(_this));
    u_writerFree(w);

    return result;
}
Example #11
0
_DataWriter
_DataWriterNew (
    const _Topic topic,
    const _TypeSupport typesupport,
    const gapi_dataWriterQos *qos,
    const struct gapi_dataWriterListener *a_listener,
    const gapi_statusMask mask,
    const _Publisher publisher)
{
    _DataWriter newDataWriter;
    v_writerQos writerQos;
    u_writer uWriter;
    _TypeSupport typeSupport = (_TypeSupport)typesupport;
    char dataWriterId[256];
    gapi_string topicName;

    newDataWriter = _DataWriterAlloc();

    if ( newDataWriter != NULL ) {
        _EntityInit(_Entity(newDataWriter),
                    _Entity(publisher));

        newDataWriter->topic = topic;
        if ( a_listener ) {
            newDataWriter->listener = *a_listener;
        }
        writerQos = u_writerQosNew(NULL);
        if ( (writerQos != NULL) ) {
            if ( !copyWriterQosIn(qos, writerQos) ) {
                u_writerQosFree (writerQos);
                _EntityDispose(_Entity(newDataWriter));
                newDataWriter = NULL;
            }
        } else {
            _EntityDispose(_Entity(newDataWriter));
            newDataWriter = NULL;
        }
    }

    if ( newDataWriter != NULL ) {
        u_writerCopy copy_action;

        newDataWriter->copy_in    = _TypeSupportCopyIn(typeSupport);
        newDataWriter->copy_out   = _TypeSupportCopyOut(typeSupport);
        newDataWriter->copy_cache = _TypeSupportCopyCache(typeSupport);

        copy_action = _TypeSupportGetWriterCopy(typeSupport);
        if (!copy_action) {
            copy_action = _DataWriterCopy;
        }

        topicName = _TopicDescriptionGetName (_TopicDescription(topic));
        if (topicName) {
            snprintf (dataWriterId,
                      sizeof (dataWriterId),
                      "%sWriter", topicName);
            gapi_free (topicName);
        } else {
            snprintf (dataWriterId,
                      sizeof (dataWriterId),
                      "dataWriter");
        }
        uWriter = u_writerNew(_PublisherUpublisher(publisher),
                              dataWriterId,
                              _TopicUtopic(topic),
                              copy_action,
                              writerQos,
                              FALSE);
        if ( uWriter != NULL ) {
            U_WRITER_SET(newDataWriter, uWriter);
        } else {
            _EntityDispose(_Entity(newDataWriter));
            newDataWriter = NULL;
        }
        u_writerQosFree(writerQos);
    }

    if ( newDataWriter != NULL ) {
        _Status status;

        status = _StatusNew(_Entity(newDataWriter),
                            STATUS_KIND_DATAWRITER,
                            (struct gapi_listener *)a_listener, mask);
        _EntityStatus(newDataWriter) = status;
        if (status) {
            _TopicDescriptionIncUse(_TopicDescription(topic));
        } else {
            u_writerFree(uWriter);
            _EntityDispose(_Entity(newDataWriter));
            newDataWriter = NULL;
        }
    }

    return newDataWriter;
}
Example #12
0
void
_DataWriterNotifyListener(
    _DataWriter _this,
    gapi_statusMask triggerMask)
{
    gapi_returnCode_t result;
    gapi_object source;
    _Status status;

    if ( _this == NULL ) {
        OS_REPORT(OS_ERROR,
                  "_DataWriterNotifyListener",0,
                  "Specified DataWriter = NULL.");
        return;
    }
    status = _EntityStatus(_this);
    source = _EntityHandle(_this);
    while ( _this && (triggerMask != GAPI_STATUS_KIND_NULL) ) {
        if ( triggerMask & GAPI_LIVELINESS_LOST_STATUS ) {
            gapi_livelinessLostStatus info;

            result = _DataWriter_get_liveliness_lost_status (_this, &info);
            /* Only allow the callback if there is a change since the last
             * callback, i.e if total_count_change is non zero
             */
            if (result == GAPI_RETCODE_OK && info.total_count_change != 0) {
                _StatusNotifyLivelinessLost(status, source, &info);
            }
            triggerMask &= ~GAPI_LIVELINESS_LOST_STATUS;
        }
        if ( triggerMask & GAPI_OFFERED_DEADLINE_MISSED_STATUS ) {
            gapi_offeredDeadlineMissedStatus info;

            result = _DataWriter_get_offered_deadline_missed_status (_this, &info);
            /* Only allow the callback if there is a change since the last
             * callback, i.e if total_count_change is non zero
             */
            if (result == GAPI_RETCODE_OK && info.total_count_change != 0) {
                _StatusNotifyOfferedDeadlineMissed(status, source, &info);
            }
            triggerMask &= ~GAPI_OFFERED_DEADLINE_MISSED_STATUS;
        }
        if ( triggerMask & GAPI_OFFERED_INCOMPATIBLE_QOS_STATUS ) {
            gapi_offeredIncompatibleQosStatus info;
            gapi_qosPolicyCount policyCount[MAX_POLICY_COUNT_ID];

            info.policies._maximum = MAX_POLICY_COUNT_ID;
            info.policies._length  = 0;
            info.policies._buffer  = policyCount;

            result = _DataWriter_get_offered_incompatible_qos_status (_this, &info);

            /* Only allow the callback if there is a change since the last
             * callback, i.e if total_count_change is non zero
             */

            if (result == GAPI_RETCODE_OK && info.total_count_change != 0) {
                _StatusNotifyOfferedIncompatibleQos(status, source, &info);
            }
            triggerMask &= ~GAPI_OFFERED_INCOMPATIBLE_QOS_STATUS;
        }
        if ( triggerMask & GAPI_PUBLICATION_MATCH_STATUS ) {
            gapi_publicationMatchedStatus info;

            result = _DataWriter_get_publication_matched_status (_this, &info);
            /* Only allow the callback if there is a change since the last
             * callback, i.e if total_count_change is non zero
             */
            if (result == GAPI_RETCODE_OK && info.current_count_change != 0) {
                _StatusNotifyPublicationMatch(status, source, &info);
            }
            triggerMask &= ~GAPI_PUBLICATION_MATCH_STATUS;
        }
    }
}
Example #13
0
_Publisher
_PublisherNew (
    u_participant uParticipant,
    const gapi_publisherQos *qos,
    const struct gapi_publisherListener *a_listener,
    const gapi_statusMask mask,
    const _DomainParticipant participant)
{
    v_publisherQos publisherQos;
    _Publisher newPublisher;

    assert(uParticipant);
    assert(qos);
    assert(participant);

    newPublisher = _PublisherAlloc();

    if ( newPublisher ) {
        _EntityInit (_Entity(newPublisher),
                           _Entity(participant));
        gapi_dataWriterQosCopy (&gapi_dataWriterQosDefault,
                                &newPublisher->_defDataWriterQos);
        if ( a_listener ) {
            newPublisher->_Listener = *a_listener;
        }
    }

    if ( newPublisher ) {
        publisherQos = u_publisherQosNew(NULL);
        if ( publisherQos ) {
            if ( !copyPublisherQosIn(qos, publisherQos)) {
                _EntityDispose(_Entity(newPublisher));
                newPublisher = NULL;
            }
        } else {
            _EntityDispose(_Entity(newPublisher));
            newPublisher = NULL;
        }
    }

    if ( newPublisher  ) {
        u_publisher uPublisher;

        uPublisher = u_publisherNew (uParticipant,
                                     "publisher",
                                     publisherQos,
                                     FALSE);
        u_publisherQosFree(publisherQos);
        if ( uPublisher ) {
            U_PUBLISHER_SET(newPublisher, uPublisher);
        } else {
            _EntityDispose(_Entity(newPublisher));
            newPublisher = NULL;
        }
    }

    if ( newPublisher ) {
        _Status status;

        status = _StatusNew(_Entity(newPublisher),
                            STATUS_KIND_PUBLISHER,
                            (struct gapi_listener *)a_listener, mask);
        if (status) {
            _EntityStatus(newPublisher) = status;
            if ( qos->partition.name._length == 0 ) {
                /*
                 * behaviour of the kernel in case of an empty sequence
                 * is that it is related to none of the partitions,
                 * while DCPS expects it to be conected to all partitions.
                 * Therefore this has to be done seperately.
                 */
                u_publisherPublish (U_PUBLISHER_GET(newPublisher), "");
            }
        } else {
            u_publisherFree(U_PUBLISHER_GET(newPublisher));
            _EntityDispose(_Entity(newPublisher));
            newPublisher = NULL;
        }
    }

    return newPublisher;
}
Example #14
0
void
_DataReaderNotifyListener(
    _DataReader _this,
    gapi_statusMask triggerMask)
{
    _Status status;
    gapi_object source;
    gapi_returnCode_t result;

    if (_this == NULL) {
        OS_REPORT(OS_ERROR,
                  "_DataReaderNotifyListener",0,
                  "Specified DataReader = NULL.");
        return;
    }
    status = _EntityStatus(_this);
    source = _EntityHandle(_this);

    while ( _this && (triggerMask != GAPI_STATUS_KIND_NULL) ) {
        if ( triggerMask & GAPI_DATA_AVAILABLE_STATUS ) {
            /* The behaviour for the triggering of data_on_readers and
             * data_available is described in the DDS specification:
             * first, the middleware tries to trigger the SubscriberListener
             * operation on_data_on_readers with a parameter of the related
             * Subscriber;
             * if this does not succeed (no listener or operation non-enabled),
             * it tries to trigger on_data_available on all the related
             * DataReaderListener objects, with as parameter the related DataReader.
             * This is implemented by the following if else block.
             */
            if (!_StatusNotifyDataOnReaders(status, source)) {
                _StatusNotifyDataAvailable(status, source);
            }
            triggerMask &= ~GAPI_DATA_AVAILABLE_STATUS;
        }
        if ( triggerMask & GAPI_SAMPLE_REJECTED_STATUS ) {
            gapi_sampleRejectedStatus info;

            result = _DataReader_get_sample_rejected_status(_this, &info);
            /* Only allow the callback if there is a change since the last
             * callback, i.e if total_count_change is non zero
             */
            if (result == GAPI_RETCODE_OK && info.total_count_change != 0) {
                _StatusNotifySampleRejected(status, source, &info);
            }
            triggerMask &= ~GAPI_SAMPLE_REJECTED_STATUS;
        }
        if ( triggerMask & GAPI_LIVELINESS_CHANGED_STATUS ) {
            gapi_livelinessChangedStatus info;

            result = _DataReader_get_liveliness_changed_status(_this, &info);
            /* Only allow the callback if there is a change since the last
             * callback, i.e if either alive_count_change or
             * not_alive_count_change are non zero.
             */
            if (result == GAPI_RETCODE_OK &&
                (info.alive_count_change != 0 ||
                 info.not_alive_count_change != 0))
            {
                _StatusNotifyLivelinessChanged(status, source, &info);
            }
            triggerMask &= ~GAPI_LIVELINESS_CHANGED_STATUS;
        }
        if ( triggerMask & GAPI_REQUESTED_DEADLINE_MISSED_STATUS ) {
            gapi_requestedDeadlineMissedStatus info;

            result = _DataReader_get_requested_deadline_missed_status(_this, &info);
            /* Only allow the callback if there is a change since the last
             * callback, i.e if total_count_change is non zero
             */
            if (result == GAPI_RETCODE_OK && info.total_count_change != 0) {
                _StatusNotifyRequestedDeadlineMissed(status, source, &info);
            }
            triggerMask &= ~GAPI_REQUESTED_DEADLINE_MISSED_STATUS;
        }
        if ( triggerMask & GAPI_REQUESTED_INCOMPATIBLE_QOS_STATUS ) {
            gapi_requestedIncompatibleQosStatus info;
            gapi_qosPolicyCount policyCount[MAX_POLICY_COUNT_ID];

            info.policies._maximum = MAX_POLICY_COUNT_ID;
            info.policies._length  = 0;
            info.policies._buffer  = policyCount;

            result = _DataReader_get_requested_incompatible_qos_status(_this, &info);
            /* Only allow the callback if there is a change since the last
             * callback, i.e if total_count_change is non zero
             */
            if (result == GAPI_RETCODE_OK && info.total_count_change != 0) {
                _StatusNotifyRequestedIncompatibleQos(status, source, &info);
            }
            triggerMask &= ~GAPI_REQUESTED_INCOMPATIBLE_QOS_STATUS;
        }
        if ( triggerMask & GAPI_SAMPLE_LOST_STATUS ) {
            gapi_sampleLostStatus info;

            result = _DataReader_get_sample_lost_status (_this, &info);
            /* Only allow the callback if there is a change since the last
             * callback, i.e if total_count_change is non zero
             */
            if (result == GAPI_RETCODE_OK && info.total_count_change != 0) {
                _StatusNotifySampleLost(status, source, &info);
            }
            triggerMask &= ~GAPI_SAMPLE_LOST_STATUS;
        }
        if ( triggerMask & GAPI_SUBSCRIPTION_MATCH_STATUS ) {
            gapi_subscriptionMatchedStatus info;

            result = _DataReader_get_subscription_matched_status (_this, &info);
            /* Only allow the callback if there is a change since the last
             * callback, i.e if total_count_change is non zero
             */
            if (result == GAPI_RETCODE_OK && info.current_count_change != 0) {
                _StatusNotifySubscriptionMatch(status, source, &info);
            }
            triggerMask &= ~GAPI_SUBSCRIPTION_MATCH_STATUS;
        }
    }
}
Example #15
0
c_bool
_DataReaderInit (
    _DataReader _this,
    const _Subscriber subscriber,
    const _TopicDescription topicDescription,
    const _TypeSupport typesupport,
    const struct gapi_dataReaderListener *a_listener,
    const gapi_statusMask mask,
    const u_dataReader uReader)
{
    c_bool noError;

    noError = ((_this != NULL) &&
               (topicDescription != NULL) &&
               (typesupport != NULL) &&
               (uReader != NULL));

    if (noError) {
        _EntityInit(_Entity(_this),
                          _Entity(subscriber));

        U_DATAREADER_SET(_this, uReader);
        u_entityAction(u_entity(uReader),getCopyInfo,_this);

        _this->topicDescription = topicDescription;

        if ( a_listener ) {
            _this->_Listener = *a_listener;
        } else {
            memset(&_this->_Listener, 0,
                   sizeof(_this->_Listener));
        }

        _this->readerCopy = _TypeSupportGetReaderCopy(typesupport);
        if (_this->readerCopy == NULL) {
            _this->readerCopy = _DataReaderCopy;
        }
        _this->copy_in = _TypeSupportCopyIn (typesupport);
        _this->copy_out = _TypeSupportCopyOut (typesupport);
        _this->copy_cache = _TypeSupportCopyCache (typesupport);
        _this->allocSize = _TypeSupportTopicAllocSize(typesupport);
        _this->allocBuffer = _TypeSupportTopicAllocBuffer(typesupport);

        _this->reader_mask.sampleStateMask   = (c_long)0;
        _this->reader_mask.viewStateMask     = (c_long)0;
        _this->reader_mask.instanceStateMask = (c_long)0;
    }
    if (noError) {
        _Status status;

        status = _StatusNew(_Entity(_this),
                            STATUS_KIND_DATAREADER,
                            (struct gapi_listener *)a_listener, mask);
        _EntityStatus(_this) = status;
        if (!status) {
            noError = FALSE;
        }
    }
    if (noError) {
        _TopicDescriptionIncUse(topicDescription);
    }
    return noError;
}
Example #16
0
_Subscriber
_BuiltinSubscriberNew (
    u_participant uParticipant,
    _DomainParticipantFactory factory,
    _DomainParticipant participant)
{
    u_subscriber s;
    _Status status;
    _Subscriber newSubscriber = _SubscriberAlloc();
    gapi_handle handle;
    _TypeSupport typeSupport;
    gapi_dataReaderQos rQos;
    long i;

    s = u_participantGetBuiltinSubscriber(uParticipant);

    if (s) {
        newSubscriber = _SubscriberAlloc();

        if (newSubscriber != NULL) {

            _EntityInit(_Entity(newSubscriber), _Entity(participant));

            U_SUBSCRIBER_SET(newSubscriber, s);

            status = _StatusNew(_Entity(newSubscriber),
                                STATUS_KIND_SUBSCRIBER,
                                NULL, 0);
            if (status) {
                for ( i = 0; i < MAX_BUILTIN_TOPIC; i++ ) {
                    _DataReader reader = NULL;
                    _Topic topic = NULL;

                    typeSupport = _DomainParticipantFindTypeSupport(participant,
                                                                    _BuiltinTopicTypeName(i));
                    if (typeSupport) {
                        c_iter uTopicList;
                        u_topic uTopic;

                        uTopicList = u_participantFindTopic(uParticipant,
                                                            _BuiltinTopicName(i),
                                                            C_TIME_ZERO);
                        uTopic = c_iterTakeFirst(uTopicList);
                        if (uTopic) {
                            topic = _TopicFromKernelTopic(uTopic,
                                                          _BuiltinTopicName(i),
                                                          _BuiltinTopicTypeName(i),
                                                          typeSupport,
                                                          participant,
                                                          NULL);
                            while (uTopic) {
                                uTopic = c_iterTakeFirst(uTopicList);
                                /* multiple instances should not occure but
                                 * just in case this loop frees all references.
                                 */
                                assert(uTopic == NULL);
                                u_entityFree(u_entity(uTopic));
                            }
                        } else {
                            OS_REPORT_2(OS_WARNING,"_BuiltinSubscriberNew",0,
                                        "failed to resolve User layer Topic "
                                        "'%s' for Participant 0x%x",
                                        _BuiltinTopicName(i), participant);
                        }
                    } else {
                        OS_REPORT_2(OS_WARNING,"_BuiltinSubscriberNew",0,
                                    "Builtin TypeSupport for type '%s' is not "
                                    "yet registered for Participant 0x%x",
                                    _BuiltinTopicTypeName(i), participant);
                    }

                    if (topic) {
                        initBuiltinDataReaderQos(&rQos);
                        reader = _DataReaderNew(_TopicDescription(topic),
                                                typeSupport,
                                                &rQos,
                                                NULL, 0,
                                                newSubscriber);

                        _EntityRelease(topic);
                    } else {
                        OS_REPORT_2(OS_WARNING,"_BuiltinSubscriberNew",0,
                                    "failed to create Builtin Topic '%s' "
                                    "for Participant 0x%x",
                                    _BuiltinTopicName(i), participant);
                    }

                    if ( reader ) {
                        _ENTITY_REGISTER_OBJECT(_Entity(newSubscriber),
                                                (_Object)reader);
                        handle = _EntityRelease(reader);
                        gapi_entity_enable(handle);
                    }
                }
                newSubscriber->builtin = TRUE;
                _EntityStatus(newSubscriber) = status;
            } else {
                _EntityDispose(_Entity(newSubscriber));
                newSubscriber = NULL;
            }
        }
    }
    return newSubscriber;
}
Example #17
0
_Subscriber
_SubscriberNew (
    u_participant uParticipant,
    const gapi_subscriberQos  *qos,
    const struct gapi_subscriberListener *a_listener,
    const gapi_statusMask mask,
    const _DomainParticipant participant)
{
    _Subscriber newSubscriber;
    v_subscriberQos subscriberQos;
    gapi_long len;

    assert(uParticipant);
    assert(qos);
    assert(participant);

    newSubscriber = _SubscriberAlloc();

    if ( newSubscriber != NULL ) {
        _EntityInit(_Entity(newSubscriber),
                          _Entity(participant));
        gapi_dataReaderQosCopy (&gapi_dataReaderQosDefault,
                                &newSubscriber->_defDataReaderQos);
        if ( a_listener ) {
            newSubscriber->_Listener = *a_listener;
        }
    }

    if  (newSubscriber != NULL ) {
        subscriberQos = u_subscriberQosNew(NULL);
        if ( subscriberQos != NULL ) {
            if ( !copySubscriberQosIn(qos, subscriberQos) ) {
                _EntityDispose(_Entity(newSubscriber));
                newSubscriber = NULL;
            }
        } else {
            _EntityDispose(_Entity(newSubscriber));
            newSubscriber = NULL;
        }
    }

    if ( newSubscriber != NULL) {
        u_subscriber uSubscriber;
        uSubscriber = u_subscriberNew(uParticipant, "subscriber", subscriberQos, FALSE);
        u_subscriberQosFree(subscriberQos);
        if ( uSubscriber != NULL ) {
            U_SUBSCRIBER_SET(newSubscriber, uSubscriber);
        } else {
            _EntityDispose(_Entity(newSubscriber));
            newSubscriber = NULL;
        }
    }

    if ( newSubscriber != NULL) {
        _Status status;

        status = _StatusNew(_Entity(newSubscriber),
                            STATUS_KIND_SUBSCRIBER,
                            (struct gapi_listener *)a_listener, mask);
        if (status) {
            _EntityStatus(newSubscriber) = status;
            len = (gapi_long)qos->partition.name._length;
            if ( qos->partition.name._length == 0UL ) {
                /*
                 * behaviour of the kernel in case of an empty sequence
                 * is that it is related to none of the partitions,
                 * while DCPS expects it to be conected to all partitions.
                 * Therefore this has to be done seperately.
                 */
                u_subscriberSubscribe (U_SUBSCRIBER_GET(newSubscriber), "");
            }
            newSubscriber->builtin = FALSE;
        } else {
            u_subscriberFree(U_SUBSCRIBER_GET(newSubscriber));
            _EntityDispose(_Entity(newSubscriber));
            newSubscriber = NULL;
        }
    }

    return newSubscriber;
}