jni_topic jni_topicNew( jni_participant p, const char* name, const char* typeName, const char* keyList, v_topicQos qos) { jni_topic topic; assert(name); assert(typeName); if((p == NULL) || (p->uparticipant == NULL)){ goto err_badParam; } if((topic = os_malloc(sizeof *topic)) == NULL){ goto err_mallocTopic; } jni_topicDescription(topic)->participant = p; if((topic->utopic = u_topicNew(p->uparticipant, name, typeName, keyList, qos)) == NULL){ goto err_u_topicNew; } if((jni_topicDescription(topic)->name = os_strdup(name)) == NULL){ goto err_strdupName; } if((jni_topicDescription(topic)->typeName = os_strdup(typeName)) == NULL){ goto err_strdupTypeName; } if(keyList){ if((jni_topicDescription(topic)->keyList = os_strdup(keyList)) == NULL){ goto err_strdupKeyList; } } else { jni_topicDescription(topic)->keyList = NULL; } return topic; /* Error handling */ err_strdupKeyList: os_free(jni_topicDescription(topic)->typeName); err_strdupTypeName: os_free(jni_topicDescription(topic)->name); err_strdupName: /* Ignore return value since we are already in an error condition. */ (void) u_topicFree(topic->utopic); err_u_topicNew: os_free(topic); err_mallocTopic: err_badParam: return NULL; }
dds::topic::detail::Topic<T>::Topic(const dds::domain::DomainParticipant& dp, const std::string& name, const std::string& type_name, const dds::topic::qos::TopicQos& qos, dds::topic::TopicListener<T>* listener, const dds::core::status::StatusMask& mask) : org::opensplice::topic::TopicDescriptionDelegate(dp, name, type_name), org::opensplice::topic::AnyTopicDelegate(qos, dp, name, type_name) { ISOCPP_REPORT_STACK_NC_BEGIN(); dds::domain::DomainParticipant participant = dds::core::null; /* The dp argument can be nil. Use the participant we know isn't nil because * the TopicDescriptionDelegate would have created it when needed. */ participant = this->domain_participant(); // Set the correct (IDL) type_name in the TopicDescription. org::opensplice::topic::TopicDescriptionDelegate::myTypeName = org::opensplice::topic::TopicTraits<T>::getTypeName(); // get and validate the kernel qos org::opensplice::topic::qos::TopicQosDelegate tQos = qos.delegate(); tQos.check(); u_topicQos uTopicQos = tQos.u_qos(); u_participant uParticipant = participant->registerType( org::opensplice::topic::TopicTraits<T>::getTypeName(), org::opensplice::topic::TopicTraits<T>::getDescriptor(), org::opensplice::topic::TopicTraits<T>::getDataRepresentationId(), org::opensplice::topic::TopicTraits<T>::getTypeHash(), org::opensplice::topic::TopicTraits<T>::getMetaData(), org::opensplice::topic::TopicTraits<T>::getExtentions()); u_topic uTopic = u_topicNew( uParticipant, name.c_str(), org::opensplice::topic::TopicDescriptionDelegate::myTypeName.c_str(), org::opensplice::topic::TopicTraits<T>::getKeyList(), uTopicQos); u_topicQosFree(uTopicQos); if (!uTopic) { ISOCPP_THROW_EXCEPTION(ISOCPP_ERROR, "Failed to create Topic"); } this->userHandle = (u_object)uTopic; this->listener_set((void*)listener, mask); }
d_storeResult d_topicInfoInject( d_topicInfo _this, d_store store, u_participant participant) { d_storeResult result; c_type type; struct baseFind f; u_topic utopic; u_entityAction(u_entity(participant), d_storeGetBase, &f); type = cloneType(c_getBase(_this), f.base, _this->dataType); if(type){ utopic = u_topicNew(participant, _this->name, _this->typeName, _this->keyExpr, _this->qos); if(utopic) { d_storeReport(store, D_LEVEL_FINE, "Topic %s created.\n", _this->name); u_topicFree(utopic); result = D_STORE_RESULT_OK; } else { result = D_STORE_RESULT_METADATA_MISMATCH; d_storeReport(store, D_LEVEL_SEVERE, "Topic '%s' with typeName '%s' and keyList '%s' could NOT be created.\n", _this->name, _this->typeName, _this->keyExpr); OS_REPORT_3(OS_ERROR, "d_topicInfoInject", (os_int32)result, "Topic '%s' with typeName '%s' and keyList '%s' could NOT be created.\n", _this->name, _this->typeName, _this->keyExpr); } } else { result = D_STORE_RESULT_METADATA_MISMATCH; OS_REPORT_1(OS_ERROR, "d_topicInfoInject",(os_int32)result, "Failed to register type '%s'.", _this->typeName); } return result; }