ADTF  3.18.3
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 
16 namespace adtf
17 {
18 namespace filter
19 {
20 namespace riddler
21 {
22 
36 {
37 public:
42 
54  const std::string& strInputPinName,
55  bool bForwardTriggerViaOutputPins = true);
56 
59  cSubstreamHandling& operator=(cSubstreamHandling&& oOther);
60 
61  cSubstreamHandling(const cSubstreamHandling&) = delete;
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 
174 private:
175  class cImplementation;
176  std::unique_ptr<cImplementation> m_pImplementation;
177 };
178 
189 template <typename FilterBase = adtf::filter::cFilter>
190 class substream_filter: public FilterBase, protected cSubstreamHandling
191 {
192 public:
193  substream_filter(const std::string& strInputPinName = "input"):
194  cSubstreamHandling(this, strInputPinName)
195  {
196  }
197 };
198 
206 
207 }
208 
212 
213 }
214 }
Base class for adtf::filter::flash::cFilter, adtf::filter::flash::cSampleStreamingSource and adtf::fi...
Utility class to handle substream routing within a filter.
cSubstreamHandling(adtf::filter::hollow::cGraphObject *pFilter, const std::string &strInputPinName, bool bForwardTriggerViaOutputPins=true)
Constructs a new object that will create an input pin at the given graph object (i....
std::function< void(const adtf::ucom::iobject_ptr< const adtf::streaming::ISample > &)> tSampleCallback
a function that processes samples
cSubstreamHandling()
Constructs an empty object that cannot perform any operations other than being assigned another value...
void RemoveAllHandlers()
Removes all installed handlers.
void AddSubstreamHandler(const std::string &strName, tGeneratorCallback fnGeneratorCallback)
Installs a handler generator for the given substream.
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...
void AddSubstreamHandler(const std::string &strName, tSampleCallback fnCallback)
Installs a handler for samples of the given substream.
void AddElementHandler(const std::string &strSubstreamName, const std::string &strElementName, std::function< void(adtf::base::flash::tNanoSeconds, T)> fnCallback, bool bNameHeuristic=false)
Installs a handler for the given element of the given substream.
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.
void AddElementHandler(const std::string &strSubstreamName, const std::string &strElementName, std::function< void(adtf::base::flash::tNanoSeconds, tElementValue)> fnCallback, bool bNameHeuristic=false)
Installs a handler for the given element of the given substream.
void AddSubstreamHandler(const std::regex &strNameExpression, tNamedGeneratorCallback fnGeneratorCallback)
Installs a handler generator that will be called for each available substream that matches the regula...
Helper class to implement a filter with a single input pin that processes substreams.
Base object pointer to realize binary compatible reference counting in interface methods.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
substream_filter<> cSubstreamFilter
Helper typedef to use substream_filter with the default filter base class.
Namespace for entire ADTF SDK.