ADTF  3.14.3
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  {
216  RETURN_NOERROR;
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  }
228  RETURN_NOERROR;
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 
334  tResult Init(tInitStage eStage) override;
335 
346  tResult Start() override;
347  tResult Stop() override;
348 
352  tResult Shutdown(tInitStage eStage) override;
353 
354  tResult SetName(const char* strName) override;
355  tResult GetName(base::ant::IString&& strName) const override;
356  tResult SetParent(const ucom::ant::IObject* poParentObject) override;
357  tResult GetParent(const ucom::ant::IObject*& poParentObject) const override;
358 
359  tResult GetPins(ucom::ant::iobject_list<streaming::ant::IPin>& oPins) const override;
360  tResult FindPin(const char* strName, ucom::ant::iobject_ptr<ucom::ant::IObject>& pPin) const override;
361 
362  tResult GetBindingObjects(ucom::ant::iobject_list<streaming::ant::IBindingObject>& lstBindingObject) override;
363  tResult GetBindingObjects(ucom::ant::iobject_list<const streaming::ant::IBindingObject>& lstBindingObject) const override;
364  tResult FindBindingObject(const char* strName,
365  ucom::ant::iobject_ptr<const ucom::ant::IObject>& pIBindingObject) const override;
366  tResult FindBindingObject(const char* strName,
367  ucom::ant::iobject_ptr<ucom::ant::IObject>& pIBindingObject) override;
368 
369  tResult GetRunners(ucom::ant::iobject_list<streaming::ant::IRunner>& lstRunners) const override;
370  tResult FindRunner(const char* strName, ucom::ant::iobject_ptr<ucom::ant::IObject>& pRunner) const override;
371  tResult GetInnerPipes(ucom::ant::iobject_list<streaming::ant::ITriggerPipe>& lstInnerTriggerPipes) const override;
372 
373  tResult RequestPin(const char* strName,
376  tResult RequestPin(const char* strName,
379 
380  tResult RequestBindingObject(const char* strName,
383  tResult RequestBindingObject(const char* strName,
386 
387  tResult SetState(tFilterState eFilterState) override;
388  tFilterState GetState() const override;
389 
390  tResult GetProperties(ucom::ant::iobject_ptr<const base::ant::IProperties>& pProperties) const override;
391  tResult GetProperties(ucom::ant::iobject_ptr<base::ant::IProperties>& pProperties) override;
392  tResult AttachConfiguration(const char* strName, base::ant::IConfiguration& oAttachedConfiguration) override;
393  tResult DetachConfiguration(const char* strName) override;
394 
395  private:
396  class cImplementation;
397  std::unique_ptr<cImplementation> m_pImplementation;
398 };
399 
400 template<typename DATA_BINDING_IMPL_TYPE>
401 inline tResult filter_create_pin(DATA_BINDING_IMPL_TYPE& oFilter, adtf::streaming::flash::ISampleReader& oReader)
402 {
403  return streaming::flash::create_pin(oFilter, oReader);
404 }
405 
406 template<typename DATA_BINDING_IMPL_TYPE>
407 inline tResult filter_create_pin(DATA_BINDING_IMPL_TYPE& oFilter, adtf::streaming::flash::ISampleWriter& oWriter)
408 {
409  return streaming::flash::create_pin(oFilter, oWriter);
410 }
411 
412 template<typename DATA_BINDING_IMPL_TYPE>
413 inline tResult filter_create_pin(DATA_BINDING_IMPL_TYPE& oFilter,
415  const char* strName,
417 {
418  RETURN_IF_FAILED(adtf::streaming::flash::make_sample_reader(oReader, strName, pType));
419  return streaming::flash::create_pin(oFilter, oReader);
420 }
421 
422 template<typename DATA_BINDING_IMPL_TYPE>
423 inline tResult filter_create_pin(DATA_BINDING_IMPL_TYPE& oFilter,
425  const char* strName,
426  const ucom::ant::iobject_ptr<const streaming::ant::IStreamType>& pType)
427 {
428  RETURN_IF_FAILED(adtf::streaming::flash::make_sample_writer(oWriter, strName, pType));
429  return filter_create_pin(oFilter, oWriter);
430 }
431 
432 template<typename DATA_BINDING_IMPL_TYPE, typename READERWRITERTYPE, typename PINTYPE>
433 tResult filter_create_pin(DATA_BINDING_IMPL_TYPE& oFilter, READERWRITERTYPE& oReaderORWriter, ucom::ant::iobject_ptr<PINTYPE>& pPin)
434 {
435  ucom::ant::object_ptr<ucom::ant::IObject> pHelper;
436  RETURN_IF_FAILED(streaming::flash::create_pin(oFilter, oReaderORWriter, pHelper));
437  return pPin.Reset(ucom::ant::ucom_object_ptr_cast<PINTYPE>(pHelper));
438 }
439 
440 }
441 
442 namespace hollow
443 {
444 
446 class cFilter:
447  public ucom::catwo::object<streaming::ant::INamedGraphObject,
448  streaming::ant::IDataBinding,
449  streaming::ant::IInterfaceBinding,
450  streaming::ant::IRuntimeBehaviour,
451  streaming::ant::IDynamicDataBinding,
452  streaming::ant::IDynamicInterfaceBinding,
453  streaming::ant::IFilter,
454  base::ant::IConfiguration>,
455  public cGraphObject,
457 {
458  public:
459  // this needs to be here because unfortunately multiple base classes have this as well (altough it is not needed at all)
460  template <typename T>
462 
463  cFilter();
464  ~cFilter() override;
465 
467  tResult Init(tInitStage eStage) override;
468 
470  tResult Start() override;
471  tResult Stop() override;
472 
476  tResult Shutdown(tInitStage eStage) override;
477 
478  tResult SetName(const char* strName) override;
479  tResult GetName(base::ant::IString&& strName) const override;
480  tResult SetParent(const ucom::ant::IObject* poParentObject) override;
481  tResult GetParent(const ucom::ant::IObject*& poParentObject) const override;
482 
483  tResult GetPins(ucom::ant::iobject_list<streaming::ant::IPin>& oPins) const override;
484  tResult FindPin(const char* strName, ucom::ant::iobject_ptr<ucom::ant::IObject>& pPin) const override;
485 
486  tResult GetBindingObjects(ucom::ant::iobject_list<streaming::ant::IBindingObject>& lstBindingObject) override;
487  tResult GetBindingObjects(ucom::ant::iobject_list<const streaming::ant::IBindingObject>& lstBindingObject) const override;
488  tResult FindBindingObject(const char* strName,
489  ucom::ant::iobject_ptr<const ucom::ant::IObject>& pIBindingObject) const override;
490  tResult FindBindingObject(const char* strName,
491  ucom::ant::iobject_ptr<ucom::ant::IObject>& pIBindingObject) override;
492 
493  tResult GetRunners(ucom::ant::iobject_list<streaming::ant::IRunner>& lstRunners) const override;
494  tResult FindRunner(const char* strName, ucom::ant::iobject_ptr<ucom::ant::IObject>& pRunner) const override;
495  tResult GetInnerPipes(ucom::ant::iobject_list<streaming::ant::ITriggerPipe>& lstInnerTriggerPipes) const override;
496 
497  tResult RequestPin(const char* strName,
500  tResult RequestPin(const char* strName,
503 
504  tResult RequestBindingObject(const char* strName,
507  tResult RequestBindingObject(const char* strName,
510 
511  tResult SetState(tFilterState eFilterState) override;
512  tFilterState GetState() const override;
513 
514  tResult GetProperties(ucom::ant::iobject_ptr<const base::ant::IProperties>& pProperties) const override;
515  tResult GetProperties(ucom::ant::iobject_ptr<base::ant::IProperties>& pProperties) override;
516  tResult AttachConfiguration(const char* strName, base::ant::IConfiguration& oAttachedConfiguration) override;
517  tResult DetachConfiguration(const char* strName) override;
518 
519  private:
520  class cImplementation;
521  std::unique_ptr<cImplementation> m_pImplementation;
522 };
523 
524 }
525 
526 using hollow::cFilter;
527 
529 using flash::filter_create_pin;
530 
531 
532 } //namespace filter
533 } //namespace adtf
534 
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:24
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:183
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:34
A Possible Sample Reader of a Trigger Function! Sample reader with a internal queue,...
Definition: samplereader.h:796
Specialized Sample Writer to write DATA of type DATA_TYPE.
Definition: samplewriter.h:247
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:359
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
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:346
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:932
sample_reader< cDynamicSampleReaderQueue > cDynamicSampleReader
The cDynamicSampleReader will create a sample reader which will create a internal sample queue with u...
Definition: samplereader.h:831
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:285
#define RETURN_IF_FAILED(s)
returns if the expression returns a failed tResult or throws an exception.

Copyright © Audi Electronics Venture GmbH. All rights reserved. (Generated on Thu Jun 9 2022 by doxygen 1.9.1)