/* 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); }
const char * _BuiltinFindTopicName ( _Entity entity) { const char *name = NULL; switch (_ObjectGetKind(_Object(entity))) { case OBJECT_KIND_DOMAINPARTICIPANT: name = builtinTopicTypeInfo[_BUILTIN_PARTICIPANT_INFO].topicName; break; case OBJECT_KIND_TOPIC: name = builtinTopicTypeInfo[_BUILTIN_TOPIC_INFO].topicName; break; case OBJECT_KIND_DATAWRITER: name = builtinTopicTypeInfo[_BUILTIN_PUBLICATION_INFO].topicName; break; case OBJECT_KIND_DATAREADER: name = builtinTopicTypeInfo[_BUILTIN_SUBSCRIPTION_INFO].topicName; break; default: break; } return name; }
gapi_returnCode_t _ReadConditionFree( _ReadCondition readcondition) { gapi_returnCode_t result = GAPI_RETCODE_OK; if (_ObjectGetKind(_Object(readcondition)) == OBJECT_KIND_QUERYCONDITION ) { _QueryConditionFree((_QueryCondition)readcondition); } else { _ReadConditionDispose(readcondition); } return result; }
void _ConditionDispose( _Condition _this) { gapi_waitSet waitset; waitset = c_iterTakeFirst(_this->waitsets); while (waitset) { gapi_condition handle = _EntityRelease(_this); gapi_waitSet_detach_condition(waitset, handle); _this = gapi_conditionClaim(handle, NULL); waitset = c_iterTakeFirst(_this->waitsets); } c_iterFree(_this->waitsets); if (_ObjectGetKind(_Object(_this)) != OBJECT_KIND_GUARDCONDITION) { _EntityDelete(_this); } }
void _ConditionFree( _Condition _this) { switch (_ObjectGetKind(_Object(_this))) { case OBJECT_KIND_QUERYCONDITION: _QueryConditionFree((_QueryCondition)_this); break; case OBJECT_KIND_READCONDITION: _ReadConditionFree((_ReadCondition)_this); break; case OBJECT_KIND_STATUSCONDITION: _StatusConditionFree((_StatusCondition)_this); break; case OBJECT_KIND_GUARDCONDITION: _GuardConditionFree(_this); break; default: assert(0); break; } }
_DataReader _DataReaderNew ( const _TopicDescription topicDescription, const _TypeSupport typesupport, const gapi_dataReaderQos *qos, const struct gapi_dataReaderListener *a_listener, const gapi_statusMask mask, const _Subscriber subscriber) { _DataReader _this; v_readerQos readerQos; u_dataReader uReader; gapi_string topicName; char dataReaderId[256]; c_bool noError = TRUE; readerQos = u_readerQosNew(NULL); if ( readerQos != NULL ) { if ( gapi_kernelReaderQosCopyIn(qos, readerQos) ) { q_expr expr; c_value *params; topicName = _TopicDescriptionGetName (topicDescription); if (topicName) { snprintf (dataReaderId, sizeof(dataReaderId), "%sReader", topicName); gapi_free (topicName); } else { snprintf (dataReaderId, sizeof(dataReaderId), "dataReader"); } expr = _TopicDescriptionGetExpr(topicDescription); if (_ObjectGetKind(_Object(topicDescription)) == OBJECT_KIND_CONTENTFILTEREDTOPIC) { params = _ContentFilteredTopicParameters( (_ContentFilteredTopic)topicDescription); } else { params = NULL; } uReader = u_dataReaderNew(_SubscriberUsubscriber(subscriber), dataReaderId, expr, params, readerQos, FALSE); q_dispose(expr); os_free(params); noError = (uReader != NULL); if (noError) { _this = _DataReaderAlloc(); if ( _this != NULL ) { noError = _DataReaderInit(_this, subscriber, topicDescription, typesupport, a_listener, mask, uReader); if (!noError) { _EntityDispose(_Entity(_this)); } } if (!noError) { u_dataReaderFree(uReader); } } } else { noError = FALSE; } u_readerQosFree(readerQos); } else { noError = FALSE; } if (!noError) { _this = NULL; } return _this; }
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; }