gapi_returnCode_t gapi_dataReader_set_qos ( gapi_dataReader _this, const gapi_dataReaderQos *qos) { gapi_returnCode_t result = GAPI_RETCODE_OK; u_result uResult; _DataReader dataReader; v_readerQos dataReaderQos; gapi_context context; GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_SET_QOS); dataReader = gapi_dataReaderClaim(_this, &result); if ( dataReader ) { if ( qos ) { result = gapi_dataReaderQosIsConsistent(qos, &context); } else { result = GAPI_RETCODE_BAD_PARAMETER; } } if (( result == GAPI_RETCODE_OK ) && (_EntityEnabled(dataReader))){ gapi_dataReaderQos * existing_qos = gapi_dataReaderQos__alloc(); result = gapi_dataReaderQosCheckMutability(qos, _DataReaderGetQos(dataReader, existing_qos), &context); gapi_free(existing_qos); } if ( result == GAPI_RETCODE_OK ) { dataReaderQos = u_readerQosNew(NULL); if (dataReaderQos) { if ( gapi_kernelReaderQosCopyIn(qos, dataReaderQos) ) { uResult = u_entitySetQoS(_EntityUEntity(dataReader), (v_qos)(dataReaderQos) ); result = kernelResultToApiResult(uResult); u_readerQosFree(dataReaderQos); } else { result = GAPI_RETCODE_OUT_OF_RESOURCES; } } else { result = GAPI_RETCODE_OUT_OF_RESOURCES; } } _EntityRelease(dataReader); return result; }
static u_result create_builtin_readers (struct builtin_datareader_set *drset, u_participant p) { v_subscriberQos sQos = NULL; v_readerQos rdQos = NULL; v_gid gid; c_value ps[1]; drset->subscriber = NULL; drset->participant_dr = NULL; drset->subscription_dr = NULL; drset->publication_dr = NULL; if ((sQos = u_subscriberQosNew (NULL)) == NULL) goto fail; sQos->presentation.access_scope = V_PRESENTATION_TOPIC; if ((sQos->partition = os_strdup ("__BUILT-IN PARTITION__")) == NULL) goto fail; if ((rdQos = u_readerQosNew (NULL)) == NULL) goto fail; rdQos->durability.kind = V_DURABILITY_TRANSIENT; rdQos->reliability.kind = V_RELIABILITY_RELIABLE; rdQos->history.kind = V_HISTORY_KEEPLAST; rdQos->history.depth = 1; if ((drset->subscriber = u_subscriberNew (p, "DDSI2BuiltinSubscriber", sQos, TRUE)) == NULL) goto fail; gid = u_entityGid ((u_entity) drset->subscriber); ps[0].kind = V_ULONG; ps[0].is.ULong = gid.systemId; in_printf (IN_LEVEL_INFO, "create_builtin_readers: systemId = %lx\n", (unsigned long) ps[0].is.ULong); if ((drset->participant_dr = u_subscriberCreateDataReader (drset->subscriber, "DCPSParticipantReader", "select * from DCPSParticipant where key.systemId = %0", ps, rdQos, TRUE)) == NULL) goto fail; if ((drset->subscription_dr = u_subscriberCreateDataReader (drset->subscriber, "DCPSSubscriptionReader", "select * from DCPSSubscription where key.systemId = %0", ps, rdQos, TRUE)) == NULL) goto fail; if ((drset->publication_dr = u_subscriberCreateDataReader (drset->subscriber, "DCPSPublicationReader", "select * from DCPSPublication where key.systemId = %0", ps, rdQos, TRUE)) == NULL) goto fail; u_readerQosFree (rdQos); u_subscriberQosFree (sQos); return U_RESULT_OK; fail: destroy_builtin_readers (drset); if (rdQos) u_readerQosFree (rdQos); if (sQos) u_subscriberQosFree (sQos); return U_RESULT_INTERNAL_ERROR; }
/************************************************************** * Protected functions **************************************************************/ v_qos u_qosNew( v_qos tmpl) { v_qos q; q = NULL; if (tmpl != NULL) { switch (tmpl->kind) { case V_PARTITION_QOS: q = (v_qos)u_partitionQosNew((v_partitionQos)tmpl); break; case V_PARTICIPANT_QOS: q = (v_qos)u_participantQosNew((v_participantQos)tmpl); break; case V_TOPIC_QOS: q = (v_qos)u_topicQosNew((v_topicQos)tmpl); break; case V_WRITER_QOS: q = (v_qos)u_writerQosNew((v_writerQos)tmpl); break; case V_READER_QOS: q = (v_qos)u_readerQosNew((v_readerQos)tmpl); break; case V_PUBLISHER_QOS: q = (v_qos)u_publisherQosNew((v_publisherQos)tmpl); break; case V_SUBSCRIBER_QOS: q = (v_qos)u_subscriberQosNew((v_subscriberQos)tmpl); break; case V_DATAVIEW_QOS: q = (v_qos)u_dataViewQosNew((v_dataViewQos)tmpl); break; default: OS_REPORT_1(OS_ERROR, "u_qosNew", 0, "unsupported qos %d", tmpl->kind); break; } } return q; }
_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; }
DDS::ReturnCode_t DDS::OpenSplice::DataReader::nlReq_init ( DDS::OpenSplice::Subscriber *subscriber, const DDS::DataReaderQos &qos, DDS::OpenSplice::TopicDescription *a_topic, const char *name) { DDS::OpenSplice::ContentFilteredTopic *contentFilteredTopic; DDS::ULong i = 0; DDS::ULong length = 0; DDS::ULong bytes = 0; DDS::ReturnCode_t result = DDS::RETCODE_OK; u_readerQos uReaderQos = NULL; u_dataReader uReader = NULL; const char *expression = NULL; c_value *uParameters = NULL; assert (subscriber != NULL); /* Only check for QoS consistency here in debug builds. It's unnecessary to to verify it twice in release builds. */ assert (DDS::OpenSplice::Utils::qosIsConsistent (qos) == DDS::RETCODE_OK); assert (a_topic != NULL); assert (name != NULL); uReaderQos = u_readerQosNew (NULL); if (uReaderQos != NULL) { result = DDS::OpenSplice::Utils::copyQosIn (qos, uReaderQos); } else { result = DDS::RETCODE_OUT_OF_RESOURCES; CPP_REPORT(result, "Could not copy DataReaderQos."); } if (result == DDS::RETCODE_OK) { result = this->pimpl->views->init(); } if (result == DDS::RETCODE_OK) { result = this->pimpl->conditions->init(); } if (result == DDS::RETCODE_OK) { result = a_topic->write_lock(); if (result == DDS::RETCODE_OK) { expression = a_topic->rlReq_get_topic_expression (); assert(expression); switch (a_topic->rlReq_get_kind()) { case DDS::OpenSplice::CONTENTFILTEREDTOPIC: contentFilteredTopic = dynamic_cast<DDS::OpenSplice::ContentFilteredTopic *>(a_topic); if (contentFilteredTopic != NULL) { length = contentFilteredTopic->filterParameters.length (); if(length > 0) { bytes = length * sizeof (struct c_value); uParameters = (c_value *)os_malloc (bytes); for (i = 0; i < length; i++) { const c_string param = (const c_string) contentFilteredTopic->filterParameters[i].in(); uParameters[i] = c_stringValue(param); } } } else { result = DDS::RETCODE_BAD_PARAMETER; CPP_REPORT(result, "a_topic invalid, not of type '%s'", "DDS::OpenSplice::ContentFilteredTopic"); } break; case DDS::OpenSplice::TOPIC: default: uParameters = NULL; break; } } if (result == DDS::RETCODE_OK) { uReader = u_dataReaderNew ( u_subscriber (subscriber->rlReq_get_user_entity ()), name, expression, uParameters, length, uReaderQos); if (uReader == NULL) { result = DDS::RETCODE_OUT_OF_RESOURCES; CPP_REPORT(result, "Could not create DataReader."); } } if (result == DDS::RETCODE_OK) { result = DDS::OpenSplice::Entity::nlReq_init (u_entity (uReader)); if (result == DDS::RETCODE_OK) { (void) DDS::Subscriber::_duplicate(subscriber); this->pimpl->subscriber = subscriber; (void) DDS::TopicDescription::_duplicate(a_topic); this->pimpl->topic = a_topic; a_topic->wlReq_incrNrUsers(); setDomainId(subscriber->getDomainId()); } } a_topic->unlock(); } if (uReaderQos) { u_readerQosFree (uReaderQos); } if (uParameters) { os_free (uParameters); } return result; }