gapi_returnCode_t gapi_publisher_delete_contained_entities ( gapi_publisher _this) { _Publisher publisher; _DataWriter dataWriter; gapi_dataWriter handle; gapi_returnCode_t result = GAPI_RETCODE_OK; c_iter writers; u_writer w; void *userData; publisher = gapi_publisherClaim(_this, &result); if ( publisher != NULL ) { /* delete all datawriters in the datawriterSet */ writers = u_publisherLookupWriters(U_PUBLISHER_GET(publisher),NULL); w = c_iterTakeFirst(writers); while (w) { handle = u_entityGetUserData(u_entity(w)); dataWriter = gapi_dataWriterClaimNB(handle,&result); if (dataWriter) { userData = _ObjectGetUserData(_Object(dataWriter)); _DataWriterFree(dataWriter); } w = c_iterTakeFirst(writers); } c_iterFree(writers); _EntityRelease(publisher); } else { result = GAPI_RETCODE_BAD_PARAMETER; } return result; }
/* DomainParticipant * get_participant(); */ gapi_domainParticipant gapi_topicDescription_get_participant ( gapi_topicDescription _this) { _TopicDescription topicDescription; _Topic topic; _DomainParticipant participant = NULL; topicDescription = gapi_topicDescriptionClaim(_this, NULL); if ( topicDescription != NULL ) { /* all entities except for content filtered topics have a reference * to a user layer entity. So except for content filtered topics * entities get their participant from the user layer entity. * Content filters instead do this via the related topic. */ if (_ObjectGetKind(_Object(topicDescription)) == OBJECT_KIND_CONTENTFILTEREDTOPIC) { topic = _ContentFilteredTopicGetRelatedTopic(_ContentFilteredTopic(topicDescription)); participant = _EntityParticipant(_Entity(topic)); } else { participant = _EntityParticipant(_Entity(topicDescription)); } } _EntityRelease(topicDescription); return (gapi_domainParticipant)_EntityHandle(participant); }
const char * _BuiltinFindTopicName ( _Entity entity) { const char *name = NULL; switch (_ObjectGetKind(_Object(entity))) { case OBJECT_KIND_DOMAINPARTICIPANT: name = builtinTopicTypeInfo[_BUILTIN_PARTICIPANT_INFO].topicName; break; case OBJECT_KIND_TOPIC: name = builtinTopicTypeInfo[_BUILTIN_TOPIC_INFO].topicName; break; case OBJECT_KIND_DATAWRITER: name = builtinTopicTypeInfo[_BUILTIN_PUBLICATION_INFO].topicName; break; case OBJECT_KIND_DATAREADER: name = builtinTopicTypeInfo[_BUILTIN_SUBSCRIPTION_INFO].topicName; break; default: break; } return name; }
/* ReadCondition * create_readcondition( * in SampleStateMask sample_states, * in ViewStateMask view_states, * in InstanceStateMask instance_states); */ gapi_readCondition gapi_dataReaderView_create_readcondition ( gapi_dataReaderView _this, const gapi_sampleStateMask sample_states, const gapi_viewStateMask view_states, const gapi_instanceStateMask instance_states) { _DataReaderView datareaderview; _ReadCondition readCondition = NULL; datareaderview = gapi_dataReaderViewClaim(_this, NULL); if ( datareaderview && _EntityEnabled(datareaderview) && gapi_stateMasksValid(sample_states, view_states, instance_states) ) { _DataReader datareader; datareader = _DataReaderViewDataReader(datareaderview); readCondition = _ReadConditionNew ( sample_states, view_states, instance_states, datareader, datareaderview); _EntityRelease(datareader); if ( readCondition != NULL ) { gapi_deleteEntityAction deleteAction; void *actionArg; if ( _ObjectGetDeleteAction(_Object(readCondition), &deleteAction, &actionArg) ) { _ObjectSetDeleteAction(_Object(readCondition), deleteAction, actionArg); } _ENTITY_REGISTER_OBJECT(_Entity(datareaderview), (_Object)readCondition); } } _EntityRelease(datareaderview); return (gapi_readCondition)_EntityRelease(readCondition); }
/* ReturnCode_t * delete_contained_entities(); */ gapi_returnCode_t gapi_dataReaderView_delete_contained_entities ( gapi_dataReaderView _this) { gapi_returnCode_t result = GAPI_RETCODE_OK; _DataReaderView datareaderview; gapi_context context; _Condition condition = NULL; c_iter entities; u_entity e; u_result ur; GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_DELETE_CONTAINED_ENTITIES); if ( _this != NULL ) { datareaderview = gapi_dataReaderViewClaim(_this, &result); if ( datareaderview != NULL ) { if (!gapi_loanRegistry_is_empty(datareaderview->loanRegistry)) { result = GAPI_RETCODE_PRECONDITION_NOT_MET; } else { entities = u_readerLookupQueries(U_READER_GET(datareaderview)); e = c_iterTakeFirst(entities); while (e) { condition = u_entityGetUserData(e); if (condition) { _ObjectReadClaimNotBusy(_Object(condition)); _ConditionFree(condition); } else { if (e == u_entity(datareaderview->uQuery)) { datareaderview->uQuery = NULL; ur = u_queryFree(u_query(e)); if (ur == U_RESULT_OK) { result = GAPI_RETCODE_OK; } else { result = GAPI_RETCODE_BAD_PARAMETER; } } else { assert(condition); result = GAPI_RETCODE_BAD_PARAMETER; } } e = c_iterTakeFirst(entities); } c_iterFree(entities); } _EntityRelease(datareaderview); } else { result = GAPI_RETCODE_ALREADY_DELETED; } } else { result = GAPI_RETCODE_BAD_PARAMETER; } return result; }
/** * @fn Class *URLSessionTask::_URLSessionTask(void) * @memberof URLSessionTask */ Class *_URLSessionTask(void) { static Class *clazz; static Once once; do_once(&once, { clazz = _initialize(&(const ClassDef) { .name = "URLSessionTask", .superclass = _Object(), .instanceSize = sizeof(URLSessionTask), .interfaceOffset = offsetof(URLSessionTask, interface), .interfaceSize = sizeof(URLSessionTaskInterface), .initialize = initialize, }); });
/** * @fn Class *TableColumn::_TableColumn(void) * @memberof TableColumn */ Class *_TableColumn(void) { static Class *clazz; static Once once; do_once(&once, { clazz = _initialize(&(const ClassDef) { .name = "TableColumn", .superclass = _Object(), .instanceSize = sizeof(TableColumn), .interfaceOffset = offsetof(TableColumn, interface), .interfaceSize = sizeof(TableColumnInterface), .initialize = initialize, }); });
gapi_returnCode_t _ReadConditionFree( _ReadCondition readcondition) { gapi_returnCode_t result = GAPI_RETCODE_OK; if (_ObjectGetKind(_Object(readcondition)) == OBJECT_KIND_QUERYCONDITION ) { _QueryConditionFree((_QueryCondition)readcondition); } else { _ReadConditionDispose(readcondition); } return result; }
/** * @fn Class *Resource::_Resource(void) * @memberof Resource */ Class *_Resource(void) { static Class *clazz; static Once once; do_once(&once, { clazz = _initialize(&(const ClassDef) { .name = "Resource", .superclass = _Object(), .instanceSize = sizeof(Resource), .interfaceOffset = offsetof(Resource, interface), .interfaceSize = sizeof(ResourceInterface), .initialize = initialize, .destroy = destroy, }); });
void _ConditionDispose( _Condition _this) { gapi_waitSet waitset; waitset = c_iterTakeFirst(_this->waitsets); while (waitset) { gapi_condition handle = _EntityRelease(_this); gapi_waitSet_detach_condition(waitset, handle); _this = gapi_conditionClaim(handle, NULL); waitset = c_iterTakeFirst(_this->waitsets); } c_iterFree(_this->waitsets); if (_ObjectGetKind(_Object(_this)) != OBJECT_KIND_GUARDCONDITION) { _EntityDelete(_this); } }
void _ConditionFree( _Condition _this) { switch (_ObjectGetKind(_Object(_this))) { case OBJECT_KIND_QUERYCONDITION: _QueryConditionFree((_QueryCondition)_this); break; case OBJECT_KIND_READCONDITION: _ReadConditionFree((_ReadCondition)_this); break; case OBJECT_KIND_STATUSCONDITION: _StatusConditionFree((_StatusCondition)_this); break; case OBJECT_KIND_GUARDCONDITION: _GuardConditionFree(_this); break; default: assert(0); break; } }
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; }
_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; }
gapi_dataReader gapi_subscriber_create_datareader ( gapi_subscriber _this, const gapi_topicDescription a_topic, const gapi_dataReaderQos *qos, const struct gapi_dataReaderListener *a_listener, const gapi_statusMask mask) { _Subscriber subscriber; _DataReader datareader = NULL; gapi_dataReader result = NULL; _TopicDescription topicDescription = NULL; gapi_dataReaderQos *readerQos; gapi_context context; gapi_topicQos* topicQos; GAPI_CONTEXT_SET(context, _this, GAPI_METHOD_CREATE_DATAREADER); subscriber = gapi_subscriberClaim(_this, NULL); if ( subscriber ) { if ( !subscriber->builtin ) { topicDescription = _TopicDescriptionFromHandle(a_topic); } } if ( topicDescription ) { if ( qos == GAPI_DATAREADER_QOS_DEFAULT ) { readerQos = &subscriber->_defDataReaderQos; } else if ( qos == GAPI_DATAREADER_QOS_USE_TOPIC_QOS ) { _Topic topic = NULL; switch(_ObjectGetKind(_Object(topicDescription))) { case OBJECT_KIND_TOPIC: topic = _Topic(topicDescription); break; case OBJECT_KIND_CONTENTFILTEREDTOPIC: topic = _ContentFilteredTopicGetRelatedTopic(_ContentFilteredTopic(topicDescription)); break; default: topic = NULL; break; } if ( topic ) { topicQos = gapi_topicQos__alloc(); readerQos = gapi_dataReaderQos__alloc(); gapi_dataReaderQosCopy(&subscriber->_defDataReaderQos, readerQos); _TopicGetQos(topic, topicQos); gapi_mergeTopicQosWithDataReaderQos(topicQos,readerQos); gapi_free(topicQos); } else { readerQos = (gapi_dataReaderQos *)qos; } } else { readerQos = (gapi_dataReaderQos *)qos; } if ( gapi_dataReaderQosIsConsistent(readerQos, &context) == GAPI_RETCODE_OK ) { gapi_char *typeName; gapi_char *topicName; _DomainParticipant participant; _TypeSupport typeSupport; /* find topic with the participant for consistency */ typeName = _TopicDescriptionGetTypeName(topicDescription); topicName = _TopicDescriptionGetName(topicDescription); participant = _EntityParticipant(_Entity(subscriber)); /* find type support for the data type to find * data reader create function. */ typeSupport = _DomainParticipantFindType(participant, typeName); if(typeSupport) { /* if create function is NULL, take default from data reader */ datareader = _DataReaderNew(topicDescription, typeSupport, readerQos, a_listener, mask, subscriber); if ( datareader ) { _ENTITY_REGISTER_OBJECT(_Entity(subscriber), (_Object)datareader); } }else{ OS_REPORT_1(OS_WARNING, "gapi_subscriber_create_datareader", 0, "TypeSupport %s not found !", typeName); } gapi_free(typeName); gapi_free(topicName); } if (qos == GAPI_DATAREADER_QOS_USE_TOPIC_QOS) { gapi_free(readerQos); } } _EntityRelease(subscriber); if ( datareader ) { gapi_object statusHandle; statusHandle = _EntityHandle(_Entity(datareader)->status); result = (gapi_dataReader)_EntityRelease(datareader); } return result; }