ADTF
Loading...
Searching...
No Matches
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{
20
34{
35public:
40
52 const std::string& strInputPinName,
53 bool bForwardTriggerViaOutputPins = true);
54
67
70
73
76
79
91 void AddSubstreamHandler(const std::string& strName,
92 tGeneratorCallback fnGeneratorCallback);
93
105 void AddSubstreamHandler(const std::regex& strNameExpression,
106 tNamedGeneratorCallback fnGeneratorCallback);
107
117 void AddSubstreamHandler(const std::string& strName,
118 tSampleCallback fnCallback);
119
124 using tElementValue = std::variant<bool, int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t, float, double>;
125
142 void AddElementHandler(const std::string& strSubstreamName,
143 const std::string& strElementName,
144 std::function<void(adtf::base::flash::tNanoSeconds, tElementValue)> fnCallback,
145 bool bNameHeuristic = false);
146
161 template <typename T>
162 void AddElementHandler(const std::string& strSubstreamName,
163 const std::string& strElementName,
164 std::function<void(adtf::base::flash::tNanoSeconds, T)> fnCallback,
165 bool bNameHeuristic = false)
166 {
167 AddElementHandler(strSubstreamName, strElementName, [fnCallback](adtf::base::flash::tNanoSeconds tmSampleTime, tElementValue xValue)
168 {
169 std::visit([&](auto&& xTypedValue)
170 {
171 fnCallback(tmSampleTime, static_cast<T>(xTypedValue));
172 }, xValue);
173 },
174 bNameHeuristic);
175 }
176
185
186private:
187 class cImplementation;
188 std::unique_ptr<cImplementation> m_pImplementation;
189};
190
201template <typename FilterBase = adtf::filter::cFilter>
202class substream_filter: public FilterBase, protected cSubstreamHandling
203{
204public:
205 substream_filter(const std::string& strInputPinName = "input"):
206 cSubstreamHandling(this, strInputPinName)
207 {
208 }
209};
210
218
219}
220}
Definition graph_object.h:174
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, tElementValue)> fnCallback, bool bNameHeuristic=false)
cSubstreamHandling & operator=(cSubstreamHandling &&oOther)
void AddSubstreamHandler(const std::regex &strNameExpression, tNamedGeneratorCallback fnGeneratorCallback)
cSubstreamHandling(adtf::filter::cGraphObject *pFilter, const std::string &strInputPinName, bool bForwardTriggerViaOutputPins=true)
cSubstreamHandling(cSubstreamHandling &&oOther)
std::variant< bool, int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t, uint64_t, float, double > tElementValue
Definition substream_handling.h:124
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:72
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:78
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:162
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:75
Definition substream_handling.h:203
Namespace for the ADTF Filter SDK.
Definition configurable_runner.h:18
substream_filter<> cSubstreamFilter
Definition substream_handling.h:217
ant::iobject_ptr< T > iobject_ptr
Alias always bringing the latest version of ant::iobject_ptr into scope.
Definition object_ptr_intf.h:437
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