RTI Connext Modern C++ API
Version 5.2.0
|
<<extension>> A class to inherit from when implementing a custom content filter More...
#include <rti/topic/ContentFilter.hpp>
Public Member Functions | |
virtual CompileData & | compile (const std::string &expression, const dds::core::StringSeq ¶meters, 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. | |
<<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
T | The type of the samples that this ContentFilter will filter |
CompileData | the 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 |
|
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.
expression | An std::string with the filter expression. If you want to manipulate this string, you must first make a copy of it. |
parameters | A 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_code | The 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_name | Fully qualified class name of the related Topic. |
old_compile_data | The 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. |
|
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.
compile_data | The last return value of the compile function for this instance of the content filter. |
sample | A deserialized sample to be filtered. |
meta_data | Meta data associated with the sample. |
|
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.
compile_data | The last return value of the compile function for this instance of the content filter. |