Specifying ContentFilteredTopics in an XML file

7 posts / 0 new
Last post
Offline
Last seen: 9 years 9 months ago
Joined: 06/05/2014
Posts: 1
Specifying ContentFilteredTopics in an XML file

My question is how would I specify a ContentFilteredTopic within the USER_PROFILE_QOS.xml file that I am declaring all of my topics, writers, and readers etc. I found in RTI_CoreLibrariesAndUtilities_QoS_Reference_Guide.pdf about how you can add content filters to DataReaders and subscribers and everything, however this does not appear to produce a ContentFilteredTopic anywhere. As such, how would I update the expression parameter's dynamically? 

In summary, can I declare/define a CFT in an xml file so that I can use its functions within my program, and also what is the difference if any between using ContentFilteredTopics and specifying a SQL filter in an xml file for a DataReader.

Thank you for your time, and hopefully its something easy that I missed.

Offline
Last seen: 2 months 1 week ago
Joined: 04/23/2014
Posts: 57

As far I know, you cannot create ContentFilteredTopic in an XML file, you have to do it programmatically.

In the User's Manual section '5.4.3 Creating ContentFilteredTopics' is explained how to create and manage it. You have two options when creating the filter: 'STRINGMATCH Filter Expression Notation' and 'SQL Filter Expression Notation'. Both of them are explained in the User's Manual as well. Also, you have an example where the SQL filter use case is explained: http://community.rti.com/examples/content-filtered-topic.

We are working on improving that example to add the other use case. I will add a comment in the thread once it is ready.

Angel.

Offline
Last seen: 3 years 9 months ago
Joined: 09/10/2010
Posts: 32

Hello Brendan,

     To set the filter expression parameters dynamically, you would use the following wihtin your code:

 

   DDS_ReturnCode_t set_expression_parameters
                            (const struct DDS_StringSeq & parameters)

parameters

The filter expression parameters. Each element in the parameter sequence corre- sponds to a positional parameter in the filter expression. When using the default DDS_SQLFILTER_NAME, parameter strings are automatically converted to the member type. For example, "4" is converted to the integer 4. This parameter can- not be NULL. 

 

 

 

 

Fernando Garcia's picture
Offline
Last seen: 4 months 6 days ago
Joined: 05/18/2011
Posts: 199

Hi Brendan,

In addition to Bert's comment, note that you can define the parameters in the XML file using the following syntax:

<datareader name="FooDataReader" topic_ref="FooTopic">  
   <filter name="FooFilter" kind="builtin.sql">
        <parameter_list> 
            <param>a</param>
        </parameter_list> 
        <expression> a > 5 </expression> 
   </filter>
</datareader>
Offline
Last seen: 3 years 1 week ago
Joined: 01/15/2013
Posts: 94

Hi Brendan,

Just to clarify, when using the syntax Fernando is mentioning, you have to use the XML Application Creation functionality to access your ContentFilteredTopic. As far as I know, I don't think it can be done in XML for an application not using XML App Creation.

Thanks,

Juanlu

Offline
Last seen: 9 years 6 months ago
Joined: 08/04/2014
Posts: 6

Bert, Fernando & Brendan

I'm using XML App Creation and have included a filter on my subscriber (as per Fernando's example) in the XML, but how do I specify the parameter values in my C++ application?

If I use create_participant_from_config, how do I then get to the point where I use set_expression_params to specify the actual value?

Thanks,

Julie

Fernando Garcia's picture
Offline
Last seen: 4 months 6 days ago
Joined: 05/18/2011
Posts: 199

Hello Julie,

To specify the parameter values in C++ you will need to lookup the Content Filtered Topic (CFT) created via XML and perform operations on it just like you would do with a CFT created using the regular C++ API. Here's what you need to do.

// First lookup the geneneric "topic" data type, i.e., Topic Description
DDSTopicDescription * topic_description = participant->lookup_topicdescription(cft_name);
// Then narrow the Topic Description to get the actual Content Filtered Topic 
DDSContentFilteredTopic * cft = DDSContentFilteredTopic::narrow(topic_description);
// (Here you would set the value of the different parameters in the "parameters" sequence)
// Once you have set the parameters, just call set_expression_parameters() on the CFT
retcode = cft->set_expression_parameters(parameters);

We have a complete example on how to set expression parameters in our examples section, please take a look at it to understand how to initialize the parameters sequence.

Let me know if this works for you,
Fernando.