RTI Connext Modern C++ API  Version 5.3.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rti::topic::ContentFilter< T, CompileData > Class Template Referenceabstract

<<extension>> A class to inherit from when implementing a custom content filter More...

#include <rti/topic/ContentFilter.hpp>

Inheritance diagram for rti::topic::ContentFilter< T, CompileData >:
rti::topic::WriterContentFilter< T, CompileData, WriterFilterData > rti::topic::WriterContentFilterHelper< T, CompileData, WriterFilterData >

Public Member Functions

virtual CompileData & compile (const std::string &expression, const dds::core::StringSeq &parameters, const dds::core::optional< dds::core::xtypes::DynamicType > &type_code, const std::string &type_class_name, CompileData *old_compile_data)=0
 Compile an instance of the content filter according to the filter expression and parameters of the given data type.
 
virtual bool evaluate (CompileData &compile_data, const T &sample, const FilterSampleInfo &meta_data)=0
 Evaluate whether the sample is passing the filter or not according to the sample content.
 
virtual void finalize (CompileData &compile_data)=0
 A previously compiled instance of the content filter is no longer in use and resources can now be cleaned up.
 

Detailed Description

template<typename T, typename CompileData = no_compile_data_t>
class rti::topic::ContentFilter< T, CompileData >

<<extension>> A class to inherit from when implementing a custom content filter

This interface can be implemented by an application-provided class and then registered with the DomainParticipant such that samples can be filtered for dds::topic::ContentFilteredTopic with the filter name that the filter is registered with.

Note: the API for using a custom content filter is subject to change in a future release.

For an example of how to create a custom content filter see Creating Custom Content Filters

Template Parameters
TThe type of the samples that this ContentFilter will filter
CompileDatathe type of the data that the compile function will return. If your compile function will not return data, you can leave this template parameter to the default no_compile_data_t type and return rti::topic::no_compile_data in your compile function
See Also
rti::topic::CustomFilter
dds::domain::DomainParticipant::register_contentfilter()

Member Function Documentation

template<typename T , typename CompileData = no_compile_data_t>
virtual CompileData& rti::topic::ContentFilter< T, CompileData >::compile ( const std::string &  expression,
const dds::core::StringSeq parameters,
const dds::core::optional< dds::core::xtypes::DynamicType > &  type_code,
const std::string &  type_class_name,
CompileData *  old_compile_data 
)
pure virtual

Compile an instance of the content filter according to the filter expression and parameters of the given data type.

This method is called when an instance of the locally registered content filter is created or when the expression parameter for the locally registered content filter instance is changed.

An instance of the locally registered content filter is created every time a local dds::topic::ContentFilteredTopic with the matching filter name is created, or when a dds::sub::DataReader with a matching filter name is discovered.

It is possible for multiple threads to be calling into this function at the same time. However, this function will never be called on a content filter that has been unregistered.

Parameters
expressionAn std::string with the filter expression. If you want to manipulate this string, you must first make a copy of it.
parametersA string sequence with the expression parameters the ContentFilteredTopic was created with. The string sequence is equal (but not identical) to the string sequence passed to dds::topic::ContentFilteredTopic(). Note that the sequence passed to the compile function is owned by RTI Connext and must not be referenced outside the compile function.
type_codeThe DynamicType for the related Topic of the ContentFilteredTopic. A type code is a description of a type in terms of which types it contains (such as long, string, etc.) and the corresponding member field names in the data type structure. The type code can be used to write custom content filters that can be used with any type.
type_class_nameFully qualified class name of the related Topic.
old_compile_dataThe previous CompileData value from a previous call to this instance of a content filter. If the compile function is called more than once for an instance of a ContentFilteredTopic, e.g., if the expression parameters are changed, then the CompileData value returned by the previous invocation is passed in the old_compile_data parameter (which can be NULL). If this is a new instance of the filter, NULL is passed. This parameter is useful for freeing or reusing previously allocated resources.
Returns
User specified compile data for this instance of the content filter. This value is then passed to the evaluate finalize functions for this instance of the content filter. Can be set to rti::topic::no_compile_data.
template<typename T , typename CompileData = no_compile_data_t>
virtual bool rti::topic::ContentFilter< T, CompileData >::evaluate ( CompileData &  compile_data,
const T &  sample,
const FilterSampleInfo meta_data 
)
pure virtual

Evaluate whether the sample is passing the filter or not according to the sample content.

This method is called when a sample for a locally created dds::sub::DataReader associated with the filter is received, or when a sample for a discovered dds::sub::DataReader assocated with the filter needs to be sent.

It is possible for multiple threads to be calling into this function at the same time. However, this function will never be called on a content filter that has been unregistered.

Parameters
compile_dataThe last return value of the compile function for this instance of the content filter.
sampleA deserialized sample to be filtered.
meta_dataMeta data associated with the sample.
Returns
The function must return false if the sample should be filtered out (did not pass the filter), true otherwise
template<typename T , typename CompileData = no_compile_data_t>
virtual void rti::topic::ContentFilter< T, CompileData >::finalize ( CompileData &  compile_data)
pure virtual

A previously compiled instance of the content filter is no longer in use and resources can now be cleaned up.

This method is called when an instance of the locally registered content filter is deleted.

An instance of the locally registered content filter is deleted every time a local dds::topic::ContentFilteredTopic with the matching filter name is deleted, or when a dds::sub::DataReader with a matching filter name is removed due to discovery.

This method is also called on all instances of the discovered dds::sub::DataReader with a matching filter name if the filter is unregistered with dds::domain::DomainParticipant::unregister_contentfilter(const std::string & filter_name)

It is possible for multiple threads to be calling into this function at the same time. However, this function will never be called on a content filter that has been unregistered.

Parameters
compile_dataThe last return value of the compile function for this instance of the content filter.

RTI Connext Modern C++ API Version 5.3.0 Copyright © Sun Jun 25 2017 Real-Time Innovations, Inc