DDS_StatusCondition DDS_Subscriber_get_statuscondition (DDS_Subscriber sp) { Domain_t *dp; StatusCondition_t *scp; ctrc_printd (DCPS_ID, DCPS_S_G_SCOND, &sp, sizeof (sp)); if (!subscriber_ptr (sp, NULL)) return (NULL); dp = domain_ptr (sp->domain, 1, NULL); if (!dp) return (NULL); scp = sp->condition; if (!scp) { scp = dcps_new_status_condition (); if (!scp) return (NULL); scp->entity = (Entity_t *) sp; sp->condition = scp; } lock_release (dp->lock); return ((DDS_StatusCondition) scp); }
DDS_ReturnCode_t DDS_Subscriber_enable (DDS_Subscriber sp) { Domain_t *dp; DDS_ReturnCode_t ret; ctrc_printd (DCPS_ID, DCPS_S_ENABLE, &sp, sizeof (sp)); if (!subscriber_ptr (sp, &ret)) return (ret); dp = domain_ptr (sp->domain, 1, &ret); if (!dp) return (ret); if ((dp->participant.p_flags & EF_ENABLED) == 0) { lock_release (dp->lock); return (DDS_RETCODE_NOT_ENABLED); } if ((sp->entity.flags & EF_ENABLED) == 0) { /* ... todo ... */ sp->entity.flags |= EF_ENABLED | EF_NOT_IGNORED; } lock_release (dp->lock); return (DDS_RETCODE_OK); }
DDS_ReturnCode_t DDS_Subscriber_get_default_datareader_qos (DDS_Subscriber sp, DDS_DataReaderQos *qos) { Domain_t *dp; DDS_ReturnCode_t ret; ctrc_begind (DCPS_ID, DCPS_S_G_DR_QOS, &sp, sizeof (sp)); ctrc_contd (&qos, sizeof (qos)); ctrc_endd (); if (!qos) { log_printf (DCPS_ID, 0, "get_default_datareader_qos: invalid parameters!\r\n"); return (DDS_RETCODE_BAD_PARAMETER); } if (!subscriber_ptr (sp, &ret)) return (ret); dp = domain_ptr (sp->domain, 1, &ret); if (!dp) return (ret); *qos = sp->def_reader_qos; lock_release (dp->lock); return (DDS_RETCODE_OK); }
DDS_ReturnCode_t DDS_Subscriber_set_qos (DDS_Subscriber sp, DDS_SubscriberQos *qos) { Domain_t *dp; DDS_ReturnCode_t ret; ctrc_printd (DCPS_ID, DCPS_S_S_QOS, &sp, sizeof (sp)); ctrc_contd (&qos, sizeof (qos)); ctrc_endd (); if (!subscriber_ptr (sp, &ret)) return (ret); dp = domain_ptr (sp->domain, 1, &ret); if (!dp) return (ret); if (qos == DDS_PUBLISHER_QOS_DEFAULT) qos = &sp->domain->def_subscriber_qos; else if (!qos_valid_subscriber_qos (qos)) { ret = DDS_RETCODE_BAD_PARAMETER; goto done; } ret = qos_subscriber_update (&sp->qos, qos); if (ret == DDS_RETCODE_OK) sl_walk (&sp->domain->participant.p_endpoints, update_reader_qos, sp); done: lock_release (dp->lock); return (ret); }
DDS_ReturnCode_t DDS_Subscriber_set_default_datareader_qos (DDS_Subscriber sp, DDS_DataReaderQos *qos) { Domain_t *dp; DDS_ReturnCode_t ret; ctrc_begind (DCPS_ID, DCPS_S_S_DR_QOS, &sp, sizeof (sp)); ctrc_contd (&qos, sizeof (qos)); ctrc_endd (); if (!subscriber_ptr (sp, &ret)) return (ret); dp = domain_ptr (sp->domain, 1, &ret); if (!dp) return (ret); if (qos == DDS_DATAREADER_QOS_DEFAULT) qos = (DDS_DataReaderQos *) &qos_def_reader_qos; else if (!qos_valid_reader_qos (qos)) { ret = DDS_RETCODE_BAD_PARAMETER; goto done; } sp->def_reader_qos = *qos; done: lock_release (dp->lock); return (ret); }
DDS_ReturnCode_t DDS_DomainParticipant_set_qos (DDS_DomainParticipant dp, DDS_DomainParticipantQos *qos) { DDS_ReturnCode_t ret; ctrc_begind (DCPS_ID, DCPS_DP_S_QOS, &dp, sizeof (dp)); ctrc_contd (&qos, sizeof (qos)); ctrc_endd (); if (!domain_ptr (dp, 1, &ret)) return (ret); if (qos == DDS_PARTICIPANT_QOS_DEFAULT) qos = &dcps_def_participant_qos; else if (!qos_valid_participant_qos (qos)) { ret = DDS_RETCODE_BAD_PARAMETER; goto done; } if (dp->participant.p_user_data) str_unref (dp->participant.p_user_data); dp->participant.p_user_data = qos_octets2str (&qos->user_data.value); dp->autoenable = qos->entity_factory.autoenable_created_entities; if ((dp->participant.p_flags & EF_ENABLED) != 0) ret = disc_participant_update (dp); done: lock_release (dp->lock); return (ret); }
DDS_ReturnCode_t DDS_DomainParticipant_get_discovered_topics (DDS_DomainParticipant dp, DDS_InstanceHandleSeq *handles) { DDS_ReturnCode_t ret; ctrc_begind (DCPS_ID, DCPS_DP_G_DISC_T_S, &dp, sizeof (dp)); ctrc_contd (&handles, sizeof (handles)); ctrc_endd (); if (!handles) return (DDS_RETCODE_BAD_PARAMETER); if (!domain_ptr (dp, 1, &ret)) return (ret); DDS_SEQ_INIT (*handles); if ((dp->participant.p_flags & EF_ENABLED) == 0) { lock_release (dp->lock); return (DDS_RETCODE_NOT_ENABLED); } sl_walk (&dp->participant.p_topics, topic_add_handle, handles); lock_release (dp->lock); return (ret); }
DDS_ReturnCode_t DDS_DomainParticipant_ignore_publication (DDS_DomainParticipant dp, DDS_InstanceHandle_t handle) { Entity_t *ep; DDS_ReturnCode_t ret; ctrc_begind (DCPS_ID, DCPS_DP_IGN_PUB, &dp, sizeof (dp)); ctrc_contd (&handle, sizeof (handle)); ctrc_endd (); if (!domain_ptr (dp, 1, &ret)) return (ret); if ((dp->participant.p_flags & EF_ENABLED) == 0) { lock_release (dp->lock); return (DDS_RETCODE_NOT_ENABLED); } ep = entity_ptr (handle); if (!ep || ep->type != ET_WRITER || !entity_discovered (ep->flags)) { ret = DDS_RETCODE_ALREADY_DELETED; goto done; } ret = disc_ignore_writer ((DiscoveredWriter_t *) ep); done: lock_release (dp->lock); return (ret); }
DDS_ReturnCode_t DDS_DomainParticipant_delete_typesupport (DDS_DomainParticipant dp, DDS_TypeSupport ts) { struct type_sup_rem_state_st state; DDS_ReturnCode_t ret; ctrc_begind (DCPS_ID, DCPS_DP_D_TS, &p, sizeof (p)); ctrc_contd (&ts, sizeof (ts)); ctrc_endd (); /* Validate some required arguments. */ if (!ts) return (DDS_RETCODE_BAD_PARAMETER); if (!domain_ptr (dp, 1, &ret)) return (ret); /* Search type name in participant type list. */ state.part = dp; state.ts = ts; state.ret = DDS_RETCODE_ALREADY_DELETED; sl_walk (&dp->types, delete_type_support, &state); lock_release (dp->lock); return (state.ret); }
DDS_ReturnCode_t DDS_Subscriber_set_listener (DDS_Subscriber sp, DDS_SubscriberListener *listener, DDS_StatusMask mask) { Domain_t *dp; DDS_ReturnCode_t ret; ctrc_printd (DCPS_ID, DCPS_S_S_LIS, &sp, sizeof (sp)); ctrc_contd (&listener, sizeof (listener)); ctrc_contd (&mask, sizeof (mask)); ctrc_endd (); if (!subscriber_ptr (sp, &ret)) return (ret); dp = domain_ptr (sp->domain, 1, &ret); if (!dp) return (ret); dcps_update_listener ((Entity_t *) sp, &dp->lock, &sp->mask, &sp->listener, mask, listener); lock_release (dp->lock); return (DDS_RETCODE_OK); }
DDS_MultiTopic DDS_DomainParticipant_create_multitopic ( DDS_DomainParticipant dp, const char *name, const char *type_name, const char *subs_expr, DDS_StringSeq *expr_pars) { ctrc_begind (DCPS_ID, DCPS_DP_C_MTOP, &dp, sizeof (dp)); ctrc_contd (name, strlen (name) + 1); ctrc_contd (type_name, strlen (type_name) + 1); ctrc_contd (subs_expr, strlen (subs_expr) + 1); ctrc_contd (&expr_pars, sizeof (expr_pars)); ctrc_endd (); ARG_NOT_USED (expr_pars) /* Check some required parameters. */ if (!domain_ptr (dp, 0, NULL)) return (NULL); if (!subs_expr || !name || !type_name) return (NULL); return (NULL); }
DDS_DomainId_t DDS_DomainParticipant_get_domain_id (DDS_DomainParticipant dp) { DDS_DomainId_t id; DDS_ReturnCode_t ret; ctrc_printd (DCPS_ID, DCPS_DP_G_ID, &p, sizeof (p)); if (!domain_ptr (dp, 1, &ret)) return (0); id = dp->domain_id; lock_release (dp->lock); return (id); }
DDS_InstanceHandle_t DDS_DomainParticipant_get_instance_handle (DDS_DomainParticipant dp) { DDS_InstanceHandle_t handle; ctrc_printd (DCPS_ID, DCPS_DP_G_HANDLE, &dp, sizeof (dp)); if (!domain_ptr (dp, 1, NULL)) return (DDS_HANDLE_NIL); handle = dp->participant.p_handle; lock_release (dp->lock); return (handle); }
int DDS_DomainParticipant_contains_entity (DDS_DomainParticipant dp, DDS_InstanceHandle_t handle) { Entity_t *ep; int contained = 0; ctrc_begind (DCPS_ID, DCPS_DP_CONT, &dp, sizeof (dp)); ctrc_contd (&handle, sizeof (handle)); ctrc_endd (); if (!domain_ptr (dp, 1, NULL)) return (0); ep = entity_ptr (handle); if (!ep) goto done; if ((ep->flags & EF_LOCAL) == 0) goto done; switch (ep->type) { case ET_TOPIC: contained = (((Topic_t *) ep)->domain == dp); break; case ET_PUBLISHER: contained = (((Publisher_t *) ep)->domain == dp); break; case ET_SUBSCRIBER: contained = (((Subscriber_t *) ep)->domain == dp); break; case ET_WRITER: contained = (((Writer_t *) ep)->w_publisher->domain == dp); break; case ET_READER: contained = (((Reader_t *) ep)->r_subscriber->domain == dp); break; case ET_PARTICIPANT: default: break; } done: lock_release (dp->lock); return (contained); }
DDS_StatusMask DDS_DomainParticipant_get_status_changes (DDS_DomainParticipant dp) { DDS_StatusMask m; ctrc_printd (DCPS_ID, DCPS_DP_G_STAT, &dp, sizeof (dp)); if (!domain_ptr (dp, 1, NULL)) return (0); /* No status mask on participant for now! */ m = 0U; lock_release (dp->lock); return (m); }
DDS_ReturnCode_t DDS_DomainParticipant_delete_subscriber (DDS_DomainParticipant dp, DDS_Subscriber sp) { Condition_t *cp; DDS_ReturnCode_t ret; ctrc_begind (DCPS_ID, DCPS_DP_D_SUB, &dp, sizeof (dp)); ctrc_contd (&sp, sizeof (sp)); ctrc_endd (); prof_start (dcps_delete_sub); if (!domain_ptr (dp, 1, &ret)) return (ret); if (!subscriber_ptr (sp, &ret)) goto done; if (sp->domain != dp) { ret = DDS_RETCODE_BAD_PARAMETER; goto done; } if (sp->nreaders) { log_printf (DCPS_ID, 0, "delete_subscriber(): still readers connected!\r\n"); ret = DDS_RETCODE_PRECONDITION_NOT_MET; goto done; } if (!dds_purge_notifications ((Entity_t *) sp, DDS_ALL_STATUS, 1)) { ret = DDS_RETCODE_PRECONDITION_NOT_MET; goto done; } sp->entity.flags &= ~EF_ENABLED; qos_subscriber_free (&sp->qos); /* Delete StatusCondition if it exists. */ if (sp->condition) { cp = (Condition_t *) sp->condition; if (cp->deferred) dds_defer_waitset_undo (sp, sp->condition); dcps_delete_status_condition (sp->condition); sp->condition = NULL; } subscriber_delete (sp); done: lock_release (dp->lock); prof_stop (dcps_delete_sub, 1); return (ret); }
DDS_DomainParticipantListener *DDS_DomainParticipant_get_listener (DDS_DomainParticipant dp) { DDS_DomainParticipantListener *listener; ctrc_printd (DCPS_ID, DCPS_DP_G_LIS, &dp, sizeof (dp)); /* Get Domain Participant. */ if (!domain_ptr (dp, 1, NULL)) { log_printf (DCPS_ID, 0, "get_listener: domain doesn't exist!\r\n"); return (NULL); } listener = &dp->listener; lock_release (dp->lock); return (listener); }
DDS_ReturnCode_t DDS_DomainParticipant_enable (DDS_DomainParticipant dp) { #ifdef RTPS_USED int i; #endif #if defined (DDS_DEBUG) && defined (DDS_SERVER) static int server_running = 0; #endif DDS_ReturnCode_t error; ctrc_printd (DCPS_ID, DCPS_DP_ENABLE, &dp, sizeof (dp)); if (!domain_ptr (dp, 1, &error)) return (error); if ((dp->participant.p_flags & EF_ENABLED) == 0) { dp->participant.p_flags |= EF_ENABLED | EF_NOT_IGNORED; #ifdef RTPS_USED if (rtps_used) /* Create RTPS and Discovery participants. */ for (i = 0; i < 64; i++) { error = rtps_participant_create (dp); if (error && error != DDS_RETCODE_PRECONDITION_NOT_MET) { lock_release (dp->lock); return (error); } if (!error) break; domain_used (dp); if (dp->participant_id == ILLEGAL_PID) return (DDS_RETCODE_OUT_OF_RESOURCES); } #endif #if defined (DDS_DEBUG) && defined (DDS_SERVER) if (!server_running) { server_running = 1; DDS_Debug_server_start (2, DDS_DEBUG_PORT_DEFAULT); } #endif } lock_release (dp->lock); return (DDS_RETCODE_OK); }
DDS_ReturnCode_t DDS_DomainParticipant_delete_contained_entities (DDS_DomainParticipant dp) { Publisher_t *up; Subscriber_t *sp; Condition_t *cp; DDS_ReturnCode_t ret; ctrc_printd (DCPS_ID, DCPS_DP_D_CONT, &dp, sizeof (dp)); if (!domain_ptr (dp, 1, &ret)) return (ret); while ((up = dp->publishers.head) != NULL) { delete_publisher_entities (dp, up); if (up->nwriters != 0) { lock_release (dp->lock); return (DDS_RETCODE_PRECONDITION_NOT_MET); } dtrc_printf ("participant_delete_contained_entitities: delete Publisher (%p)\r\n", (void *) up); qos_publisher_free (&up->qos); if (up->condition) { cp = (Condition_t *) up->condition; if (cp->deferred) dds_defer_waitset_undo (up, up->condition); dcps_delete_status_condition (up->condition); } publisher_delete (up); } while ((sp = dp->subscribers.head) != NULL) { delete_subscriber_entities (dp, sp); if (sp->nreaders != 0) { lock_release (dp->lock); return (DDS_RETCODE_PRECONDITION_NOT_MET); } dtrc_printf ("participant_delete_contained_entitities: delete Subscriber (%p)\r\n", (void *) sp); qos_subscriber_free (&sp->qos); if (sp->condition) { cp = (Condition_t *) sp->condition; if (cp->deferred) dds_defer_waitset_undo (sp, sp->condition); dcps_delete_status_condition (sp->condition); } subscriber_delete (sp); } sl_walk (&dp->participant.p_topics, dcps_delete_topic, dp); sl_walk (&dp->types, delete_type, dp); lock_release (dp->lock); return (DDS_RETCODE_OK); }
DDS_ReturnCode_t DDS_DomainParticipant_assert_liveliness (DDS_DomainParticipant dp) { DDS_ReturnCode_t ret; ctrc_printd (DCPS_ID, DCPS_DP_ASSERT, &dp, sizeof (dp)); if (!domain_ptr (dp, 1, &ret)) return (ret); if ((dp->participant.p_flags & EF_ENABLED) == 0) { lock_release (dp->lock); return (DDS_RETCODE_NOT_ENABLED); } liveliness_participant_assert (dp); lock_release (dp->lock); return (ret); }
DDS_Publisher DDS_DomainParticipant_create_publisher (DDS_DomainParticipant dp, const DDS_PublisherQos *qos, const DDS_PublisherListener *listener, DDS_StatusMask mask) { Publisher_t *up; int enable; ctrc_begind (DCPS_ID, DCPS_DP_C_PUB, &dp, sizeof (dp)); ctrc_contd (&qos, sizeof (qos)); ctrc_contd (&listener, sizeof (listener)); ctrc_contd (&mask, sizeof (mask)); ctrc_endd (); prof_start (dcps_create_pub); if (!domain_ptr (dp, 1, NULL)) return (NULL); if (qos == DDS_PUBLISHER_QOS_DEFAULT) qos = &dp->def_publisher_qos; else if (!qos_valid_publisher_qos (qos)) { up = NULL; goto done; } up = publisher_create (dp, 0); if (!up) goto done; qos_publisher_new (&up->qos, qos); if (listener) up->listener = *listener; up->mask = mask; up->def_writer_qos = qos_def_writer_qos; enable = dp->autoenable; lock_release (dp->lock); if (enable) DDS_Publisher_enable (up); return (up); done: lock_release (dp->lock); prof_stop (dcps_create_pub, 1); return (NULL); }
DDS_Subscriber DDS_DomainParticipant_create_subscriber (DDS_DomainParticipant dp, const DDS_SubscriberQos *qos, const DDS_SubscriberListener *listener, DDS_StatusMask mask) { Subscriber_t *sp; int enable; ctrc_begind (DCPS_ID, DCPS_DP_C_SUB, &dp, sizeof (dp)); ctrc_contd (&qos, sizeof (qos)); ctrc_contd (&listener, sizeof (listener)); ctrc_contd (&mask, sizeof (mask)); ctrc_endd (); prof_start (dcps_create_sub); if (!domain_ptr (dp, 1, NULL)) return (NULL); if (qos == DDS_SUBSCRIBER_QOS_DEFAULT) qos = &dp->def_subscriber_qos; else if (!qos_valid_subscriber_qos (qos)) { sp = NULL; goto done; } sp = subscriber_create (dp, 0); if (!sp) goto done; qos_subscriber_new (&sp->qos, qos); if (listener) sp->listener = *listener; sp->mask = mask; enable = dp->autoenable; lock_release (dp->lock); if (enable) DDS_Subscriber_enable (sp); prof_stop (dcps_create_sub, 1); return (sp); done: lock_release (dp->lock); return (NULL); }
DDS_DomainParticipant DDS_Subscriber_get_participant (DDS_Subscriber sp) { Domain_t *dp; DDS_DomainParticipant part; ctrc_printd (DCPS_ID, DCPS_S_G_PART, &sp, sizeof (sp)); if (!subscriber_ptr (sp, NULL)) return (NULL); dp = domain_ptr (sp->domain, 1, NULL); if (!dp) return (NULL); part = sp->domain; lock_release (dp->lock); return (part); }
DDS_StatusMask DDS_Subscriber_get_status_changes (DDS_Subscriber sp) { Domain_t *dp; DDS_StatusMask m; ctrc_printd (DCPS_ID, DCPS_S_G_STAT, &sp, sizeof (sp)); if (!subscriber_ptr (sp, NULL)) return (0); dp = domain_ptr (sp->domain, 1, NULL); if (!dp) return (0); m = sp->status; lock_release (dp->lock); return (m); }
DDS_ReturnCode_t DDS_DomainParticipant_delete_multitopic ( DDS_DomainParticipant dp, DDS_MultiTopic t) { DDS_ReturnCode_t ret; ctrc_begind (DCPS_ID, DCPS_DP_D_MTOP, &dp, sizeof (dp)); ctrc_contd (&t, sizeof (t)); ctrc_endd (); ARG_NOT_USED (t) /* Check some required parameters. */ if (!domain_ptr (dp, 0, &ret)) return (ret); return (DDS_RETCODE_UNSUPPORTED); }
DDS_SubscriberListener *DDS_Subscriber_get_listener (DDS_Subscriber sp) { Domain_t *dp; DDS_SubscriberListener *lp; ctrc_printd (DCPS_ID, DCPS_S_G_LIS, &sp, sizeof (sp)); if (!subscriber_ptr (sp, NULL)) return (NULL); dp = domain_ptr (sp->domain, 1, NULL); if (!dp) return (NULL); lp = &sp->listener; lock_release (dp->lock); return (lp); }
DDS_ReturnCode_t DDS_DomainParticipant_delete_publisher (DDS_DomainParticipant dp, DDS_Publisher up) { Condition_t *cp; DDS_ReturnCode_t ret; ctrc_begind (DCPS_ID, DCPS_DP_D_PUB, &dp, sizeof (dp)); ctrc_contd (&up, sizeof (up)); ctrc_endd (); prof_start (dcps_delete_pub); if (!domain_ptr (dp, 1, &ret)) return (ret); if (!publisher_ptr (up, &ret)) goto done; if (up->domain != dp) { ret = DDS_RETCODE_BAD_PARAMETER; goto done; } if (up->nwriters) { log_printf (DCPS_ID, 0, "delete_publisher(): still writers connected!\r\n"); ret = DDS_RETCODE_PRECONDITION_NOT_MET; goto done; } /* Delete StatusCondition if it exists. */ if (up->condition) { cp = (Condition_t *) up->condition; if (cp->deferred) dds_defer_waitset_undo (up, up->condition); dcps_delete_status_condition (up->condition); up->condition = NULL; } qos_publisher_free (&up->qos); publisher_delete (up); done: lock_release (dp->lock); prof_stop (dcps_delete_pub, 1); return (ret); }
DDS_ReturnCode_t DDS_DomainParticipant_get_current_time (DDS_DomainParticipant dp, DDS_Time_t *current_time) { DDS_ReturnCode_t ret; ctrc_begind (DCPS_ID, DCPS_DP_G_TIME, &dp, sizeof (dp)); ctrc_contd (current_time, sizeof (*current_time)); ctrc_endd (); if (!current_time) return (DDS_RETCODE_BAD_PARAMETER); if (!domain_ptr (dp, 1, &ret)) return (ret); sys_gettime ((Time_t *) current_time); lock_release (dp->lock); return (DDS_RETCODE_OK); }
DDS_Subscriber DDS_DomainParticipant_get_builtin_subscriber (DDS_DomainParticipant dp) { Subscriber_t *sp; ctrc_printd (DCPS_ID, DCPS_DP_G_BI_SUB, &dp, sizeof (dp)); if (!domain_ptr (dp, 1, NULL)) return (NULL); if ((sp = dp->builtin_subscriber) == NULL) { sp = dp->builtin_subscriber = subscriber_create (dp, 1); if (sp) { qos_subscriber_new (&sp->qos, &qos_def_subscriber_qos); sp->def_reader_qos = qos_def_reader_qos; } } lock_release (dp->lock); return (sp); }
DDS_ReturnCode_t DDS_DomainParticipant_get_qos (DDS_DomainParticipant dp, DDS_DomainParticipantQos *qos) { DDS_ReturnCode_t ret; ctrc_begind (DCPS_ID, DCPS_DP_G_QOS, &dp, sizeof (dp)); ctrc_contd (&qos, sizeof (qos)); ctrc_endd (); if (!qos) return (DDS_RETCODE_BAD_PARAMETER); if (!domain_ptr (dp, 1, &ret)) return (ret); qos_str2octets (dp->participant.p_user_data, &qos->user_data.value); qos->entity_factory.autoenable_created_entities = dp->autoenable; lock_release (dp->lock); return (DDS_RETCODE_OK); }