@@ -281,6 +281,9 @@ class ShapeOptions {
281281 useconds_t periodic_announcement_period_us;
282282
283283 unsigned int datafrag_size;
284+ char * cft_expression;
285+
286+ int size_modulo;
284287
285288public:
286289 // -------------------------------------------------------------
@@ -338,6 +341,9 @@ class ShapeOptions {
338341 periodic_announcement_period_us = 0 ;
339342
340343 datafrag_size = 0 ; // Default: 0 (means not set)
344+ cft_expression = NULL ;
345+
346+ size_modulo = 0 ; // 0 means disabled
341347 }
342348
343349 // -------------------------------------------------------------
@@ -346,6 +352,7 @@ class ShapeOptions {
346352 STRING_FREE (topic_name);
347353 STRING_FREE (color);
348354 STRING_FREE (partition);
355+ STRING_FREE (cft_expression);
349356 }
350357
351358 // -------------------------------------------------------------
@@ -413,6 +420,13 @@ class ShapeOptions {
413420 printf (" announcement period in ms. Default 0 (off)\n " );
414421 printf (" --datafrag-size <bytes> : set the data fragment size (default: 0, means\n " );
415422 printf (" not set)\n " );
423+ printf (" --cft <expression> : ContentFilteredTopic filter expression (quotes\n " );
424+ printf (" required around the expression). Cannot be used with\n " );
425+ printf (" -c on subscriber applications\n " );
426+ printf (" --size-modulo <int> : If set, the modulo operation is applied to the\n " );
427+ printf (" shapesize. This will make that shapesize is in the\n " );
428+ printf (" range [1,N]. This only applies if shapesize is\n " );
429+ printf (" increased (-z 0)\n " );
416430 }
417431
418432 // -------------------------------------------------------------
@@ -425,7 +439,7 @@ class ShapeOptions {
425439 logger.log_message (" please specify publish [-P] or subscribe [-S]" , Verbosity::ERROR);
426440 return false ;
427441 }
428- if ( publish && subscribe ) {
442+ if (publish && subscribe) {
429443 logger.log_message (" please specify only one of: publish [-P] or subscribe [-S]" , Verbosity::ERROR);
430444 return false ;
431445 }
@@ -442,6 +456,9 @@ class ShapeOptions {
442456 if (publish && take_read_next_instance == false ) {
443457 logger.log_message (" warning: --take-read ignored on publisher applications" , Verbosity::ERROR);
444458 }
459+ if (publish && cft_expression != NULL ) {
460+ logger.log_message (" warning: --cft ignored on publisher applications" , Verbosity::ERROR);
461+ }
445462 if (subscribe && shapesize != 20 ) {
446463 logger.log_message (" warning: shapesize [-z] ignored on subscriber applications" , Verbosity::ERROR);
447464 }
@@ -477,6 +494,13 @@ class ShapeOptions {
477494 logger.log_message (" warning: use of take/read_next_instance() not available, using take/read()" , Verbosity::ERROR);
478495 }
479496#endif
497+ if (size_modulo > 0 && shapesize != 0 ) {
498+ logger.log_message (" warning: --size-modulo has no effect unless shapesize (-z) is set to 0" , Verbosity::ERROR);
499+ }
500+ if (subscribe && color != NULL && cft_expression != NULL ) {
501+ logger.log_message (" error: cannot specify both --cft and -c/--color for subscriber applications" , Verbosity::ERROR);
502+ return false ;
503+ }
480504
481505 return true ;
482506 }
@@ -504,7 +528,9 @@ class ShapeOptions {
504528 {" take-read" , no_argument, NULL , ' K' },
505529 {" time-filter" , required_argument, NULL , ' i' },
506530 {" periodic-announcement" , required_argument, NULL , ' N' },
507- {" datafrag-size" , required_argument, NULL , ' F' },
531+ {" datafrag-size" , required_argument, NULL , ' Z' },
532+ {" cft" , required_argument, NULL , ' F' },
533+ {" size-modulo" , required_argument, NULL , ' Q' },
508534 {NULL , 0 , NULL , 0 }
509535 };
510536
@@ -889,7 +915,7 @@ class ShapeOptions {
889915 periodic_announcement_period_us = (useconds_t ) converted_param * 1000 ;
890916 break ;
891917 }
892- case ' F ' : {
918+ case ' Z ' : {
893919 unsigned int converted_param = 0 ;
894920 if (sscanf (optarg, " %u" , &converted_param) == 0 ) {
895921 logger.log_message (" unrecognized value for datafrag-size "
@@ -907,6 +933,17 @@ class ShapeOptions {
907933 parse_ok = false ;
908934 }
909935 datafrag_size = converted_param;
936+ case ' F' :
937+ cft_expression = strdup (optarg);
938+ break ;
939+ case ' Q' : {
940+ int converted_param = 0 ;
941+ if (sscanf (optarg, " %d" , &converted_param) == 0 || converted_param < 1 ) {
942+ logger.log_message (" incorrect value for size-modulo, must be >=1" , Verbosity::ERROR);
943+ parse_ok = false ;
944+ } else {
945+ size_modulo = converted_param;
946+ }
910947 break ;
911948 }
912949 case ' ?' :
@@ -1643,19 +1680,26 @@ class ShapeApplication {
16431680 logger.log_message (" HistoryDepth = " + std::to_string (dr_qos.history FIELD_ACCESSOR.depth ), Verbosity::DEBUG);
16441681 }
16451682
1646- if ( options->color != NULL ) {
1683+ if ( options->cft_expression != NULL || options-> color != NULL ) {
16471684 /* For Connext Micro color will be always NULL */
16481685#if !defined(RTI_CONNEXT_MICRO)
16491686 /* filter on specified color */
16501687 ContentFilteredTopic *cft = NULL ;
1651- StringSeq cf_params;
1688+ StringSeq cf_params;
16521689
16531690 for (unsigned int i = 0 ; i < options->num_topics ; ++i) {
16541691 const std::string filtered_topic_name_str =
16551692 std::string (options->topic_name ) +
16561693 (i > 0 ? std::to_string (i) : " " ) +
16571694 " _filtered" ;
16581695 const char * filtered_topic_name = filtered_topic_name_str.c_str ();
1696+ const char * filter_expr = nullptr ;
1697+
1698+ if (options->cft_expression != NULL ) {
1699+ filter_expr = options->cft_expression ;
1700+ cft = dp->create_contentfilteredtopic (filtered_topic_name, topics[i], filter_expr, cf_params);
1701+ logger.log_message (" ContentFilterTopic = \" " + std::string (filter_expr) + " \" " , Verbosity::DEBUG);
1702+ } else if (options->color != NULL ) {
16591703 #if defined(RTI_CONNEXT_DDS)
16601704 char parameter[64 ];
16611705 snprintf (parameter, 64 , " '%s'" , options->color );
@@ -1688,7 +1732,7 @@ class ShapeApplication {
16881732 return false ;
16891733 }
16901734
1691- printf (" Create reader for topic: %s color: %s \n " , cft->get_name () NAME_ACCESSOR, options-> color );
1735+ printf (" Create reader for topic: %s\n " , cft->get_name () NAME_ACCESSOR);
16921736 drs[i] = dynamic_cast <ShapeTypeDataReader *>(sub->create_datareader (cft, dr_qos, NULL , LISTENER_STATUS_MASK_NONE));
16931737 if (drs[i] == NULL ) {
16941738 logger.log_message (" failed to create datareader[" + std::to_string (i) + " ] topic: " + topics[i]->get_name (), Verbosity::ERROR);
@@ -1888,6 +1932,7 @@ class ShapeApplication {
18881932 if (sample_info->instance_state != ALIVE_INSTANCE_STATE) {
18891933 ShapeType shape_key;
18901934 shape_initialize_w_color (shape_key, NULL );
1935+
18911936#if defined(EPROSIMA_FAST_DDS)
18921937 shape_key.color FIELD_ACCESSOR = instance_handle_color[sample_info->instance_handle ] NAME_ACCESSOR;
18931938#elif defined(RTI_CONNEXT_MICRO)
@@ -1996,7 +2041,13 @@ class ShapeApplication {
19962041 moveShape (&shape);
19972042
19982043 if (options->shapesize == 0 ) {
1999- shape.shapesize FIELD_ACCESSOR += 1 ;
2044+ if (options->size_modulo > 0 ) {
2045+ // Size cannot be 0, so increase it after modulo operation
2046+ shape.shapesize FIELD_ACCESSOR =
2047+ (shape.shapesize FIELD_ACCESSOR % options->size_modulo ) + 1 ;
2048+ } else {
2049+ shape.shapesize FIELD_ACCESSOR += 1 ;
2050+ }
20002051 }
20012052
20022053#if !defined(RTI_CONNEXT_MICRO)
0 commit comments