u_result u__topicDeinitW( void *_this) { u_result result; u_topic topic; assert(_this != NULL); topic = u_topic(_this); result = u__entityDeinitW(_this); if (result == U_RESULT_OK) { if (topic->name) { os_free(topic->name); topic->name = NULL; } } else { OS_REPORT(OS_WARNING, "u__topicDeinitW", result, "Operation u__topicDeinitW failed. " "Topic = 0x%"PA_PRIxADDR"", (os_address)_this); } return result; }
c_char* cmx_writerNew( const c_char* publisher, const c_char* name, const c_char* topic, const c_char* qos) { u_publisher pub; u_topic top; u_writer wri; c_char* result; cmx_entityArg arg; u_result ur; cmx_entityKernelArg kernelArg; v_writerQos wQos; result = NULL; pub = u_publisher(cmx_entityUserEntity(publisher)); if(pub != NULL){ top = u_topic(cmx_entityUserEntity(topic)); if(top != NULL){ kernelArg = cmx_entityKernelArg(os_malloc(C_SIZEOF(cmx_entityKernelArg))); u_entityAction(u_entity(pub), cmx_entityKernelAction, (c_voidp)kernelArg); if(qos != NULL){ wQos = v_writerQos(cmx_qosKernelQosFromKind(qos, K_WRITER, c_getBase(c_object(kernelArg->kernel)))); if(wQos == NULL){ wQos = v_writerQosNew(kernelArg->kernel, NULL); wQos->reliability.kind = V_RELIABILITY_RELIABLE; } } else { wQos = v_writerQosNew(kernelArg->kernel, NULL); wQos->reliability.kind = V_RELIABILITY_RELIABLE; } wri = u_writerNew(pub, name, top, NULL, wQos, TRUE); os_free(kernelArg); c_free(wQos); if(wri != NULL){ cmx_registerEntity(u_entity(wri)); arg = cmx_entityArg(os_malloc(C_SIZEOF(cmx_entityArg))); arg->entity = u_entity(wri); arg->create = FALSE; arg->participant = NULL; arg->result = NULL; ur = u_entityAction(u_entity(wri), cmx_entityNewFromAction, (c_voidp)(arg)); if(ur == U_RESULT_OK){ result = arg->result; os_free(arg); } } } } return result; }
u_topic DJA_DCPSUtilityBridge_us_createTopic( DLRL_Exception* exception, void* userData, DK_ObjectHomeAdmin* home, LOC_char* topicName, LOC_char* typeName, void** topicUserData, void** ls_topic, LOC_boolean isMainTopic) { /* JNI thread env */ JNIEnv* env = (JNIEnv*)userData; /* Cached JNI data used within this call */ jmethodID createTopicMid = cachedJNI.dcpsUtil_createTopic_mid; /* java topic entity description */ jobject jtopic = NULL; /* needed string representations of topic name and type */ jstring jtypeName = NULL; jstring jtopicName = NULL; /* the java object home */ jobject ls_objectHome = NULL; jobject ls_participant = NULL; DJA_CachedJNITypedObject* typedObjectCachedData = NULL; DJA_CachedJNITypedTopic* typedTopicCachedData = NULL; gapi_topic gapiTopic = NULL; _Topic _topic = NULL; gapi_returnCode_t result = GAPI_RETCODE_OK; u_topic utopic = NULL; DLRL_INFO(INF_ENTER); assert(exception); assert(userData); assert(home); assert(topicName); assert(typeName); /* get java objects */ /* the cache getter on the object home doesnt require a release on the returned pointer */ ls_participant = (jobject)DK_CacheAdmin_us_getLSParticipant(DK_ObjectHomeAdmin_us_getCache(home)); ls_objectHome = (jobject)DK_ObjectHomeAdmin_us_getLSHome(home); typedObjectCachedData = (DJA_CachedJNITypedObject*)DK_ObjectHomeAdmin_us_getUserData(home); if(isMainTopic) { typedTopicCachedData = DJA_Initialisation_loadTypedTopicCache(exception, env, typedObjectCachedData, home, ls_objectHome); DLRL_Exception_PROPAGATE(exception); *topicUserData = (void*)typedTopicCachedData; } jtypeName = (*env)->NewStringUTF(env, typeName); DLRL_JavaException_PROPAGATE(env, exception); jtopicName = (*env)->NewStringUTF(env, topicName); DLRL_JavaException_PROPAGATE(env, exception); DLRL_INFO(INF_CALLBACK, "objectHome->createTopic(participant, topicName, typeName)"); jtopic = (*env)->CallStaticObjectMethod(env, cachedJNI.dcpsUtil_class, createTopicMid, ls_participant, jtopicName, jtypeName); DLRL_JavaException_PROPAGATE(env, exception); if(!jtopic){ DLRL_Exception_THROW(exception, DLRL_DCPS_ERROR, "Unable to create the DCPS topic with name '%s' and type '%s' " "Check DCPS error log file for (possibly) more information.", topicName, typeName); } DLRL_INFO(INF_DCPS, "saj_read_gapi_address(topic)"); gapiTopic = jtopic? (gapi_topic)saj_read_gapi_address(env, jtopic) : NULL; if(!gapiTopic){ DLRL_Exception_THROW(exception, DLRL_DCPS_ERROR, "Unable to create the DCPS Topic entity for " "topic %s with type %s of %s '%p'. " "Check DCPS error log file for (possibly) more " "information.", DLRL_VALID_NAME(topicName), DLRL_VALID_NAME(typeName), "DK_ObjectHomeAdmin", home); } _topic = gapi_topicClaim(gapiTopic, &result); DLRL_Exception_PROPAGATE_GAPI_RESULT(exception, result, "Failed to claim the topic handle"); utopic = _TopicUtopic(_topic); if(utopic) { /* now create a proxy to this user layer topic which can be used by the DLRL * in a safe manner, as the user layer topic returned by the _TopicUtopic * operation is owned by the gapi. */ utopic = u_topic(DK_DCPSUtility_ts_createProxyUserEntity(exception, u_entity(utopic))); } _EntityRelease(_topic);/* before the propagate */ DLRL_Exception_PROPAGATE(exception);/* after the release */ if(!utopic){ DLRL_Exception_THROW(exception, DLRL_DCPS_ERROR, "Unable to create the DCPS Topic entity for " "topic %s with type %s of %s '%p'. " "Check DCPS error log file for (possibly) more " "information.", DLRL_VALID_NAME(topicName), DLRL_VALID_NAME(typeName), "DK_ObjectHomeAdmin", home); } *ls_topic = (void*)(*(env))->NewGlobalRef (env, jtopic); if(!(*ls_topic)) { u_entityFree(u_entity(utopic)); utopic = NULL; DLRL_Exception_THROW(exception, DLRL_OUT_OF_MEMORY, "Unable to create a global ref for the " "type specific topic class."); } DLRL_Exception_EXIT(exception); if((exception->exceptionID != DLRL_NO_EXCEPTION) && typedTopicCachedData){ DJA_Initialisation_us_destroyTypedTopicCache(env, typedTopicCachedData); *topicUserData = NULL; } if(jtopic){ (*env)->DeleteLocalRef(env, jtopic); } if(jtopicName){ (*env)->DeleteLocalRef(env, jtopicName); } if(jtypeName){ (*env)->DeleteLocalRef(env, jtypeName); } /* returning NULL means an error has occured */ DLRL_INFO(INF_EXIT); return utopic; }