ADTF
Loading...
Searching...
No Matches
filter.h
Go to the documentation of this file.
1
7#pragma once
8#include "graph_object.h"
9
18
19#include <memory>
20
21namespace adtf
22{
23namespace filter
24{
25namespace ant
26{
27
32class cConfigurableFilter : public ucom::catwo::object<streaming::ant::cFilterBase,
33 base::ant::configuration<>>
34
35{
36
37public:
40 typedef streaming::ant::cFilterBase base_type_filter;
41
42protected:
46 virtual ~cConfigurableFilter() = default;
47
48public:
54
59
60 tResult AttachConfiguration(const char* strName, base::ant::IConfiguration& oAttachedConfiguration) override
61 {
62 return base_type_conf::configuration::AttachConfiguration(strName, oAttachedConfiguration);
63 }
64
65 tResult DetachConfiguration(const char* strName) override
66 {
67 return base_type_conf::configuration::DetachConfiguration(strName);
68 }
69};
70
71
74
76template <typename DATA_TYPE>
78
81
83template<tTimeStamp TIME_RANGE, bool STORELASTSAMPLE = true>
85
87template<size_t MAX_SIZE, bool STORELASTSAMPLE = true>
89
90
108{
110 A_UTILS_D(cFilter)
111
112public:
114
115protected:
121 ADTF3_DEPRECATED("Triggerfunctions have been superseded by using the API of flash::cFilter.")
124 virtual ~cFilter() override;
125
126public:
127
128 tResult RegisterRunner(const char* strName, adtf::base::ant::IRunnable& oRunnable) override;
129
138 tResult ConfigureDataInTrigger(const char* strRunnerName, const char* strPinName);
147 tResult ConfigureDataOutTrigger(const char* strRunnerName, const char* strPinName);
148
157 tResult ConfigureTimerTrigger(const char* strRunnerName, tTimeStamp tmPeriod);
169 tResult ConfigureThreadTrigger(const char* strRunnerName, bool bCallCyclic);
170
171};
172
180template<typename READERWRITERTYPE, typename PINTYPE>
181tResult filter_create_pin_with_exact_name(cFilter& oFilter, READERWRITERTYPE& oReaderWriter, ucom::ant::iobject_ptr<PINTYPE>& pPinType)
182{
183 adtf::util::cString strName;
184 oReaderWriter.GetName(adtf_string_intf(strName));
186 oReaderWriter.GetType(pType);
187 return streaming::ant::create_pin<cFilter>(oFilter, oReaderWriter, strName, pType, pPinType);
188}
189
196template<typename READERWRITERTYPE>
197tResult filter_create_pin_with_exact_name(cFilter& oFilter, READERWRITERTYPE& oReaderWriter)
198{
199 adtf::util::cString strName;
200 oReaderWriter.GetName(adtf_string_intf(strName));
202 oReaderWriter.GetType(pType);
203 return streaming::ant::create_pin<cFilter>(oFilter, oReaderWriter, strName, pType);
204}
205
206
207template<typename READERWRITERTYPE, typename PINTYPE>
208tResult filter_create_pin(cFilter& oFilter, READERWRITERTYPE& oReaderORWriter, ucom::ant::iobject_ptr<PINTYPE>& pPin)
209{
210 using namespace adtf::streaming::ant;
211 adtf_util::cString strNameOfReaderAndPin;
212 oReaderORWriter.GetName(adtf_string_intf(strNameOfReaderAndPin));
213 int nCurrentTry = 1;
214 while (true)
215 {
216 tResult nRes = filter_create_pin_with_exact_name<READERWRITERTYPE, PINTYPE>(oFilter, oReaderORWriter, pPin);
217 if (IS_OK(nRes))
218 {
220 }
221 if (nRes == ERR_RESOURCE_IN_USE)
222 {
223 adtf_util::cString strNameOfReaderAndPinTry = adtf_util::cString::Format("%s_%d.3", strNameOfReaderAndPin.GetPtr(), nCurrentTry++);
224 oReaderORWriter.SetName(strNameOfReaderAndPinTry);
225 }
226 else
227 {
228 return nRes;
229 }
230 }
232}
233
234inline tResult filter_create_pin(cFilter& oFilter, adtf::streaming::ant::cSampleReader& oReader)
235{
236 ucom::object_ptr<streaming::ant::IInPin> pPin;
237 return filter_create_pin<streaming::ant::cSampleReader, streaming::ant::IInPin>(oFilter, oReader, pPin);
238}
239
240inline tResult filter_create_pin(cFilter& oFilter, adtf::streaming::ant::cSampleWriter& oWriter)
241{
242 ucom::object_ptr<streaming::ant::IOutPin> pPin;
243 return filter_create_pin<streaming::ant::cSampleWriter, streaming::ant::IOutPin>(oFilter, oWriter, pPin);
244}
245
246inline tResult filter_create_pin(cFilter& oFilter,
247 adtf::streaming::ant::cSampleReader& oReaderORWriter,
248 const char* strName,
249 const ucom::ant::iobject_ptr<const adtf::streaming::ant::IStreamType>& pType)
250{
251 RETURN_IF_FAILED(adtf::streaming::ant::make_sample_reader(oReaderORWriter, strName, pType));
252 return filter_create_pin(oFilter, oReaderORWriter);
253}
254
255inline tResult filter_create_pin(cFilter& oFilter,
256 adtf::streaming::ant::cSampleWriter& oReaderORWriter,
257 const char* strName,
258 const ucom::ant::iobject_ptr<const streaming::ant::IStreamType>& pType)
259{
260 RETURN_IF_FAILED(adtf::streaming::ant::make_sample_writer(oReaderORWriter, strName, pType));
261 return filter_create_pin(oFilter, oReaderORWriter);
262}
263
264} //namespace ant
265
278class cFilter:
279 public ucom::catwo::object<streaming::ant::INamedGraphObject,
280 streaming::ant::IDataBinding,
281 streaming::ant::IInterfaceBinding,
282 streaming::ant::IRuntimeBehaviour,
283 streaming::ant::IDynamicDataBinding,
284 streaming::ant::IDynamicInterfaceBinding,
285 streaming::ant::IFilter,
286 base::ant::IConfiguration>,
287 public cGraphObject,
289{
290 public:
291 // this needs to be here because unfortunately multiple base classes have this as well (altough it is not needed at all)
292 template <typename T>
293 using iobject_ptr = adtf::ucom::ant::iobject_ptr<T>;
294
295 cFilter();
296 ~cFilter() override;
297
326 tResult Init(tInitStage eStage) override;
327
336 tResult Start() override;
337 tResult Stop() override;
338
342 tResult Shutdown(tInitStage eStage) override;
343
344 tResult SetName(const char* strName) override;
345 tResult GetName(base::ant::IString&& strName) const override;
346 tResult SetParent(const ucom::ant::IObject* poParentObject) override;
347 tResult GetParent(const ucom::ant::IObject*& poParentObject) const override;
348
349 tResult GetPins(ucom::ant::iobject_list<streaming::ant::IPin>& oPins) const override;
350 tResult FindPin(const char* strName, ucom::ant::iobject_ptr<ucom::ant::IObject>& pPin) const override;
351
352 tResult GetBindingObjects(ucom::ant::iobject_list<streaming::ant::IBindingObject>& lstBindingObject) override;
353 tResult GetBindingObjects(ucom::ant::iobject_list<const streaming::ant::IBindingObject>& lstBindingObject) const override;
354 tResult FindBindingObject(const char* strName,
355 ucom::ant::iobject_ptr<const ucom::ant::IObject>& pIBindingObject) const override;
356 tResult FindBindingObject(const char* strName,
357 ucom::ant::iobject_ptr<ucom::ant::IObject>& pIBindingObject) override;
358
359 tResult GetRunners(ucom::ant::iobject_list<streaming::ant::IRunner>& lstRunners) const override;
360 tResult FindRunner(const char* strName, ucom::ant::iobject_ptr<ucom::ant::IObject>& pRunner) const override;
361 tResult GetInnerPipes(ucom::ant::iobject_list<streaming::ant::ITriggerPipe>& lstInnerTriggerPipes) const override;
362
363 tResult RequestPin(const char* strName,
366 tResult RequestPin(const char* strName,
369
370 tResult RequestBindingObject(const char* strName,
373 tResult RequestBindingObject(const char* strName,
376
377 tResult SetState(tFilterState eFilterState) override;
378 tFilterState GetState() const override;
379
382 tResult AttachConfiguration(const char* strName, base::ant::IConfiguration& oAttachedConfiguration) override;
383 tResult DetachConfiguration(const char* strName) override;
384
385 private:
386 class cImplementation;
387 std::unique_ptr<cImplementation> m_pImplementation;
388};
389
390template<typename DATA_BINDING_IMPL_TYPE>
391inline tResult filter_create_pin(DATA_BINDING_IMPL_TYPE& oFilter, adtf::streaming::flash::ISampleReader& oReader)
392{
393 return streaming::flash::create_pin(oFilter, oReader);
394}
395
396template<typename DATA_BINDING_IMPL_TYPE>
397inline tResult filter_create_pin(DATA_BINDING_IMPL_TYPE& oFilter, adtf::streaming::flash::ISampleWriter& oWriter)
398{
399 return streaming::flash::create_pin(oFilter, oWriter);
400}
401
402template<typename DATA_BINDING_IMPL_TYPE>
403inline tResult filter_create_pin(DATA_BINDING_IMPL_TYPE& oFilter,
405 const char* strName,
407{
408 RETURN_IF_FAILED(adtf::streaming::flash::make_sample_reader(oReader, strName, pType));
409 return streaming::flash::create_pin(oFilter, oReader);
410}
411
412template<typename DATA_BINDING_IMPL_TYPE>
413inline tResult filter_create_pin(DATA_BINDING_IMPL_TYPE& oFilter,
414 adtf::streaming::flash::ISampleWriter& oWriter,
415 const char* strName,
416 const ucom::ant::iobject_ptr<const streaming::ant::IStreamType>& pType)
417{
418 RETURN_IF_FAILED(adtf::streaming::flash::make_sample_writer(oWriter, strName, pType));
419 return filter_create_pin(oFilter, oWriter);
420}
421
422template<typename DATA_BINDING_IMPL_TYPE, typename READERWRITERTYPE, typename PINTYPE>
423tResult filter_create_pin(DATA_BINDING_IMPL_TYPE& oFilter, READERWRITERTYPE& oReaderORWriter, ucom::ant::iobject_ptr<PINTYPE>& pPin)
424{
425 ucom::ant::object_ptr<ucom::ant::IObject> pHelper;
426 RETURN_IF_FAILED(streaming::flash::create_pin(oFilter, oReaderORWriter, pHelper));
428}
429
430} //namespace filter
431} //namespace adtf
432
#define ADTF3_DEPRECATED(_depr_message_)
Definition adtf_base_deprecated.h:27
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Definition result.h:29
#define IS_OK(s)
Check if result is OK.
Definition result.h:17
Definition configuration_intf.h:24
Definition string_intf.h:29
Definition configuration.h:221
tResult GetProperties(adtf::ucom::ant::iobject_ptr< const IProperties > &pProperties) const override
Definition configuration.h:240
tResult AttachConfiguration(const char *strName, base::ant::IConfiguration &oAttachedConfiguration) override
Definition filter.h:60
virtual ~cConfigurableFilter()=default
DTOR.
tResult GetProperties(ucom::ant::iobject_ptr< const base::ant::IProperties > &pProperties) const override
Definition filter.h:50
tResult DetachConfiguration(const char *strName) override
Definition filter.h:65
base::ant::configuration base_type_conf
used base type
Definition filter.h:39
tResult GetProperties(ucom::ant::iobject_ptr< base::ant::IProperties > &pProperties) override
Definition filter.h:55
Definition filter.h:108
tResult ConfigureDataOutTrigger(const char *strRunnerName, const char *strPinName)
tResult ConfigureDataInTrigger(const char *strRunnerName, const char *strPinName)
virtual ~cFilter() override
DTOR.
tResult ConfigureThreadTrigger(const char *strRunnerName, bool bCallCyclic)
tResult ConfigureTimerTrigger(const char *strRunnerName, tTimeStamp tmPeriod)
streaming::ant::cFilterBase::tInitStage tInitStage
dpointer impl
Definition filter.h:113
Definition filter.h:289
tResult Stop() override
tResult Start() override
tResult Init(tInitStage eStage) override
tResult Shutdown(tInitStage eStage) override
cGraphObject()
Default Constructor.
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
Definition filter_levelmachine.h:25
tInitStage
The Filters InitStages will be used for the cFilterLevelmachine::Init and cFilterLevelmachine::Shutdo...
Definition filter_levelmachine.h:45
Definition samplewriter.h:34
Definition samplewriter.h:250
Definition samplestreamer_intf.h:188
Definition samplestreamer_intf.h:234
Definition object_intf.h:33
virtual tResult Reset(const iobject_ptr< T > &i_oOther)=0
Reset this object_ptr<> with the content of another iobject_ptr<>
Base object pointer to realize binary compatible reference counting in interface methods.
Definition object_ptr_intf.h:112
Definition object_ptr.h:384
Definition object.h:397
Namespace for the ADTF Base SDK.
Definition adtf_base_type_traits.h:13
Namespace for all functionality of the ADTF Filter SDK provided since v3.0.
Definition filter.h:26
tResult filter_create_pin_with_exact_name(cFilter &oFilter, READERWRITERTYPE &oReaderWriter, ucom::ant::iobject_ptr< PINTYPE > &pPinType)
Definition filter.h:181
adtf::streaming::ant::cSampleWriter cPinWriter
use cSampleWriter as cPinWriter
Definition filter.h:73
adtf::streaming::ant::sample_writer< DATA_TYPE > pin_writer
Definition filter.h:77
adtf::streaming::ant::size_limited_sample_reader< MAX_SIZE, STORELASTSAMPLE > size_limited_pin_reader
Definition filter.h:88
adtf::streaming::ant::cDynamicSampleReader cPinReader
use cSampleReader as cPinReader
Definition filter.h:80
adtf::streaming::ant::time_limited_sample_reader< TIME_RANGE, STORELASTSAMPLE > time_limited_pin_reader
Definition filter.h:84
Namespace for the ADTF Filter SDK.
Definition configurable_runner.h:18
Namespace for all functionality of the ADTF Streaming SDK provided since v3.0.
Definition bindingproxyoutport.h:16
sample_reader< cDynamicSampleReaderQueue > cDynamicSampleReader
The cDynamicSampleReader will create a sample reader which will create a internal sample queue with u...
Definition samplereader.h:807
sample_reader< time_limited_sample_reader_queue< TIME_RANGE >, STORELASTSAMPLE > time_limited_sample_reader
Definition samplereader.h:819
sample_reader< size_limited_sample_reader_queue< MAX_SIZE >, STORELASTSAMPLE > size_limited_sample_reader
Definition samplereader.h:831
tResult make_sample_writer(cSampleWriter &oWriter, const char *strNameOfWriter, const ucom::ant::iobject_ptr< const IStreamType > &pStreamType)
Definition samplewriter.h:344
tResult make_sample_reader(cSampleReader &oReader, const char *strNameOfReader, const ucom::iobject_ptr< const IStreamType > &pStreamType)
Definition samplereader.h:910
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)
Definition pin_creation.h:37
object_ptr< T > ucom_object_ptr_cast(object_ptr< T > oCasted)
Create an object_ptr with an already shared resource of implicitly convertible type.
Definition object_ptr_utilities.h:104
iobject_enum< T > iobject_list
Definition object_list.h:387
Namespace for the ADTF uCOM SDK.
Definition adtf_system.h:324
Namespace for all functionality provided by ADTF and its SDKs.
Definition adtf_client_connector.h:14
#define adtf_string_intf(__string__)
Definition string_intf.h:465