Esempio n. 1
0
void
_DataReaderTriggerNotify (
    _DataReader _this)
{
    _Status status;
    gapi_listener_DataAvailableListener callback;
    void *listenerData;
    gapi_object handle;

    assert(_this);

    status = _Entity(_this)->status;
    callback     = status->callbackInfo.on_data_available;
    listenerData = status->callbackInfo.listenerData;

    if ( callback && listenerData ) {
        if (u_dataReaderDataAvailableTest(U_DATAREADER_GET(_this))) {
            handle = _EntityHandle(_this);
            _EntitySetBusy(_this);
            _EntityRelease(_this);
            callback(listenerData, handle);
            gapi_objectClearBusy(handle);
            (void)gapi_dataReaderClaim(handle, NULL);
        }
    }
}
/*     DomainParticipant
 *     get_participant();
 */
gapi_domainParticipant
gapi_topicDescription_get_participant (
    gapi_topicDescription _this)
{
    _TopicDescription topicDescription;
    _Topic topic;
    _DomainParticipant participant = NULL;
    
    topicDescription = gapi_topicDescriptionClaim(_this, NULL);   

    if ( topicDescription != NULL ) {
        /* all entities except for content filtered topics have a reference
         * to a user layer entity. So except for content filtered topics
         * entities get their participant from the user layer entity.
         * Content filters instead do this via the related topic.
         */
        if (_ObjectGetKind(_Object(topicDescription)) == OBJECT_KIND_CONTENTFILTEREDTOPIC) {
            topic = _ContentFilteredTopicGetRelatedTopic(_ContentFilteredTopic(topicDescription));
            participant = _EntityParticipant(_Entity(topic));
        } else {
            participant = _EntityParticipant(_Entity(topicDescription));
        }
    }

    _EntityRelease(topicDescription);
     
    return (gapi_domainParticipant)_EntityHandle(participant);
}
Esempio n. 3
0
gapi_topicDescription
gapi_dataReader_get_topicdescription (
    gapi_dataReader _this)
{
    gapi_topicDescription topicDescription = NULL;
    _DataReader datareader;

    datareader = gapi_dataReaderClaim(_this, NULL);
    if ( datareader != NULL ) {
        topicDescription = (gapi_topicDescription)_EntityHandle(datareader->topicDescription);
        _EntityRelease(datareader);
    }
    return topicDescription;
}
Esempio n. 4
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);
    }
}
Esempio n. 5
0
/*     DataReaderView
 *     get_datareaderview();
 */
gapi_dataReader
gapi_readCondition_get_datareaderview(
    gapi_readCondition _this)
{
    _ReadCondition readcondition;
    _DataReaderView dataReaderView = (_DataReaderView)0;

    readcondition = gapi_readConditionClaim(_this, NULL);
    if (readcondition != NULL) {
        dataReaderView = readcondition->dataReaderView;
    }
    _EntityRelease(readcondition);

    return (gapi_dataReaderView)_EntityHandle(dataReaderView);
}
Esempio n. 6
0
/*     DataReader
 *     get_datareader();
 */
