DDS::ReturnCode_t DDS::OpenSplice::DataReaderView::nlReq_init ( DDS::OpenSplice::DataReader *reader, const char *name, const DDS::DataReaderViewQos &qos) { DDS::ReturnCode_t result; u_dataViewQos uQos = NULL; u_dataView uView = NULL; assert (reader != NULL); assert (name != NULL); /* qos consistency already checked in create_view */ assert (DDS::OpenSplice::Utils::qosIsConsistent(qos) == DDS::RETCODE_OK); uQos = u_dataViewQosNew(NULL); if (uQos) { result = DDS::OpenSplice::Utils::copyQosIn(qos, uQos); if (result == DDS::RETCODE_OK) { uView = u_dataViewNew( u_dataReader(reader->rlReq_get_user_entity()), name, uQos); if (uView) { result = DDS::OpenSplice::Entity::nlReq_init (u_entity (uView)); if (result == DDS::RETCODE_OK) { (void) DDS::DataReader::_duplicate(reader); this->pimpl->reader = reader; setDomainId(reader->getDomainId()); } if (result == DDS::RETCODE_OK) { result = this->pimpl->conditions->init(); } } else { result = DDS::RETCODE_OUT_OF_RESOURCES; CPP_REPORT(result, "Could not create DataReaderView."); } } u_dataViewQosFree(uQos); } else { result = DDS::RETCODE_OUT_OF_RESOURCES; CPP_REPORT(result, "Could not copy DataReaderViewQos."); } return result; }
DDS::ReturnCode_t DDS::OpenSplice::ReadCondition::nlReq_init ( DDS::OpenSplice::Entity *reader, DDS::SampleStateMask sample_states, DDS::ViewStateMask view_states, DDS::InstanceStateMask instance_states) { DDS::ReturnCode_t result = DDS::RETCODE_OK; u_reader uReader = NULL; u_sampleMask mask = statesMask(sample_states, view_states, instance_states); const os_char *kind; this->reader = reader; this->sample_states = sample_states; this->view_states = view_states; this->instance_states = instance_states; result = DDS::OpenSplice::Condition::nlReq_init(); if (result == DDS::RETCODE_OK) { setDomainId(reader->getDomainId()); if (reader->rlReq_get_kind() == DATAREADERVIEW) { uReader = u_reader(dynamic_cast<DataReaderView*>(reader)->rlReq_get_user_entity ()); kind = "DataReaderView"; } else { assert (reader->rlReq_get_kind() == DATAREADER); uReader = u_reader(dynamic_cast<DataReader*>(reader)->rlReq_get_user_entity ()); kind = "DataReader"; } if (uReader) { if (this->uQuery == NULL) { // Query condition can initialize uQuery before ReadCondition::nlReq_init is called // from QueryCondition::nlReq_init. In that case, do not create a query here this->uQuery = u_queryNew(uReader, NULL, "1=1", NULL, 0, mask); if (this->uQuery == NULL) { result = DDS::RETCODE_ERROR; CPP_REPORT(result, "Could not create ReadCondition."); } } } else { result = DDS::RETCODE_BAD_PARAMETER; CPP_REPORT(result, "%s is not initialized.", kind); } } return result; }
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; }