ADTF  3.18.2
filtersdk/include/adtffiltersdk/filter.h
Go to the documentation of this file.
1 
7 #pragma once
8 #include "graph_object.h"
9 
10 #include <adtfbase/configuration.h>
18 
19 #include <memory>
20 
21 namespace adtf
22 {
23 namespace filter
24 {
25 namespace ant
26 {
27 
32 class cConfigurableFilter : public ucom::catwo::object<streaming::ant::cFilterBase,
33  base::ant::configuration<>>
34 
35 {
36 
37 public:
41 
42 protected:
44  cConfigurableFilter() = default;
46  virtual ~cConfigurableFilter() = default;
47 
48 public:
51  {
52  return base_type_conf::GetProperties(pProperties);
53  }
56  {
57  return base_type_conf::configuration::GetProperties(pProperties);
58  }
60  tResult AttachConfiguration(const char* strName, base::ant::IConfiguration& oAttachedConfiguration) override
61  {
62  return base_type_conf::configuration::AttachConfiguration(strName, oAttachedConfiguration);
63  }
65  tResult DetachConfiguration(const char* strName) override
66  {
67  return base_type_conf::configuration::DetachConfiguration(strName);
68  }
69 };
70 
71 
74 
76 template <typename DATA_TYPE>
78 
81 
83 template<tTimeStamp TIME_RANGE, bool STORELASTSAMPLE = true>
85 
87 template<size_t MAX_SIZE, bool STORELASTSAMPLE = true>
89 
90 
110 {
113 
114 public:
116 
117 protected:
121  virtual ~cFilter() = default;
122 
123 public:
124 
125  tResult RegisterRunner(const char* strName, adtf::base::ant::IRunnable& oRunnable) override;
126 
135  tResult ConfigureDataInTrigger(const char* strRunnerName, const char* strPinName);
144  tResult ConfigureDataOutTrigger(const char* strRunnerName, const char* strPinName);
145 
154  tResult ConfigureTimerTrigger(const char* strRunnerName, tTimeStamp tmPeriod);
166  tResult ConfigureThreadTrigger(const char* strRunnerName, bool bCallCyclic);
167 
168 };
169 
177 template<typename READERWRITERTYPE, typename PINTYPE>
178 tResult filter_create_pin_with_exact_name(cFilter& oFilter, READERWRITERTYPE& oReaderWriter, ucom::ant::iobject_ptr<PINTYPE>& pPinType)
179 {
180  adtf::util::cString strName;
181  oReaderWriter.GetName(adtf_string_intf(strName));
183  oReaderWriter.GetType(pType);
184  return streaming::ant::create_pin<cFilter>(oFilter, oReaderWriter, strName, pType, pPinType);
185 }
186 
193 template<typename READERWRITERTYPE>
194 tResult filter_create_pin_with_exact_name(cFilter& oFilter, READERWRITERTYPE& oReaderWriter)
195 {
196  adtf::util::cString strName;
197  oReaderWriter.GetName(adtf_string_intf(strName));
199  oReaderWriter.GetType(pType);
200  return streaming::ant::create_pin<cFilter>(oFilter, oReaderWriter, strName, pType);
201 }
202 
203 
204 template<typename READERWRITERTYPE, typename PINTYPE>
205 tResult filter_create_pin(cFilter& oFilter, READERWRITERTYPE& oReaderORWriter, ucom::ant::iobject_ptr<PINTYPE>& pPin)
206 {
207  using namespace adtf::streaming::ant;
208  adtf_util::cString strNameOfReaderAndPin;
209  oReaderORWriter.GetName(adtf_string_intf(strNameOfReaderAndPin));
210  int nCurrentTry = 1;
211  while (true)
212  {
213  tResult nRes = filter_create_pin_with_exact_name<READERWRITERTYPE, PINTYPE>(oFilter, oReaderORWriter, pPin);
214  if (IS_OK(nRes))
215  {
217  }
218  if (nRes == ERR_RESOURCE_IN_USE)
219  {
220  adtf_util::cString strNameOfReaderAndPinTry = adtf_util::cString::Format("%s_%d.3", strNameOfReaderAndPin.GetPtr(), nCurrentTry++);
221  oReaderORWriter.SetName(strNameOfReaderAndPinTry);
222  }
223  else
224  {
225  return nRes;
226  }
227  }
229 }
230 
231 inline tResult filter_create_pin(cFilter& oFilter, adtf::streaming::ant::cSampleReader& oReader)
232 {
233  ucom::object_ptr<streaming::ant::IInPin> pPin;
234  return filter_create_pin<streaming::ant::cSampleReader, streaming::ant::IInPin>(oFilter, oReader, pPin);
235 }
236 
237 inline tResult filter_create_pin(cFilter& oFilter, adtf::streaming::ant::cSampleWriter& oWriter)
238 {
239  ucom::object_ptr<streaming::ant::IOutPin> pPin;
240  return filter_create_pin<streaming::ant::cSampleWriter, streaming::ant::IOutPin>(oFilter, oWriter, pPin);
241 }
242 
243 inline tResult filter_create_pin(cFilter& oFilter,
244  adtf::streaming::ant::cSampleReader& oReaderORWriter,
245  const char* strName,
246  const ucom::ant::iobject_ptr<const adtf::streaming::ant::IStreamType>& pType)
247 {
248  RETURN_IF_FAILED(adtf::streaming::ant::make_sample_reader(oReaderORWriter, strName, pType));
249  return filter_create_pin(oFilter, oReaderORWriter);
250 }
251 
252 inline tResult filter_create_pin(cFilter& oFilter,
253  adtf::streaming::ant::cSampleWriter& oReaderORWriter,
254  const char* strName,
255  const ucom::ant::iobject_ptr<const streaming::ant::IStreamType>& pType)
256 {
257  RETURN_IF_FAILED(adtf::streaming::ant::make_sample_writer(oReaderORWriter, strName, pType));
258  return filter_create_pin(oFilter, oReaderORWriter);
259 }
260 
261 } //namespace ant
262 
263 namespace flash
264 {
265 
285 class cFilter:
286  public ucom::catwo::object<streaming::ant::INamedGraphObject,
287  streaming::ant::IDataBinding,
288  streaming::ant::IInterfaceBinding,
289  streaming::ant::IRuntimeBehaviour,
290  streaming::ant::IDynamicDataBinding,
291  streaming::ant::IDynamicInterfaceBinding,
292  streaming::ant::IFilter,
293  base::ant::IConfiguration>,
294  public cGraphObject,
296 {
297  public:
298  // this needs to be here because unfortunately multiple base classes have this as well (altough it is not needed at all)
299  template <typename T>
301 
309  ~cFilter() override;
310 
339  tResult Init(tInitStage eStage) override;
340 
349  tResult Start() override;
350  tResult Stop() override;
351 
355  tResult Shutdown(tInitStage eStage) override;
356 
357  tResult SetName(const char* strName) override;
358  tResult GetName(base::ant::IString&& strName) const override;
359  tResult SetParent(const ucom::ant::IObject* poParentObject) override;
360  tResult GetParent(const ucom::ant::IObject*& poParentObject) const override;
361 
362  tResult GetPins(ucom::ant::iobject_list<streaming::ant::IPin>& oPins) const override;
363  tResult FindPin(const char* strName, ucom::ant::iobject_ptr<ucom::ant::IObject>& pPin) const override;
364 
365  tResult GetBindingObjects(ucom::ant::iobject_list<streaming::ant::IBindingObject>& lstBindingObject) override;
366  tResult GetBindingObjects(ucom::ant::iobject_list<const streaming::ant::IBindingObject>& lstBindingObject) const override;
367  tResult FindBindingObject(const char* strName,
368  ucom::ant::iobject_ptr<const ucom::ant::IObject>& pIBindingObject) const override;
369  tResult FindBindingObject(const char* strName,
370  ucom::ant::iobject_ptr<ucom::ant::IObject>& pIBindingObject) override;
371 
372  tResult GetRunners(ucom::ant::iobject_list<streaming::ant::IRunner>& lstRunners) const override;
373  tResult FindRunner(const char* strName, ucom::ant::iobject_ptr<ucom::ant::IObject>& pRunner) const override;
374  tResult GetInnerPipes(ucom::ant::iobject_list<streaming::ant::ITriggerPipe>& lstInnerTriggerPipes) const override;
375 
376  tResult RequestPin(const char* strName,
379  tResult RequestPin(const char* strName,
382 
383  tResult RequestBindingObject(const char* strName,
386  tResult RequestBindingObject(const char* strName,
389 
390  tResult SetState(tFilterState eFilterState) override;
391  tFilterState GetState() const override;
392 
393  tResult GetProperties(ucom::ant::iobject_ptr<const base::ant::IProperties>& pProperties) const override;
394  tResult GetProperties(ucom::ant::iobject_ptr<base::ant::IProperties>& pProperties) override;
395  tResult AttachConfiguration(const char* strName, base::ant::IConfiguration& oAttachedConfiguration) override;
396  tResult DetachConfiguration(const char* strName) override;
397 
398  private:
399  class cImplementation;
400  std::unique_ptr<cImplementation> m_pImplementation;
401 };
402 
403 template<typename DATA_BINDING_IMPL_TYPE>
404 inline tResult filter_create_pin(DATA_BINDING_IMPL_TYPE& oFilter, adtf::streaming::flash::ISampleReader& oReader)
405 {
406  return streaming::flash::create_pin(oFilter, oReader);
407 }
408 
409 template<typename DATA_BINDING_IMPL_TYPE>
410 inline tResult filter_create_pin(DATA_BINDING_IMPL_TYPE& oFilter, adtf::streaming::flash::ISampleWriter& oWriter)
411 {
412  return streaming::flash::create_pin(oFilter, oWriter);
413 }
414 
415 template<typename DATA_BINDING_IMPL_TYPE>
416 inline tResult filter_create_pin(DATA_BINDING_IMPL_TYPE& oFilter,
418  const char* strName,
420 {
421  RETURN_IF_FAILED(adtf::streaming::flash::make_sample_reader(oReader, strName, pType));
422  return streaming::flash::create_pin(oFilter, oReader);
423 }
424 
425 template<typename DATA_BINDING_IMPL_TYPE>
426 inline tResult filter_create_pin(DATA_BINDING_IMPL_TYPE& oFilter,
428  const char* strName,
429  const ucom::ant::iobject_ptr<const streaming::ant::IStreamType>& pType)
430 {
431  RETURN_IF_FAILED(adtf::streaming::flash::make_sample_writer(oWriter, strName, pType));
432  return filter_create_pin(oFilter, oWriter);
433 }
434 
435 template<typename DATA_BINDING_IMPL_TYPE, typename READERWRITERTYPE, typename PINTYPE>
436 tResult filter_create_pin(DATA_BINDING_IMPL_TYPE& oFilter, READERWRITERTYPE& oReaderORWriter, ucom::ant::iobject_ptr<PINTYPE>& pPin)
437 {
438  ucom::ant::object_ptr<ucom::ant::IObject> pHelper;
439  RETURN_IF_FAILED(streaming::flash::create_pin(oFilter, oReaderORWriter, pHelper));
440  return pPin.Reset(ucom::ant::ucom_object_ptr_cast<PINTYPE>(pHelper));
441 }
442 
443 }
444 
445 namespace hollow
446 {
447 
449 class cFilter:
450  public ucom::catwo::object<streaming::ant::INamedGraphObject,
451  streaming::ant::IDataBinding,
452  streaming::ant::IInterfaceBinding,
453  streaming::ant::IRuntimeBehaviour,
454  streaming::ant::IDynamicDataBinding,
455  streaming::ant::IDynamicInterfaceBinding,
456  streaming::ant::IFilter,
457  base::ant::IConfiguration>,
458  public cGraphObject,
460 {
461  public:
462  // this needs to be here because unfortunately multiple base classes have this as well (altough it is not needed at all)
463  template <typename T>
465 
466  cFilter();
467  ~cFilter() override;
468 
470  tResult Init(tInitStage eStage) override;
471 
473  tResult Start() override;
474  tResult Stop() override;
475 
479  tResult Shutdown(tInitStage eStage) override;
480 
481  tResult SetName(const char* strName) override;
482  tResult GetName(base::ant::IString&& strName) const override;
483  tResult SetParent(const ucom::ant::IObject* poParentObject) override;
484  tResult GetParent(const ucom::ant::IObject*& poParentObject) const override;
485 
486  tResult GetPins(ucom::ant::iobject_list<streaming::ant::IPin>& oPins) const override;
487  tResult FindPin(const char* strName, ucom::ant::iobject_ptr<ucom::ant::IObject>& pPin) const override;
488 
489  tResult GetBindingObjects(ucom::ant::iobject_list<streaming::ant::IBindingObject>& lstBindingObject) override;
490  tResult GetBindingObjects(ucom::ant::iobject_list<const streaming::ant::IBindingObject>& lstBindingObject) const override;
491  tResult FindBindingObject(const char* strName,
492  ucom::ant::iobject_ptr<const ucom::ant::IObject>& pIBindingObject) const override;
493  tResult FindBindingObject(const char* strName,
494  ucom::ant::iobject_ptr<ucom::ant::IObject>& pIBindingObject) override;
495 
496  tResult GetRunners(ucom::ant::iobject_list<streaming::ant::IRunner>& lstRunners) const override;
497  tResult FindRunner(const char* strName, ucom::ant::iobject_ptr<ucom::ant::IObject>& pRunner) const override;
498  tResult GetInnerPipes(ucom::ant::iobject_list<streaming::ant::ITriggerPipe>& lstInnerTriggerPipes) const override;
499 
500  tResult RequestPin(const char* strName,
503  tResult RequestPin(const char* strName,
506 
507  tResult RequestBindingObject(const char* strName,
510  tResult RequestBindingObject(const char* strName,
513 
514  tResult SetState(tFilterState eFilterState) override;
515  tFilterState GetState() const override;
516 
517  tResult GetProperties(ucom::ant::iobject_ptr<const base::ant::IProperties>& pProperties) const override;
518  tResult GetProperties(ucom::ant::iobject_ptr<base::ant::IProperties>& pProperties) override;
519  tResult AttachConfiguration(const char* strName, base::ant::IConfiguration& oAttachedConfiguration) override;
520  tResult DetachConfiguration(const char* strName) override;
521 
522  private:
523  class cImplementation;
524  std::unique_ptr<cImplementation> m_pImplementation;
525 };
526 
527 }
528 
529 using hollow::cFilter;
530 
532 using flash::filter_create_pin;
533 
534 
535 } //namespace filter
536 } //namespace adtf
537 
#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.
ucom Interface to a objects configuration.
The Runnable interface defines common methods for a running component.
Definition: runnable_intf.h:26
The IString interface provides methods for getting and setting strings through abstract interfaces.
Definition: string_intf.h:28
Implementation helper template to enriches an implementation with the default implementation of IConf...
tResult GetProperties(adtf::ucom::ant::iobject_ptr< const IProperties > &pProperties) const override
Gets the configuration with only read access.
Enriches the adtf::streaming::ant::cFilterBase class with the configuration.
virtual ~cConfigurableFilter()=default
DTOR.
base::ant::configuration base_type_conf
used base type
tResult AttachConfiguration(const char *strName, base::ant::IConfiguration &oAttachedConfiguration) override
Attaches the given configuration and its properties as property tree item of this.
tResult GetProperties(ucom::ant::iobject_ptr< base::ant::IProperties > &pProperties) override
Gets the properties with read access.
tResult GetProperties(ucom::ant::iobject_ptr< const base::ant::IProperties > &pProperties) const override
Gets the properties with read access.
tResult DetachConfiguration(const char *strName) override
Detaches a configuration with the specified name.
virtual ~cFilter()=default
DTOR.
tResult ConfigureThreadTrigger(const char *strRunnerName, bool bCallCyclic)
Creates an internal a internal thread configuration for a timing trigger.
tResult ConfigureDataInTrigger(const char *strRunnerName, const char *strPinName)
Creates an internal trigger pipe for the given pin.
tResult ConfigureTimerTrigger(const char *strRunnerName, tTimeStamp tmPeriod)
Creates an internal a internal trigger configuration for a timing trigger.
tResult ConfigureDataOutTrigger(const char *strRunnerName, const char *strPinName)
Creates an internal trigger pipe for the given pin.
A_UTILS_D(cFilter)
dpointer impl
tResult Shutdown(tInitStage eStage) override
Implements the default cFilterLevelmachine state machine call.
tResult Init(tInitStage eStage) override
Initializes the filter.
tResult Stop() override
Implements the default cFilterLevelmachine state machine calls.
tResult Start() override
Reset your internal data here.
Base class for adtf::filter::flash::cFilter, adtf::filter::flash::cSampleStreamingSource and adtf::fi...
Definition: graph_object.h:184
tResult Shutdown(tInitStage eStage) override
Implements the default cFilterLevelmachine state machine call.
tResult Init(tInitStage eStage) override
Initializes the filter.
tResult Stop() override
Implements the default cFilterLevelmachine state machine calls.
tResult Start() override
Reset your internal data here.
Base class for adtf::filter::flash::cFilter, adtf::filter::flash::cSampleStreamingSource and adtf::fi...
The cFilterBase class implements a basic filter that supports the ant::IFilter interfaces.
Definition: filterbase.h:37
cFilterLevelmachine::tInitStage tInitStage
private d-pointer
Definition: filterbase.h:46
The Default Filter Level State Machine.
tInitStage
The Filters InitStages will be used for the cFilterLevelmachine::Init and cFilterLevelmachine::Shutdo...
The default Sample Reader will read the incomung Stream of a IInPin.
Definition: samplereader.h:174
This base implementation of a sample writer is able to write to one Sample Stream which is connected ...
Definition: samplewriter.h:35
A Possible Sample Reader of a Trigger Function! Sample reader with a internal queue,...
Definition: samplereader.h:778
Specialized Sample Writer to write DATA of type DATA_TYPE.
Definition: samplewriter.h:248
Interface for sample reads that read from sample streams via input pins.
Interface for sample writers that write to sample streams via output pins.
Base class for every interface type within the uCOM.
Definition: object_intf.h:31
Base object pointer to realize binary compatible reference counting in interface methods.
Use this template if you want to implement an ucom::ant::IObject based Interface and/or subclass an e...
Definition: object.h:379
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
string_base< cStackString > cString
cString implementation for a stack string which works on stack if string is lower than A_UTILS_DEFAUL...
Definition: string.h:2778
tResult filter_create_pin_with_exact_name(cFilter &oFilter, READERWRITERTYPE &oReaderWriter, ucom::ant::iobject_ptr< PINTYPE > &pPinType)
Creates a Pin for the given reader which has to have the same name as the oReader.
Namespace for all functionality of the ADTF Streaming SDK provided since v3.0.
tResult make_sample_writer(cSampleWriter &oWriter, const char *strNameOfWriter, const ucom::ant::iobject_ptr< const IStreamType > &pStreamType)
Definition: samplewriter.h:348
tResult make_sample_reader(cSampleReader &oReader, const char *strNameOfReader, const ucom::iobject_ptr< const IStreamType > &pStreamType)
Initializes a cSampleReader with given name and StreamType param[in] oReader Reader to intialize para...
Definition: samplereader.h:914
sample_reader< cDynamicSampleReaderQueue > cDynamicSampleReader
The cDynamicSampleReader will create a sample reader which will create a internal sample queue with u...
Definition: samplereader.h:813
tResult create_pin(DATA_BINDING_IMPL_TYPE &oDataBindingImpl, cSampleWriter &oWriter, const char *strNameOfWriterAndPin, const ucom::iobject_ptr< const IStreamType > &pStreamType, ucom::iobject_ptr< IOutPin > &pPinCreated)
Creates a cOutPin and registers it at the given oDataBindingImpl instance.
Definition: pin_creation.h:37
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
#define adtf_string_intf(__string__)
The adtf_string_intf Macro helps to easily create a rvalue reference of a adtf::util::cString.
Definition: string_intf.h:371