From e6b739cc7e901ca8637bf3f5a72f5956cd764249 Mon Sep 17 00:00:00 2001 From: christian mueller Date: Mon, 6 Feb 2012 17:53:36 +0100 Subject: * added function to routing algorithm that takes care of the route in case source and sink are in the same domain... --- AudioManagerDaemon/src/Router.cpp | 38 +++++++++++++++++++++++++++++++++++--- includes/config.h | 2 +- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/AudioManagerDaemon/src/Router.cpp b/AudioManagerDaemon/src/Router.cpp index 4fedf65..8bc2924 100644 --- a/AudioManagerDaemon/src/Router.cpp +++ b/AudioManagerDaemon/src/Router.cpp @@ -42,6 +42,7 @@ Router::Router(DatabaseHandler* iDatabaseHandler, ControlSender* iSender) : am_Error_e Router::getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector & returnList) { + returnList.clear(); //first find out in which domains the source and sink are am_domainID_t sourceDomainID; am_domainID_t sinkDomainID; @@ -50,6 +51,37 @@ am_Error_e Router::getRoute(const bool onlyfree, const am_sourceID_t sourceID, c if (mDatabaseHandler->getDomainOfSink(sinkID, sinkDomainID) != E_OK) return (E_NON_EXISTENT); + if (sourceDomainID == sinkDomainID) //shortcut if the domains are the same... + { + //first get the list of possible connection formats + std::vector listFormats, listPriorityConnectionFormats; + listPossibleConnectionFormats(sourceID, sinkID, listFormats); + + //get the prio of the Controller: + mControlSender->getConnectionFormatChoice(sourceID, sinkID, listFormats, listPriorityConnectionFormats); + + //no possible connection, so no route ! + if (listPriorityConnectionFormats.empty()) + return E_NOT_POSSIBLE; + + //return the first item as route: + am_RoutingElement_s routingElement; + routingElement.sourceID = sourceID; + routingElement.sinkID = sinkID; + routingElement.connectionFormat = listPriorityConnectionFormats[0]; + routingElement.domainID = sourceDomainID; + + //Now get a route: + am_Route_s actualRoute; + actualRoute.route.push_back(routingElement); + actualRoute.sourceID = sourceID; + actualRoute.sinkID = sinkID; + + //push it to the return list - we are done here ... + returnList.push_back(actualRoute); + return E_OK; + + } RoutingTree routingtree(sourceDomainID); //Build up a Tree from the Source_Domain to every other domain. std::vector flattree; //This list is the flat tree std::vector matchtree; @@ -132,8 +164,8 @@ void Router::listPossibleConnectionFormats(const am_sourceID_t sourceID, const a std::vector listSinkFormats; mDatabaseHandler->getListSinkConnectionFormats(sinkID, listSinkFormats); mDatabaseHandler->getListSourceConnectionFormats(sourceID, listSourceFormats); - std::sort(listSinkFormats.begin(),listSinkFormats.end()); //todo: this might be not needed if we use strictly sorted input - std::sort(listSourceFormats.begin(),listSourceFormats.end()); //todo: this might be not needed if we use strictly sorted input + std::sort(listSinkFormats.begin(), listSinkFormats.end()); //todo: this might be not needed if we use strictly sorted input + std::sort(listSourceFormats.begin(), listSourceFormats.end()); //todo: this might be not needed if we use strictly sorted input std::insert_iterator > inserter(listFormats, listFormats.begin()); set_intersection(listSourceFormats.begin(), listSourceFormats.end(), listSinkFormats.begin(), listSinkFormats.end(), inserter); } @@ -157,7 +189,7 @@ am_Error_e Router::findBestWay(std::vector & listRoute, std std::vector::iterator tempIterator(routeIterator); tempIterator--; listRestrictedOutputFormatsGateways(*gatewayIterator, (tempIterator)->connectionFormat, listRestrictedConnectionFormats); - std::sort(listRestrictedConnectionFormats.begin(),listRestrictedConnectionFormats.end()); //todo: this might be not needed if we use strictly sorted input + std::sort(listRestrictedConnectionFormats.begin(), listRestrictedConnectionFormats.end()); //todo: this might be not needed if we use strictly sorted input set_intersection(listConnectionFormats.begin(), listConnectionFormats.end(), listRestrictedConnectionFormats.begin(), listRestrictedConnectionFormats.end(), inserter); gatewayIterator++; } diff --git a/includes/config.h b/includes/config.h index 2b4b736..3e1542a 100644 --- a/includes/config.h +++ b/includes/config.h @@ -1,7 +1,7 @@ #ifndef _CONFIG_H #define _CONFIG_H -#define DAEMONVERSION "ver-0.0.1-23-g74cf9b9" +#define DAEMONVERSION "ver-0.0.1-24-gba9e8ff" #define WITH_DBUS_WRAPPER #define WITH_SOCKETHANDLER_LOOP -- cgit v1.2.1