ADTF  3.18.4
Source Code for Substream Dumper Plugin
Location
./src/examples/src/adtf/filters/standard_filters/substream_element_dumper/
Namespace for entire ADTF SDK.
Build Environment
To see how to set up the build environment have a look at ADTF CMake Environment
this implementation shows:
Implementation
using namespace adtf::ucom;
using namespace adtf::base;
using namespace adtf::streaming;
using namespace adtf::filter;
// This filter derives from cSubstreamFilter instead of cFilter
// If you want to use the substream handling functionality with a different base class, use the substream_filter<> template.
class cDemoSubStreamElementDumper: public cSubstreamFilter
{
public:
ADTF_CLASS_ID_NAME(cDemoSubStreamElementDumper,
"demo_substream_element_dumper.filter.adtf.cid",
"Substream Element Dumper");
public:
cDemoSubStreamElementDumper()
{
// cSubstreamFilter will create a single input pin (the name can be specified via the constructor and defaults to "input").
// If you want to handle multiple inputs use cSubstreamHandling directly.
SetDescription("input", "Incoming data of substreams.");
// Register our properties
m_strSubstreamName.SetDescription("The name of the substream that the element should be dumped of.");
RegisterPropertyVariable("substream_name", m_strSubstreamName);
m_strElementName.SetDescription("The name of the element to be dumped, i.e. 'parent.intermediate.leaf'");
RegisterPropertyVariable("element_name", m_strElementName);
// Set a short description for the component
SetDescription("Use this filter to dump a single element of a specific substream.");
// Set help link to jump to documentation from ADTF Configuration Editor
SetHelpLink("$(ADTF_DIR)/doc/adtf_html/page_demo_substream_element_dumper.html");
}
tResult Init(tInitStage eStage)
{
RETURN_IF_FAILED(cSubstreamFilter::Init(eStage));
if (eStage == StageNormal)
{
// Here we add a handler for a specific (DDL) element of a substream based on our properties.
// Please take a look at all the other Add* functions of cSubstreamHandling.
AddElementHandler<double>(m_strSubstreamName, m_strElementName, [this](tNanoSeconds /* tmTimestamp */, double fValue)
{
// Whenever a sample is received on the specified substream, the given element value
// will be retrieved from the sample and passed to this handler.
LOG_INFO("%s.%s = %f", m_strSubstreamName->c_str(), m_strElementName->c_str(), fValue);
});
}
}
tResult Shutdown(tInitStage eStage)
{
if (eStage == StageNormal)
{
RemoveAllHandlers();
}
return cSubstreamFilter::Shutdown(eStage);
}
private:
property_variable<std::string> m_strSubstreamName;
property_variable<std::string> m_strElementName;
};
// this creates the plugin entry methods and class factories
ADTF_PLUGIN("Substream Element Dumper Plugin", cDemoSubStreamElementDumper);
#define ADTF_PLUGIN(__plugin_identifier,...)
The ADTF Plugin Macro will add the code of a adtf::ucom::ant::IPlugin implementation.
Definition: adtf_plugin.h:22
Copyright © Audi Electronics Venture GmbH.
#define RETURN_IF_FAILED(s)
Return if expression is failed, which requires the calling function's return type to be tResult.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
#define ADTF_CLASS_ID_NAME(_class, _strcid, _strclabel)
Common macro to enable correct treatment of class identifier AND Class Name by IClassInfo.
Definition: class_id.h:33
Namespace for the ADTF Base SDK.
substream_filter<> cSubstreamFilter
Helper typedef to use substream_filter with the default filter base class.
Namespace for the ADTF Filter SDK.
Namespace for the ADTF Streaming SDK.
Namespace for the ADTF uCOM3 SDK.