ADTF
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
substream_handling.h
Go to the documentation of this file.
1
7#pragma once
8#include "graph_object.h"
9#include "filter.h"
10#include <vector>
11#include <optional>
12#include <variant>
13#include <functional>
14#include <regex>
15
16namespace adtf
17{
18namespace filter
19{
20namespace riddler
21{
22
36{
37public:
42
54 const std::string& strInputPinName,
55 bool bForwardTriggerViaOutputPins = true);
56
59 cSubstreamHandling& operator=(cSubstreamHandling&& oOther);
60
62 cSubstreamHandling& operator=(const cSubstreamHandling&) = delete;
63
66
69
72
84 void AddSubstreamHandler(const std::string& strName,
85 tGeneratorCallback fnGeneratorCallback);
86
97 void AddSubstreamHandler(const std::regex& strNameExpression,
98 tNamedGeneratorCallback fnGeneratorCallback);
99
109 void AddSubstreamHandler(const std::string& strName,
110 tSampleCallback fnCallback);
111
112 using tElementValue = std::variant<bool, int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t, float, double>;
113
130 void AddElementHandler(const std::string& strSubstreamName,
131 const std::string& strElementName,
132 std::function<void(adtf::base::flash::tNanoSeconds, tElementValue)> fnCallback,
133 bool bNameHeuristic = false);
134
149 template <typename T>
150 void AddElementHandler(const std::string& strSubstreamName,
151 const std::string& strElementName,
152 std::function<void(adtf::base::flash::tNanoSeconds, T)> fnCallback,
153 bool bNameHeuristic = false)
154 {
155 AddElementHandler(strSubstreamName, strElementName, [fnCallback](adtf::base::flash::tNanoSeconds tmSampleTime, tElementValue xValue)
156 {
157 std::visit([&](auto&& xTypedValue)
158 {
159 fnCallback(tmSampleTime, static_cast<T>(xTypedValue));
160 }, xValue);
161 },
162 bNameHeuristic);
163 }
164
173
174private:
175 class cImplementation;
176 std::unique_ptr<cImplementation> m_pImplementation;
177};
178
189template <typename FilterBase = adtf::filter::cFilter>
190class substream_filter: public FilterBase, protected cSubstreamHandling
191{
192public:
193 substream_filter(const std::string& strInputPinName = "input"):
194 cSubstreamHandling(this, strInputPinName)
195 {
196 }
197};
198
206
207}
208
212
213}
214}
Definition graph_object.h:1223
Definition substream_handling.h:36
void AddSubstreamHandler(const std::string &strName, tGeneratorCallback fnGeneratorCallback)
std::function< void(const adtf::ucom::iobject_ptr< const adtf::streaming::ISample > &)> tSampleCallback
a function that processes samples
Definition substream_handling.h:65
cSubstreamHandling(adtf::filter::hollow::cGraphObject *pFilter, const std::string &strInputPinName, bool bForwardTriggerViaOutputPins=true)
void AddSubstreamHandler(const std::string &strName, tSampleCallback fnCallback)
void AddElementHandler(const std::string &strSubstreamName, const std::string &strElementName, std::function< void(adtf::base::flash::tNanoSeconds, T)> fnCallback, bool bNameHeuristic=false)
Definition substream_handling.h:150
void AddSubstreamHandler(const std::regex &strNameExpression, tNamedGeneratorCallback fnGeneratorCallback)
std::function< tSampleCallback(const adtf::ucom::iobject_ptr< const adtf::streaming::IStreamType > &)> tGeneratorCallback
a function that generates a function that processes samples for a given stream type.
Definition substream_handling.h:68
std::function< tSampleCallback(const std::string &, const adtf::ucom::iobject_ptr< const adtf::streaming::IStreamType > &)> tNamedGeneratorCallback
a function that generates a function that processes samples for a given substream name and stream typ...
Definition substream_handling.h:71
void AddElementHandler(const std::string &strSubstreamName, const std::string &strElementName, std::function< void(adtf::base::flash::tNanoSeconds, tElementValue)> fnCallback, bool bNameHeuristic=false)
Definition substream_handling.h:191
Namespace for all functionality of the ADTF Filter SDK provided since v3.17.
Definition runner_fallback.h:17
substream_filter<> cSubstreamFilter
Definition substream_handling.h:205
Namespace for the ADTF Filter SDK.
Definition dynamic_filter.h:13
ant::iobject_ptr< T > iobject_ptr
Alias always bringing the latest version of ant::iobject_ptr into scope.
Definition object_ptr_intf.h:428
Namespace for all functionality provided by ADTF and its SDKs.
Definition adtf_client_connector.h:14
A timestamp with nanosecond precision.
Definition chrono.h:23