ADTF  3.18.2
graph_utils.h
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include "graph.h"
10 #include "samplestream.h"
12 #include "filtergraphport.h"
13 #include "samplestreaminport.h"
14 #include "samplestreamoutport.h"
15 #include "data_binding_intf.h"
16 #include "interface_binding_intf.h"
17 #include "runtime_behaviour_intf.h"
18 #include <memory>
19 
20 namespace adtf
21 {
22 
23 namespace streaming
24 {
25 
26 namespace devil
27 {
40  const util::cString& strCID,
41  const util::cString& strName,
42  const std::map<util::cString, util::cString>& oProperties,
43  int32_t nOrderNumber,
45 {
47  RETURN_IF_FAILED(_runtime->CreateInstance(strCID, pNewObject));
48  RETURN_IF_FAILED(pNewObject->SetName(strName));
49  if (!oProperties.empty())
50  {
51  auto pConfiguration = ucom::ucom_cast<base::IConfiguration*>(pNewObject.Get());
52  for (const auto& oProperty: oProperties)
53  {
54  base::set_property_by_path<util::cString>(*pConfiguration, oProperty.first, oProperty.second);
55  }
56  }
57 
58  RETURN_IF_FAILED(oGraph.AddNamedGraphObject(pNewObject, nOrderNumber));
59  return pObject.Reset(pNewObject);
60 }
61 
73  const util::cString& strCID,
74  const util::cString& strName,
75  const std::map<util::cString, util::cString>& oProperties = {},
76  int32_t nOrderNumber = 0)
77 {
79  return add_graph_object(oGraph, strCID, strName, oProperties, nOrderNumber, pObject);
80 }
81 
82 inline tResult add_sample_stream(ant::cGraph& oGraph,
83  const util::cString& strName,
84  int32_t nOrderNumber,
85  ucom::iobject_ptr<ucom::IObject>& pSampleStream)
86 {
87  ucom::object_ptr<ant::INamedGraphObject> pNewSampleStream = ucom::make_object_ptr<cSampleStream>(strName);
88  RETURN_IF_FAILED(oGraph.AddNamedGraphObject(pNewSampleStream, nOrderNumber));
89  return pSampleStream.Reset(pNewSampleStream);
90 }
91 
100 inline tResult add_sample_stream(ant::cGraph& oGraph,
101  const util::cString& strName,
102  int32_t nOrderNumber = 0)
103 {
104  ucom::object_ptr<ucom::IObject> pSampleStream;
105  return add_sample_stream(oGraph, strName, nOrderNumber, pSampleStream);
106 }
107 
118  const util::cString& strName,
119  int32_t nOrderNumber,
120  ucom::iobject_ptr<ucom::IObject>& pBindingProxy)
121 {
122  ucom::object_ptr<ant::INamedGraphObject> pNewBindingProxy = ucom::make_object_ptr<cDefaultBindingProxy>(strName);
123  RETURN_IF_FAILED(oGraph.AddNamedGraphObject(pNewBindingProxy, nOrderNumber));
124  return pBindingProxy.Reset(pNewBindingProxy);
125 }
126 
134 inline tResult add_binding_proxy(cGraph& oGraph, const util::cString& strName, int32_t nOrderNumber = 0)
135 {
136  ucom::object_ptr<ucom::IObject> pBindingProxy;
137  return add_binding_proxy(oGraph, strName, nOrderNumber, pBindingProxy);
138 }
139 
150  const util::cString& strName,
151  int32_t nOrderNumber,
153 {
154  ucom::object_ptr<ant::INamedGraphObject> pNewPort = ucom::make_object_ptr<cFilterGraphDataOutPort>(strName);
155  RETURN_IF_FAILED(oGraph.AddNamedGraphObject(pNewPort, nOrderNumber));
156  return pPort.Reset(pNewPort);
157 }
158 
168  const util::cString& strName,
169  int32_t nOrderNumber = 0)
170 {
172  return add_data_out_port(oGraph, strName, nOrderNumber, pPort);
173 }
174 
185  const util::cString& strName,
186  int32_t nOrderNumber,
188 {
189  ucom::object_ptr<ant::INamedGraphObject> pNewPort = ucom::make_object_ptr<cFilterGraphDataInPort>(strName);
190  RETURN_IF_FAILED(oGraph.AddNamedGraphObject(pNewPort, nOrderNumber));
191  return pPort.Reset(pNewPort);
192 }
193 
203  const util::cString& strName,
204  int32_t nOrderNumber = 0)
205 {
207  return add_data_in_port(oGraph, strName, nOrderNumber, pPort);
208 }
209 
221  const util::cString& strName,
222  const util::cString& strPortID,
223  int32_t nOrderNumber,
225 {
226  ucom::object_ptr<ant::INamedGraphObject> pNewPort = ucom::make_object_ptr<cSampleStreamOutPort>(strName, strPortID);
227  RETURN_IF_FAILED(oGraph.AddNamedGraphObject(pNewPort, nOrderNumber));
228  return pPort.Reset(pNewPort);
229 }
230 
241  const util::cString& strName,
242  const util::cString& strPortID,
243  int32_t nOrderNumber = 0)
244 {
246  return add_sample_stream_out_port(oGraph, strName, strPortID, nOrderNumber, pPort);
247 }
248 
260  const util::cString& strName,
261  const util::cString& strPortID,
262  int32_t nOrderNumber,
264 {
265  ucom::object_ptr<ant::INamedGraphObject> pNewPort = ucom::make_object_ptr<cSampleStreamInPort>(strName, strPortID);
266  RETURN_IF_FAILED(oGraph.AddNamedGraphObject(pNewPort, nOrderNumber));
267  return pPort.Reset(pNewPort);
268 }
269 
280  const util::cString& strName,
281  const util::cString& strPortID,
282  int32_t nOrderNumber = 0)
283 {
285  return add_sample_stream_in_port(oGraph, strName, strPortID, nOrderNumber, pPort);
286 }
287 
288 }
289 
290 namespace hollow
291 {
292 
299 inline void get_data_binding_objects(ant::IDataBinding* pDataBinding,
301 {
302  adtf::ucom::object_vector<IPin> oPins;
303  pDataBinding->GetPins(oPins);
304  for (auto& pPin: oPins)
305  {
306  oObjects.PushObject(pPin);
307  }
308 }
309 
318 {
319  adtf::ucom::object_vector<IBindingObject> oBindingObjects;
320  pInterfaceBinding->GetBindingObjects(oBindingObjects);
321  for (auto& pBindingObject: oBindingObjects)
322  {
323  oObjects.PushObject(pBindingObject);
324  }
325 }
326 
334 {
335  adtf::ucom::object_vector<IRunner> oRunnerObjects;
336  pRuntimeBehaviour->GetRunners(oRunnerObjects);
337  for (auto& pRunner: oRunnerObjects)
338  {
339  oObjects.PushObject(pRunner);
340  }
341 }
342 
350 
357 inline void get_graph_objects(ant::IGraph* pGraph,
359 {
360  adtf::ucom::object_vector<INamedGraphObject> oChildren;
361  pGraph->GetNamedGraphObjects(oChildren);
362  for (auto& pChild: oChildren)
363  {
364  oObjects.PushObject(pChild);
365  get_child_objects(*pChild, oObjects);
366  }
367 }
368 
377 {
378  using namespace adtf::ucom;
379  auto pDataBinding = ucom_cast<IDataBinding*>(&oObject);
380  if (pDataBinding)
381  {
382  get_data_binding_objects(pDataBinding, oObjects);
383  }
384 
385  auto pInterfaceBinding = ucom_cast<IInterfaceBinding*>(&oObject);
386  if (pInterfaceBinding)
387  {
388  get_interface_binding_objects(pInterfaceBinding, oObjects);
389  }
390 
391  auto pRuntimeBehaviour = ucom_cast<IRuntimeBehaviour*>(&oObject);
392  if (pRuntimeBehaviour)
393  {
394  get_runner_objects(pRuntimeBehaviour, oObjects);
395  }
396 
397  auto pGraph = ucom_cast<IGraph*>(&oObject);
398  if (pGraph)
399  {
400  get_graph_objects(pGraph, oObjects);
401  }
402 }
403 
404 }
405 
410 using devil::add_sample_stream;
413 
419 
420 }
421 
422 }
#define RETURN_IF_FAILED(s)
Return if expression is failed, which requires the calling function's return type to be tResult.
The IDataBinding interfaces provides methods for retrive information of the Pins published.
virtual tResult GetPins(ucom::ant::iobject_list< IPin > &lstPins) const =0
Returns the current Pins (only const access).
Defines the Interface used to connect Items to each other.
Definition: graph_intf.h:104
virtual tResult GetNamedGraphObjects(ucom::ant::iobject_list< INamedGraphObject > &lstItems) const =0
Gets a every registered graph objects.
The IInterfaceBinding provides an interface to implement and access a common dynamic binding object r...
virtual tResult GetBindingObjects(iobject_list< IBindingObject > &lstBindingObject)=0
Return a list of all Binding Objects on lstBindingObject.
Interface for a NamedGraphObject which can be added to the FilterGraph.
The RuntimeBehaviour interface is to clearly define a filters running entry points (IRunner) and thei...
virtual tResult GetRunners(iobject_list< IRunner > &lstRunners) const =0
Returns the current Runners.
Default implementation for the IFilterGraph interface.
Definition: graph.h:22
virtual tResult AddNamedGraphObject(const ucom::ant::iobject_ptr< INamedGraphObject > &pGraphObject, int32_t ui32OrderNumber)
This is to intialize and build an FilterGraph.
virtual tResult CreateInstance(const char *strCID, iobject_ptr< IObject > &pObject, const tChar *strNameOfObject="") const =0
Creates a new instance of an object.
Interface definition for a container of objects.
Definition: object_list.h:22
virtual tResult PushObject(const value_type &oObject)=0
Pushes a object of value_type to the container.
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.
Object pointer implementation used for reference counting on objects of type IObject.
Definition: object_ptr.h:163
virtual T * Get() const
Get pointer to shared object.
Definition: object_ptr.h:381
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.
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 add_binding_proxy(ant::cGraph &oGraph, const util::cString &strName, int32_t nOrderNumber, ucom::iobject_ptr< ucom::IObject > &pBindingProxy)
adds a Binding Proxy to a graph and return the created proxy.
Definition: graph_utils.h:117
tResult add_sample_stream_in_port(ant::cGraph &oGraph, const util::cString &strName, const util::cString &strPortID, int32_t nOrderNumber, ucom::iobject_ptr< ucom::IObject > &pPort)
adds a Stream In Port to a graph and return the created port.
Definition: graph_utils.h:259
tResult add_sample_stream_out_port(ant::cGraph &oGraph, const util::cString &strName, const util::cString &strPortID, int32_t nOrderNumber, ucom::iobject_ptr< ucom::IObject > &pPort)
adds a Stream Out Port to a graph and return the created port.
Definition: graph_utils.h:220
tResult add_data_out_port(ant::cGraph &oGraph, const util::cString &strName, int32_t nOrderNumber, ucom::iobject_ptr< ucom::IObject > &pPort)
adds an Out Port to a graph and return the created port.
Definition: graph_utils.h:149
tResult add_graph_object(ant::cGraph &oGraph, const util::cString &strCID, const util::cString &strName, const std::map< util::cString, util::cString > &oProperties, int32_t nOrderNumber, ucom::iobject_ptr< ucom::IObject > &pObject)
Convenience functionality to create and add add graph object to a existing graph.
Definition: graph_utils.h:39
tResult add_data_in_port(ant::cGraph &oGraph, const util::cString &strName, int32_t nOrderNumber, ucom::iobject_ptr< ucom::IObject > &pPort)
adds an In Port to a graph and return the created port.
Definition: graph_utils.h:184
void get_runner_objects(ant::IRuntimeBehaviour *pRuntimeBehaviour, ucom::ant::iobject_enum< ucom::ant::IObject > &oObjects)
Get all runner objects object out of pRuntimeBehaviour.
Definition: graph_utils.h:333
void get_child_objects(ant::INamedGraphObject &oObject, ucom::ant::iobject_enum< ucom::ant::IObject > &oObjects)
Get all child objects of the given oObject.
Definition: graph_utils.h:375
void get_data_binding_objects(ant::IDataBinding *pDataBinding, ucom::ant::iobject_enum< adtf::ucom::ant::IObject > &oObjects)
Get all the data binding objects out of pDataBinding.
Definition: graph_utils.h:299
void get_graph_objects(ant::IGraph *pGraph, ucom::ant::iobject_enum< ucom::ant::IObject > &oObjects)
Get all graph objects out of the pGraph.
Definition: graph_utils.h:357
void get_interface_binding_objects(ant::IInterfaceBinding *pInterfaceBinding, ucom::ant::iobject_enum< adtf::ucom::ant::IObject > &oObjects)
Get all the interface binding objects out of pInterfaceBinding.
Definition: graph_utils.h:316
Namespace for the ADTF uCOM3 SDK.
Namespace for entire ADTF SDK.
adtf::ucom::IRuntime * _runtime
Global Runtime Pointer to reference to the current runtime.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.
Copyright © Audi Electronics Venture GmbH.