ADTF
Loading...
Searching...
No Matches
Example Substream Element Dumper

Description

Shows how to access members of incoming substreams.

Prebuilt Binaries

Source Code

./examples/demo_adtfplugins/substream_element_dumper/

Filter

substream_element_dumper.cpp

#include "substream_element_dumper.h"
using namespace adtf::ucom;
using namespace adtf::base;
using namespace adtf::streaming;
using namespace adtf::filter;
cDemoSubStreamElementDumper::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/html/page_substream_element_dumper.html");
}
cDemoSubStreamElementDumper::~cDemoSubStreamElementDumper() = default;
tResult cDemoSubStreamElementDumper::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 cDemoSubStreamElementDumper::Shutdown(tInitStage eStage)
{
if (eStage == StageNormal)
{
RemoveAllHandlers();
}
}
// this creates the plugin entry methods and class factories
ADTF_PLUGIN("Substream Element Dumper Plugin", cDemoSubStreamElementDumper);
#define ADTF_PLUGIN(__plugin_identifier,...)
Definition adtf_plugin.h:29
#define LOG_INFO(...)
Logs an info message.
Definition log.h:388
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Definition result.h:29
tResult Init(tInitStage eStage) override
tResult Shutdown(tInitStage eStage) override
Namespace for the ADTF Base SDK.
Definition adtf_base_type_traits.h:13
Namespace for the ADTF Filter SDK.
Definition configurable_runner.h:18
Namespace for the ADTF Streaming SDK.
Definition bindingproxyinport.h:14
Namespace for the ADTF uCOM SDK.
Definition adtf_system.h:324
A timestamp with nanosecond precision.
Definition chrono.h:23