Create ContentFilterTopic by Char comparision

3 posts / 0 new
Last post
Offline
Last seen: 3 years 11 months ago
Joined: 09/25/2020
Posts: 5
Create ContentFilterTopic by Char comparision

Hello, I ´ve  a problem using DDS Filter. The problem is about content condition in filter topic. My topic has several fields and one like this: 

Arbitrary_field:
[0]: 'E'
[1]: 'x'
[2]: 'a'
[3]: 'm'
[4]: 'p'
[5]: 'l'
[6]: 'e'

 

The result above is when I publish the topic and I watch it by DDS Spy. I´d like filter it by name ('Example').

If I print by screen the result I get something like this:

 

[..., Arbitrary_field: {E , x, a, m, p, l, e}, ...]

 

I´m using ContentFilteredTopic like this:

     _filter="Arbitrary_field='{E, x, a, m, p, l, e}'";
     _topic = new ContentFilteredTopic<topic_type>(
             topic,
             name,
            Filter(_filter)
        );
 
This construction has worked well in other cases but I don´t know the correct form to fill "_filter" or if exists another form
to make it. Can you help me?
 
Thanks and best regards.

 

Organization:
Offline
Last seen: 1 month 1 week ago
Joined: 12/16/2020
Posts: 1

Hello Rafael,

From your explanation, I guess you are using an array or a Sequence for this specific field (correct me if I am wrong).

Let's assume for example you are using the following IDL type definition:

struct HelloWorld {
     char Arbitrary_field[7];
};

Then, if you want to filter your samples by ‘{E, x, a, m, p, l, e}’, you should check for each array’s position individually. This is how your filter expression should look like:

_filter = “Arbitrary_field[0]='E' AND 
           Arbitrary_field[1]='x' AND
           Arbitrary_field[2]='a' AND 
           Arbitrary_field[3]='m' AND 
           Arbitrary_field[4]='p' AND 
           Arbitrary_field[5]='l' AND 
           Arbitrary_field[6]='e'”;

*Note: This filter expression also works for Sequences.

Finally, you can find more information about SQL Filter Expressions in our Core Libraries User’s Manual.

Best regards,
Alvaro

Offline
Last seen: 3 years 11 months ago
Joined: 09/25/2020
Posts: 5

Perfect, now it works fine, with an addition: ,I've had to change ContentFilteredTopic size because it's defined in 256 bytes default and I'll need more. I hope don't have any problems in future with that. 

Thank for all!

Regards.