ADTF  3.14.3
filterbase.h
Go to the documentation of this file.
1 
7 #pragma once
8 #include "filter_levelmachine.h"
9 #include "runtime_behaviour.h"
10 #include "interface_binding.h"
11 #include "data_binding.h"
12 #include "named_graph_object.h"
13 #include "reference_clock_intf.h"
14 #include "triggerpipe.h"
15 #include "runner.h"
17 
18 namespace adtf
19 {
20 namespace streaming
21 {
22 namespace ant
23 {
24 
25 
34  public ucom::catwo::object<cFilterLevelmachine,
35  ucom::ant::cClassInfo,
36  runtime_behaviour<interface_binding<data_binding<named_graph_object<IFilter>>>>>
37 {
39  A_UTILS_D(cFilterBase)
40 
41  public:
47 
48  protected:
49 
56 
57 
58  public:
67  virtual ~cFilterBase();
68 
69  public: //overwrites cFilterBaseLevelmachine
71  tResult Init(tInitStage eStage) override;
73  tResult Shutdown(tInitStage eStage) override;
75  tResult Start() override;
77  tResult Stop() override;
78 
79  public: // implements IFilter
80  IFilter::tFilterState GetState() const override;
81 
91  tResult SetState(IFilter::tFilterState eState) override;
92 
93 
94  public: //overwrites cDataBinding
95  tResult RegisterPin(const ucom::ant::iobject_ptr<IPin>& pPin) override;
96 
99  tResult UnregisterPin(const ucom::ant::iobject_ptr<IPin>& pPin) override;
100 
101  public: //overwrites cInterfaceBinding
103  tResult RegisterBindingObject(const ucom::ant::iobject_ptr<IBindingObject>& pBindingObject) override;
104 
105  public: //implements cFilterBase
108  tResult RegisterRunner(const ucom::ant::iobject_ptr<IRunner>& pBindingObject) override;
109 };
110 
111 
112 
132 template <typename DATABINDING_BEHAVIOUR_CLASS>
133 inline tResult create_inner_pipe(DATABINDING_BEHAVIOUR_CLASS& oComponent,
134  adtf_util::cStringList lstItems)
135 {
137  for (const auto& itElem : lstItems)
138  {
140  if (IS_FAILED(oComponent.FindPin(itElem, pCurrentItem)))
141  {
142  if (IS_FAILED(oComponent.FindRunner(itElem, pCurrentItem)))
143  {
144  RETURN_ERROR(ERR_NOT_FOUND);
145  }
146  }
147  lstListOfItemsForPipe.PushObject(pCurrentItem);
148  }
150  RETURN_IF_FAILED(create_trigger_pipe("generated_pipe", pInnerPipe, lstListOfItemsForPipe));
151  RETURN_IF_FAILED(oComponent.RegisterInnerPipe(pInnerPipe));
152  return pInnerPipe->Open();
153 }
154 
175 template <typename DATABINDING_BEHAVIOUR_CLASS>
176 tResult create_inner_pipe(DATABINDING_BEHAVIOUR_CLASS& oComponent,
177  const adtf_util::cString& strNameOfRunner,
178  const adtf_util::cString& strSource,
180 {
183  if (IS_FAILED(oComponent.FindPin(strSource, pCurrentItem)))
184  {
185  if (IS_FAILED(oComponent.FindRunner(strSource, pCurrentItem)))
186  {
187  RETURN_ERROR(ERR_NOT_FOUND);
188  }
189  }
190  lstListOfItemsForPipe.PushObject(pCurrentItem);
191  ucom::object_ptr<IRunner> pRunner = ucom::make_object_ptr<cRunner>(strNameOfRunner, oRunFunc);
192  RETURN_IF_FAILED(oComponent.RegisterRunner(pRunner));
193 
194  lstListOfItemsForPipe.PushObject(ucom::ucom_object_ptr_cast<ITriggerPipeItem>(pRunner));
195 
197  RETURN_IF_FAILED(create_trigger_pipe("generated_pipe", pInnerPipe, lstListOfItemsForPipe));
198  RETURN_IF_FAILED(oComponent.RegisterInnerPipe(pInnerPipe));
199  return pInnerPipe->Open();
200 }
201 
211 template<typename INTERFACE>
212 tResult create_server(cFilterBase& oFilter,
213  const char* strServerName,
214  const adtf::ucom::iobject_ptr<INTERFACE>& pServerInterface)
215 {
216  using namespace adtf::ucom;
217  object_ptr<IBindingServer> pBindingServer = make_object_ptr<cBindingServer>(strServerName,
219  ucom_object_ptr_cast<IObject>(pServerInterface));
220  RETURN_IF_FAILED(oFilter.RegisterBindingObject(pBindingServer));
221  RETURN_NOERROR;
222 }
223 
231 template<typename INTERFACE>
232 tResult create_client(cFilterBase& oFilter, const char* strClientName)
233 {
234  using namespace adtf::ucom;
235  object_ptr<IBindingClient> pBindingClient = make_object_ptr<cBindingClient>(strClientName,
237  RETURN_IF_FAILED(oFilter.RegisterBindingObject(pBindingClient));
238  RETURN_NOERROR;
239 }
240 
249 inline tResult create_runner(cFilterBase& oFilter,
250  const char* strNameOfRunner,
251  adtf::base::ant::IRunnable& oRunnable)
252 {
253  return oFilter.RegisterRunner(strNameOfRunner, oRunnable);
254 }
255 
256 
257 } //namespace ant
258 
259 namespace flash
260 {
261 
263 
264 template <typename DATABINDING_BEHAVIOUR_CLASS, typename RUN_FUNC>
265 tResult create_inner_pipe(DATABINDING_BEHAVIOUR_CLASS& oComponent,
266  const adtf_util::cString& strNameOfRunner,
267  const adtf_util::cString& strSource,
268  RUN_FUNC oRunFunc)
269 {
272  if (IS_FAILED(oComponent.FindPin(strSource, pCurrentItem)))
273  {
274  if (IS_FAILED(oComponent.FindRunner(strSource, pCurrentItem)))
275  {
276  RETURN_ERROR(ERR_NOT_FOUND);
277  }
278  }
279  lstListOfItemsForPipe.PushObject(pCurrentItem);
280  ucom::object_ptr<IRunner> pRunner = ucom::make_object_ptr<cRunner>(strNameOfRunner, oRunFunc);
281  RETURN_IF_FAILED(oComponent.RegisterRunner(pRunner));
282 
283  lstListOfItemsForPipe.PushObject(ucom::ucom_object_ptr_cast<ITriggerPipeItem>(pRunner));
284 
286  RETURN_IF_FAILED(create_trigger_pipe("generated_pipe", pInnerPipe, lstListOfItemsForPipe));
287  RETURN_IF_FAILED(oComponent.RegisterInnerPipe(pInnerPipe));
288  return pInnerPipe->Open();
289 }
290 
301 template<typename Interface, typename InterfaceBinding>
302 tResult create_server(InterfaceBinding& oInterfaceBinding,
303  const char* strServerName,
304  const adtf::ucom::iobject_ptr<Interface>& pServerInterface)
305 {
306  using namespace adtf::ucom;
307  object_ptr<IBindingServer> pBindingServer = make_object_ptr<cBindingServer>(strServerName,
309  ucom_object_ptr_cast<IObject>(pServerInterface));
310  RETURN_IF_FAILED(oInterfaceBinding.RegisterBindingObject(pBindingServer));
311  RETURN_NOERROR;
312 }
313 
322 template<typename Interface, typename InterfaceBinding>
323 tResult create_client(InterfaceBinding& oInterfaceBinding, const char* strClientName)
324 {
325  using namespace adtf::ucom;
326  object_ptr<IBindingClient> pBindingClient = make_object_ptr<cBindingClient>(strClientName,
328  RETURN_IF_FAILED(oInterfaceBinding.RegisterBindingObject(pBindingClient));
329  RETURN_NOERROR;
330 }
331 
332 }
333 
335 using ant::cFilterBase;
336 using flash::create_inner_pipe;
339 using ant::create_runner;
340 
341 } //namespace streaming
342 } //namespace adtf
The Runnable interface defines common methods for a running component.
Definition: runnable_intf.h:26
Runnable helper implementaton template.
Definition: runnable.h:58
tFilterState
specifies the several types of filter states
Definition: filter_intf.h:44
Binding type generation template to initialize a BindingType with the information of the INTERFACE ty...
virtual tResult RegisterPin(const ucom::ant::iobject_ptr< IPin > &pIPin)
Registers a Pin in a pin list.
The cFilterBase class implements a basic filter that supports the ant::IFilter interfaces.
Definition: filterbase.h:37
virtual tResult RegisterBindingObject(const ucom::ant::iobject_ptr< IBindingObject > &pBindingObject)
RegisterBindingObject will register the given pBindingObject within the internal registry.
ucom::object_ptr< services::ant::IReferenceClock > _clock
A reference to the clock service.
Definition: filterbase.h:55
tResult Shutdown(tInitStage eStage) override
Implements the default cFilterLevelmachine state machine call.
cFilterLevelmachine::tInitStage tInitStage
private d-pointer
Definition: filterbase.h:46
virtual tResult RegisterPin(const ucom::ant::iobject_ptr< IPin > &pIPin)
gets cDataBinding RegisterPin Variant visible
virtual tResult RegisterRunner(const ucom::ant::iobject_ptr< IRunner > &pRunner)
Registers and publishes a IRunner object to the IRuntimeBehaviour.
tResult SetState(IFilter::tFilterState eState) override
Sets the state of the filter.
virtual ~cFilterBase()
Destructor.
tResult Init(tInitStage eStage) override
Implements the default cFilterLevelmachine state machine call.
tResult Stop() override
Implements the default cFilterLevelmachine state machine calls.
tResult Start() override
Implements the default cFilterLevelmachine state machine calls.
tInitStage
The Filters InitStages will be used for the cFilterLevelmachine::Init and cFilterLevelmachine::Shutdo...
virtual tResult RegisterBindingObject(const ucom::ant::iobject_ptr< IBindingObject > &pBindingObject)
RegisterBindingObject will register the given pBindingObject within the internal registry.
virtual tResult RegisterRunner(const ucom::ant::iobject_ptr< IRunner > &pRunner)
Registers and publishes a IRunner object to the IRuntimeBehaviour.
virtual tResult RegisterInnerPipe(const ucom::ant::iobject_ptr< ITriggerPipe > &pTriggerPipe)
Registers and publishes an inner ITriggerPipe object to the IRuntimeBehaviour.
Base object pointer to realize binary compatible reference counting in interface methods.
container type template for a set of object_ptr This template will provide a container for object_ptr...
Definition: object_list.h:216
Object pointer implementation used for reference counting on objects of type IObject.
Definition: object_ptr.h:158
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.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
tResult create_server(cFilterBase &oFilter, const char *strServerName, const adtf::ucom::iobject_ptr< INTERFACE > &pServerInterface)
Creates a binding server object for the given INTERFACE type and register it on the cFilterBase insta...
Definition: filterbase.h:212
tResult create_runner(cFilterBase &oFilter, const char *strNameOfRunner, adtf::base::ant::IRunnable &oRunnable)
Creates a runner on the given cFilterBase and connect it to the given Runnable You only need to imple...
Definition: filterbase.h:249
tResult create_inner_pipe(DATABINDING_BEHAVIOUR_CLASS &oComponent, adtf_util::cStringList lstItems)
Creates a Trigger Pipe and registers it at the given oFilter instance.
Definition: filterbase.h:133
tResult create_client(cFilterBase &oFilter, const char *strClientName)
Creates a binding client object for the given INTERFACE type and register it on the cFilterBase insta...
Definition: filterbase.h:232
tResult create_trigger_pipe(const char *strNameOfPipe, adtf::ucom::ant::iobject_ptr< ITriggerPipe > &pTriggerPipe, adtf::ucom::ant::object_list< ITriggerPipeItem > lstNextItems)
Creates a Trigger Pipe with given items in lstNextItems.
tResult create_client(InterfaceBinding &oInterfaceBinding, const char *strClientName)
Creates a binding client object for the given INTERFACE type and register it on the cFilterBase insta...
Definition: filterbase.h:323
tResult create_server(InterfaceBinding &oInterfaceBinding, const char *strServerName, const adtf::ucom::iobject_ptr< Interface > &pServerInterface)
Creates a binding server object for the given INTERFACE type and register it on the cFilterBase insta...
Definition: filterbase.h:302
std::enable_if< !std::is_base_of< enable_object_ptr_from_this< typename std::remove_cv< Implementation >::type >, typename std::remove_cv< Implementation >::type >::value, object_ptr< Implementation > >::type make_object_ptr(Args &&... args)
Create an instance of type object_ptr with Implementation as the shared resource.
Namespace for the ADTF uCOM3 SDK.
Namespace for entire ADTF SDK.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
#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)