CoreDX DDS Modern C++ API
ContentFilteredTopic Use Cases

Create a ContentFilteredTopic

Create a ContentFilteredTopic with a simple filter.

#include <dds/domain/ddsdomain.hpp>
#include <dds/topic/ddstopic.hpp>
#include "foo.hh" // declares the foo types used in the examples
dds::topic::Topic< foo::ExampleType > topic( dp, "ExampleTopic" );
dds::topic::ContentFilteredTopic<foo::ExampleType> cf_topic( topic, "CFExampleTopic", dds::topic::Filter ( "theKey = 2" ) );

Create a ContentFilteredTopic with a parameterized filter, parameters to be specified later.

dds::topic::ContentFilteredTopic<foo::ExampleType> cf_topic( topic, "CFExampleTopic", dds::topic::Filter ( "theKey = %0" ) );

Create a ContentFilteredTopic with a parameterized filter, with parameters specfied at time of creation.

std::vector<std::string> params;
params.push_back("2");
dds::topic::ContentFilteredTopic<foo::ExampleType> cf_topic( topic, "CFExampleTopic", dds::topic::Filter ( "theKey = %0", params ) );

Create a ContentFilteredTopic with a parameterized filter, with parameters specfied at time of creation as an initilializer list.

dds::topic::ContentFilteredTopic<foo::ExampleType> cf_topic( topic, "CFExampleTopic", dds::topic::Filter ( "theKey = %0", { "2" } ) );

Setting or changing the filter parameters after creation.

std::vector<std::string> new_params;
params.push_back("10");
cf_topic.filter_parameters( new_params.begin(), new_params.end() );

Using a ContentFilteredTopic

Once a ContentFilteredTopic is created, it can be used in place of a standard Topic. A DataReader associcated with a ContentFilteredTopic will apply the filter to limit the samples presented to the application.

dds::sub::DataReader<foo::ExampleType> filtered_reader( sub, cf_topic );

© 2009-2020 Twin Oaks Computing, Inc
Castle Rock, CO 80104
All rights reserved.