gapi_dataReader
gapi_readCondition_get_datareader(
    gapi_readCondition _this)
{
    _ReadCondition readcondition;
    _DataReader dataReader = (_DataReader)0;

    readcondition = gapi_readConditionClaim(_this, NULL);
    if (readcondition != NULL) {
        dataReader = readcondition->dataReader;
    }
    _EntityRelease(readcondition);

    return (gapi_dataReader)_EntityHandle(dataReader);
}
Esempio n. 7
0
gapi_domainParticipant
gapi_subscriber_get_participant (
    gapi_subscriber _this)
{
    _Subscriber subscriber;
    _DomainParticipant participant = NULL;

    subscriber = gapi_subscriberClaim(_this, NULL);

    if ( subscriber != NULL) {
        participant = _EntityParticipant(_Entity(subscriber));
        _EntityRelease(subscriber);
    }

    return (gapi_domainParticipant)_EntityHandle(participant);
}
Esempio n. 8
0
gapi_domainParticipant
gapi_publisher_get_participant (
    gapi_publisher _this)
{
    _Publisher publisher;
    _DomainParticipant participant = NULL;

    publisher  = gapi_publisherClaim(_this, NULL);

    if ( publisher != NULL ) {
        participant = _EntityParticipant(_Entity(publisher));
    }

    _EntityRelease(publisher);

    return (gapi_domainParticipant)_EntityHandle(participant);
}
Esempio n. 9
0
gapi_returnCode_t
_SubscriberDeleteContainedEntities (
    _Subscriber _this)
{
    gapi_dataReader handle;
    gapi_returnCode_t result = GAPI_RETCODE_OK;
    _DataReader dataReader;
    c_iter readers;
    u_dataReader r;
    gapi_context context;

    GAPI_CONTEXT_SET(context, _EntityHandle(_this), GAPI_METHOD_DELETE_CONTAINED_ENTITIES);

    if ( _this ) {
        readers = u_subscriberLookupReaders(U_SUBSCRIBER_GET(_this),NULL);

        r = c_iterTakeFirst(readers);
        while (r) {
            handle = u_entityGetUserData(u_entity(r));
            result = gapi_dataReader_delete_contained_entities(handle);
            if (result == GAPI_RETCODE_OK) {
                dataReader = gapi_dataReaderClaimNB(handle,&result);
                if (dataReader) {
                    if ( _DataReaderPrepareDelete(dataReader, &context) ) {
                        _DataReaderFree(dataReader);
                    } else if (result == GAPI_RETCODE_OK) {
                        result = GAPI_RETCODE_PRECONDITION_NOT_MET;
                    }
                }
            } else if (result == GAPI_RETCODE_ALREADY_DELETED) {
                result = GAPI_RETCODE_OK;
            }
            r = c_iterTakeFirst(readers);
        }
        c_iterFree(readers);
    }
    return result;
}
Esempio n. 10
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;
        }
    }
}
Esempio n. 11
0
gapi_dataWriter
gapi_publisher_create_datawriter (
    gapi_publisher _this,
    const gapi_topic a_topic,
    const gapi_dataWriterQos *qos,
    const struct gapi_dataWriterListener *a_listener,
    const gapi_statusMask mask)
{
    _Publisher publisher;
    _DataWriter datawriter = NULL;
    gapi_dataWriter result = NULL;
    _Topic          topic  = NULL;
    gapi_dataWriterQos *writerQos;
    gapi_context context;
    gapi_topicQos* topicQos;
    gapi_returnCode_t rc;

    GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_CREATE_DATAWRITER);

    publisher = gapi_publisherClaim(_this, NULL);

    if ( publisher ) {
        topic = _TopicFromHandle(a_topic);
    }

    if ( topic ) {
        if ( qos == GAPI_DATAWRITER_QOS_DEFAULT ) {
            writerQos = &publisher->_defDataWriterQos;
        } else if ( qos == GAPI_DATAWRITER_QOS_USE_TOPIC_QOS ) {
            topicQos = gapi_topicQos__alloc();
            writerQos = gapi_dataWriterQos__alloc();
            gapi_dataWriterQosCopy(&publisher->_defDataWriterQos, writerQos);
            _TopicGetQos(topic, topicQos);
            gapi_mergeTopicQosWithDataWriterQos(topicQos,writerQos);
            gapi_free(topicQos);
        } else {
            writerQos = (gapi_dataWriterQos *)qos;
        }

        rc = gapi_dataWriterQosIsConsistent(writerQos, &context);

        if ( rc == GAPI_RETCODE_OK ) {
            gapi_char *typeName;
            gapi_char *topicName;
            _DomainParticipant participant;
            _TypeSupport typeSupport = NULL;

            /* find topic with the participant for consistency */
            typeName  = _TopicGetTypeName(topic);
            topicName = _TopicGetName(topic);
            participant = _EntityParticipant(_Entity(publisher));

            /* find type support for the data type to find data writer create function */
            typeSupport = _DomainParticipantFindType(participant, typeName);
            if(typeSupport)
            {
                /* if create function is NULL, take default from data writer */
                datawriter = _DataWriterNew(topic,
                                            typeSupport,
                                            writerQos,
                                            a_listener,
                                            mask,
                                            publisher);
                if ( datawriter ) {
                    _ENTITY_REGISTER_OBJECT(_Entity(publisher),
                                            (_Object)datawriter);
                }
            }else{
                OS_REPORT_1(OS_WARNING,
                            "gapi_publisher_create_datawriter", 0,
                            "TypeSupport %s not found !",
                            typeName);
            }

            gapi_free(typeName);
            gapi_free(topicName);
        }

        if (qos == GAPI_DATAWRITER_QOS_USE_TOPIC_QOS) {
            gapi_free(writerQos);
        }
    }

    _EntityRelease(publisher);

    if ( datawriter ) {
        gapi_object statusHandle;
        statusHandle = _EntityHandle(_Entity(datawriter)->status);
        result = (gapi_dataWriter)_EntityRelease(datawriter);
    }

    return result;
}
Esempio n. 12
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;
        }
    }
}
Esempio n. 13
0
gapi_dataReader
gapi_subscriber_create_datareader (
    gapi_subscriber _this,
    const gapi_topicDescription a_topic,
    const gapi_dataReaderQos *qos,
    const struct gapi_dataReaderListener *a_listener,
    const gapi_statusMask mask)
{
    _Subscriber         subscriber;
    _DataReader         datareader       = NULL;
    gapi_dataReader     result           = NULL;
    _TopicDescription   topicDescription = NULL;
    gapi_dataReaderQos *readerQos;
    gapi_context        context;
    gapi_topicQos* topicQos;

    GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_CREATE_DATAREADER);

    subscriber = gapi_subscriberClaim(_this, NULL);

    if ( subscriber ) {
        if ( !subscriber->builtin ) {
            topicDescription = _TopicDescriptionFromHandle(a_topic);
        }
    }

    if ( topicDescription ) {
        if ( qos == GAPI_DATAREADER_QOS_DEFAULT ) {
            readerQos = &subscriber->_defDataReaderQos;
        } else if ( qos == GAPI_DATAREADER_QOS_USE_TOPIC_QOS ) {
            _Topic topic = NULL;
            switch(_ObjectGetKind(_Object(topicDescription))) {
            case OBJECT_KIND_TOPIC:
                topic = _Topic(topicDescription);
            break;
            case OBJECT_KIND_CONTENTFILTEREDTOPIC:
                topic = _ContentFilteredTopicGetRelatedTopic(_ContentFilteredTopic(topicDescription));
            break;
            default:
                topic = NULL;
            break;
            }
            if ( topic ) {
                topicQos = gapi_topicQos__alloc();
                readerQos = gapi_dataReaderQos__alloc();
                gapi_dataReaderQosCopy(&subscriber->_defDataReaderQos, readerQos);
                _TopicGetQos(topic, topicQos);
                gapi_mergeTopicQosWithDataReaderQos(topicQos,readerQos);
                gapi_free(topicQos);
            } else {
                readerQos = (gapi_dataReaderQos *)qos;
            }
        } else {
            readerQos = (gapi_dataReaderQos *)qos;
        }

        if (  gapi_dataReaderQosIsConsistent(readerQos, &context) == GAPI_RETCODE_OK ) {
            gapi_char *typeName;
            gapi_char *topicName;
            _DomainParticipant participant;
            _TypeSupport typeSupport;

            /* find topic with the participant for consistency */
            typeName  = _TopicDescriptionGetTypeName(topicDescription);
            topicName = _TopicDescriptionGetName(topicDescription);
            participant = _EntityParticipant(_Entity(subscriber));


            /* find type support for the data type to find
             * data reader create function.
             */
            typeSupport = _DomainParticipantFindType(participant, typeName);
            if(typeSupport)
            {          
                /* if create function is NULL, take default from data reader */
                datareader = _DataReaderNew(topicDescription,
                                            typeSupport,
                                            readerQos,
                                            a_listener,
                                            mask,
                                            subscriber);
                if ( datareader ) {
                    _ENTITY_REGISTER_OBJECT(_Entity(subscriber),
                                            (_Object)datareader);
                }
            }else{
                OS_REPORT_1(OS_WARNING,
                            "gapi_subscriber_create_datareader", 0,
                            "TypeSupport %s not found !",
                            typeName);
            }
            
            gapi_free(typeName);
            gapi_free(topicName);
        }

        if (qos == GAPI_DATAREADER_QOS_USE_TOPIC_QOS) {
            gapi_free(readerQos);
        }
    }

    _EntityRelease(subscriber);

    if ( datareader ) {
        gapi_object statusHandle;
        statusHandle = _EntityHandle(_Entity(datareader)->status);
        result = (gapi_dataReader)_EntityRelease(datareader);
    }

    return result;
}