void Codes_Downld_finalize_ex( Codes_Downld* sample,RTIBool deletePointers) { DDS_String_free(sample->nodeId); DDS_String_free(sample->label); DDS_String_free(sample->msgstr); DDS_OctetSeq_finalize(&sample->data); }
void Monitor_Cmd_finalize_ex( Monitor_Cmd* sample,RTIBool deletePointers) { DDS_String_free(sample->msgstr); }
static int subscriber_main(int domainId, int sample_count) { DDS_DomainParticipant *participant = NULL; DDS_Subscriber *subscriber = NULL; DDS_Topic *topic = NULL; struct DDS_DataReaderListener reader_listener = DDS_DataReaderListener_INITIALIZER; DDS_DataReader *reader = NULL; DDS_ReturnCode_t retcode; const char *type_name = NULL; int count = 0; struct DDS_Duration_t poll_period = { 1, 0 }; const char* param_list[] = { "2", "divides" }; DDS_ContentFilteredTopic *cft = NULL; struct DDS_StringSeq parameters; struct DDS_ContentFilter custom_filter = DDS_ContentFilter_INITIALIZER; /* To customize participant QoS, use the configuration file USER_QOS_PROFILES.xml */ participant = DDS_DomainParticipantFactory_create_participant( DDS_TheParticipantFactory, domainId, &DDS_PARTICIPANT_QOS_DEFAULT, NULL /* listener */, DDS_STATUS_MASK_NONE); if (participant == NULL) { printf("create_participant error\n"); subscriber_shutdown(participant); return -1; } /* To customize subscriber QoS, use the configuration file USER_QOS_PROFILES.xml */ subscriber = DDS_DomainParticipant_create_subscriber(participant, &DDS_SUBSCRIBER_QOS_DEFAULT, NULL /* listener */, DDS_STATUS_MASK_NONE); if (subscriber == NULL) { printf("create_subscriber error\n"); subscriber_shutdown(participant); return -1; } /* Register the type before creating the topic */ type_name = ccfTypeSupport_get_type_name(); retcode = ccfTypeSupport_register_type(participant, type_name); if (retcode != DDS_RETCODE_OK) { printf("register_type error %d\n", retcode); subscriber_shutdown(participant); return -1; } /* To customize topic QoS, use the configuration file USER_QOS_PROFILES.xml */ topic = DDS_DomainParticipant_create_topic(participant, "Example ccf", type_name, &DDS_TOPIC_QOS_DEFAULT, NULL /* listener */, DDS_STATUS_MASK_NONE); if (topic == NULL) { printf("create_topic error\n"); subscriber_shutdown(participant); return -1; } /*------ Start changes for Custom_Content_Filter ------*/ /* Create and register custom filter */ custom_filter.compile = custom_filter_compile_function; custom_filter.evaluate = custom_filter_evaluate_function; custom_filter.finalize = custom_filter_finalize_function; custom_filter.filter_data = NULL; retcode = DDS_DomainParticipant_register_contentfilter(participant, "CustomFilter", &custom_filter); if (retcode != DDS_RETCODE_OK) { printf("Failed to register custom content filter"); subscriber_shutdown(participant); return -1; } DDS_StringSeq_initialize(¶meters); DDS_StringSeq_set_maximum(¶meters, 2); DDS_StringSeq_from_array(¶meters, param_list, 2); cft = DDS_DomainParticipant_create_contentfilteredtopic_with_filter( participant, "ContentFilteredTopic", topic, "%0 %1 x", ¶meters, "CustomFilter"); if (cft == NULL) { printf("create_contentfilteredtopic error\n"); subscriber_shutdown(participant); return -1; } printf("Filter: 2 divides x\n"); /* Note that we pass 'ccf' rather than 'topic' to the datareader below */ /*------ End changes for Custom_Content_Filter ------*/ /* Set up a data reader listener */ reader_listener.on_requested_deadline_missed = ccfListener_on_requested_deadline_missed; reader_listener.on_requested_incompatible_qos = ccfListener_on_requested_incompatible_qos; reader_listener.on_sample_rejected = ccfListener_on_sample_rejected; reader_listener.on_liveliness_changed = ccfListener_on_liveliness_changed; reader_listener.on_sample_lost = ccfListener_on_sample_lost; reader_listener.on_subscription_matched = ccfListener_on_subscription_matched; reader_listener.on_data_available = ccfListener_on_data_available; /* * NOTE THAT WE USE THE PREVIOUSLY CREATED CUSTOM FILTERED TOPIC TO READ * NEW SAMPLES */ reader = DDS_Subscriber_create_datareader(subscriber, DDS_Topic_as_topicdescription(cft), &DDS_DATAREADER_QOS_DEFAULT, &reader_listener, DDS_STATUS_MASK_ALL); if (reader == NULL) { printf("create_datareader error\n"); subscriber_shutdown(participant); return -1; } /* Start changes for Custom_Content_Filter */ /* Main loop */ for (count = 0; (sample_count == 0) || (count < sample_count); ++count) { if (count == 10) { printf("changing filter parameters\n"); printf("Filter: 15 greater-than x\n"); DDS_String_free(DDS_StringSeq_get(¶meters, 0)); DDS_String_free(DDS_StringSeq_get(¶meters, 1)); *DDS_StringSeq_get_reference(¶meters, 0) = DDS_String_dup("15"); *DDS_StringSeq_get_reference(¶meters, 1) = DDS_String_dup( "greater-than"); retcode = DDS_ContentFilteredTopic_set_expression_parameters(cft, ¶meters); if (retcode != DDS_RETCODE_OK) { printf("set_expression_parameters error\n"); subscriber_shutdown(participant); return -1; } } else if (count == 20) { struct DDS_StringSeq oldParameters; printf("changing filter parameters\n"); printf("Filter: 3 divides x\n"); DDS_ContentFilteredTopic_get_expression_parameters(cft, &oldParameters); DDS_String_free(DDS_StringSeq_get(&oldParameters, 0)); *DDS_StringSeq_get_reference(&oldParameters, 0) = DDS_String_dup( "3"); *DDS_StringSeq_get_reference(&oldParameters, 1) = DDS_String_dup( "divides"); retcode = DDS_ContentFilteredTopic_set_expression_parameters(cft, &oldParameters); if (retcode != DDS_RETCODE_OK) { printf("set_expression_parameters error\n"); subscriber_shutdown(participant); return -1; } } NDDS_Utility_sleep(&poll_period); } /* Cleanup and delete all entities */ return subscriber_shutdown(participant); }