AudioManager  7.6.6
Native Application Runtime Environment
CAmRouter.cpp
Go to the documentation of this file.
1 
25 #include <cassert>
26 #include <algorithm>
27 #include <vector>
28 #include <iterator>
29 #include "CAmRouter.h"
30 #include "IAmDatabaseHandler.h"
31 #include "CAmControlSender.h"
32 #include "CAmDltWrapper.h"
33 
34 namespace am
35 {
36 
37  template<class X> void getMergeConnectionFormats(const X * element, const am_CustomConnectionFormat_t connectionFormat,
38  const std::vector<am_CustomConnectionFormat_t> & listConnectionFormats, std::vector<am_CustomConnectionFormat_t> & outListMergeConnectionFormats)
39  {
40  std::vector<am_CustomConnectionFormat_t> listRestrictedConnectionFormats;
41  CAmRouter::getRestrictedOutputFormats(element->convertionMatrix, element->listSourceFormats, element->listSinkFormats, connectionFormat,
42  listRestrictedConnectionFormats);
43  std::sort(listRestrictedConnectionFormats.begin(), listRestrictedConnectionFormats.end()); //todo: this might be not needed if we use strictly sorted input
44  std::insert_iterator<std::vector<am_CustomConnectionFormat_t> > inserter(outListMergeConnectionFormats, outListMergeConnectionFormats.begin());
45  set_intersection(listConnectionFormats.begin(), listConnectionFormats.end(), listRestrictedConnectionFormats.begin(),
46  listRestrictedConnectionFormats.end(), inserter);
47  }
48 
50  CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks(),
51  mpDatabaseHandler(iDatabaseHandler), //
52  mpControlSender(iSender),
53  mUpdateGraphNodesAction(true),
54  mMaxAllowedCycles(MAX_ALLOWED_DOMAIN_CYCLES),
55  mMaxPathCount(MAX_ROUTING_PATHS),
56  mRoutingGraph(),
57  mNodeListSources(),
58  mNodeListSinks(),
59  mNodeListGateways(),
60  mNodeListConverters()
61  {
62  assert(mpDatabaseHandler);
63  assert(mpControlSender);
64 
65  dboNewSink = [&](const am_Sink_s& sink)
66  {
67  mUpdateGraphNodesAction = true;
68  };
69  dboNewSource = [&](const am_Source_s& source)
70  {
71  mUpdateGraphNodesAction=true;
72  };
73  dboNewGateway = [&](const am_Gateway_s& gateway)
74  {
75  mUpdateGraphNodesAction=true;
76  };
77  dboNewConverter = [&](const am_Converter_s& coverter)
78  {
79  mUpdateGraphNodesAction=true;
80  };
81  dboRemovedSink = [&](const am_sinkID_t sinkID, const bool visible)
82  {
83  mUpdateGraphNodesAction=true;
84  };
85  dboRemovedSource = [&](const am_sourceID_t sourceID, const bool visible)
86  {
87  mUpdateGraphNodesAction=true;
88  };
89  dboRemoveGateway = [&](const am_gatewayID_t gatewayID)
90  {
91  mUpdateGraphNodesAction=true;
92  };
93  dboRemoveConverter = [&](const am_converterID_t converterID)
94  {
95  mUpdateGraphNodesAction=true;
96  };
97  }
98 
100  {
101  }
102 
111  am_Error_e CAmRouter::getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s> & returnList)
112  {
113  if (mUpdateGraphNodesAction)
114  {
115  load();
116  mUpdateGraphNodesAction = false;
117  }
118  return getRouteFromLoadedNodes(onlyfree, sourceID, sinkID, returnList);
119  }
120 
121  am_Error_e CAmRouter::getRoute(const bool onlyfree, const am_Source_s & aSource, const am_Sink_s & aSink, std::vector<am_Route_s> & listRoutes)
122  {
123  return getRoute(onlyfree, aSource.sourceID, aSink.sinkID, listRoutes);
124  }
125 
126  am_Error_e CAmRouter::getRouteFromLoadedNodes(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID,
127  std::vector<am_Route_s> & returnList)
128  {
129  returnList.clear();
130 
131  CAmRoutingNode* pRootSource = sourceNodeWithID(sourceID);
132  CAmRoutingNode* pRootSink = sinkNodeWithID(sinkID);
133 
134  if (!pRootSource || !pRootSink)
135  return E_NON_EXISTENT;
136 
137  //try to find paths without cycles
138  am_Error_e error = getFirstNShortestPaths(onlyfree, 0, mMaxPathCount, *pRootSource, *pRootSink, returnList);
139 
140  //if no paths have been found, we start a second search with cycles.
141  if (!returnList.size() && mMaxAllowedCycles > 0)
142  {
143  error = getFirstNShortestPaths(onlyfree, mMaxAllowedCycles, mMaxPathCount, *pRootSource, *pRootSink, returnList);
144  }
145 
146  /* For shortest path use the following call:
147  *
148  * error = getShortestPath(*pRootSource, *pRootSink, listRoutes);
149  */
150  return error;
151  }
152 
153  am_Error_e CAmRouter::getRouteFromLoadedNodes(const bool onlyfree, const am_Source_s & aSource, const am_Sink_s & aSink,
154  std::vector<am_Route_s> & listRoutes)
155  {
156  return getRouteFromLoadedNodes(onlyfree, aSource.sourceID, aSink.sinkID, listRoutes);
157  }
158 
160  {
161  clear();
162 
163  am_RoutingNodeData_s nodeDataSrc;
164  nodeDataSrc.type = CAmNodeDataType::SOURCE;
165  mpDatabaseHandler->enumerateSources([&](const am_Source_s & obj)
166  {
167  nodeDataSrc.data.source = (am_Source_s*)&obj;
168  auto node = &mRoutingGraph.addNode(nodeDataSrc);
169  mNodeListSources[nodeDataSrc.data.source->domainID].push_back(node);
170  });
171 
172  am_RoutingNodeData_s nodeDataSink;
173  nodeDataSink.type = CAmNodeDataType::SINK;
174  mpDatabaseHandler->enumerateSinks([&](const am_Sink_s & obj)
175  {
176  nodeDataSink.data.sink = (am_Sink_s*)&obj;
177  auto node = &mRoutingGraph.addNode(nodeDataSink);
178  mNodeListSinks[nodeDataSink.data.sink->domainID].push_back(node);
179  });
180 
181  am_RoutingNodeData_s nodeDataGateway;
182  nodeDataGateway.type = CAmNodeDataType::GATEWAY;
183  mpDatabaseHandler->enumerateGateways([&](const am_Gateway_s & obj)
184  {
185  nodeDataGateway.data.gateway = (am_Gateway_s*)&obj;
186  auto node = &mRoutingGraph.addNode(nodeDataGateway);
187  mNodeListGateways[nodeDataGateway.data.gateway->controlDomainID].push_back(node);
188  });
189 
190  am_RoutingNodeData_s nodeDataConverter;
191  nodeDataConverter.type = CAmNodeDataType::CONVERTER;
192  mpDatabaseHandler->enumerateConverters([&](const am_Converter_s & obj)
193  {
194  nodeDataConverter.data.converter = (am_Converter_s*)&obj;
195  auto node = &mRoutingGraph.addNode(nodeDataConverter);
196  mNodeListConverters[nodeDataConverter.data.converter->domainID].push_back(node);
197  });
198 
199  constructConverterConnections();
200  constructGatewayConnections();
201  constructSourceSinkConnections();
202 
203 #ifdef TRACE_GRAPH
204  mRoutingGraph.trace([&](const CAmRoutingNode & node, const std::vector<CAmVertex<am_RoutingNodeData_s,uint16_t>*> & list)
205  {
206  std::cout << "Node " << node.getIndex() << ":";
207  ((CAmRoutingNode &)node).getData().trace();
208  std::cout << "-->[";
209  int count = 0;
210  std::for_each(list.begin(), list.end(), [&](const CAmVertex<am_RoutingNodeData_s,uint16_t>* refVertex)
211  {
212  am::CAmNode<am::am_RoutingNodeData_s>* data = refVertex->getNode();
213  if(count>0)
214  std::cout << ", ";
215  std::cout << "Node " << data->getIndex() << ":";
216  data->getData().trace();
217  count++;
218  });
219  std::cout << "]" << std::endl;
220  });
221 #endif
222 
223  }
224 
226  {
227  mRoutingGraph.clear();
228  mNodeListSources.clear();
229  mNodeListSinks.clear();
230  mNodeListGateways.clear();
231  mNodeListConverters.clear();
232  }
233 
235  {
236  CAmRoutingNode* result = NULL;
237  for (auto it = mNodeListSinks.begin(); it != mNodeListSinks.end(); it++)
238  {
239  result = sinkNodeWithID(sinkID, it->first);
240  if (result)
241  return result;
242  }
243  return result;
244  }
245 
247  {
248  CAmRoutingNode* result = NULL;
249  std::vector<CAmRoutingNode*> & value = mNodeListSinks[domainID];
250  auto iter = std::find_if(value.begin(), value.end(), [sinkID](CAmRoutingNode* node)
251  {
252  return node->getData().data.sink->sinkID==sinkID;
253  });
254  if (iter != value.end())
255  result = *iter;
256  return result;
257  }
258 
260  {
261  CAmRoutingNode* result = NULL;
262  for (auto it = mNodeListSources.begin(); it != mNodeListSources.end(); it++)
263  {
264  result = sourceNodeWithID(sourceID, it->first);
265  if (result)
266  return result;
267  }
268  return result;
269  }
270 
272  {
273  CAmRoutingNode* result = NULL;
274  std::vector<CAmRoutingNode*> & value = mNodeListSources[domainID];
275  auto iter = std::find_if(value.begin(), value.end(), [sourceID](CAmRoutingNode* node)
276  {
277  return node->getData().data.source->sourceID==sourceID;
278  });
279  if (iter != value.end())
280  result = *iter;
281  return result;
282  }
283 
285  {
286  CAmRoutingNode* result = NULL;
287  std::vector<CAmRoutingNode*> & value = mNodeListConverters[domainID];
288  auto iter = std::find_if(value.begin(), value.end(), [sinkID](CAmRoutingNode* node)
289  {
290  return node->getData().data.converter->sinkID==sinkID;
291  });
292  if (iter != value.end())
293  result = *iter;
294  return result;
295  }
296 
298  {
299  for (auto it = mNodeListGateways.begin(); it != mNodeListGateways.end(); it++)
300  {
301  std::vector<CAmRoutingNode*> & value = it->second;
302  auto iter = std::find_if(value.begin(), value.end(), [sinkID](CAmRoutingNode* node)
303  {
304  return node->getData().data.gateway->sinkID==sinkID;
305  });
306  if (iter != value.end())
307  return *iter;
308  }
309  return NULL;
310  }
311 
312  void CAmRouter::constructSourceSinkConnections()
313  {
314  std::vector<am_CustomConnectionFormat_t> intersection;
315  for (auto itSrc = mNodeListSources.begin(); itSrc != mNodeListSources.end(); itSrc++)
316  {
317  for (auto it = itSrc->second.begin(); it != itSrc->second.end(); it++)
318  {
319  CAmRoutingNode* srcNode = *it;
320  am_RoutingNodeData_s & srcNodeData = srcNode->getData();
321  am_Source_s * source = srcNodeData.data.source;
322  for (auto itSink = mNodeListSinks[itSrc->first].begin(); itSink != mNodeListSinks[itSrc->first].end(); itSink++)
323  {
324  CAmRoutingNode* sinkNode = *itSink;
325  am_RoutingNodeData_s & sinkNodeData = sinkNode->getData();
326  am_Sink_s * sink = sinkNodeData.data.sink;
327 
328  intersection.clear();
329  //Check whether the hidden sink formats match the source formats...
331  if (intersection.size() > 0) //OK match source -> sink
332  {
333  mRoutingGraph.connectNodes(*srcNode, *sinkNode, CF_UNKNOWN, 1);
334  }
335  }
336  }
337  }
338  }
339 
340  void CAmRouter::constructGatewayConnections()
341  {
342  std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
343  for (auto iter = mNodeListGateways.begin(); iter != mNodeListGateways.end(); iter++)
344  {
345  for (auto it = iter->second.begin(); it != iter->second.end(); it++)
346  {
347  CAmRoutingNode* gatewayNode = *it;
348  am_RoutingNodeData_s & gatewayNodeData = gatewayNode->getData();
349  am_Gateway_s * gateway = gatewayNodeData.data.gateway;
350  //Get only gateways with end point in current source domain
351 
352  //Get the sink connected to the gateway...
353  CAmRoutingNode *gatewaySinkNode = this->sinkNodeWithID(gateway->sinkID, gateway->domainSinkID);
354  if (gatewaySinkNode)
355  {
356  am_RoutingNodeData_s & gatewaySinkData = gatewaySinkNode->getData();
357  //Check whether the hidden sink formats match the source formats...
358  sourceFormats.clear();
359  sinkFormats.clear();
360  if (getAllowedFormatsFromConvMatrix(gateway->convertionMatrix, gateway->listSourceFormats, gateway->listSinkFormats, sourceFormats,
361  sinkFormats))
362  {
363  CAmRoutingNode *gatewaySourceNode = this->sourceNodeWithID(gateway->sourceID, gateway->domainSourceID);
364  if (gatewaySourceNode)
365  {
366  //Connections hidden_sink->gateway->hidden_source
367  mRoutingGraph.connectNodes(*gatewaySinkNode, *gatewayNode, CF_UNKNOWN, 1);
368  mRoutingGraph.connectNodes(*gatewayNode, *gatewaySourceNode, CF_UNKNOWN, 1);
369  }
370  }
371  }
372  }
373  }
374  }
375 
376  void CAmRouter::constructConverterConnections()
377  {
378  std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
379 
380  for (auto iter = mNodeListConverters.begin(); iter != mNodeListConverters.end(); iter++)
381  {
382  for (auto it = iter->second.begin(); it != iter->second.end(); it++)
383  {
384  CAmRoutingNode* converterNode = *it;
385  am_RoutingNodeData_s & converterNodeData = converterNode->getData();
386  am_Converter_s * converter = converterNodeData.data.converter;
387  //Get only converters with end point in current source domain
388 
389  //Get the sink connected to the converter...
390  CAmRoutingNode *converterSinkNode = this->sinkNodeWithID(converter->sinkID, converter->domainID);
391  if (converterSinkNode)
392  {
393  am_RoutingNodeData_s & converterSinkData = converterSinkNode->getData();
394  //Check whether the hidden sink formats match the source formats...
395  sourceFormats.clear();
396  sinkFormats.clear();
397  if (getAllowedFormatsFromConvMatrix(converter->convertionMatrix, converter->listSourceFormats, converter->listSinkFormats, sourceFormats,
398  sinkFormats))
399  {
400  CAmRoutingNode *converterSourceNode = this->sourceNodeWithID(converter->sourceID, converter->domainID);
401  if (converterSourceNode)
402  {
403  //Connections hidden_sink->converter->hidden_source
404  mRoutingGraph.connectNodes(*converterSinkNode, *converterNode, CF_UNKNOWN, 1);
405  mRoutingGraph.connectNodes(*converterNode, *converterSourceNode, CF_UNKNOWN, 1);
406  }
407  }
408  }
409  }
410  }
411  }
412 
413  void CAmRouter::getVerticesForSource(const CAmRoutingNode & node, CAmRoutingListVertices & list)
414  {
415  am_RoutingNodeData_s & srcNodeData = ((CAmRoutingNode*) &node)->getData();
416  std::vector<am_CustomConnectionFormat_t> intersection;
417  am_Source_s * source = srcNodeData.data.source;
418  std::vector<CAmRoutingNode*> & sinks = mNodeListSinks[source->domainID];
419  for (auto itSink = sinks.begin(); itSink != sinks.end(); itSink++)
420  {
421  CAmRoutingNode* sinkNode = *itSink;
422  am_RoutingNodeData_s & sinkNodeData = sinkNode->getData();
423  am_Sink_s * sink = sinkNodeData.data.sink;
424 
425  intersection.clear();
426  //Check whether the hidden sink formats match the source formats...
428  if (intersection.size() > 0) //OK match source -> sink
429  {
430  list.emplace_back(sinkNode, CF_UNKNOWN, 1);
431  }
432  }
433  }
434 
435  void CAmRouter::getVerticesForSink(const CAmRoutingNode & node, CAmRoutingListVertices & list)
436  {
437  am_RoutingNodeData_s & sinkNodeData = ((CAmRoutingNode*) &node)->getData();
438  std::vector<am_CustomConnectionFormat_t> intersection;
439  am_Sink_s * sink = sinkNodeData.data.sink;
440 
441  CAmRoutingNode *converterNode = converterNodeWithSinkID(sink->sinkID, sink->domainID);
442  if (converterNode)
443  {
444  std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
445  am_RoutingNodeData_s & converterData = converterNode->getData();
446  am_Converter_s * converter = converterData.data.converter;
447 
448  if (getAllowedFormatsFromConvMatrix(converter->convertionMatrix, converter->listSourceFormats, converter->listSinkFormats, sourceFormats,
449  sinkFormats))
450  list.emplace_back(converterNode, CF_UNKNOWN, 1);
451  }
452  else
453  {
454  std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
455  CAmRoutingNode *gatewayNode = gatewayNodeWithSinkID(sink->sinkID);
456  if (gatewayNode)
457  {
458  std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
459  am_RoutingNodeData_s & gatewayData = gatewayNode->getData();
460  am_Gateway_s * gateway = gatewayData.data.gateway;
461 
462  if (getAllowedFormatsFromConvMatrix(gateway->convertionMatrix, gateway->listSourceFormats, gateway->listSinkFormats, sourceFormats,
463  sinkFormats))
464  list.emplace_back(gatewayNode, CF_UNKNOWN, 1);
465  }
466  }
467 
468  }
469 
470  void CAmRouter::getVerticesForConverter(const CAmRoutingNode & node, CAmRoutingListVertices & list)
471  {
472  std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
473  am_RoutingNodeData_s & converterNodeData = ((CAmRoutingNode*) &node)->getData();
474  am_Converter_s * converter = converterNodeData.data.converter;
475  //Get only converters with end point in current source domain
476  if (getAllowedFormatsFromConvMatrix(converter->convertionMatrix, converter->listSourceFormats, converter->listSinkFormats, sourceFormats, sinkFormats))
477  {
478  CAmRoutingNode *converterSourceNode = this->sourceNodeWithID(converter->sourceID, converter->domainID);
479  if (converterSourceNode)
480  {
481  list.emplace_back(converterSourceNode, CF_UNKNOWN, 1);
482  }
483  }
484  }
485 
486  void CAmRouter::getVerticesForGateway(const CAmRoutingNode & node, CAmRoutingListVertices & list)
487  {
488  am_RoutingNodeData_s & gatewayNodeData = ((CAmRoutingNode*) &node)->getData();
489  std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
490  am_Gateway_s * gateway = gatewayNodeData.data.gateway;
491  if (getAllowedFormatsFromConvMatrix(gateway->convertionMatrix, gateway->listSourceFormats, gateway->listSinkFormats, sourceFormats, sinkFormats))
492  {
493  CAmRoutingNode *gatewaySourceNode = this->sourceNodeWithID(gateway->sourceID, gateway->domainSourceID);
494  if (gatewaySourceNode)
495  {
496  //Connections hidden_sink->gateway->hidden_source
497  list.emplace_back(gatewaySourceNode, CF_UNKNOWN, 1);
498  }
499  }
500  }
501 
502  void CAmRouter::getVerticesForNode(const CAmRoutingNode & node, CAmRoutingListVertices & list)
503  {
504  am_RoutingNodeData_s & nodeData = ((CAmRoutingNode*) &node)->getData();
505  if (nodeData.type == CAmNodeDataType::SOURCE)
506  {
507  getVerticesForSource(node, list);
508  }
509  else if (nodeData.type == CAmNodeDataType::SINK)
510  {
511  getVerticesForSink(node, list);
512  }
513  else if (nodeData.type == CAmNodeDataType::CONVERTER)
514  {
515  getVerticesForConverter(node, list);
516  }
517  else if (nodeData.type == CAmNodeDataType::GATEWAY)
518  {
519  getVerticesForGateway(node, list);
520  }
521  }
522 
523  am_Error_e CAmRouter::determineConnectionFormatsForPath(am_Route_s & routeObjects, std::vector<CAmRoutingNode*> & nodes, std::vector<am_Route_s> & result)
524  {
525  std::vector<am_RoutingElement_s>::iterator routingElementIterator = routeObjects.route.begin();
526  std::vector<CAmRoutingNode*>::iterator nodeIterator = nodes.begin();
527  if (routingElementIterator != routeObjects.route.end() && nodeIterator != nodes.end())
528  return doConnectionFormatsForPath(routeObjects, nodes, routingElementIterator, nodeIterator, result);
529  return E_OK;
530  }
531 
532  am_Error_e CAmRouter::doConnectionFormatsForPath(am_Route_s & routeObjects, std::vector<CAmRoutingNode*> & nodes,
533  std::vector<am_RoutingElement_s>::iterator routingElementIterator, std::vector<CAmRoutingNode*>::iterator nodeIterator,
534  std::vector<am_Route_s> & result)
535  {
536  am_Error_e returnError = E_NOT_POSSIBLE;
537  std::vector<am_CustomConnectionFormat_t> listConnectionFormats;
538  std::vector<am_CustomConnectionFormat_t> listMergeConnectionFormats;
539 
540  std::vector<CAmRoutingNode*>::iterator currentNodeIterator = nodeIterator;
541  std::vector<am_RoutingElement_s>::iterator currentRoutingElementIterator = routingElementIterator;
542 
543  if (currentRoutingElementIterator != routeObjects.route.begin())
544  {
545  std::vector<am_CustomConnectionFormat_t> listConnectionFormats;
546  std::vector<am_RoutingElement_s>::iterator tempIterator = (currentRoutingElementIterator - 1);
547  CAmRoutingNode * currentNode = *currentNodeIterator;
548  if ((returnError = getSourceSinkPossibleConnectionFormats(currentNodeIterator + 1, currentNodeIterator + 2, listConnectionFormats)) != E_OK)
549  return returnError;
550 
551  if (currentNode->getData().type == CAmNodeDataType::GATEWAY)
552  {
553  am_Gateway_s *gateway = currentNode->getData().data.gateway;
554  getMergeConnectionFormats(gateway, tempIterator->connectionFormat, listConnectionFormats, listMergeConnectionFormats);
555  }
556  else if (currentNode->getData().type == CAmNodeDataType::CONVERTER)
557  {
558  am_Converter_s *converter = currentNode->getData().data.converter;
559  getMergeConnectionFormats(converter, tempIterator->connectionFormat, listConnectionFormats, listMergeConnectionFormats);
560  }
561  else
562  return (E_UNKNOWN);
563  currentNodeIterator += 3;
564  }
565  else
566  {
567  CAmRoutingNode * currentNode = *currentNodeIterator;
568  if (currentNode->getData().type != CAmNodeDataType::SOURCE)
569  return (E_UNKNOWN);
570  currentNodeIterator++;
571 
572  if (currentNodeIterator == nodes.end())
573  return (E_UNKNOWN);
574 
575  CAmRoutingNode * nodeSink = *currentNodeIterator;
576  if (nodeSink->getData().type != CAmNodeDataType::SINK)
577  return (E_UNKNOWN);
578 
579  am_Source_s *source = currentNode->getData().data.source;
580  am_Sink_s *sink = nodeSink->getData().data.sink;
581  listPossibleConnectionFormats(source->listConnectionFormats, sink->listConnectionFormats, listMergeConnectionFormats);
582  currentNodeIterator += 1; //now we are on the next converter/gateway
583  }
584  //let the controller decide:
585  std::vector<am_CustomConnectionFormat_t> listPriorityConnectionFormats;
586  if ((returnError = mpControlSender->getConnectionFormatChoice(currentRoutingElementIterator->sourceID, currentRoutingElementIterator->sinkID,
587  routeObjects, listMergeConnectionFormats, listPriorityConnectionFormats)) != E_OK)
588  return (returnError);
589 
590  if (listPriorityConnectionFormats.empty())
591  return (E_NOT_POSSIBLE);
592  //we have the list sorted after priors - now we try one after the other with the next part of the route
593  std::vector<am_CustomConnectionFormat_t>::iterator connectionFormatIterator = listPriorityConnectionFormats.begin();
594  //here we need to check if we are at the end and stop
595  std::vector<am_RoutingElement_s>::iterator nextIterator = currentRoutingElementIterator + 1; //next pair source and sink
596  if (nextIterator == routeObjects.route.end())
597  {
598  for (; connectionFormatIterator != listPriorityConnectionFormats.end(); ++connectionFormatIterator)
599  {
600  currentRoutingElementIterator->connectionFormat = *connectionFormatIterator;
601  result.push_back(routeObjects);
602  }
603  }
604  else
605  {
606  for (; connectionFormatIterator != listPriorityConnectionFormats.end(); ++connectionFormatIterator)
607  {
608  currentRoutingElementIterator->connectionFormat = *connectionFormatIterator;
609  doConnectionFormatsForPath(routeObjects, nodes, nextIterator, currentNodeIterator, result);
610  }
611  }
612  return (E_OK);
613  }
614 
615  am_Error_e CAmRouter::cfPermutationsForPath(am_Route_s shortestRoute, std::vector<CAmRoutingNode*> resultNodesPath, std::vector<am_Route_s>& resultPath)
616  {
617  std::vector<am_Route_s> result;
618  am_Error_e err = determineConnectionFormatsForPath(shortestRoute, resultNodesPath, result);
619  if (err != E_UNKNOWN)
620  {
621  resultPath.insert(resultPath.end(), result.begin(), result.end());
622 #ifdef TRACE_GRAPH
623  std::cout
624  << "Determined connection formats for path from source:"
625  << shortestRoute.sourceID << " to sink:" << shortestRoute.sinkID
626  << "\n";
627  for (auto routeConnectionFormats : result)
628  {
629  std::cout << "[";
630  for (auto it = routeConnectionFormats.route.begin();it != routeConnectionFormats.route.end(); it++)
631  {
632  am_RoutingElement_s& routingElement = *it;
633  if (it - routeConnectionFormats.route.begin() > 0)
634  std::cout << " -> ";
635 
636  std::cout << routingElement.sourceID << ":"
637  << routingElement.sinkID << " CF:"
638  << routingElement.connectionFormat << " D:"
639  << routingElement.domainID;
640  }
641  std::cout << "]\n";
642  }
643 #endif
644  }
645 #ifdef TRACE_GRAPH
646  else
647  {
648  std::cout
649  << "Error by determining connection formats for path from source:"
650  << shortestRoute.sourceID << " to sink:" << shortestRoute.sinkID
651  << "\n";
652  }
653 #endif
654  return err;
655  }
656 
657  am_Error_e CAmRouter::getShortestPath(CAmRoutingNode & aSource, CAmRoutingNode & aSink, std::vector<am_Route_s> & resultPath)
658  {
659  am_Error_e err = E_OK;
660  am_Route_s shortestRoute;
661  std::vector<CAmRoutingNode*> resultNodesPath;
662  am_RoutingNodeData_s & sinkNodeData = aSink.getData();
663  am_RoutingNodeData_s & sourceNodeData = aSource.getData();
664  shortestRoute.sinkID = sinkNodeData.data.sink->sinkID;
665  shortestRoute.sourceID = sourceNodeData.data.source->sourceID;
666 
667  mRoutingGraph.getShortestPath(aSource, aSink, [&shortestRoute, &resultNodesPath](const am_GraphPathPosition_e position, CAmRoutingNode & object)
668  {
669  am_RoutingElement_s * element;
670  //reverse order
671  resultNodesPath.insert(resultNodesPath.begin(), (CAmRoutingNode*)&object);
672  am_RoutingNodeData_s & routingData = object.getData();
673  if(routingData.type==CAmNodeDataType::SINK)
674  {
675  auto iter = shortestRoute.route.emplace(shortestRoute.route.begin());
676  element = &(*iter);
677  element->domainID = routingData.data.sink->domainID;
678  element->sinkID = routingData.data.sink->sinkID;
679  element->connectionFormat = CF_UNKNOWN;
680  }
681  else if(routingData.type==CAmNodeDataType::SOURCE)
682  {
683  element->domainID = routingData.data.source->domainID;
684  element->sourceID = routingData.data.source->sourceID;
685  element->connectionFormat = CF_UNKNOWN;
686  }
687  });
688 
689  if (shortestRoute.route.size())
690  {
691  err = cfPermutationsForPath(shortestRoute, resultNodesPath, resultPath);
692  }
693  return err;
694  }
695 
696  int CAmRouter::insertPostion(const std::vector<CAmRoutingNode*>& path, const std::vector<std::vector<CAmRoutingNode*> >& nodes)
697  {
698  int index = 0;
699  if (!nodes.empty())
700  {
701  auto itNodes = nodes.begin();
702  for (; itNodes != nodes.end(); itNodes++)
703  {
704  if (itNodes->size() > path.size())
705  break;
706  }
707  if (itNodes == nodes.end())
708  index = nodes.size();
709  else
710  index = itNodes - nodes.begin();
711  }
712  return index;
713  }
714 
715  am_Error_e CAmRouter::getFirstNShortestPaths(const bool onlyFree, const unsigned cycles, const unsigned maxPathCount, CAmRoutingNode & aSource,
716  CAmRoutingNode & aSink, std::vector<am_Route_s> & resultPath)
717  {
718  if (aSource.getData().type != CAmNodeDataType::SOURCE || aSink.getData().type != CAmNodeDataType::SINK)
719  return E_NOT_POSSIBLE;
720  const am_sinkID_t sinkID = aSink.getData().data.sink->sinkID;
721  const am_sourceID_t sourceID = aSource.getData().data.source->sourceID;
722  std::vector<am_Route_s> paths;
723  std::vector<std::vector<CAmRoutingNode*>> nodes;
724  std::vector<am_domainID_t> visitedDomains;
725  visitedDomains.push_back(((CAmRoutingNode*) &aSource)->getData().domainID());
726 
727  auto cbShouldVisitNode = [&visitedDomains, &cycles, &onlyFree, this](const CAmRoutingNode * node)->bool
728  {
729  if(CAmRouter::shouldGoInDomain(visitedDomains, node->getData().domainID(), cycles))
730  {
731  const am_RoutingNodeData_s & nodeData = node->getData();
732  if(am_RoutingNodeData_s::GATEWAY==nodeData.type)
733  {
734  const am_Gateway_s * gateway = nodeData.data.gateway;
735  return (!onlyFree || !isComponentConnected(*gateway));
736  }
737  else if(am_RoutingNodeData_s::CONVERTER==nodeData.type)
738  {
739  const am_Converter_s * converter = nodeData.data.converter;
740  return (!onlyFree || !isComponentConnected(*converter));
741  }
742  return true;
743  }
744  return false;
745  };
746  auto cbWillVisitNode = [&visitedDomains](const CAmRoutingNode * node)
747  { visitedDomains.push_back(node->getData().domainID());};
748  auto cbDidVisitNode = [&visitedDomains](const CAmRoutingNode * node)
749  { visitedDomains.erase(visitedDomains.end()-1);};
750  auto cbDidFinish = [&resultPath, &nodes, &paths, &sinkID, &sourceID](const std::vector<CAmRoutingNode*> & path)
751  {
752  int index = CAmRouter::insertPostion(path, nodes);
753  nodes.emplace(nodes.begin()+index);
754  paths.emplace(paths.begin()+index);
755  nodes[index] = path;
756  am_Route_s & nextRoute = paths[index];
757  nextRoute.sinkID = sinkID;
758  nextRoute.sourceID = sourceID;
759  am_RoutingElement_s * element;
760  for(auto it = path.begin(); it!=path.end(); it++)
761  {
762  am_RoutingNodeData_s & routingData = (*it)->getData();
763  if(routingData.type==CAmNodeDataType::SOURCE)
764  {
765  auto iter = nextRoute.route.emplace(nextRoute.route.end());
766  element = &(*iter);
767  element->domainID = routingData.data.source->domainID;
768  element->sourceID = routingData.data.source->sourceID;
769  element->connectionFormat = CF_UNKNOWN;
770  }
771  else if(routingData.type==CAmNodeDataType::SINK)
772  {
773  element->domainID = routingData.data.sink->domainID;
774  element->sinkID = routingData.data.sink->sinkID;
775  element->connectionFormat = CF_UNKNOWN;
776  }
777  }
778  };
779 
780  mRoutingGraph.getAllPaths(aSource, aSink, cbShouldVisitNode, cbWillVisitNode, cbDidVisitNode, cbDidFinish);
781  unsigned pathsFound = 0;
782  am_Error_e cfError = E_OK;
783  for (auto it = paths.begin(); pathsFound < maxPathCount && it != paths.end(); it++)
784  {
785  cfError = cfPermutationsForPath(*it, nodes[it - paths.begin()], resultPath);
786  if (E_OK == cfError)
787  {
788  pathsFound += (resultPath.size() > 0);
789  }
790  }
791  if (pathsFound)
792  return E_OK;
793  else
794  return E_NOT_POSSIBLE;
795  }
796 
797  bool CAmRouter::shouldGoInDomain(const std::vector<am_domainID_t> & visitedDomains, const am_domainID_t nodeDomainID, const unsigned maxCyclesNumber)
798  {
799  unsigned recourseCounter(0);
800  if (visitedDomains.size())
801  {
802  if (visitedDomains.back() == nodeDomainID)
803  return true;
804  unsigned count = 0;
805  am_domainID_t lastDomain = 0;
806  for (auto it = visitedDomains.begin(); it != visitedDomains.end() - 1; it++)
807  {
808  if (lastDomain != *it)
809  {
810  if (nodeDomainID == *it)
811  {
812  recourseCounter++;
813  if (recourseCounter > maxCyclesNumber)
814  return false;
815  }
816  lastDomain = *it;
817  }
818  }
819  }
820  return true;
821  }
822 
823  bool CAmRouter::shouldGoInDomain(const std::vector<am_domainID_t> & visitedDomains, const am_domainID_t nodeDomainID)
824  {
825  return CAmRouter::shouldGoInDomain(visitedDomains, nodeDomainID, mMaxAllowedCycles);
826  }
827 
828  bool CAmRouter::getAllowedFormatsFromConvMatrix(const std::vector<bool> & convertionMatrix,
829  const std::vector<am_CustomConnectionFormat_t> & listSourceFormats, const std::vector<am_CustomConnectionFormat_t> & listSinkFormats,
830  std::vector<am_CustomConnectionFormat_t> & sourceFormats, std::vector<am_CustomConnectionFormat_t> & sinkFormats)
831  {
832  const size_t sizeSourceFormats = listSourceFormats.size();
833  const size_t sizeSinkFormats = listSinkFormats.size();
834  const size_t sizeConvertionMatrix = convertionMatrix.size();
835 
836  if (sizeSourceFormats == 0 || sizeSinkFormats == 0 || sizeConvertionMatrix == 0 || sizeConvertionMatrix != sizeSinkFormats * sizeSourceFormats)
837  {
838  return false;
839  }
840 
841  std::vector<bool>::const_iterator iterator = convertionMatrix.begin();
842  for (; iterator != convertionMatrix.end(); ++iterator)
843  {
844  if (true == *iterator)
845  {
846  const size_t index = iterator - convertionMatrix.begin();
847  size_t idx = index % sizeSourceFormats;
848  sourceFormats.push_back(listSourceFormats.at(idx));
849  idx = index / sizeSourceFormats;
850  sinkFormats.push_back(listSinkFormats.at(idx));
851  }
852  }
853  return sourceFormats.size() > 0;
854  }
855 
856  void CAmRouter::listPossibleConnectionFormats(std::vector<am_CustomConnectionFormat_t> & inListSourceFormats,
857  std::vector<am_CustomConnectionFormat_t> & inListSinkFormats, std::vector<am_CustomConnectionFormat_t> & outListFormats)
858  {
859  std::sort(inListSourceFormats.begin(), inListSourceFormats.end());
860  std::sort(inListSinkFormats.begin(), inListSinkFormats.end());
861  std::insert_iterator<std::vector<am_CustomConnectionFormat_t> > inserter(outListFormats, outListFormats.begin());
862  set_intersection(inListSourceFormats.begin(), inListSourceFormats.end(), inListSinkFormats.begin(), inListSinkFormats.end(), inserter);
863  }
864 
865  bool CAmRouter::getRestrictedOutputFormats(const std::vector<bool> & convertionMatrix, const std::vector<am_CustomConnectionFormat_t> & listSourceFormats,
866  const std::vector<am_CustomConnectionFormat_t> & listSinkFormats, const am_CustomConnectionFormat_t connectionFormat,
867  std::vector<am_CustomConnectionFormat_t> & listFormats)
868  {
869  listFormats.clear();
870  std::vector<am_CustomConnectionFormat_t>::const_iterator rowSinkIterator = listSinkFormats.begin();
871  std::vector<bool>::const_iterator matrixIterator = convertionMatrix.begin();
872 
873  //find the row number of the sink
874  rowSinkIterator = find(listSinkFormats.begin(), listSinkFormats.end(), connectionFormat);
875  int rowNumberSink = rowSinkIterator - listSinkFormats.begin();
876 
877  //go through the convertionMatrix and find out if the conversion is possible, if yes, add connectionFormat ...
878  std::advance(matrixIterator, rowNumberSink);
879 
880  //iterate line-wise through the matrix and add more formats
881  do
882  {
883  if (*matrixIterator)
884  {
885  listFormats.push_back(listSourceFormats.at((matrixIterator - convertionMatrix.begin()) / listSinkFormats.size()));
886  }
887  std::advance(matrixIterator, listSinkFormats.size());
888  } while (convertionMatrix.end() - matrixIterator > 0);
889 
890  return listFormats.size();
891  }
892 
893  am_Error_e CAmRouter::getSourceSinkPossibleConnectionFormats(std::vector<CAmRoutingNode*>::iterator iteratorSource,
894  std::vector<CAmRoutingNode*>::iterator iteratorSink, std::vector<am_CustomConnectionFormat_t> & outConnectionFormats)
895  {
896  CAmRoutingNode * nodeSink = *iteratorSink;
897  if (nodeSink->getData().type != CAmNodeDataType::SINK)
898  return (E_UNKNOWN);
899 
900  CAmRoutingNode * nodeSource = *iteratorSource;
901  if (nodeSource->getData().type != CAmNodeDataType::SOURCE)
902  return (E_UNKNOWN);
903 
904  am_Source_s *source = nodeSource->getData().data.source;
905  am_Sink_s *sink = nodeSink->getData().data.sink;
906  listPossibleConnectionFormats(source->listConnectionFormats, sink->listConnectionFormats, outConnectionFormats);
907  return (E_OK);
908  }
909 
910  am_Error_e CAmRouter::getAllPaths(CAmRoutingNode & aSource, CAmRoutingNode & aSink, std::vector<am_Route_s> & resultPath,
911  std::vector<std::vector<CAmRoutingNode*>> & resultNodesPath, const bool includeCycles, const bool onlyFree)
912  {
913 
914  if (aSource.getData().type != CAmNodeDataType::SOURCE || aSink.getData().type != CAmNodeDataType::SINK)
915  return E_NOT_POSSIBLE;
916 
917  unsigned cycles;
918  if (includeCycles)
919  cycles = UINT_MAX;
920  else
921  cycles = 0;
922 
923  uint8_t errorsCount = 0, successCount = 0;
924  const am_sinkID_t sinkID = aSink.getData().data.sink->sinkID;
925  const am_sourceID_t sourceID = aSource.getData().data.source->sourceID;
926  std::vector<am_Route_s> paths;
927  std::vector<am_domainID_t> visitedDomains;
928  visitedDomains.push_back(((CAmRoutingNode*) &aSource)->getData().domainID());
929  mRoutingGraph.getAllPaths(aSource, aSink, [&visitedDomains, &cycles, &onlyFree, this](const CAmRoutingNode * node)->bool
930  {
931  if(CAmRouter::shouldGoInDomain(visitedDomains, node->getData().domainID(), cycles))
932  {
933  const am_RoutingNodeData_s & nodeData = node->getData();
934  if(am_RoutingNodeData_s::GATEWAY==nodeData.type)
935  {
936  const am_Gateway_s * gateway = nodeData.data.gateway;
937  return (!onlyFree || !isComponentConnected(*gateway));
938  }
939  else if(am_RoutingNodeData_s::CONVERTER==nodeData.type)
940  {
941  const am_Converter_s * converter = nodeData.data.converter;
942  return (!onlyFree || !isComponentConnected(*converter));
943  }
944  return true;
945  }
946  return false;
947  }, [&visitedDomains](const CAmRoutingNode * node)
948  {
949  visitedDomains.push_back(node->getData().domainID());
950  }, [&visitedDomains](const CAmRoutingNode * node)
951  { visitedDomains.erase(visitedDomains.end()-1);},
952  [&resultPath, &resultNodesPath, &paths, &errorsCount, &successCount, &sinkID, &sourceID](const std::vector<CAmRoutingNode*> & path)
953  {
954  int index = CAmRouter::insertPostion(path, resultNodesPath);
955  resultNodesPath.emplace(resultNodesPath.begin()+index);
956  paths.emplace(paths.begin()+index);
957  resultNodesPath[index] = path;
958  am_Route_s & nextRoute = paths[index];
959  nextRoute.sinkID = sinkID;
960  nextRoute.sourceID = sourceID;
961  am_RoutingElement_s * element;
962  for(auto it = path.begin(); it!=path.end(); it++)
963  {
964  am_RoutingNodeData_s & routingData = (*it)->getData();
965  if(routingData.type==CAmNodeDataType::SOURCE)
966  {
967  auto iter = nextRoute.route.emplace(nextRoute.route.end());
968  element = &(*iter);
969  element->domainID = routingData.data.source->domainID;
970  element->sourceID = routingData.data.source->sourceID;
971  element->connectionFormat = CF_UNKNOWN;
972  }
973  else if(routingData.type==CAmNodeDataType::SINK)
974  {
975  element->domainID = routingData.data.sink->domainID;
976  element->sinkID = routingData.data.sink->sinkID;
977  element->connectionFormat = CF_UNKNOWN;
978  }
979  }
980  });
981 
982  for (auto it = paths.begin(); successCount < mMaxPathCount && it != paths.end(); it++)
983  {
984  if (cfPermutationsForPath(*it, resultNodesPath[it - paths.begin()], resultPath) == E_UNKNOWN)
985  errorsCount++;
986  else
987  successCount++;
988  }
989 
990  if (successCount)
991  return E_OK;
992  if (errorsCount)
993  return E_NOT_POSSIBLE;
994  return E_OK;
995  }
996 
997 }
CAmRoutingNode * converterNodeWithSinkID(const am_sinkID_t sinkID, const am_domainID_t domainID)
Returns a converter node for given sinkID.
Definition: CAmRouter.cpp:284
am_sourceID_t sourceID
The sourceID of the converter sink-end.
std::function< void(const am_sourceID_t, const bool)> dboRemovedSource
CAmRoutingNode * sourceNodeWithID(const am_sourceID_t sourceID)
Returns a source node with given sourceID.
Definition: CAmRouter.cpp:259
std::function< void(const am_Sink_s &)> dboNewSink
virtual am_Error_e enumerateSources(std::function< void(const am_Source_s &element)> cb) const =0
am_sourceID_t sourceID
the source ID
am_domainID_t domainID() const
Definition: CAmRouter.h:132
A Common-API wrapper class, which loads the common-api runtime and instantiates all necessary objects...
the desired object is non existent
am_Error_e
the errors of the audiomanager.
am_domainID_t domainSourceID
The ID of the source.
void getShortestPath(const CAmNode< T > &source, const CAmListNodePtrs &listTargets, std::vector< CAmListNodePtrs > &resultPath)
Finds the shortest path from given node to all nodes in listTargets.
Definition: CAmGraph.h:554
void connectNodes(const CAmNode< T > &first, const CAmNode< T > &last, const V &vertexData, const int16_t weight=1)
Connect first with last node and set user data and weight to the vertex.
Definition: CAmGraph.h:481
std::function< void(const am_sinkID_t, const bool)> dboRemovedSink
This struct describes the attribiutes of a sink.
NodeData & getData()
Setters and getters.
Definition: CAmGraph.h:91
std::function< void(const am_converterID_t)> dboRemoveConverter
am_CustomConnectionFormat_t connectionFormat
the connectionformat that is used for the route
am_sinkID_t sinkID
This is the ID of the sink, it is unique in the system.
CAmNode< T > & addNode(const T &in)
Adds a new node to the graph with given user data.
Definition: CAmGraph.h:410
am_domainID_t controlDomainID
This is the ID of the domain that registers the gateway.
am_NodeDataType_e type
data type:sink, source, gateway or converter
Definition: CAmRouter.h:82
uint16_t am_CustomConnectionFormat_t
This type classifies the format in which data is exchanged within a connection.
am_sourceID_t sourceID
the sourceID where the route starts
am_sinkID_t sinkID
The sinkID of the convertersink-end.
union am::am_RoutingNodeData_s::@0 data
union pointer to sink, source, gateway or converter
static bool getRestrictedOutputFormats(const std::vector< bool > &convertionMatrix, const std::vector< am_CustomConnectionFormat_t > &listSourceFormats, const std::vector< am_CustomConnectionFormat_t > &listSinkFormats, const am_CustomConnectionFormat_t connectionFormat, std::vector< am_CustomConnectionFormat_t > &listFormats)
Definition: CAmRouter.cpp:865
am_Error_e getFirstNShortestPaths(const bool onlyfree, const unsigned cycles, const unsigned maxPathCount, CAmRoutingNode &source, CAmRoutingNode &sink, std::vector< am_Route_s > &resultPath)
Find first mMaxPathCount paths between given source and sink.
Definition: CAmRouter.cpp:715
A_CONST am_CustomConnectionFormat_t CF_UNKNOWN
SPDX license identifier: MPL-2.0.
virtual am_Error_e enumerateConverters(std::function< void(const am_Converter_s &element)> cb) const =0
std::function< void(const am_Source_s &)> dboNewSource
GRAPH_PATH_END am_GraphPathPosition_e
Definition: CAmGraph.h:58
am_sinkID_t sinkID
the sinkID
am_Error_e getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector< am_CustomConnectionFormat_t > listPossibleConnectionFormats, std::vector< am_CustomConnectionFormat_t > &listPrioConnectionFormats)
am_sinkID_t sinkID
The sinkID of the gateway sink-end.
am_Error_e getRouteFromLoadedNodes(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector< am_Route_s > &returnList)
Find first mMaxPathCount paths between given source and sink after the nodes have been loaded...
Definition: CAmRouter.cpp:126
SPDX license identifier: MPL-2.0.
std::vector< am_CustomConnectionFormat_t > listSinkFormats
This is the list of available formats on the sink side of the gateway.
am_Source_s * source
Definition: CAmRouter.h:85
#define MAX_ROUTING_PATHS
Optimal path search is implemented with graph which contains nodes - sinks, sources, gateways, converters.
Definition: CAmRouter.h:56
uint16_t am_converterID_t
a converter ID
std::vector< am_CustomConnectionFormat_t > listSourceFormats
This is the list of available formats on the source side of the converter.
CAmRoutingNode * sinkNodeWithID(const am_sinkID_t sinkID)
Returns a sink node with given sinkID.
Definition: CAmRouter.cpp:234
static void listPossibleConnectionFormats(std::vector< am_CustomConnectionFormat_t > &inListSourceFormats, std::vector< am_CustomConnectionFormat_t > &inListSinkFormats, std::vector< am_CustomConnectionFormat_t > &outListFormats)
Definition: CAmRouter.cpp:856
This represents one "hopp" in a route.
SPDX license identifier: MPL-2.0.
am_domainID_t domainID
The domainID is the domain the source belongs to.
am_Gateway_s * gateway
Definition: CAmRouter.h:87
uint16_t am_sourceID_t
a source ID
CAmRouter(IAmDatabaseHandler *iDatabaseHandler, CAmControlSender *iSender)
Definition: CAmRouter.cpp:49
#define MAX_ALLOWED_DOMAIN_CYCLES
How many times the routing algorithm should look back into domains.
Definition: CAmRouter.h:68
std::vector< am_CustomConnectionFormat_t > listSinkFormats
This is the list of available formats on the sink side of the gateway.
am_Error_e getAllPaths(CAmRoutingNode &aSource, CAmRoutingNode &aSink, std::vector< am_Route_s > &resultPath, std::vector< std::vector< CAmRoutingNode * >> &resultNodesPath, const bool includeCycles=false, const bool onlyFree=false) __attribute__((deprecated("You should use am_Error_e getFirstNShortestPaths( const bool onlyFree
DEPRECATED!
Definition: CAmRouter.cpp:910
sends data to the commandInterface, takes the file of the library that needs to be loaded ...
static bool getAllowedFormatsFromConvMatrix(const std::vector< bool > &convertionMatrix, const std::vector< am_CustomConnectionFormat_t > &listSourceFormats, const std::vector< am_CustomConnectionFormat_t > &listSinkFormats, std::vector< am_CustomConnectionFormat_t > &sourceFormats, std::vector< am_CustomConnectionFormat_t > &sinkFormats)
Definition: CAmRouter.cpp:828
void trace(std::function< void(const CAmNode< T > &, const std::vector< CAmVertex< T, V > * > &)> cb)
Goes through all nodes and vertices and calls the callback.
Definition: CAmGraph.h:535
void getMergeConnectionFormats(const X *element, const am_CustomConnectionFormat_t connectionFormat, const std::vector< am_CustomConnectionFormat_t > &listConnectionFormats, std::vector< am_CustomConnectionFormat_t > &outListMergeConnectionFormats)
Definition: CAmRouter.cpp:37
This class handles and abstracts the database.
This struct describes the attributes of a converter.
am_domainID_t domainSinkID
The ID of the sink.
std::vector< am_RoutingElement_s > route
the actual route as list of routing elements
a list of routing elements that lead from source to sink
std::vector< bool > convertionMatrix
This is matrix holding information about the conversion capability of the gateway, it&#39;s length is defined by the length(listSinkFormats) x length(listSourceFormats).
virtual am_Error_e enumerateSinks(std::function< void(const am_Sink_s &element)> cb) const =0
am_sourceID_t sourceID
This is the ID of the source, it is unique in the system.
am_Error_e getShortestPath(CAmRoutingNode &source, CAmRoutingNode &sink, std::vector< am_Route_s > &resultPath)
Find the shortest path between given source and sink.
Definition: CAmRouter.cpp:657
the desired action is not possible
am_Converter_s * converter
Definition: CAmRouter.h:88
std::list< CAmRoutingVertex > CAmRoutingListVertices
Definition: CAmRouter.h:151
virtual am_Error_e enumerateGateways(std::function< void(const am_Gateway_s &element)> cb) const =0
std::vector< bool > convertionMatrix
This is matrix holding information about the conversion capability of the converter, it&#39;s length is defined by the length(listSinkFormats) x length(listSourceFormats).
am_sourceID_t sourceID
The sourceID of the gateway sink-end.
am_domainID_t domainID
This is the ID of the domain that registers the converter.
void clear()
Clears all nodes and vertices.
Definition: CAmGraph.h:523
This struct describes the attributes of a gateway.
static bool shouldGoInDomain(const std::vector< am_domainID_t > &visitedDomains, const am_domainID_t nodeDomainID, const unsigned maxCyclesNumber)
Definition: CAmRouter.cpp:797
std::vector< am_CustomConnectionFormat_t > listSourceFormats
This is the list of available formats on the source side of the gateway.
am_sinkID_t sinkID
the sinkID where the route ends
CAmRoutingNode * gatewayNodeWithSinkID(const am_sinkID_t sinkID)
Returns a gateway node for given sinkID.
Definition: CAmRouter.cpp:297
uint16_t getIndex() const
Definition: CAmGraph.h:93
std::function< void(const am_Gateway_s &)> dboNewGateway
uint16_t am_domainID_t
a domain ID
no error - positive reply
SPDX license identifier: MPL-2.0.
std::vector< am_CustomConnectionFormat_t > listConnectionFormats
This list holds information about the formats that the Source is capable of supporting when deliverin...
void getAllPaths(CAmNode< T > &src, CAmNode< T > &dst, std::function< bool(const CAmNode< T > *)> cbShouldVisitNode, std::function< void(const CAmNode< T > *)> cbWillVisitNode, std::function< void(const CAmNode< T > *)> cbDidVisitNode, std::function< void(const CAmNodeReferenceList &path)> cbDidFindPath)
Finds all possible paths between two given nodes.
Definition: CAmGraph.h:656
uint16_t am_gatewayID_t
a gateway ID
This struct describes the attribiutes of a source.
uint16_t am_sinkID_t
a sink ID
This class handles and abstracts the database.
am_domainID_t domainID
The domainID is the domain the sink belongs to.
am_domainID_t domainID
the domainID the routeElement is in
am_Error_e getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector< am_Route_s > &returnList)
Find first mMaxPathCount paths between given source and sink.
Definition: CAmRouter.cpp:111
std::function< void(const am_gatewayID_t)> dboRemoveGateway
std::vector< am_CustomConnectionFormat_t > listConnectionFormats
This list holds information about the formats that the Source is capable of supporting when deliverin...
A structure used as user data in the graph nodes.
Definition: CAmRouter.h:76
std::function< void(const am_Converter_s &)> dboNewConverter
static am_Error_e getSourceSinkPossibleConnectionFormats(std::vector< CAmRoutingNode * >::iterator iteratorSource, std::vector< CAmRoutingNode * >::iterator iteratorSink, std::vector< am_CustomConnectionFormat_t > &outConnectionFormats)
Definition: CAmRouter.cpp:893