Hello all,
How can I filter unions based on the data embedded?
I mean there is an enum integrated in the union telling me which data is stored. This enum I can access in C++.
But how do I create for example a content filtered topic based on this internal enum?
Best regards,
Andreas
Hi Andreas,
Are you talking about something like this?
enum my_enum { BLUE, GREEN, YELLOW, RED }; union my_union switch(my_enum) { case BLUE : long blue_value; case GREEN : long green_value; case YELLOW : long yellow_value; case RED : long red_value; default : long nothing; };If this is your case, I was able to create a CFT based on the example provided in the community. Just try this:
DDS_StringSeq parameters(1); const char* param_list[] = {"1"}; parameters.from_array(param_list, 1); DDSContentFilteredTopic *cft = NULL; cft = participant->create_contentfilteredtopic( "ContentFilteredTopic", topic, "(_d = %0)", parameters); if (cft == NULL) { printf("create_contentfilteredtopic error\n"); subscriber_shutdown(participant); return -1; }Note that _d refers to the discriminator, which in this case is the enum value (that can be filtered as an int).
Thanks,
Juanjo Martin
Great, that was easy. Thank you!