Download Getting Started Guide - Community RTI Connext Users
Transcript
Subscribing Only to Relevant Data
5.2.1
❏
How old it is. You can indicate that data is relevant for only a certain period of
time (its lifespan) and/or that you wish to retain only a certain number of data
samples (a history depth). For example, if you are interested in the last ten articles
from each news outlet, you can set the history depth to 10.
❏
How fast it’s updated. Sometimes data streams represent the state of a moving or
changing object—for example, an application may publish the position of a moving vehicle or the changing price of a certain financial instrument. Subscribing
applications may only be able to—or interested in—processing this data at a certain maximum rate. For example, if the changing state is to be plotted in a user
interface, a human viewer is unlikely to be able to process more than a couple of
changes per second. If the application attempts to process updates any faster, it
will only confuse the viewer and consume resources unnecessarily.
Content-Based Filtering
A DataReader can filter incoming data by subscribing not to a given Topic itself, but to a
ContentFilteredTopic that associates the Topic with an SQL-like expression that indicates
which data samples are of interest to the subscribing application. Each subscribing
application can specify its own content-based filter, as it desires; publishing applications’ code does not need to change to allow subscribers to filter on data contents.
5.2.1.1
Implementation
The C++ code looks like this:
The Topic and ContentFilteredTopic classes share a base class: TopicDescription.
The variable contentFilterExpression in the above example code is a SQL expression;
see immediately below.
5-5
5. Design Patterns for
Rapid Development
DDSContentFilteredTopic cft =
participant->create_contentfilteredtopic(
cftName.c_str(),
topic,
contentFilterExpression.c_str(),
noFilterParams);
if (cft == NULL) {
throw std::runtime_error(
"Unable to create ContentFilteredTopic");
}