gapi_dataReaderView gapi_dataReader_create_view ( gapi_dataReader _this, const gapi_dataReaderViewQos *qos) { _DataReader datareader = NULL; _DataReaderView view = NULL; gapi_dataReaderViewQos *viewQos; gapi_context context; GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_CREATE_VIEW); datareader = gapi_dataReaderClaim(_this, NULL); if ( datareader && _EntityEnabled(datareader)) { if ( qos == GAPI_DATAVIEW_QOS_DEFAULT ) { viewQos = (gapi_dataReaderViewQos *)&datareader->_defDataReaderViewQos; } else { viewQos = (gapi_dataReaderViewQos *)qos; } if (gapi_dataReaderViewQosIsConsistent(viewQos,&context) == GAPI_RETCODE_OK) { view = _DataReaderViewNew (viewQos, datareader); if ( view ) { _ENTITY_REGISTER_OBJECT(_Entity(datareader), (_Object)view); } } } _EntityRelease(datareader); return (gapi_dataReaderView)_EntityRelease(view); }
gapi_returnCode_t gapi_dataReader_set_listener ( gapi_dataReader _this, const struct gapi_dataReaderListener *a_listener, const gapi_statusMask mask) { gapi_returnCode_t result = GAPI_RETCODE_OK; _DataReader datareader; datareader = gapi_dataReaderClaim(_this, &result); if ( datareader ) { _Status status; if ( a_listener ) { datareader->_Listener = *a_listener; } else { memset(&datareader->_Listener, 0, sizeof(datareader->_Listener)); } status = _EntityStatus(datareader); if ( _StatusSetListener(status, (struct gapi_listener *)a_listener, mask) ) { result = GAPI_RETCODE_OK; } _EntityRelease(datareader); } return result; }
void _DataReaderTriggerNotify ( _DataReader _this) { _Status status; gapi_listener_DataAvailableListener callback; void *listenerData; gapi_object handle; assert(_this); status = _Entity(_this)->status; callback = status->callbackInfo.on_data_available; listenerData = status->callbackInfo.listenerData; if ( callback && listenerData ) { if (u_dataReaderDataAvailableTest(U_DATAREADER_GET(_this))) { handle = _EntityHandle(_this); _EntitySetBusy(_this); _EntityRelease(_this); callback(listenerData, handle); gapi_objectClearBusy(handle); (void)gapi_dataReaderClaim(handle, NULL); } } }
gapi_returnCode_t gapi_dataReader_set_default_datareaderview_qos ( gapi_dataReader _this, const gapi_dataReaderViewQos *qos) { gapi_returnCode_t result = GAPI_RETCODE_OK; _DataReader dataReader = (_DataReader)_this; gapi_context context; GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_SET_DEFAULT_DATAREADERVIEW_QOS); dataReader = gapi_dataReaderClaim(_this, &result); if ( dataReader ) { if ( qos ) { result = gapi_dataReaderViewQosIsConsistent(qos, &context); if ( result == GAPI_RETCODE_OK ) { gapi_dataReaderViewQosCopy (qos, &dataReader->_defDataReaderViewQos); } } else { result = GAPI_RETCODE_BAD_PARAMETER; } _EntityRelease(dataReader); } return result; }
gapi_returnCode_t gapi_dataReader_get_matched_publication_data ( gapi_dataReader _this, gapi_publicationBuiltinTopicData *publication_data, const gapi_instanceHandle_t publication_handle) { gapi_returnCode_t result; _DataReader datareader; datareader = gapi_dataReaderClaim(_this, &result); if (datareader != NULL) { if (_EntityEnabled(datareader)) { result = _DataReader_get_matched_publication_data ( datareader, publication_data, publication_handle); } else { result=GAPI_RETCODE_NOT_ENABLED; } } _EntityRelease(datareader); return result; }
gapi_returnCode_t gapi_dataReader_wait_for_historical_data ( gapi_dataReader _this, const gapi_duration_t *max_wait) { gapi_returnCode_t result = GAPI_RETCODE_OK; _DataReader datareader; c_time c_time_max_wait; u_result uResult; datareader = gapi_dataReaderClaim(_this, &result); if (datareader) { if ( !max_wait || !gapi_validDuration(max_wait)) { result = GAPI_RETCODE_BAD_PARAMETER; } else if (!_EntityEnabled(datareader)) { result = GAPI_RETCODE_NOT_ENABLED; } else { kernelCopyInDuration(max_wait, &c_time_max_wait); uResult = u_dataReaderWaitForHistoricalData( U_DATAREADER_GET(datareader), c_time_max_wait); result = kernelResultToApiResult(uResult); } _EntityRelease(datareader); } return result; }
gapi_returnCode_t gapi_dataReader_delete_readcondition ( gapi_dataReader _this, const gapi_readCondition a_condition) { gapi_returnCode_t result = GAPI_RETCODE_OK; _DataReader datareader; _ReadCondition readCondition = NULL; c_bool contains; if (_this && a_condition) { datareader = gapi_dataReaderClaim(_this, &result); if (datareader != NULL) { readCondition = gapi_readConditionClaim(a_condition, NULL); if (readCondition != NULL ) { contains = u_readerContainsQuery(U_READER_GET(datareader), U_QUERY_GET(readCondition)); if (contains) { _ReadConditionFree(readCondition); } else { result = GAPI_RETCODE_PRECONDITION_NOT_MET; _EntityRelease(readCondition); } } else { result = GAPI_RETCODE_ALREADY_DELETED; } _EntityRelease(datareader); } else { result = GAPI_RETCODE_ALREADY_DELETED; } } else { result = GAPI_RETCODE_BAD_PARAMETER; } return result; }
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; }
gapi_topicDescription gapi_dataReader_get_topicdescription ( gapi_dataReader _this) { gapi_topicDescription topicDescription = NULL; _DataReader datareader; datareader = gapi_dataReaderClaim(_this, NULL); if ( datareader != NULL ) { topicDescription = (gapi_topicDescription)_EntityHandle(datareader->topicDescription); _EntityRelease(datareader); } return topicDescription; }
gapi_returnCode_t gapi_dataReader_get_qos ( gapi_dataReader _this, gapi_dataReaderQos *qos) { _DataReader dataReader; gapi_returnCode_t result; dataReader = gapi_dataReaderClaim(_this, &result); if ( dataReader && qos ) { _DataReaderGetQos(dataReader, qos); } _EntityRelease(dataReader); return result; }
gapi_subscriber gapi_dataReader_get_subscriber ( gapi_dataReader _this) { gapi_subscriber subscriber = NULL; _DataReader datareader; u_subscriber uSubscriber; datareader = gapi_dataReaderClaim(_this, NULL); if ( datareader != NULL ) { uSubscriber = u_dataReaderSubscriber(U_DATAREADER_GET(datareader)); subscriber = u_entityGetUserData(u_entity(uSubscriber)); _EntityRelease(datareader); } return subscriber; }
struct gapi_dataReaderListener gapi_dataReader_get_listener ( gapi_dataReader _this) { struct gapi_dataReaderListener listener; _DataReader datareader; datareader = gapi_dataReaderClaim(_this, NULL); if ( datareader != NULL ) { listener = datareader->_Listener; _EntityRelease(datareader); } else { memset(&listener, 0, sizeof(listener)); } return listener; }
gapi_returnCode_t gapi_dataReader_set_notread_threshold ( gapi_dataReader _this, gapi_long threshold) { _DataReader datareader; gapi_returnCode_t result; datareader = gapi_dataReaderClaim(_this, &result); if (datareader != NULL) { result = _DataReader_set_notread_threshold ( datareader, threshold); } _EntityRelease(datareader); return result; }
gapi_returnCode_t gapi_dataReader_get_default_datareaderview_qos ( gapi_dataReader _this, gapi_dataReaderViewQos *qos) { _DataReader datareader; gapi_returnCode_t result; datareader = gapi_dataReaderClaim(_this, &result); if ( datareader) { if ( qos ) { gapi_dataReaderViewQosCopy (&datareader->_defDataReaderViewQos, qos); } _EntityRelease(datareader); } return result; }
static c_bool trigger_reader( u_dataReader reader, c_voidp arg) { gapi_dataReader handle; _DataReader dataReader; assert(reader); handle = u_entityGetUserData(u_entity(reader)); dataReader = gapi_dataReaderClaim(handle,NULL); if (dataReader) { _DataReaderTriggerNotify(dataReader); _EntityRelease(dataReader); } return TRUE; }
gapi_returnCode_t gapi_dataReader_delete_view ( gapi_dataReader _this, gapi_dataReaderView a_view) { gapi_returnCode_t result = GAPI_RETCODE_OK; _DataReader datareader; _DataReaderView view = NULL; c_bool contains; gapi_context context; GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_DELETE_DATAREADER); datareader = gapi_dataReaderClaim(_this, &result); if ( datareader != NULL ) { view = gapi_dataReaderViewClaim(a_view, NULL); if ( view != NULL ) { contains = u_dataReaderContainsView(U_DATAREADER_GET(datareader), U_DATAREADERVIEW_GET(view)); if (contains) { if (_DataReaderViewPrepareDelete(view,&context)) { _DataReaderViewFree(view); view = NULL; } else { result = GAPI_RETCODE_PRECONDITION_NOT_MET; } } else { result = GAPI_RETCODE_PRECONDITION_NOT_MET; } _EntityRelease(view); } else { result = GAPI_RETCODE_BAD_PARAMETER; } _EntityRelease(datareader); } else { result = GAPI_RETCODE_ALREADY_DELETED; } return result; }
gapi_readCondition gapi_dataReader_create_readcondition ( gapi_dataReader _this, const gapi_sampleStateMask sample_states, const gapi_viewStateMask view_states, const gapi_instanceStateMask instance_states) { _DataReader datareader; _ReadCondition readCondition = NULL; datareader = gapi_dataReaderClaim(_this, NULL); if ( datareader ) { if (_EntityEnabled(datareader) && gapi_stateMasksValid(sample_states, view_states, instance_states) ) { readCondition = _ReadConditionNew (sample_states, view_states, instance_states, datareader, NULL); if ( readCondition != NULL ) { gapi_deleteEntityAction deleteAction; void *actionArg; if ( _ObjectGetDeleteAction(_Object(readCondition), &deleteAction, &actionArg) ) { _ObjectSetDeleteAction(_Object(readCondition), deleteAction, actionArg); } _ENTITY_REGISTER_OBJECT(_Entity(datareader), (_Object)readCondition); } } _EntityRelease(datareader); } return (gapi_readCondition)_EntityRelease(readCondition); }
gapi_returnCode_t gapi_dataReader_get_requested_deadline_missed_status ( gapi_dataReader _this, gapi_requestedDeadlineMissedStatus *status) { gapi_returnCode_t result; _DataReader datareader; datareader = gapi_dataReaderClaim(_this, &result); if (datareader != NULL) { if (_EntityEnabled(datareader)) { result = _DataReader_get_requested_deadline_missed_status( datareader, status); } else { result=GAPI_RETCODE_NOT_ENABLED; } _EntityRelease(datareader); } return result; }
gapi_returnCode_t gapi_dataReader_get_sample_lost_status ( gapi_dataReader _this, gapi_sampleLostStatus *status) { gapi_returnCode_t result; _DataReader datareader; datareader = gapi_dataReaderClaim(_this, &result); if (datareader != NULL) { if (_EntityEnabled(datareader)) { result = _DataReader_get_sample_lost_status ( datareader, status); } else { result=GAPI_RETCODE_NOT_ENABLED; } _EntityRelease(datareader); } return result; }
gapi_queryCondition gapi_dataReader_create_querycondition ( gapi_dataReader _this, const gapi_sampleStateMask sample_states, const gapi_viewStateMask view_states, const gapi_instanceStateMask instance_states, const gapi_char *query_expression, const gapi_stringSeq *query_parameters) { _DataReader datareader; gapi_boolean licensed; _QueryCondition queryCondition = NULL; licensed = _DomainParticipantFactoryIsContentSubscriptionAvailable(); if(licensed == TRUE){ datareader = gapi_dataReaderClaim(_this, NULL); if ( datareader && _EntityEnabled(datareader) && query_expression && gapi_sequence_is_valid(query_parameters) && gapi_stateMasksValid(sample_states, view_states, instance_states) ) { queryCondition = _QueryConditionNew(sample_states, view_states, instance_states, query_expression, query_parameters, datareader, NULL); if ( queryCondition != NULL ) { _ENTITY_REGISTER_OBJECT(_Entity(datareader), (_Object)queryCondition); } } _EntityRelease(datareader); } return (gapi_queryCondition)_EntityRelease(queryCondition); }
u_reader DJA_DCPSUtilityBridge_us_createDataReader( DLRL_Exception* exception, void* userData, DK_TopicInfo* topicInfo, void** ls_reader) { /* JNI thread env */ JNIEnv* env = NULL; DJA_CachedJNITypedTopic* typedTopicCachedData = NULL; jobject jtopic = NULL; jobject ls_participant = NULL; jstring jtopicName = NULL; DK_CacheAdmin* cache = NULL; jobject ls_subscriber = NULL; jobject jdataReader= NULL; DK_ObjectHomeAdmin* home = NULL; LOC_char* topicName = NULL; gapi_dataReader gapiReader = NULL; _DataReader _reader = NULL; gapi_returnCode_t result = GAPI_RETCODE_OK; u_reader ureader = NULL; DLRL_INFO(INF_ENTER); assert(exception); assert(userData); assert(topicInfo); env = (JNIEnv*)userData; home = DK_TopicInfo_us_getOwner(topicInfo);/* no duplicate done */ topicName = (LOC_char*)DK_TopicInfo_us_getTopicName(topicInfo); assert(topicName); typedTopicCachedData = (DJA_CachedJNITypedTopic*)DK_TopicInfo_us_getTopicUserData(topicInfo); /* typedTopicCachedData may be null*/ /* get java object */ jtopic = (jobject)DK_TopicInfo_us_getLSTopic(topicInfo); /* the cache getter on the object home doesnt require a release on the returned pointer */ cache = DK_ObjectHomeAdmin_us_getCache(home); ls_participant = (jobject)DK_CacheAdmin_us_getLSParticipant(cache); ls_subscriber = (jobject)DK_CacheAdmin_us_getLSSubscriber(cache); jtopicName = (*env)->NewStringUTF(env, topicName); DLRL_JavaException_PROPAGATE(env, exception); DLRL_INFO(INF_CALLBACK, "objectHome->createDataReader(participant, subscriber, topic, topicName)"); jdataReader = (*env)->CallStaticObjectMethod(env, cachedJNI.dcpsUtil_class, cachedJNI.dcpsUtil_createDataReader_mid, ls_participant, ls_subscriber, jtopic, jtopicName); DLRL_JavaException_PROPAGATE(env, exception); if(!jdataReader){ DLRL_Exception_THROW(exception, DLRL_DCPS_ERROR, "Creation of data reader for topic %s failed! " "Check DCPS error log file for (possibly) more information.", topicName); } if(typedTopicCachedData) { /* no need to undo the following action in case of an exception later on, as the typedTopicCachedData is already */ /* managed by the DLRL whom will ensure its cleaned properly. */ DJA_Initialisation_loadTypedReaderCache(exception, env, typedTopicCachedData, jdataReader); DLRL_Exception_PROPAGATE(exception); } DLRL_INFO(INF_DCPS, "saj_read_gapi_address(datareader)"); gapiReader = jdataReader? (gapi_dataReader)saj_read_gapi_address(env, jdataReader) : NULL; if(!gapiReader){ DLRL_Exception_THROW(exception, DLRL_DCPS_ERROR, "Unable to create the DCPS DataReader entity for topic %s of DLRL Kernel ObjectHomeAdmin '%s'. " "Check DCPS error log file for (possibly) more information.", DLRL_VALID_NAME(topicName), DLRL_VALID_NAME(DK_ObjectHomeAdmin_us_getName(home))); } _reader = gapi_dataReaderClaim(gapiReader, &result); DLRL_Exception_PROPAGATE_GAPI_RESULT(exception, result, "Failed to claim the data reader handle"); ureader = u_reader(_DataReaderUreader(_reader)); if(ureader) { /* now create a proxy to this user layer ureader which can be used by the DLRL * in a safe manner, as the user layer ureader returned by the _DataReaderUreader * operation is owned by the gapi. */ ureader = u_reader(DK_DCPSUtility_ts_createProxyUserEntity(exception, u_entity(ureader))); } _EntityRelease(_reader);/* before the propagate */ DLRL_Exception_PROPAGATE(exception);/* after the release */ if(!ureader){ DLRL_Exception_THROW(exception, DLRL_DCPS_ERROR, "Unable to create the DCPS DataReader entity for topic %s of DLRL Kernel ObjectHomeAdmin '%s'. " "Check DCPS error log file for (possibly) more information.", DLRL_VALID_NAME(topicName), DLRL_VALID_NAME(DK_ObjectHomeAdmin_us_getName(home))); } *ls_reader = (void*)(*(env))->NewGlobalRef (env, jdataReader); if(!(*ls_reader)) { u_entityFree(u_entity(ureader)); ureader = NULL; DLRL_Exception_THROW(exception, DLRL_OUT_OF_MEMORY, "Unable to create a global ref for the type specific DataReader class."); } DLRL_Exception_EXIT(exception); if(exception->exceptionID != DLRL_NO_EXCEPTION){ /* return null if an exception occured, clean the data reader if it existed (later an exception will be set when */ /* JNI raises an exception as well */ ureader = NULL; } if(jtopicName){ (*env)->DeleteLocalRef(env, jtopicName); } if(jdataReader){ (*env)->DeleteLocalRef(env, jdataReader); } DLRL_INFO(INF_EXIT); return ureader; }
gapi_returnCode_t gapi_dataReader_wait_for_historical_data_w_condition ( gapi_dataReader _this, const gapi_char *filter_expression, const gapi_stringSeq *filter_parameters, const gapi_time_t *min_source_timestamp, const gapi_time_t *max_source_timestamp, const gapi_resourceLimitsQosPolicy *resource_limits, const gapi_duration_t *max_wait) { gapi_returnCode_t result; _DataReader datareader; c_time c_time_max_wait, c_time_min_source_timestamp, c_time_max_source_timestamp; u_result uResult; c_ulong length, i; c_char** params; struct v_resourcePolicy resource; datareader = gapi_dataReaderClaim(_this, &result); if (datareader) { if ( !max_wait || !gapi_validDuration(max_wait)) { result = GAPI_RETCODE_BAD_PARAMETER; } else if (!_EntityEnabled(datareader)) { result = GAPI_RETCODE_NOT_ENABLED; } else if(filter_parameters && !gapi_stringSeqValid(filter_parameters)){ result = GAPI_RETCODE_BAD_PARAMETER; } else { if(filter_parameters){ length = filter_parameters->_length; params = (c_char**)(os_malloc(length*sizeof(c_char*))); for(i=0; i<length; i++){ params[i] = filter_parameters->_buffer[i]; } } else { params = NULL; length = 0; } kernelCopyInDuration(max_wait, &c_time_max_wait); if ( (kernelCopyInTime(min_source_timestamp, &c_time_min_source_timestamp) != GAPI_RETCODE_OK) || (kernelCopyInTime(max_source_timestamp, &c_time_max_source_timestamp) != GAPI_RETCODE_OK) ) { result = GAPI_RETCODE_BAD_PARAMETER; } else { resource.max_samples = resource_limits->max_samples; resource.max_instances = resource_limits->max_instances; resource.max_samples_per_instance = resource_limits->max_samples_per_instance; uResult= u_dataReaderWaitForHistoricalDataWithCondition( U_DATAREADER_GET(datareader), (c_char*)filter_expression, params, length, c_time_min_source_timestamp, c_time_max_source_timestamp, &resource, c_time_max_wait); result = kernelResultToApiResult(uResult); } } _EntityRelease(datareader); } return result; }
gapi_returnCode_t gapi_dataReader_delete_contained_entities ( gapi_dataReader _this) { gapi_object handle; gapi_returnCode_t result = GAPI_RETCODE_OK; _DataReader datareader; gapi_context context; _Condition condition = NULL; _DataReaderView view = NULL; c_iter entities; u_entity e; u_result ur; GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_DELETE_CONTAINED_ENTITIES); datareader = gapi_dataReaderClaim(_this, &result); if ( datareader != NULL ) { if (!gapi_loanRegistry_is_empty(datareader->loanRegistry)) { result = GAPI_RETCODE_PRECONDITION_NOT_MET; } else { entities = u_readerLookupQueries(U_READER_GET(datareader)); e = c_iterTakeFirst(entities); while (e) { condition = u_entityGetUserData(e); if (condition) { _ObjectReadClaimNotBusy(_Object(condition)); _ConditionFree(condition); } else { assert(condition); result = GAPI_RETCODE_BAD_PARAMETER; } e = c_iterTakeFirst(entities); } c_iterFree(entities); entities = u_dataReaderLookupViews(U_DATAREADER_GET(datareader)); e = c_iterTakeFirst(entities); while (e) { handle = u_entityGetUserData(e); view = _DataReaderView(gapi_conditionClaimNB(handle,&result)); if (view) { _DataReaderViewFree(view); } else { ur = u_dataViewFree(u_dataView(e)); if (ur == U_RESULT_OK) { result = GAPI_RETCODE_OK; } else { result = GAPI_RETCODE_BAD_PARAMETER; } } e = c_iterTakeFirst(entities); } c_iterFree(entities); } _EntityRelease(datareader); } else { result = GAPI_RETCODE_BAD_PARAMETER; } return result; }