summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksandar Donchev <Aleksander.Donchev@partner.bmw.de>2017-02-13 18:20:26 +0100
committerChristian Linke <christian.linke@bmw.de>2017-02-20 08:49:44 -0800
commitff7a091bd6500413853f381d14be55de2e3affa3 (patch)
tree9f08492872ce7de767f66535178bd0575b72a5b7
parent9ad6f67f6c39ec4ff49c382d5beaf9006f664fcb (diff)
downloadaudiomanager-ff7a091bd6500413853f381d14be55de2e3affa3.tar.gz
* if needed the routing graph will be re-created from getRoute after aRouter_adaptions
database change has been observed. Signed-off-by: Christian Linke <christian.linke@bmw.de>
-rw-r--r--AudioManagerCore/include/CAmGraph.h32
-rw-r--r--AudioManagerCore/include/CAmRouter.h631
-rw-r--r--AudioManagerCore/src/CAmRouter.cpp1772
-rw-r--r--AudioManagerCore/test/AmRouterMapTest/CAmRouterMapTest.cpp3078
-rw-r--r--AudioManagerCore/test/AmRouterMapTest/CAmRouterMapTest.h93
5 files changed, 2846 insertions, 2760 deletions
diff --git a/AudioManagerCore/include/CAmGraph.h b/AudioManagerCore/include/CAmGraph.h
index a27d512..45043f7 100644
--- a/AudioManagerCore/include/CAmGraph.h
+++ b/AudioManagerCore/include/CAmGraph.h
@@ -409,12 +409,12 @@ namespace am
*/
CAmNode<T> & addNode(const T & in)
{
- size_t index = mStoreNodes.size();
- mStoreNodes.emplace_back(in, index);
- mStoreAdjList.emplace_back();
- mPointersNodes.push_back(&mStoreNodes.back());
- mPointersAdjList.push_back(&mStoreAdjList.back());
- return mStoreNodes.back();
+ size_t index = mStoreNodes.size();
+ mStoreNodes.emplace_back(in, index);
+ mStoreAdjList.emplace_back();
+ mPointersNodes.push_back(&mStoreNodes.back());
+ mPointersAdjList.push_back(&mStoreAdjList.back());
+ return mStoreNodes.back();
}
/**
@@ -463,16 +463,16 @@ namespace am
*/
void removeNode(const CAmNode<T> & node)
{
- uint16_t index = node.getIndex();
- removeAllVerticesToNode(node);
- mPointersAdjList.erase(mPointersAdjList.begin()+index);
- mPointersNodes.erase(mPointersNodes.begin()+index);
- auto iter = std::find_if(mStoreNodes.begin(), mStoreNodes.end(), [&node](const CAmNode<T> & otherNode){
- return &otherNode==&node;
- });
- if(iter!=mStoreNodes.end())
- mStoreNodes.erase(iter);
- updateIndexes(index);
+ uint16_t index = node.getIndex();
+ removeAllVerticesToNode(node);
+ mPointersAdjList.erase(mPointersAdjList.begin()+index);
+ mPointersNodes.erase(mPointersNodes.begin()+index);
+ auto iter = std::find_if(mStoreNodes.begin(), mStoreNodes.end(), [&node](const CAmNode<T> & otherNode){
+ return &otherNode==&node;
+ });
+ if(iter!=mStoreNodes.end())
+ mStoreNodes.erase(iter);
+ updateIndexes(index);
}
/**
diff --git a/AudioManagerCore/include/CAmRouter.h b/AudioManagerCore/include/CAmRouter.h
index 7543abc..88f73ea 100644
--- a/AudioManagerCore/include/CAmRouter.h
+++ b/AudioManagerCore/include/CAmRouter.h
@@ -33,334 +33,347 @@
#include "CAmGraph.h"
#include "CAmDatabaseHandlerMap.h"
-
namespace am
{
-/**
- * Optimal path search is implemented with graph which contains nodes - sinks, sources, gateways, converters.
- * The nodes are identified by sinkID, sourceID, gatewayID, converterID.
- * A possible connection between two nodes represents the facts that the nodes can be connected with one or more connectionFormats (Node[id=1] ---> Node[id=2]).
- * It is assumption that the two nodes can be connected. The controller itself decides later whether the connection is possible or not.
- *
- */
-
-/**
- * Trace on/off.
- */
+ /**
+ * Optimal path search is implemented with graph which contains nodes - sinks, sources, gateways, converters.
+ * The nodes are identified by sinkID, sourceID, gatewayID, converterID.
+ * A possible connection between two nodes represents the facts that the nodes can be connected with one or more connectionFormats (Node[id=1] ---> Node[id=2]).
+ * It is assumption that the two nodes can be connected. The controller itself decides later whether the connection is possible or not.
+ *
+ */
+
+ /**
+ * Trace on/off.
+ */
#undef TRACE_GRAPH
-/**
- * Max paths count returned to the controller
- */
+ /**
+ * Max paths count returned to the controller
+ */
#ifndef MAX_ROUTING_PATHS
#define MAX_ROUTING_PATHS 5
#endif
-/**
- * How many times the routing algorithm should look back into domains.
- *
- * 0 - no cycles are allowed
- * 1 - default is one cycle
- * ...
- * UINT_MAX - set this define to UINT_MAX in order to allow cycles.
- *
- */
+ /**
+ * How many times the routing algorithm should look back into domains.
+ *
+ * 0 - no cycles are allowed
+ * 1 - default is one cycle
+ * ...
+ * UINT_MAX - set this define to UINT_MAX in order to allow cycles.
+ *
+ */
#ifndef MAX_ALLOWED_DOMAIN_CYCLES
#define MAX_ALLOWED_DOMAIN_CYCLES 1
#endif
-class CAmRouter;
-
-/**
- * A structure used as user data in the graph nodes.
- */
-struct am_RoutingNodeData_s
-{
- typedef enum:uint8_t {SINK, SOURCE, GATEWAY, CONVERTER} am_NodeDataType_e;
- am_NodeDataType_e type; //!< data type:sink, source, gateway or converter
- union
- {
- am_Source_s *source;
- am_Sink_s *sink;
- am_Gateway_s *gateway;
- am_Converter_s *converter;
- } data; //!< union pointer to sink, source, gateway or converter
-
- am_RoutingNodeData_s():type(SINK)
- {}
-
- bool operator==(const am_RoutingNodeData_s & anotherObject) const
- {
- bool result = false;
- if(type==anotherObject.type)
- {
- result = true;
- if(type==SINK)
- result &= (data.sink->sinkID==anotherObject.data.sink->sinkID);
- else if(type==SOURCE)
- result &= (data.source->sourceID==anotherObject.data.source->sourceID);
- else if(type==GATEWAY)
- result &= (data.gateway->gatewayID==anotherObject.data.gateway->gatewayID);
- else if(type==CONVERTER)
- result &= (data.converter->converterID==anotherObject.data.converter->converterID);
- }
- return result;
- };
+ class CAmRouter;
+
+ /**
+ * A structure used as user data in the graph nodes.
+ */
+ struct am_RoutingNodeData_s
+ {
+ typedef enum
+ :int
+ { SINK, SOURCE, GATEWAY, CONVERTER
+ } am_NodeDataType_e;
+ am_NodeDataType_e type; //!< data type:sink, source, gateway or converter
+ union
+ {
+ am_Source_s *source;
+ am_Sink_s *sink;
+ am_Gateway_s *gateway;
+ am_Converter_s *converter;
+ } data; //!< union pointer to sink, source, gateway or converter
+
+ am_RoutingNodeData_s() :
+ type(SINK)
+ {
+ }
+
+ bool operator==(const am_RoutingNodeData_s & anotherObject) const
+ {
+ bool result = false;
+ if (type == anotherObject.type)
+ {
+ result = true;
+ if (type == SINK)
+ result &= (data.sink->sinkID == anotherObject.data.sink->sinkID);
+ else if (type == SOURCE)
+ result &= (data.source->sourceID == anotherObject.data.source->sourceID);
+ else if (type == GATEWAY)
+ result &= (data.gateway->gatewayID == anotherObject.data.gateway->gatewayID);
+ else if (type == CONVERTER)
+ result &= (data.converter->converterID == anotherObject.data.converter->converterID);
+ }
+ return result;
+ }
+ ;
#ifdef TRACE_GRAPH
#define COUT_NODE(HEAD, NAME, ID) \
std::cout << HEAD << "(" << std::setfill('0') << std::setw(4) << ID << " " << NAME << ")";
- void trace() const
- {
- if(type==SINK)
- COUT_NODE("SI", data.sink->name, data.sink->sinkID )
- else if(type==SOURCE)
- COUT_NODE("SO", data.source->name, data.source->sourceID )
- else if(type==GATEWAY)
- COUT_NODE("GA", data.gateway->name, data.gateway->gatewayID )
- else if(type==CONVERTER)
- COUT_NODE("CO", data.converter->name, data.converter->converterID )
- };
+ void trace() const
+ {
+ if(type==SINK)
+ COUT_NODE("SI", data.sink->name, data.sink->sinkID )
+ else if(type==SOURCE)
+ COUT_NODE("SO", data.source->name, data.source->sourceID )
+ else if(type==GATEWAY)
+ COUT_NODE("GA", data.gateway->name, data.gateway->gatewayID )
+ else if(type==CONVERTER)
+ COUT_NODE("CO", data.converter->name, data.converter->converterID )
+ };
#endif
- am_domainID_t domainID() const
- {
- if(type==SINK)
- return data.sink->domainID;
- else if(type==SOURCE)
- return data.source->domainID;
- else if(type==GATEWAY)
- return data.gateway->controlDomainID;
- else if(type==CONVERTER)
- return data.converter->domainID;
- return 0;
- };
-};
-
-typedef am_RoutingNodeData_s::am_NodeDataType_e CAmNodeDataType;
-typedef CAmNode<am_RoutingNodeData_s> CAmRoutingNode;
-typedef CAmGraph<am_RoutingNodeData_s, uint16_t> CAmRoutingGraph;
-typedef CAmVertex<am_RoutingNodeData_s, uint16_t> CAmRoutingVertex;
-typedef std::list<CAmRoutingVertex> CAmRoutingListVertices;
-typedef std::vector<CAmRoutingListVertices*> CAmRoutingVertexReferenceList;
-
-class CAmControlSender;
-
-
-/**
- * Implements an autorouting algorithm for connecting sinks and sources via different audio domains.
- */
-class CAmRouter: public CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks
-{
- IAmDatabaseHandler* mpDatabaseHandler; //!< pointer to database handler
- CAmControlSender* mpControlSender; //!< pointer the controlsender - is used to retrieve information for the optimal route
- bool mOnlyFreeConversionNodes; //!< bool flag whether only disconnected elements should be considered or not
- unsigned mMaxAllowedCycles; //!< max allowed cycles, default is 1
- unsigned mMaxPathCount; //!< max paths count returned to the controller, default is 5
- CAmRoutingGraph mRoutingGraph; //!< graph object
- std::map<am_domainID_t,std::vector<CAmRoutingNode*>> mNodeListSources; //!< map with pointers to nodes with sources, used for quick access
- std::map<am_domainID_t,std::vector<CAmRoutingNode*>> mNodeListSinks; //!< map with pointers to nodes with sinks, used for quick access
- std::map<am_domainID_t,std::vector<CAmRoutingNode*>> mNodeListGateways; //!< map with pointers to nodes with gateways, used for quick access
- std::map<am_domainID_t,std::vector<CAmRoutingNode*>> mNodeListConverters;//!< map with pointers to nodes with converters, used for quick access
-
- /**
- * Check whether given converter or gateway has been connected.
- *
- * @param comp converter or gateway .
- */
- template <class Component> bool isComponentConnected(const Component & comp)
- {
- return mpDatabaseHandler->isComponentConnected(comp);
- }
-
- /**
- * Connect all converters to its sink and sources if possible.
- *
- */
- void constructConverterConnections();
-
- /**
- * Connect all gateways to its sink and sources if possible.
- *
- */
- void constructGatewayConnections();
-
- /**
- * Connect all sources to the sinks if possible.
- *
- */
- void constructSourceSinkConnections();
-
- /**
- * Construct list with all vertices
- */
- void getVerticesForNode(const CAmRoutingNode & node, CAmRoutingListVertices & list);
-
- /**
- * Construct list with all vertices from given source.
- */
- void getVerticesForSource(const CAmRoutingNode & node, CAmRoutingListVertices & list);
-
- /**
- * Construct list with all vertices from given sink.
- */
- void getVerticesForSink(const CAmRoutingNode & node, CAmRoutingListVertices & list);
-
- /**
- * Construct list with all vertices from given converter.
- */
- void getVerticesForConverter(const CAmRoutingNode & node, CAmRoutingListVertices & list);
-
- /**
- * Construct list with all vertices from given gateway.
- */
- void getVerticesForGateway(const CAmRoutingNode & node, CAmRoutingListVertices & list);
-
- /**
- * Connection format permutations.
- *
- * @return E_OK on success(1 or more paths), E_NOT_POSSIBLE if the CF couldn't be matached or E_UNKNOWN in any other error case.
- */
- am_Error_e determineConnectionFormatsForPath(am_Route_s & routeObjects, std::vector<CAmRoutingNode*> & nodes, std::vector<am_Route_s> & result);
- am_Error_e doConnectionFormatsForPath(am_Route_s & routeObjects,
- std::vector<CAmRoutingNode*> & route,
- std::vector<am_RoutingElement_s>::iterator routingElementIterator,
- std::vector<CAmRoutingNode*>::iterator routeIterator,
- std::vector<am_Route_s> & result);
- am_Error_e cfPermutationsForPath(am_Route_s shortestRoute, std::vector<CAmRoutingNode*> resultNodesPath, std::vector<am_Route_s>& resultPath);
-
- /**
- * Helper method.
- */
- static int insertPostion(const std::vector<CAmRoutingNode*>& path, const std::vector<std::vector<CAmRoutingNode*> >& nodes) ;
-
-
-public:
- CAmRouter(IAmDatabaseHandler* iDatabaseHandler, CAmControlSender* iSender);
- ~CAmRouter();
-
- unsigned getMaxAllowedCycles() { return mMaxAllowedCycles; }
- void setMaxAllowedCycles(unsigned count) { mMaxAllowedCycles = count; }
-
- unsigned getMaxPathCount() { return mMaxPathCount; }
- void setMaxPathCount(unsigned count) { mMaxPathCount = count; }
-
- /**
- * Find first mMaxPathCount paths between given source and sink.
- *
- * @param onlyfree only disconnected elements should be included or not.
- * @param sourceID start point.
- * @param sinkID end point.
- * @param returnList list with all possible paths
- * @return E_OK on success(1 or more paths), E_NOT_POSSIBLE if the CF couldn't be matached or E_UNKNOWN in any other error case.
- */
- am_Error_e getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s>& returnList);
- am_Error_e getRoute(const bool onlyfree, const am_Source_s & source, const am_Sink_s & sink, std::vector<am_Route_s> & listRoutes);
-
- /**
- * Find first mMaxPathCount paths between given source and sink after the nodes have been loaded.
- *
- * @param sourceID start point.
- * @param sinkID end point.
- * @param returnList list with all possible paths
- * @return E_OK on success(1 or more paths), E_NOT_POSSIBLE if the CF couldn't be matached or E_UNKNOWN in any other error case.
- */
- am_Error_e getRouteFromLoadedNodes(const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s> & returnList);
- am_Error_e getRouteFromLoadedNodes(const am_Source_s & aSource, const am_Sink_s & aSink, std::vector<am_Route_s> & listRoutes);
-
- /**
- * Find first mMaxPathCount paths between given source and sink. This method should be called only after 'load' has been called.
- *
- * @param source start point.
- * @param sink end point.
- * @param returnList list with all possible paths.
- * @return E_OK on success(1 or more paths), E_NOT_POSSIBLE if the CF couldn't be matached or E_UNKNOWN in any other error case.
- */
- am_Error_e getFirstNShortestPaths(CAmRoutingNode & source, CAmRoutingNode & sink, std::vector<am_Route_s> & resultPath);
-
- /**
- * Find the shortest path between given source and sink. This method should be called only after 'load' has been called.
- * This method do not pay attention on the parameter mMaxAllowedCycles and goes through all possible paths.
- *
- * @param source start point.
- * @param sink end point.
- * @param returnList list with the connection format permutations of the shortest path.
- * @return E_OK on success(1 or more paths), E_NOT_POSSIBLE if the CF couldn't be matached or E_UNKNOWN in any other error case.
- */
- am_Error_e getShortestPath(CAmRoutingNode & source, CAmRoutingNode & sink, std::vector<am_Route_s> & resultPath);
-
- 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);
- static void listPossibleConnectionFormats(std::vector<am_CustomConnectionFormat_t> & inListSourceFormats,
- std::vector<am_CustomConnectionFormat_t> & inListSinkFormats,
- std::vector<am_CustomConnectionFormat_t> & outListFormats);
- 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);
- static am_Error_e getSourceSinkPossibleConnectionFormats(std::vector<CAmRoutingNode*>::iterator iteratorSource,
- std::vector<CAmRoutingNode*>::iterator iteratorSink,
- std::vector<am_CustomConnectionFormat_t> & outConnectionFormats);
-
- static bool shouldGoInDomain(const std::vector<am_domainID_t> & visitedDomains, const am_domainID_t nodeDomainID, const unsigned maxCyclesNumber);
- bool shouldGoInDomain(const std::vector<am_domainID_t> & visitedDomains, const am_domainID_t nodeDomainID);
- /**
- * Returns a sink node with given sinkID.
- *
- * @param sinkID sink id.
- * @return pointer to node or NULL.
- */
- CAmRoutingNode* sinkNodeWithID(const am_sinkID_t sinkID);
- CAmRoutingNode* sinkNodeWithID(const am_sinkID_t sinkID, const am_domainID_t domainID);
-
- /**
- * Returns a source node with given sourceID.
- *
- * @param sourceID source id.
- * @return pointer to node or NULL.
- */
- CAmRoutingNode* sourceNodeWithID(const am_sourceID_t sourceID);
- CAmRoutingNode* sourceNodeWithID(const am_sourceID_t sourceID, const am_domainID_t domainID);
-
- /**
- * Returns a converter node for given sinkID.
- *
- * @param sinkID sink id.
- * @param domainID domain id.
- * @return pointer to node or NULL.
- */
- CAmRoutingNode* converterNodeWithSinkID(const am_sinkID_t sinkID, const am_domainID_t domainID);
-
- /**
- * Returns a gateway node for given sinkID.
- *
- * @param sinkID sink id.
- * @return pointer to node or NULL.
- */
- CAmRoutingNode* gatewayNodeWithSinkID(const am_sinkID_t sinkID);
-
- void load(const bool onlyFree);
- void clear();
-
- /**
- * DEPRECATED!
- */
-public:
- am_Error_e getAllPaths(CAmRoutingNode & aSource,
- CAmRoutingNode & aSink,
- std::vector<am_Route_s> & resultPath,
- std::vector<std::vector<CAmRoutingNode*>> & resultNodesPath,
- const bool includeCycles = false)
- __attribute__((deprecated("You should use am_Error_e getFirstNShortestPaths(CAmRoutingNode &, CAmRoutingNode &, std::vector<am_Route_s> &) instead!")));
-
- void getShortestPath(CAmRoutingNode & aSource, CAmRoutingNode & aSink, am_Route_s & resultPath, std::vector<CAmRoutingNode*> & resultNodesPath)
- __attribute__((deprecated("You should use am_Error_e getShortestPath(CAmRoutingNode &, CAmRoutingNode &, std::vector<am_Route_s> &) instead!")));
-};
+ am_domainID_t domainID() const
+ {
+ if (type == SINK)
+ return data.sink->domainID;
+ else if (type == SOURCE)
+ return data.source->domainID;
+ else if (type == GATEWAY)
+ return data.gateway->controlDomainID;
+ else if (type == CONVERTER)
+ return data.converter->domainID;
+ return 0;
+ }
+ ;
+ };
+
+ typedef am_RoutingNodeData_s::am_NodeDataType_e CAmNodeDataType;
+ typedef CAmNode<am_RoutingNodeData_s> CAmRoutingNode;
+ typedef CAmGraph<am_RoutingNodeData_s, uint16_t> CAmRoutingGraph;
+ typedef CAmVertex<am_RoutingNodeData_s, uint16_t> CAmRoutingVertex;
+ typedef std::list<CAmRoutingVertex> CAmRoutingListVertices;
+ typedef std::vector<CAmRoutingListVertices*> CAmRoutingVertexReferenceList;
+
+ class CAmControlSender;
+
+ /**
+ * Implements autorouting algorithm for connecting sinks and sources via different audio domains.
+ */
+ class CAmRouter: public CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks
+ {
+ IAmDatabaseHandler* mpDatabaseHandler; //!< pointer to database handler
+ CAmControlSender* mpControlSender; //!< pointer the controlsender - is used to retrieve information for the optimal route
+ bool mUpdateGraphNodesAction; //!< Flag which marks whether the graph should be rebuild
+ unsigned mMaxAllowedCycles; //!< max allowed cycles, default is 1
+ unsigned mMaxPathCount; //!< max paths count returned to the controller, default is 5
+ CAmRoutingGraph mRoutingGraph; //!< graph object
+ std::map<am_domainID_t, std::vector<CAmRoutingNode*>> mNodeListSources; //!< map with pointers to nodes with sources, used for quick access
+ std::map<am_domainID_t, std::vector<CAmRoutingNode*>> mNodeListSinks; //!< map with pointers to nodes with sinks, used for quick access
+ std::map<am_domainID_t, std::vector<CAmRoutingNode*>> mNodeListGateways; //!< map with pointers to nodes with gateways, used for quick access
+ std::map<am_domainID_t, std::vector<CAmRoutingNode*>> mNodeListConverters; //!< map with pointers to nodes with converters, used for quick access
+
+ /**
+ * Check whether given converter or gateway has been connected.
+ *
+ * @param comp converter or gateway .
+ */
+ template<class Component> bool isComponentConnected(const Component & comp)
+ {
+ return mpDatabaseHandler->isComponentConnected(comp);
+ }
+
+ /**
+ * Connect all converters to its sink and sources if possible.
+ *
+ */
+ void constructConverterConnections();
+
+ /**
+ * Connect all gateways to its sink and sources if possible.
+ *
+ */
+ void constructGatewayConnections();
+
+ /**
+ * Connect all sources to the sinks if possible.
+ *
+ */
+ void constructSourceSinkConnections();
+
+ /**
+ * Construct list with all vertices
+ */
+ void getVerticesForNode(const CAmRoutingNode & node, CAmRoutingListVertices & list);
+
+ /**
+ * Construct list with all vertices from given source.
+ */
+ void getVerticesForSource(const CAmRoutingNode & node, CAmRoutingListVertices & list);
+
+ /**
+ * Construct list with all vertices from given sink.
+ */
+ void getVerticesForSink(const CAmRoutingNode & node, CAmRoutingListVertices & list);
+
+ /**
+ * Construct list with all vertices from given converter.
+ */
+ void getVerticesForConverter(const CAmRoutingNode & node, CAmRoutingListVertices & list);
+
+ /**
+ * Construct list with all vertices from given gateway.
+ */
+ void getVerticesForGateway(const CAmRoutingNode & node, CAmRoutingListVertices & list);
+
+ /**
+ * Connection format permutations.
+ *
+ * @return E_OK on success(1 or more paths), E_NOT_POSSIBLE if the CF couldn't be matached or E_UNKNOWN in any other error case.
+ */
+ am_Error_e determineConnectionFormatsForPath(am_Route_s & routeObjects, std::vector<CAmRoutingNode*> & nodes, std::vector<am_Route_s> & result);
+ am_Error_e doConnectionFormatsForPath(am_Route_s & routeObjects, std::vector<CAmRoutingNode*> & route,
+ std::vector<am_RoutingElement_s>::iterator routingElementIterator, std::vector<CAmRoutingNode*>::iterator routeIterator,
+ std::vector<am_Route_s> & result);
+ am_Error_e cfPermutationsForPath(am_Route_s shortestRoute, std::vector<CAmRoutingNode*> resultNodesPath, std::vector<am_Route_s>& resultPath);
+
+ /**
+ * Helper method.
+ */
+ static int insertPostion(const std::vector<CAmRoutingNode*>& path, const std::vector<std::vector<CAmRoutingNode*> >& nodes);
+
+ public:
+ CAmRouter(IAmDatabaseHandler* iDatabaseHandler, CAmControlSender* iSender);
+ ~CAmRouter();
+
+ unsigned getMaxAllowedCycles()
+ {
+ return mMaxAllowedCycles;
+ }
+ void setMaxAllowedCycles(unsigned count)
+ {
+ mMaxAllowedCycles = count;
+ }
+
+ unsigned getMaxPathCount()
+ {
+ return mMaxPathCount;
+ }
+ void setMaxPathCount(unsigned count)
+ {
+ mMaxPathCount = count;
+ }
+
+ bool getUpdateGraphNodesAction()
+ {
+ return mUpdateGraphNodesAction;
+ }
+
+ /**
+ * Find first mMaxPathCount paths between given source and sink. This method will call the method load() if the parameter mUpdateGraphNodesAction is set which will rebuild the graph.
+ *
+ * @param onlyfree only disconnected elements should be included or not.
+ * @param sourceID start point.
+ * @param sinkID end point.
+ * @param returnList list with all possible paths
+ * @return E_OK on success(1 or more paths), E_NOT_POSSIBLE if the CF couldn't be matached or E_UNKNOWN in any other error case.
+ */
+ am_Error_e getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s>& returnList);
+ am_Error_e getRoute(const bool onlyfree, const am_Source_s & source, const am_Sink_s & sink, std::vector<am_Route_s> & listRoutes);
+
+ /**
+ * Find first mMaxPathCount paths between given source and sink after the nodes have been loaded. This method doesn't call load().
+ *
+ * @param onlyfree only disconnected elements should be included or not.
+ * @param sourceID start point.
+ * @param sinkID end point.
+ * @param returnList list with all possible paths
+ * @return E_OK on success(1 or more paths), E_NOT_POSSIBLE if the CF couldn't be matached or E_UNKNOWN in any other error case.
+ */
+ am_Error_e getRouteFromLoadedNodes(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s> & returnList);
+ am_Error_e getRouteFromLoadedNodes(const bool onlyfree, const am_Source_s & aSource, const am_Sink_s & aSink, std::vector<am_Route_s> & listRoutes);
+
+ /**
+ * Find first mMaxPathCount paths between given source and sink. This method doesn't call load().
+ *
+ * @param onlyfree only disconnected elements should be included or not.
+ * @param cycles allowed domain cycles.
+ * @param maxPathCount max count of returned paths.
+ * @param source start point.
+ * @param sink end point.
+ * @param returnList list with all possible paths.
+ * @return E_OK on success(1 or more paths), E_NOT_POSSIBLE if the CF couldn't be matached or E_UNKNOWN in any other error case.
+ */
+ am_Error_e getFirstNShortestPaths(const bool onlyfree, const unsigned cycles, const unsigned maxPathCount, CAmRoutingNode & source,
+ CAmRoutingNode & sink, std::vector<am_Route_s> & resultPath);
+
+ /**
+ * Find the shortest path between given source and sink. This method doesn't call load().
+ * It goes through all possible paths and returns the shortest of them.
+ *
+ * @param source start point.
+ * @param sink end point.
+ * @param returnList list with the connection format permutations of the shortest path.
+ * @return E_OK on success(1 or more paths), E_NOT_POSSIBLE if the CF couldn't be matached or E_UNKNOWN in any other error case.
+ */
+ am_Error_e getShortestPath(CAmRoutingNode & source, CAmRoutingNode & sink, std::vector<am_Route_s> & resultPath);
+
+ 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);
+ static void listPossibleConnectionFormats(std::vector<am_CustomConnectionFormat_t> & inListSourceFormats,
+ std::vector<am_CustomConnectionFormat_t> & inListSinkFormats, std::vector<am_CustomConnectionFormat_t> & outListFormats);
+ 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);
+ static am_Error_e getSourceSinkPossibleConnectionFormats(std::vector<CAmRoutingNode*>::iterator iteratorSource,
+ std::vector<CAmRoutingNode*>::iterator iteratorSink, std::vector<am_CustomConnectionFormat_t> & outConnectionFormats);
+
+ static bool shouldGoInDomain(const std::vector<am_domainID_t> & visitedDomains, const am_domainID_t nodeDomainID, const unsigned maxCyclesNumber);
+ bool shouldGoInDomain(const std::vector<am_domainID_t> & visitedDomains, const am_domainID_t nodeDomainID);
+ /**
+ * Returns a sink node with given sinkID.
+ *
+ * @param sinkID sink id.
+ * @return pointer to node or NULL.
+ */
+ CAmRoutingNode* sinkNodeWithID(const am_sinkID_t sinkID);
+ CAmRoutingNode* sinkNodeWithID(const am_sinkID_t sinkID, const am_domainID_t domainID);
+
+ /**
+ * Returns a source node with given sourceID.
+ *
+ * @param sourceID source id.
+ * @return pointer to node or NULL.
+ */
+ CAmRoutingNode* sourceNodeWithID(const am_sourceID_t sourceID);
+ CAmRoutingNode* sourceNodeWithID(const am_sourceID_t sourceID, const am_domainID_t domainID);
+
+ /**
+ * Returns a converter node for given sinkID.
+ *
+ * @param sinkID sink id.
+ * @param domainID domain id.
+ * @return pointer to node or NULL.
+ */
+ CAmRoutingNode* converterNodeWithSinkID(const am_sinkID_t sinkID, const am_domainID_t domainID);
+
+ /**
+ * Returns a gateway node for given sinkID.
+ *
+ * @param sinkID sink id.
+ * @return pointer to node or NULL.
+ */
+ CAmRoutingNode* gatewayNodeWithSinkID(const am_sinkID_t sinkID);
+
+ void load();
+ void clear();
+
+ /**
+ * DEPRECATED!
+ */
+ public:
+ 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, CAmRoutingNode &, CAmRoutingNode &, std::vector<am_Route_s> &) instead!")));
+ };
} /* namespace am */
#endif /* ROUTER_H_ */
diff --git a/AudioManagerCore/src/CAmRouter.cpp b/AudioManagerCore/src/CAmRouter.cpp
index 5edd6d5..6f1fe61 100644
--- a/AudioManagerCore/src/CAmRouter.cpp
+++ b/AudioManagerCore/src/CAmRouter.cpp
@@ -31,945 +31,967 @@
#include "CAmControlSender.h"
#include "CAmDltWrapper.h"
-
-
-namespace am {
-
-
-template <class X> void getMergeConnectionFormats(const X * element,
- const am_CustomConnectionFormat_t connectionFormat,
- const std::vector<am_CustomConnectionFormat_t> & listConnectionFormats,
- std::vector<am_CustomConnectionFormat_t> & outListMergeConnectionFormats)
+namespace am
{
- std::vector<am_CustomConnectionFormat_t> listRestrictedConnectionFormats;
- CAmRouter::getRestrictedOutputFormats(element->convertionMatrix,
- element->listSourceFormats,
- element->listSinkFormats,
- connectionFormat,
- listRestrictedConnectionFormats);
- std::sort(listRestrictedConnectionFormats.begin(), listRestrictedConnectionFormats.end()); //todo: this might be not needed if we use strictly sorted input
- std::insert_iterator<std::vector<am_CustomConnectionFormat_t> > inserter(outListMergeConnectionFormats, outListMergeConnectionFormats.begin());
- set_intersection(listConnectionFormats.begin(), listConnectionFormats.end(), listRestrictedConnectionFormats.begin(), listRestrictedConnectionFormats.end(), inserter);
-}
+ template<class X> void getMergeConnectionFormats(const X * element, const am_CustomConnectionFormat_t connectionFormat,
+ const std::vector<am_CustomConnectionFormat_t> & listConnectionFormats, std::vector<am_CustomConnectionFormat_t> & outListMergeConnectionFormats)
+ {
+ std::vector<am_CustomConnectionFormat_t> listRestrictedConnectionFormats;
+ CAmRouter::getRestrictedOutputFormats(element->convertionMatrix, element->listSourceFormats, element->listSinkFormats, connectionFormat,
+ listRestrictedConnectionFormats);
+ std::sort(listRestrictedConnectionFormats.begin(), listRestrictedConnectionFormats.end()); //todo: this might be not needed if we use strictly sorted input
+ std::insert_iterator<std::vector<am_CustomConnectionFormat_t> > inserter(outListMergeConnectionFormats, outListMergeConnectionFormats.begin());
+ set_intersection(listConnectionFormats.begin(), listConnectionFormats.end(), listRestrictedConnectionFormats.begin(),
+ listRestrictedConnectionFormats.end(), inserter);
+ }
-CAmRouter::CAmRouter(IAmDatabaseHandler* iDatabaseHandler, CAmControlSender* iSender) :
- CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks(),
- mpDatabaseHandler(iDatabaseHandler), //
- mpControlSender(iSender),
- mOnlyFreeConversionNodes(false),
- mMaxAllowedCycles(MAX_ALLOWED_DOMAIN_CYCLES),
- mMaxPathCount(MAX_ROUTING_PATHS),
- mRoutingGraph(),
- mNodeListSources(),
- mNodeListSinks(),
- mNodeListGateways(),
- mNodeListConverters()
-{
- assert(mpDatabaseHandler);
- assert(mpControlSender);
-}
+ CAmRouter::CAmRouter(IAmDatabaseHandler* iDatabaseHandler, CAmControlSender* iSender) :
+ CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks(),
+ mpDatabaseHandler(iDatabaseHandler), //
+ mpControlSender(iSender),
+ mUpdateGraphNodesAction(true),
+ mMaxAllowedCycles(MAX_ALLOWED_DOMAIN_CYCLES),
+ mMaxPathCount(MAX_ROUTING_PATHS),
+ mRoutingGraph(),
+ mNodeListSources(),
+ mNodeListSinks(),
+ mNodeListGateways(),
+ mNodeListConverters()
+ {
+ assert(mpDatabaseHandler);
+ assert(mpControlSender);
-CAmRouter::~CAmRouter()
-{
-}
+ dboNewSink = [&](const am_Sink_s& sink)
+ {
+ mUpdateGraphNodesAction = true;
+ };
+ dboNewSource = [&](const am_Source_s& source)
+ {
+ mUpdateGraphNodesAction=true;
+ };
+ dboNewGateway = [&](const am_Gateway_s& gateway)
+ {
+ mUpdateGraphNodesAction=true;
+ };
+ dboNewConverter = [&](const am_Converter_s& coverter)
+ {
+ mUpdateGraphNodesAction=true;
+ };
+ dboRemovedSink = [&](const am_sinkID_t sinkID, const bool visible)
+ {
+ mUpdateGraphNodesAction=true;
+ };
+ dboRemovedSource = [&](const am_sourceID_t sourceID, const bool visible)
+ {
+ mUpdateGraphNodesAction=true;
+ };
+ dboRemoveGateway = [&](const am_gatewayID_t gatewayID)
+ {
+ mUpdateGraphNodesAction=true;
+ };
+ dboRemoveConverter = [&](const am_converterID_t converterID)
+ {
+ mUpdateGraphNodesAction=true;
+ };
+ }
-/**
- * returns the best route between a source and a sink
- * @param onlyfree if true only free gateways are used
- * @param sourceID
- * @param sinkID
- * @param returnList this list contains a set of routes
- * @return E_OK in case of success
- */
-am_Error_e CAmRouter::getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s> & returnList)
-{
- load(onlyfree);
- return getRouteFromLoadedNodes(sourceID, sinkID, returnList);
-}
+ CAmRouter::~CAmRouter()
+ {
+ }
+ /**
+ * returns the best route between a source and a sink
+ * @param onlyfree if true only free gateways are used
+ * @param sourceID
+ * @param sinkID
+ * @param returnList this list contains a set of routes
+ * @return E_OK in case of success
+ */
+ am_Error_e CAmRouter::getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s> & returnList)
+ {
+ if (mUpdateGraphNodesAction)
+ {
+ load();
+ mUpdateGraphNodesAction = false;
+ }
+ return getRouteFromLoadedNodes(onlyfree, sourceID, sinkID, returnList);
+ }
-am_Error_e CAmRouter::getRoute(const bool onlyfree, const am_Source_s & aSource, const am_Sink_s & aSink, std::vector<am_Route_s> & listRoutes)
-{
- return getRoute(onlyfree, aSource.sourceID, aSink.sinkID, listRoutes);
-}
+ am_Error_e CAmRouter::getRoute(const bool onlyfree, const am_Source_s & aSource, const am_Sink_s & aSink, std::vector<am_Route_s> & listRoutes)
+ {
+ return getRoute(onlyfree, aSource.sourceID, aSink.sinkID, listRoutes);
+ }
-am_Error_e CAmRouter::getRouteFromLoadedNodes(const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s> & returnList)
-{
- returnList.clear();
+ am_Error_e CAmRouter::getRouteFromLoadedNodes(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID,
+ std::vector<am_Route_s> & returnList)
+ {
+ returnList.clear();
- CAmRoutingNode* pRootSource = sourceNodeWithID(sourceID);
- CAmRoutingNode* pRootSink = sinkNodeWithID(sinkID);
+ CAmRoutingNode* pRootSource = sourceNodeWithID(sourceID);
+ CAmRoutingNode* pRootSink = sinkNodeWithID(sinkID);
- if(!pRootSource || !pRootSink)
- return E_NON_EXISTENT;
+ if (!pRootSource || !pRootSink)
+ return E_NON_EXISTENT;
- //try to find paths without cycles
- const unsigned cycles = mMaxAllowedCycles;
- mMaxAllowedCycles = 0;
+ //try to find paths without cycles
+ am_Error_e error = getFirstNShortestPaths(onlyfree, 0, mMaxPathCount, *pRootSource, *pRootSink, returnList);
- am_Error_e error = getFirstNShortestPaths(*pRootSource, *pRootSink, returnList);
+ //if no paths have been found, we start a second search with cycles.
+ if (!returnList.size() && mMaxAllowedCycles > 0)
+ {
+ error = getFirstNShortestPaths(onlyfree, mMaxAllowedCycles, mMaxPathCount, *pRootSource, *pRootSink, returnList);
+ }
- mMaxAllowedCycles = cycles;
+ /* For shortest path use the following call:
+ *
+ * error = getShortestPath(*pRootSource, *pRootSink, listRoutes);
+ */
+ return error;
+ }
- //if no paths have been found, we start a second search with cycles.
- if( !returnList.size() && cycles>0 )
+ am_Error_e CAmRouter::getRouteFromLoadedNodes(const bool onlyfree, const am_Source_s & aSource, const am_Sink_s & aSink,
+ std::vector<am_Route_s> & listRoutes)
{
- error = getFirstNShortestPaths(*pRootSource, *pRootSink, returnList);
+ return getRouteFromLoadedNodes(onlyfree, aSource.sourceID, aSink.sinkID, listRoutes);
}
- /* For shortest path use the following call:
- *
- * error = getShortestPath(*pRootSource, *pRootSink, listRoutes);
- */
- return error;
-}
-
+ void CAmRouter::load()
+ {
+ clear();
-am_Error_e CAmRouter::getRouteFromLoadedNodes(const am_Source_s & aSource, const am_Sink_s & aSink, std::vector<am_Route_s> & listRoutes)
-{
- return getRouteFromLoadedNodes(aSource.sourceID, aSink.sinkID, listRoutes);
-}
+ am_RoutingNodeData_s nodeDataSrc;
+ nodeDataSrc.type = CAmNodeDataType::SOURCE;
+ mpDatabaseHandler->enumerateSources([&](const am_Source_s & obj)
+ {
+ nodeDataSrc.data.source = (am_Source_s*)&obj;
+ auto node = &mRoutingGraph.addNode(nodeDataSrc);
+ mNodeListSources[nodeDataSrc.data.source->domainID].push_back(node);
+ });
+
+ am_RoutingNodeData_s nodeDataSink;
+ nodeDataSink.type = CAmNodeDataType::SINK;
+ mpDatabaseHandler->enumerateSinks([&](const am_Sink_s & obj)
+ {
+ nodeDataSink.data.sink = (am_Sink_s*)&obj;
+ auto node = &mRoutingGraph.addNode(nodeDataSink);
+ mNodeListSinks[nodeDataSink.data.sink->domainID].push_back(node);
+ });
+
+ am_RoutingNodeData_s nodeDataGateway;
+ nodeDataGateway.type = CAmNodeDataType::GATEWAY;
+ mpDatabaseHandler->enumerateGateways([&](const am_Gateway_s & obj)
+ {
+ nodeDataGateway.data.gateway = (am_Gateway_s*)&obj;
+ auto node = &mRoutingGraph.addNode(nodeDataGateway);
+ mNodeListGateways[nodeDataGateway.data.gateway->controlDomainID].push_back(node);
+ });
+
+ am_RoutingNodeData_s nodeDataConverter;
+ nodeDataConverter.type = CAmNodeDataType::CONVERTER;
+ mpDatabaseHandler->enumerateConverters([&](const am_Converter_s & obj)
+ {
+ nodeDataConverter.data.converter = (am_Converter_s*)&obj;
+ auto node = &mRoutingGraph.addNode(nodeDataConverter);
+ mNodeListConverters[nodeDataConverter.data.converter->domainID].push_back(node);
+ });
-void CAmRouter::load(const bool onlyFree)
-{
- clear();
- mOnlyFreeConversionNodes = onlyFree;
-
- am_RoutingNodeData_s nodeDataSrc;
- nodeDataSrc.type = CAmNodeDataType::SOURCE;
- mpDatabaseHandler->enumerateSources([&](const am_Source_s & obj){
- nodeDataSrc.data.source = (am_Source_s*)&obj;
- auto node = &mRoutingGraph.addNode(nodeDataSrc);
- mNodeListSources[nodeDataSrc.data.source->domainID].push_back(node);
- });
- am_RoutingNodeData_s nodeDataSink;
- nodeDataSink.type = CAmNodeDataType::SINK;
- mpDatabaseHandler->enumerateSinks([&](const am_Sink_s & obj){
- nodeDataSink.data.sink = (am_Sink_s*)&obj;
- auto node = &mRoutingGraph.addNode(nodeDataSink);
- mNodeListSinks[nodeDataSink.data.sink->domainID].push_back(node);
- });
- am_RoutingNodeData_s nodeDataGateway;
- nodeDataGateway.type = CAmNodeDataType::GATEWAY;
- mpDatabaseHandler->enumerateGateways([&](const am_Gateway_s & obj){
- nodeDataGateway.data.gateway = (am_Gateway_s*)&obj;
- auto node = &mRoutingGraph.addNode(nodeDataGateway);
- mNodeListGateways[nodeDataGateway.data.gateway->controlDomainID].push_back(node);
- });
- am_RoutingNodeData_s nodeDataConverter;
- nodeDataConverter.type = CAmNodeDataType::CONVERTER;
- mpDatabaseHandler->enumerateConverters([&](const am_Converter_s & obj){
- nodeDataConverter.data.converter = (am_Converter_s*)&obj;
- auto node = &mRoutingGraph.addNode(nodeDataConverter);
- mNodeListConverters[nodeDataConverter.data.converter->domainID].push_back(node);
- });
-
- constructConverterConnections();
- constructGatewayConnections();
- constructSourceSinkConnections();
+ constructConverterConnections();
+ constructGatewayConnections();
+ constructSourceSinkConnections();
#ifdef TRACE_GRAPH
- mRoutingGraph.trace([&](const CAmRoutingNode & node, const std::vector<CAmVertex<am_RoutingNodeData_s,uint16_t>*> & list) {
- std::cout << "Node " << node.getIndex() << ":";
- ((CAmRoutingNode &)node).getData().trace();
- std::cout << "-->[";
- int count = 0;
- std::for_each(list.begin(), list.end(), [&](const CAmVertex<am_RoutingNodeData_s,uint16_t>* refVertex){
- am::CAmNode<am::am_RoutingNodeData_s>* data = refVertex->getNode();
- if(count>0)
- std::cout << ", ";
- std::cout << "Node " << data->getIndex() << ":";
- data->getData().trace();
- count++;
- });
- std::cout << "]" << std::endl;
- });
+ mRoutingGraph.trace([&](const CAmRoutingNode & node, const std::vector<CAmVertex<am_RoutingNodeData_s,uint16_t>*> & list)
+ {
+ std::cout << "Node " << node.getIndex() << ":";
+ ((CAmRoutingNode &)node).getData().trace();
+ std::cout << "-->[";
+ int count = 0;
+ std::for_each(list.begin(), list.end(), [&](const CAmVertex<am_RoutingNodeData_s,uint16_t>* refVertex)
+ {
+ am::CAmNode<am::am_RoutingNodeData_s>* data = refVertex->getNode();
+ if(count>0)
+ std::cout << ", ";
+ std::cout << "Node " << data->getIndex() << ":";
+ data->getData().trace();
+ count++;
+ });
+ std::cout << "]" << std::endl;
+ });
#endif
-}
+ }
-void CAmRouter::clear()
-{
- mRoutingGraph.clear();
- mNodeListSources.clear();
- mNodeListSinks.clear();
- mNodeListGateways.clear();
- mNodeListConverters.clear();
-}
+ void CAmRouter::clear()
+ {
+ mRoutingGraph.clear();
+ mNodeListSources.clear();
+ mNodeListSinks.clear();
+ mNodeListGateways.clear();
+ mNodeListConverters.clear();
+ }
-CAmRoutingNode* CAmRouter::sinkNodeWithID(const am_sinkID_t sinkID)
-{
- CAmRoutingNode* result = NULL;
- for(auto it = mNodeListSinks.begin(); it!=mNodeListSinks.end(); it++)
- {
- result = sinkNodeWithID(sinkID, it->first);
- if(result)
- return result;
- }
- return result;
-}
+ CAmRoutingNode* CAmRouter::sinkNodeWithID(const am_sinkID_t sinkID)
+ {
+ CAmRoutingNode* result = NULL;
+ for (auto it = mNodeListSinks.begin(); it != mNodeListSinks.end(); it++)
+ {
+ result = sinkNodeWithID(sinkID, it->first);
+ if (result)
+ return result;
+ }
+ return result;
+ }
-CAmRoutingNode* CAmRouter::sinkNodeWithID(const am_sinkID_t sinkID, const am_domainID_t domainID)
-{
- CAmRoutingNode* result = NULL;
- std::vector<CAmRoutingNode*> & value = mNodeListSinks[domainID];
- auto iter = std::find_if(value.begin(), value.end(), [sinkID](CAmRoutingNode* node){
- return node->getData().data.sink->sinkID==sinkID;
- });
- if(iter!=value.end())
- result = *iter;
- return result;
-}
+ CAmRoutingNode* CAmRouter::sinkNodeWithID(const am_sinkID_t sinkID, const am_domainID_t domainID)
+ {
+ CAmRoutingNode* result = NULL;
+ std::vector<CAmRoutingNode*> & value = mNodeListSinks[domainID];
+ auto iter = std::find_if(value.begin(), value.end(), [sinkID](CAmRoutingNode* node)
+ {
+ return node->getData().data.sink->sinkID==sinkID;
+ });
+ if (iter != value.end())
+ result = *iter;
+ return result;
+ }
-CAmRoutingNode* CAmRouter::sourceNodeWithID(const am_sourceID_t sourceID)
-{
- CAmRoutingNode* result = NULL;
- for(auto it = mNodeListSources.begin(); it!=mNodeListSources.end(); it++)
- {
- result = sourceNodeWithID(sourceID, it->first);
- if(result)
- return result;
- }
- return result;
-}
+ CAmRoutingNode* CAmRouter::sourceNodeWithID(const am_sourceID_t sourceID)
+ {
+ CAmRoutingNode* result = NULL;
+ for (auto it = mNodeListSources.begin(); it != mNodeListSources.end(); it++)
+ {
+ result = sourceNodeWithID(sourceID, it->first);
+ if (result)
+ return result;
+ }
+ return result;
+ }
-CAmRoutingNode* CAmRouter::sourceNodeWithID(const am_sourceID_t sourceID, const am_domainID_t domainID)
-{
- CAmRoutingNode* result = NULL;
- std::vector<CAmRoutingNode*> & value = mNodeListSources[domainID];
- auto iter = std::find_if(value.begin(), value.end(), [sourceID](CAmRoutingNode* node){
- return node->getData().data.source->sourceID==sourceID;
- });
- if(iter!=value.end())
- result = *iter;
- return result;
-}
+ CAmRoutingNode* CAmRouter::sourceNodeWithID(const am_sourceID_t sourceID, const am_domainID_t domainID)
+ {
+ CAmRoutingNode* result = NULL;
+ std::vector<CAmRoutingNode*> & value = mNodeListSources[domainID];
+ auto iter = std::find_if(value.begin(), value.end(), [sourceID](CAmRoutingNode* node)
+ {
+ return node->getData().data.source->sourceID==sourceID;
+ });
+ if (iter != value.end())
+ result = *iter;
+ return result;
+ }
-CAmRoutingNode* CAmRouter::converterNodeWithSinkID(const am_sinkID_t sinkID, const am_domainID_t domainID)
-{
- CAmRoutingNode* result = NULL;
- std::vector<CAmRoutingNode*> & value = mNodeListConverters[domainID];
- auto iter = std::find_if(value.begin(), value.end(), [sinkID](CAmRoutingNode* node){
- return node->getData().data.converter->sinkID==sinkID;
- });
- if(iter!=value.end())
- result = *iter;
- return result;
-}
+ CAmRoutingNode* CAmRouter::converterNodeWithSinkID(const am_sinkID_t sinkID, const am_domainID_t domainID)
+ {
+ CAmRoutingNode* result = NULL;
+ std::vector<CAmRoutingNode*> & value = mNodeListConverters[domainID];
+ auto iter = std::find_if(value.begin(), value.end(), [sinkID](CAmRoutingNode* node)
+ {
+ return node->getData().data.converter->sinkID==sinkID;
+ });
+ if (iter != value.end())
+ result = *iter;
+ return result;
+ }
-CAmRoutingNode* CAmRouter::gatewayNodeWithSinkID(const am_sinkID_t sinkID)
-{
- for(auto it = mNodeListGateways.begin(); it!=mNodeListGateways.end(); it++)
- {
- std::vector<CAmRoutingNode*> & value = it->second;
- auto iter = std::find_if(value.begin(), value.end(), [sinkID](CAmRoutingNode* node){
- return node->getData().data.gateway->sinkID==sinkID;
- });
- if(iter!=value.end())
- return *iter;
- }
- return NULL;
-}
+ CAmRoutingNode* CAmRouter::gatewayNodeWithSinkID(const am_sinkID_t sinkID)
+ {
+ for (auto it = mNodeListGateways.begin(); it != mNodeListGateways.end(); it++)
+ {
+ std::vector<CAmRoutingNode*> & value = it->second;
+ auto iter = std::find_if(value.begin(), value.end(), [sinkID](CAmRoutingNode* node)
+ {
+ return node->getData().data.gateway->sinkID==sinkID;
+ });
+ if (iter != value.end())
+ return *iter;
+ }
+ return NULL;
+ }
-void CAmRouter::constructSourceSinkConnections()
-{
- std::vector<am_CustomConnectionFormat_t> intersection;
- for(auto itSrc = mNodeListSources.begin(); itSrc!=mNodeListSources.end(); itSrc++)
- {
- for(auto it = itSrc->second.begin(); it!=itSrc->second.end(); it++)
- {
- CAmRoutingNode* srcNode = *it;
- am_RoutingNodeData_s & srcNodeData = srcNode->getData();
- am_Source_s * source = srcNodeData.data.source;
- for(auto itSink = mNodeListSinks[itSrc->first].begin(); itSink!=mNodeListSinks[itSrc->first].end(); itSink++)
- {
- CAmRoutingNode* sinkNode = *itSink;
- am_RoutingNodeData_s & sinkNodeData = sinkNode->getData();
- am_Sink_s * sink = sinkNodeData.data.sink;
-
- intersection.clear();
- //Check whether the hidden sink formats match the source formats...
- listPossibleConnectionFormats(source->listConnectionFormats, sink->listConnectionFormats, intersection);
- if(intersection.size()>0)//OK match source -> sink
- {
- mRoutingGraph.connectNodes(*srcNode, *sinkNode, CF_UNKNOWN, 1);
- }
- }
- }
- }
-}
+ void CAmRouter::constructSourceSinkConnections()
+ {
+ std::vector<am_CustomConnectionFormat_t> intersection;
+ for (auto itSrc = mNodeListSources.begin(); itSrc != mNodeListSources.end(); itSrc++)
+ {
+ for (auto it = itSrc->second.begin(); it != itSrc->second.end(); it++)
+ {
+ CAmRoutingNode* srcNode = *it;
+ am_RoutingNodeData_s & srcNodeData = srcNode->getData();
+ am_Source_s * source = srcNodeData.data.source;
+ for (auto itSink = mNodeListSinks[itSrc->first].begin(); itSink != mNodeListSinks[itSrc->first].end(); itSink++)
+ {
+ CAmRoutingNode* sinkNode = *itSink;
+ am_RoutingNodeData_s & sinkNodeData = sinkNode->getData();
+ am_Sink_s * sink = sinkNodeData.data.sink;
+
+ intersection.clear();
+ //Check whether the hidden sink formats match the source formats...
+ listPossibleConnectionFormats(source->listConnectionFormats, sink->listConnectionFormats, intersection);
+ if (intersection.size() > 0) //OK match source -> sink
+ {
+ mRoutingGraph.connectNodes(*srcNode, *sinkNode, CF_UNKNOWN, 1);
+ }
+ }
+ }
+ }
+ }
-void CAmRouter::constructGatewayConnections()
-{
- std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
- for(auto iter = mNodeListGateways.begin(); iter!=mNodeListGateways.end(); iter++)
- {
- for(auto it = iter->second.begin(); it!=iter->second.end(); it++)
- {
- CAmRoutingNode* gatewayNode = *it;
- am_RoutingNodeData_s & gatewayNodeData = gatewayNode->getData();
- am_Gateway_s * gateway = gatewayNodeData.data.gateway;
- //Get only gateways with end point in current source domain
- if(!mOnlyFreeConversionNodes || !isComponentConnected(*gateway))
- {
- //Get the sink connected to the gateway...
- CAmRoutingNode *gatewaySinkNode = this->sinkNodeWithID(gateway->sinkID, gateway->domainSinkID);
- if(gatewaySinkNode)
- {
- am_RoutingNodeData_s & gatewaySinkData = gatewaySinkNode->getData();
- //Check whether the hidden sink formats match the source formats...
- sourceFormats.clear();
- sinkFormats.clear();
- if(getAllowedFormatsFromConvMatrix(gateway->convertionMatrix, gateway->listSourceFormats, gateway->listSinkFormats, sourceFormats, sinkFormats))
- {
- CAmRoutingNode *gatewaySourceNode = this->sourceNodeWithID(gateway->sourceID, gateway->domainSourceID);
- if(gatewaySourceNode)
- {
- //Connections hidden_sink->gateway->hidden_source
- mRoutingGraph.connectNodes(*gatewaySinkNode, *gatewayNode, CF_UNKNOWN, 1);
- mRoutingGraph.connectNodes(*gatewayNode, *gatewaySourceNode, CF_UNKNOWN, 1);
- }
- }
- }
- }
- }
- }
-}
+ void CAmRouter::constructGatewayConnections()
+ {
+ std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
+ for (auto iter = mNodeListGateways.begin(); iter != mNodeListGateways.end(); iter++)
+ {
+ for (auto it = iter->second.begin(); it != iter->second.end(); it++)
+ {
+ CAmRoutingNode* gatewayNode = *it;
+ am_RoutingNodeData_s & gatewayNodeData = gatewayNode->getData();
+ am_Gateway_s * gateway = gatewayNodeData.data.gateway;
+ //Get only gateways with end point in current source domain
+
+ //Get the sink connected to the gateway...
+ CAmRoutingNode *gatewaySinkNode = this->sinkNodeWithID(gateway->sinkID, gateway->domainSinkID);
+ if (gatewaySinkNode)
+ {
+ am_RoutingNodeData_s & gatewaySinkData = gatewaySinkNode->getData();
+ //Check whether the hidden sink formats match the source formats...
+ sourceFormats.clear();
+ sinkFormats.clear();
+ if (getAllowedFormatsFromConvMatrix(gateway->convertionMatrix, gateway->listSourceFormats, gateway->listSinkFormats, sourceFormats,
+ sinkFormats))
+ {
+ CAmRoutingNode *gatewaySourceNode = this->sourceNodeWithID(gateway->sourceID, gateway->domainSourceID);
+ if (gatewaySourceNode)
+ {
+ //Connections hidden_sink->gateway->hidden_source
+ mRoutingGraph.connectNodes(*gatewaySinkNode, *gatewayNode, CF_UNKNOWN, 1);
+ mRoutingGraph.connectNodes(*gatewayNode, *gatewaySourceNode, CF_UNKNOWN, 1);
+ }
+ }
+ }
+ }
+ }
+ }
-void CAmRouter::constructConverterConnections()
-{
- std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
-
- for(auto iter = mNodeListConverters.begin(); iter!=mNodeListConverters.end(); iter++)
- {
- for(auto it = iter->second.begin(); it!=iter->second.end(); it++)
- {
- CAmRoutingNode* converterNode = *it;
- am_RoutingNodeData_s & converterNodeData = converterNode->getData();
- am_Converter_s * converter = converterNodeData.data.converter;
- //Get only converters with end point in current source domain
- if(!mOnlyFreeConversionNodes || !isComponentConnected(*converter))
- {
- //Get the sink connected to the converter...
- CAmRoutingNode *converterSinkNode = this->sinkNodeWithID(converter->sinkID, converter->domainID);
- if(converterSinkNode)
- {
- am_RoutingNodeData_s & converterSinkData = converterSinkNode->getData();
- //Check whether the hidden sink formats match the source formats...
- sourceFormats.clear();
- sinkFormats.clear();
- if(getAllowedFormatsFromConvMatrix(converter->convertionMatrix, converter->listSourceFormats, converter->listSinkFormats, sourceFormats, sinkFormats))
- {
- CAmRoutingNode *converterSourceNode = this->sourceNodeWithID(converter->sourceID, converter->domainID);
- if(converterSourceNode)
- {
- //Connections hidden_sink->converter->hidden_source
- mRoutingGraph.connectNodes(*converterSinkNode, *converterNode, CF_UNKNOWN, 1);
- mRoutingGraph.connectNodes(*converterNode, *converterSourceNode, CF_UNKNOWN, 1);
- }
- }
- }
- }
- }
- }
-}
+ void CAmRouter::constructConverterConnections()
+ {
+ std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
-void CAmRouter::getVerticesForSource(const CAmRoutingNode & node, CAmRoutingListVertices & list)
-{
- am_RoutingNodeData_s & srcNodeData = ((CAmRoutingNode*)&node)->getData();
- std::vector<am_CustomConnectionFormat_t> intersection;
- am_Source_s * source = srcNodeData.data.source;
- std::vector<CAmRoutingNode*> & sinks = mNodeListSinks[source->domainID];
- for(auto itSink = sinks.begin(); itSink!=sinks.end(); itSink++)
- {
- CAmRoutingNode* sinkNode = *itSink;
- am_RoutingNodeData_s & sinkNodeData = sinkNode->getData();
- am_Sink_s * sink = sinkNodeData.data.sink;
-
- intersection.clear();
- //Check whether the hidden sink formats match the source formats...
- listPossibleConnectionFormats(source->listConnectionFormats, sink->listConnectionFormats, intersection);
- if(intersection.size()>0)//OK match source -> sink
- {
- list.emplace_back(sinkNode, CF_UNKNOWN, 1);
- }
- }
-}
+ for (auto iter = mNodeListConverters.begin(); iter != mNodeListConverters.end(); iter++)
+ {
+ for (auto it = iter->second.begin(); it != iter->second.end(); it++)
+ {
+ CAmRoutingNode* converterNode = *it;
+ am_RoutingNodeData_s & converterNodeData = converterNode->getData();
+ am_Converter_s * converter = converterNodeData.data.converter;
+ //Get only converters with end point in current source domain
+
+ //Get the sink connected to the converter...
+ CAmRoutingNode *converterSinkNode = this->sinkNodeWithID(converter->sinkID, converter->domainID);
+ if (converterSinkNode)
+ {
+ am_RoutingNodeData_s & converterSinkData = converterSinkNode->getData();
+ //Check whether the hidden sink formats match the source formats...
+ sourceFormats.clear();
+ sinkFormats.clear();
+ if (getAllowedFormatsFromConvMatrix(converter->convertionMatrix, converter->listSourceFormats, converter->listSinkFormats, sourceFormats,
+ sinkFormats))
+ {
+ CAmRoutingNode *converterSourceNode = this->sourceNodeWithID(converter->sourceID, converter->domainID);
+ if (converterSourceNode)
+ {
+ //Connections hidden_sink->converter->hidden_source
+ mRoutingGraph.connectNodes(*converterSinkNode, *converterNode, CF_UNKNOWN, 1);
+ mRoutingGraph.connectNodes(*converterNode, *converterSourceNode, CF_UNKNOWN, 1);
+ }
+ }
+ }
+ }
+ }
+ }
-void CAmRouter::getVerticesForSink(const CAmRoutingNode & node, CAmRoutingListVertices & list)
-{
- am_RoutingNodeData_s & sinkNodeData = ((CAmRoutingNode*)&node)->getData();
- std::vector<am_CustomConnectionFormat_t> intersection;
- am_Sink_s * sink = sinkNodeData.data.sink;
-
- CAmRoutingNode *converterNode = converterNodeWithSinkID(sink->sinkID, sink->domainID);
- if(converterNode)
- {
- std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
- am_RoutingNodeData_s & converterData = converterNode->getData();
- am_Converter_s * converter = converterData.data.converter;
- if(!mOnlyFreeConversionNodes || !isComponentConnected(*converter))
- {
- if(getAllowedFormatsFromConvMatrix(converter->convertionMatrix, converter->listSourceFormats, converter->listSinkFormats, sourceFormats, sinkFormats))
- list.emplace_back(converterNode, CF_UNKNOWN, 1);
- }
- }
- else
- {
- std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
- CAmRoutingNode *gatewayNode = gatewayNodeWithSinkID(sink->sinkID);
- if(gatewayNode)
- {
- std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
- am_RoutingNodeData_s & gatewayData = gatewayNode->getData();
- am_Gateway_s * gateway = gatewayData.data.gateway;
- if(!mOnlyFreeConversionNodes || !isComponentConnected(*gateway))
- {
- if(getAllowedFormatsFromConvMatrix(gateway->convertionMatrix, gateway->listSourceFormats, gateway->listSinkFormats, sourceFormats, sinkFormats))
- list.emplace_back(gatewayNode, CF_UNKNOWN, 1);
- }
- }
- }
+ void CAmRouter::getVerticesForSource(const CAmRoutingNode & node, CAmRoutingListVertices & list)
+ {
+ am_RoutingNodeData_s & srcNodeData = ((CAmRoutingNode*) &node)->getData();
+ std::vector<am_CustomConnectionFormat_t> intersection;
+ am_Source_s * source = srcNodeData.data.source;
+ std::vector<CAmRoutingNode*> & sinks = mNodeListSinks[source->domainID];
+ for (auto itSink = sinks.begin(); itSink != sinks.end(); itSink++)
+ {
+ CAmRoutingNode* sinkNode = *itSink;
+ am_RoutingNodeData_s & sinkNodeData = sinkNode->getData();
+ am_Sink_s * sink = sinkNodeData.data.sink;
+
+ intersection.clear();
+ //Check whether the hidden sink formats match the source formats...
+ listPossibleConnectionFormats(source->listConnectionFormats, sink->listConnectionFormats, intersection);
+ if (intersection.size() > 0) //OK match source -> sink
+ {
+ list.emplace_back(sinkNode, CF_UNKNOWN, 1);
+ }
+ }
+ }
-}
+ void CAmRouter::getVerticesForSink(const CAmRoutingNode & node, CAmRoutingListVertices & list)
+ {
+ am_RoutingNodeData_s & sinkNodeData = ((CAmRoutingNode*) &node)->getData();
+ std::vector<am_CustomConnectionFormat_t> intersection;
+ am_Sink_s * sink = sinkNodeData.data.sink;
-void CAmRouter::getVerticesForConverter(const CAmRoutingNode & node, CAmRoutingListVertices & list)
-{
- std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
- am_RoutingNodeData_s & converterNodeData = ((CAmRoutingNode*)&node)->getData();
- am_Converter_s * converter = converterNodeData.data.converter;
- //Get only converters with end point in current source domain
- if(getAllowedFormatsFromConvMatrix(converter->convertionMatrix, converter->listSourceFormats, converter->listSinkFormats, sourceFormats, sinkFormats))
- {
- CAmRoutingNode *converterSourceNode = this->sourceNodeWithID(converter->sourceID, converter->domainID);
- if(converterSourceNode)
- {
- list.emplace_back(converterSourceNode, CF_UNKNOWN, 1);
- }
- }
-}
+ CAmRoutingNode *converterNode = converterNodeWithSinkID(sink->sinkID, sink->domainID);
+ if (converterNode)
+ {
+ std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
+ am_RoutingNodeData_s & converterData = converterNode->getData();
+ am_Converter_s * converter = converterData.data.converter;
-void CAmRouter::getVerticesForGateway(const CAmRoutingNode & node, CAmRoutingListVertices & list)
-{
- am_RoutingNodeData_s & gatewayNodeData = ((CAmRoutingNode*)&node)->getData();
- std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
- am_Gateway_s * gateway = gatewayNodeData.data.gateway;
- if(getAllowedFormatsFromConvMatrix(gateway->convertionMatrix, gateway->listSourceFormats, gateway->listSinkFormats, sourceFormats, sinkFormats))
- {
- CAmRoutingNode *gatewaySourceNode = this->sourceNodeWithID(gateway->sourceID, gateway->domainSourceID);
- if(gatewaySourceNode)
- {
- //Connections hidden_sink->gateway->hidden_source
- list.emplace_back(gatewaySourceNode, CF_UNKNOWN, 1);
- }
- }
-}
+ if (getAllowedFormatsFromConvMatrix(converter->convertionMatrix, converter->listSourceFormats, converter->listSinkFormats, sourceFormats,
+ sinkFormats))
+ list.emplace_back(converterNode, CF_UNKNOWN, 1);
+ }
+ else
+ {
+ std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
+ CAmRoutingNode *gatewayNode = gatewayNodeWithSinkID(sink->sinkID);
+ if (gatewayNode)
+ {
+ std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
+ am_RoutingNodeData_s & gatewayData = gatewayNode->getData();
+ am_Gateway_s * gateway = gatewayData.data.gateway;
+
+ if (getAllowedFormatsFromConvMatrix(gateway->convertionMatrix, gateway->listSourceFormats, gateway->listSinkFormats, sourceFormats,
+ sinkFormats))
+ list.emplace_back(gatewayNode, CF_UNKNOWN, 1);
+ }
+ }
-void CAmRouter::getVerticesForNode(
- const CAmRoutingNode & node,
- CAmRoutingListVertices & list
- )
-{
- am_RoutingNodeData_s & nodeData = ((CAmRoutingNode*)&node)->getData();
- if(nodeData.type==CAmNodeDataType::SOURCE)
- {
- getVerticesForSource(node, list);
- }
- else if(nodeData.type==CAmNodeDataType::SINK)
- {
- getVerticesForSink(node, list);
- }
- else if(nodeData.type==CAmNodeDataType::CONVERTER)
- {
- getVerticesForConverter(node, list);
- }
- else if(nodeData.type==CAmNodeDataType::GATEWAY)
- {
- getVerticesForGateway(node, list);
- }
-}
+ }
-am_Error_e CAmRouter::determineConnectionFormatsForPath(am_Route_s & routeObjects, std::vector<CAmRoutingNode*> & nodes, std::vector<am_Route_s> & result)
-{
- std::vector<am_RoutingElement_s>::iterator routingElementIterator = routeObjects.route.begin();
- std::vector<CAmRoutingNode*>::iterator nodeIterator = nodes.begin();
- if( routingElementIterator!= routeObjects.route.end() && nodeIterator!=nodes.end() )
- return doConnectionFormatsForPath(routeObjects, nodes, routingElementIterator, nodeIterator, result);
- return E_OK;
-}
+ void CAmRouter::getVerticesForConverter(const CAmRoutingNode & node, CAmRoutingListVertices & list)
+ {
+ std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
+ am_RoutingNodeData_s & converterNodeData = ((CAmRoutingNode*) &node)->getData();
+ am_Converter_s * converter = converterNodeData.data.converter;
+ //Get only converters with end point in current source domain
+ if (getAllowedFormatsFromConvMatrix(converter->convertionMatrix, converter->listSourceFormats, converter->listSinkFormats, sourceFormats, sinkFormats))
+ {
+ CAmRoutingNode *converterSourceNode = this->sourceNodeWithID(converter->sourceID, converter->domainID);
+ if (converterSourceNode)
+ {
+ list.emplace_back(converterSourceNode, CF_UNKNOWN, 1);
+ }
+ }
+ }
-am_Error_e CAmRouter::doConnectionFormatsForPath(am_Route_s & routeObjects,
- std::vector<CAmRoutingNode*> & nodes,
- std::vector<am_RoutingElement_s>::iterator routingElementIterator,
- std::vector<CAmRoutingNode*>::iterator nodeIterator,
- std::vector<am_Route_s> & result)
-{
- am_Error_e returnError = E_NOT_POSSIBLE;
- std::vector<am_CustomConnectionFormat_t> listConnectionFormats;
- std::vector<am_CustomConnectionFormat_t> listMergeConnectionFormats;
-
- std::vector<CAmRoutingNode*>::iterator currentNodeIterator = nodeIterator;
- std::vector<am_RoutingElement_s>::iterator currentRoutingElementIterator = routingElementIterator;
-
- if (currentRoutingElementIterator!=routeObjects.route.begin())
- {
- std::vector<am_CustomConnectionFormat_t> listConnectionFormats;
- std::vector<am_RoutingElement_s>::iterator tempIterator = (currentRoutingElementIterator-1);
- CAmRoutingNode * currentNode = *currentNodeIterator;
- if((returnError = getSourceSinkPossibleConnectionFormats(currentNodeIterator+1, currentNodeIterator+2, listConnectionFormats))!=E_OK)
- return returnError;
-
- if(currentNode->getData().type==CAmNodeDataType::GATEWAY)
- {
- am_Gateway_s *gateway = currentNode->getData().data.gateway;
- getMergeConnectionFormats(gateway, tempIterator->connectionFormat, listConnectionFormats, listMergeConnectionFormats);
- }
- else if(currentNode->getData().type==CAmNodeDataType::CONVERTER)
- {
- am_Converter_s *converter = currentNode->getData().data.converter;
- getMergeConnectionFormats(converter, tempIterator->connectionFormat, listConnectionFormats, listMergeConnectionFormats);
- }
- else
- return (E_UNKNOWN);
- currentNodeIterator+=3;
- }
- else
- {
- CAmRoutingNode * currentNode = *currentNodeIterator;
- if(currentNode->getData().type!=CAmNodeDataType::SOURCE)
- return (E_UNKNOWN);
- currentNodeIterator++;
-
- if(currentNodeIterator==nodes.end())
- return (E_UNKNOWN);
-
- CAmRoutingNode * nodeSink = *currentNodeIterator;
- if(nodeSink->getData().type!=CAmNodeDataType::SINK)
- return (E_UNKNOWN);
-
- am_Source_s *source = currentNode->getData().data.source;
- am_Sink_s *sink = nodeSink->getData().data.sink;
- listPossibleConnectionFormats(source->listConnectionFormats, sink->listConnectionFormats, listMergeConnectionFormats);
- currentNodeIterator+=1; //now we are on the next converter/gateway
- }
- //let the controller decide:
- std::vector<am_CustomConnectionFormat_t> listPriorityConnectionFormats;
- if((returnError = mpControlSender->getConnectionFormatChoice(currentRoutingElementIterator->sourceID, currentRoutingElementIterator->sinkID, routeObjects,
- listMergeConnectionFormats, listPriorityConnectionFormats))!= E_OK)
- return (returnError);
-
- if (listPriorityConnectionFormats.empty())
- return (E_NOT_POSSIBLE);
- //we have the list sorted after priors - now we try one after the other with the next part of the route
- std::vector<am_CustomConnectionFormat_t>::iterator connectionFormatIterator = listPriorityConnectionFormats.begin();
- //here we need to check if we are at the end and stop
- std::vector<am_RoutingElement_s>::iterator nextIterator = currentRoutingElementIterator + 1;//next pair source and sink
- if (nextIterator == routeObjects.route.end())
- {
- for (; connectionFormatIterator != listPriorityConnectionFormats.end(); ++connectionFormatIterator)
- {
- currentRoutingElementIterator->connectionFormat = *connectionFormatIterator;
- result.push_back(routeObjects);
- }
- }
- else
- {
- for (; connectionFormatIterator != listPriorityConnectionFormats.end(); ++connectionFormatIterator)
- {
- currentRoutingElementIterator->connectionFormat = *connectionFormatIterator;
- doConnectionFormatsForPath(routeObjects, nodes, nextIterator, currentNodeIterator, result);
- }
- }
- return (E_OK);
-}
+ void CAmRouter::getVerticesForGateway(const CAmRoutingNode & node, CAmRoutingListVertices & list)
+ {
+ am_RoutingNodeData_s & gatewayNodeData = ((CAmRoutingNode*) &node)->getData();
+ std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
+ am_Gateway_s * gateway = gatewayNodeData.data.gateway;
+ if (getAllowedFormatsFromConvMatrix(gateway->convertionMatrix, gateway->listSourceFormats, gateway->listSinkFormats, sourceFormats, sinkFormats))
+ {
+ CAmRoutingNode *gatewaySourceNode = this->sourceNodeWithID(gateway->sourceID, gateway->domainSourceID);
+ if (gatewaySourceNode)
+ {
+ //Connections hidden_sink->gateway->hidden_source
+ list.emplace_back(gatewaySourceNode, CF_UNKNOWN, 1);
+ }
+ }
+ }
-am_Error_e CAmRouter::cfPermutationsForPath(am_Route_s shortestRoute, std::vector<CAmRoutingNode*> resultNodesPath, std::vector<am_Route_s>& resultPath)
-{
- std::vector<am_Route_s> result;
- am_Error_e err = determineConnectionFormatsForPath(shortestRoute, resultNodesPath, result);
- if (err != E_UNKNOWN)
- {
- resultPath.insert(resultPath.end(), result.begin(), result.end());
+ void CAmRouter::getVerticesForNode(const CAmRoutingNode & node, CAmRoutingListVertices & list)
+ {
+ am_RoutingNodeData_s & nodeData = ((CAmRoutingNode*) &node)->getData();
+ if (nodeData.type == CAmNodeDataType::SOURCE)
+ {
+ getVerticesForSource(node, list);
+ }
+ else if (nodeData.type == CAmNodeDataType::SINK)
+ {
+ getVerticesForSink(node, list);
+ }
+ else if (nodeData.type == CAmNodeDataType::CONVERTER)
+ {
+ getVerticesForConverter(node, list);
+ }
+ else if (nodeData.type == CAmNodeDataType::GATEWAY)
+ {
+ getVerticesForGateway(node, list);
+ }
+ }
+
+ am_Error_e CAmRouter::determineConnectionFormatsForPath(am_Route_s & routeObjects, std::vector<CAmRoutingNode*> & nodes, std::vector<am_Route_s> & result)
+ {
+ std::vector<am_RoutingElement_s>::iterator routingElementIterator = routeObjects.route.begin();
+ std::vector<CAmRoutingNode*>::iterator nodeIterator = nodes.begin();
+ if (routingElementIterator != routeObjects.route.end() && nodeIterator != nodes.end())
+ return doConnectionFormatsForPath(routeObjects, nodes, routingElementIterator, nodeIterator, result);
+ return E_OK;
+ }
+
+ am_Error_e CAmRouter::doConnectionFormatsForPath(am_Route_s & routeObjects, std::vector<CAmRoutingNode*> & nodes,
+ std::vector<am_RoutingElement_s>::iterator routingElementIterator, std::vector<CAmRoutingNode*>::iterator nodeIterator,
+ std::vector<am_Route_s> & result)
+ {
+ am_Error_e returnError = E_NOT_POSSIBLE;
+ std::vector<am_CustomConnectionFormat_t> listConnectionFormats;
+ std::vector<am_CustomConnectionFormat_t> listMergeConnectionFormats;
+
+ std::vector<CAmRoutingNode*>::iterator currentNodeIterator = nodeIterator;
+ std::vector<am_RoutingElement_s>::iterator currentRoutingElementIterator = routingElementIterator;
+
+ if (currentRoutingElementIterator != routeObjects.route.begin())
+ {
+ std::vector<am_CustomConnectionFormat_t> listConnectionFormats;
+ std::vector<am_RoutingElement_s>::iterator tempIterator = (currentRoutingElementIterator - 1);
+ CAmRoutingNode * currentNode = *currentNodeIterator;
+ if ((returnError = getSourceSinkPossibleConnectionFormats(currentNodeIterator + 1, currentNodeIterator + 2, listConnectionFormats)) != E_OK)
+ return returnError;
+
+ if (currentNode->getData().type == CAmNodeDataType::GATEWAY)
+ {
+ am_Gateway_s *gateway = currentNode->getData().data.gateway;
+ getMergeConnectionFormats(gateway, tempIterator->connectionFormat, listConnectionFormats, listMergeConnectionFormats);
+ }
+ else if (currentNode->getData().type == CAmNodeDataType::CONVERTER)
+ {
+ am_Converter_s *converter = currentNode->getData().data.converter;
+ getMergeConnectionFormats(converter, tempIterator->connectionFormat, listConnectionFormats, listMergeConnectionFormats);
+ }
+ else
+ return (E_UNKNOWN);
+ currentNodeIterator += 3;
+ }
+ else
+ {
+ CAmRoutingNode * currentNode = *currentNodeIterator;
+ if (currentNode->getData().type != CAmNodeDataType::SOURCE)
+ return (E_UNKNOWN);
+ currentNodeIterator++;
+
+ if (currentNodeIterator == nodes.end())
+ return (E_UNKNOWN);
+
+ CAmRoutingNode * nodeSink = *currentNodeIterator;
+ if (nodeSink->getData().type != CAmNodeDataType::SINK)
+ return (E_UNKNOWN);
+
+ am_Source_s *source = currentNode->getData().data.source;
+ am_Sink_s *sink = nodeSink->getData().data.sink;
+ listPossibleConnectionFormats(source->listConnectionFormats, sink->listConnectionFormats, listMergeConnectionFormats);
+ currentNodeIterator += 1; //now we are on the next converter/gateway
+ }
+ //let the controller decide:
+ std::vector<am_CustomConnectionFormat_t> listPriorityConnectionFormats;
+ if ((returnError = mpControlSender->getConnectionFormatChoice(currentRoutingElementIterator->sourceID, currentRoutingElementIterator->sinkID,
+ routeObjects, listMergeConnectionFormats, listPriorityConnectionFormats)) != E_OK)
+ return (returnError);
+
+ if (listPriorityConnectionFormats.empty())
+ return (E_NOT_POSSIBLE);
+ //we have the list sorted after priors - now we try one after the other with the next part of the route
+ std::vector<am_CustomConnectionFormat_t>::iterator connectionFormatIterator = listPriorityConnectionFormats.begin();
+ //here we need to check if we are at the end and stop
+ std::vector<am_RoutingElement_s>::iterator nextIterator = currentRoutingElementIterator + 1; //next pair source and sink
+ if (nextIterator == routeObjects.route.end())
+ {
+ for (; connectionFormatIterator != listPriorityConnectionFormats.end(); ++connectionFormatIterator)
+ {
+ currentRoutingElementIterator->connectionFormat = *connectionFormatIterator;
+ result.push_back(routeObjects);
+ }
+ }
+ else
+ {
+ for (; connectionFormatIterator != listPriorityConnectionFormats.end(); ++connectionFormatIterator)
+ {
+ currentRoutingElementIterator->connectionFormat = *connectionFormatIterator;
+ doConnectionFormatsForPath(routeObjects, nodes, nextIterator, currentNodeIterator, result);
+ }
+ }
+ return (E_OK);
+ }
+
+ am_Error_e CAmRouter::cfPermutationsForPath(am_Route_s shortestRoute, std::vector<CAmRoutingNode*> resultNodesPath, std::vector<am_Route_s>& resultPath)
+ {
+ std::vector<am_Route_s> result;
+ am_Error_e err = determineConnectionFormatsForPath(shortestRoute, resultNodesPath, result);
+ if (err != E_UNKNOWN)
+ {
+ resultPath.insert(resultPath.end(), result.begin(), result.end());
#ifdef TRACE_GRAPH
- std::cout
- << "Determined connection formats for path from source:"
- << shortestRoute.sourceID << " to sink:" << shortestRoute.sinkID
- << "\n";
- for (auto routeConnectionFormats : result)
- {
- std::cout << "[";
- for (auto it = routeConnectionFormats.route.begin();it != routeConnectionFormats.route.end(); it++)
- {
- am_RoutingElement_s& routingElement = *it;
- if (it - routeConnectionFormats.route.begin() > 0)
- std::cout << " -> ";
-
- std::cout << routingElement.sourceID << ":"
- << routingElement.sinkID << " CF:"
- << routingElement.connectionFormat << " D:"
- << routingElement.domainID;
- }
- std::cout << "]\n";
- }
+ std::cout
+ << "Determined connection formats for path from source:"
+ << shortestRoute.sourceID << " to sink:" << shortestRoute.sinkID
+ << "\n";
+ for (auto routeConnectionFormats : result)
+ {
+ std::cout << "[";
+ for (auto it = routeConnectionFormats.route.begin();it != routeConnectionFormats.route.end(); it++)
+ {
+ am_RoutingElement_s& routingElement = *it;
+ if (it - routeConnectionFormats.route.begin() > 0)
+ std::cout << " -> ";
+
+ std::cout << routingElement.sourceID << ":"
+ << routingElement.sinkID << " CF:"
+ << routingElement.connectionFormat << " D:"
+ << routingElement.domainID;
+ }
+ std::cout << "]\n";
+ }
#endif
- }
+ }
#ifdef TRACE_GRAPH
- else
- {
- std::cout
- << "Error by determining connection formats for path from source:"
- << shortestRoute.sourceID << " to sink:" << shortestRoute.sinkID
- << "\n";
- }
+ else
+ {
+ std::cout
+ << "Error by determining connection formats for path from source:"
+ << shortestRoute.sourceID << " to sink:" << shortestRoute.sinkID
+ << "\n";
+ }
#endif
- return err;
-}
+ return err;
+ }
-am_Error_e CAmRouter::getShortestPath(CAmRoutingNode & aSource, CAmRoutingNode & aSink, std::vector<am_Route_s> & resultPath)
-{
- am_Error_e err = E_OK;
- am_Route_s shortestRoute;
- std::vector<CAmRoutingNode*> resultNodesPath;
- am_RoutingNodeData_s & sinkNodeData = aSink.getData();
- am_RoutingNodeData_s & sourceNodeData = aSource.getData();
- shortestRoute.sinkID = sinkNodeData.data.sink->sinkID;
- shortestRoute.sourceID = sourceNodeData.data.source->sourceID;
-
- mRoutingGraph.getShortestPath(aSource, aSink, [&shortestRoute, &resultNodesPath](const am_GraphPathPosition_e position, CAmRoutingNode & object){
- am_RoutingElement_s * element;
- //reverse order
- resultNodesPath.insert(resultNodesPath.begin(), (CAmRoutingNode*)&object);
- am_RoutingNodeData_s & routingData = object.getData();
- if(routingData.type==CAmNodeDataType::SINK)
- {
- auto iter = shortestRoute.route.emplace(shortestRoute.route.begin());
- element = &(*iter);
- element->domainID = routingData.data.sink->domainID;
- element->sinkID = routingData.data.sink->sinkID;
- element->connectionFormat = CF_UNKNOWN;
- }
- else if(routingData.type==CAmNodeDataType::SOURCE)
- {
- element->domainID = routingData.data.source->domainID;
- element->sourceID = routingData.data.source->sourceID;
- element->connectionFormat = CF_UNKNOWN;
- }
- });
-
- if(shortestRoute.route.size())
- {
- err = cfPermutationsForPath(shortestRoute, resultNodesPath, resultPath);
- }
- return err;
-}
+ am_Error_e CAmRouter::getShortestPath(CAmRoutingNode & aSource, CAmRoutingNode & aSink, std::vector<am_Route_s> & resultPath)
+ {
+ am_Error_e err = E_OK;
+ am_Route_s shortestRoute;
+ std::vector<CAmRoutingNode*> resultNodesPath;
+ am_RoutingNodeData_s & sinkNodeData = aSink.getData();
+ am_RoutingNodeData_s & sourceNodeData = aSource.getData();
+ shortestRoute.sinkID = sinkNodeData.data.sink->sinkID;
+ shortestRoute.sourceID = sourceNodeData.data.source->sourceID;
+
+ mRoutingGraph.getShortestPath(aSource, aSink, [&shortestRoute, &resultNodesPath](const am_GraphPathPosition_e position, CAmRoutingNode & object)
+ {
+ am_RoutingElement_s * element;
+ //reverse order
+ resultNodesPath.insert(resultNodesPath.begin(), (CAmRoutingNode*)&object);
+ am_RoutingNodeData_s & routingData = object.getData();
+ if(routingData.type==CAmNodeDataType::SINK)
+ {
+ auto iter = shortestRoute.route.emplace(shortestRoute.route.begin());
+ element = &(*iter);
+ element->domainID = routingData.data.sink->domainID;
+ element->sinkID = routingData.data.sink->sinkID;
+ element->connectionFormat = CF_UNKNOWN;
+ }
+ else if(routingData.type==CAmNodeDataType::SOURCE)
+ {
+ element->domainID = routingData.data.source->domainID;
+ element->sourceID = routingData.data.source->sourceID;
+ element->connectionFormat = CF_UNKNOWN;
+ }
+ });
+
+ if (shortestRoute.route.size())
+ {
+ err = cfPermutationsForPath(shortestRoute, resultNodesPath, resultPath);
+ }
+ return err;
+ }
-void CAmRouter::getShortestPath(CAmRoutingNode & aSource, CAmRoutingNode & aSink, am_Route_s & path, std::vector<CAmRoutingNode*> & resultNodesPath)
-{
- am_Route_s shortestRoute;
- am_RoutingNodeData_s & sinkNodeData = aSink.getData();
- am_RoutingNodeData_s & sourceNodeData = aSource.getData();
- shortestRoute.sinkID = sinkNodeData.data.sink->sinkID;
- shortestRoute.sourceID = sourceNodeData.data.source->sourceID;
-
- mRoutingGraph.getShortestPath(aSource, aSink, [&shortestRoute, &resultNodesPath](const am_GraphPathPosition_e position, CAmRoutingNode & object){
- am_RoutingElement_s * element;
- //reverse order
- resultNodesPath.insert(resultNodesPath.begin(), (CAmRoutingNode*)&object);
- am_RoutingNodeData_s & routingData = object.getData();
- if(routingData.type==CAmNodeDataType::SINK)
- {
- auto iter = shortestRoute.route.emplace(shortestRoute.route.begin());
- element = &(*iter);
- element->domainID = routingData.data.sink->domainID;
- element->sinkID = routingData.data.sink->sinkID;
- element->connectionFormat = CF_UNKNOWN;
- }
- else if(routingData.type==CAmNodeDataType::SOURCE)
- {
- element->domainID = routingData.data.source->domainID;
- element->sourceID = routingData.data.source->sourceID;
- element->connectionFormat = CF_UNKNOWN;
- }
- });
-
- if(shortestRoute.route.size())
- {
- std::vector<am_Route_s> resultPath;
- cfPermutationsForPath(shortestRoute, resultNodesPath, resultPath);
- if(resultPath.size())
- path = resultPath.front();
- }
-}
+ int CAmRouter::insertPostion(const std::vector<CAmRoutingNode*>& path, const std::vector<std::vector<CAmRoutingNode*> >& nodes)
+ {
+ int index = 0;
+ if (!nodes.empty())
+ {
+ auto itNodes = nodes.begin();
+ for (; itNodes != nodes.end(); itNodes++)
+ {
+ if (itNodes->size() > path.size())
+ break;
+ }
+ if (itNodes == nodes.end())
+ index = nodes.size();
+ else
+ index = itNodes - nodes.begin();
+ }
+ return index;
+ }
-int CAmRouter::insertPostion(const std::vector<CAmRoutingNode*>& path, const std::vector<std::vector<CAmRoutingNode*> >& nodes)
-{
- int index = 0;
- if (!nodes.empty()) {
- auto itNodes = nodes.begin();
- for (; itNodes != nodes.end(); itNodes++) {
- if (itNodes->size() > path.size())
- break;
- }
- if (itNodes == nodes.end())
- index = nodes.size();
- else
- index = itNodes - nodes.begin();
- }
- return index;
-}
+ am_Error_e CAmRouter::getFirstNShortestPaths(const bool onlyFree, const unsigned cycles, const unsigned maxPathCount, CAmRoutingNode & aSource,
+ CAmRoutingNode & aSink, std::vector<am_Route_s> & resultPath)
+ {
+ if (aSource.getData().type != CAmNodeDataType::SOURCE || aSink.getData().type != CAmNodeDataType::SINK)
+ return E_NOT_POSSIBLE;
+ const am_sinkID_t sinkID = aSink.getData().data.sink->sinkID;
+ const am_sourceID_t sourceID = aSource.getData().data.source->sourceID;
+ std::vector<am_Route_s> paths;
+ std::vector<std::vector<CAmRoutingNode*>> nodes;
+ std::vector<am_domainID_t> visitedDomains;
+ visitedDomains.push_back(((CAmRoutingNode*) &aSource)->getData().domainID());
+
+ auto cbShouldVisitNode = [&visitedDomains, &cycles, &onlyFree, this](const CAmRoutingNode * node)->bool
+ {
+ if(CAmRouter::shouldGoInDomain(visitedDomains, node->getData().domainID(), cycles))
+ {
+ const am_RoutingNodeData_s & nodeData = node->getData();
+ if(am_RoutingNodeData_s::GATEWAY==nodeData.type)
+ {
+ const am_Gateway_s * gateway = nodeData.data.gateway;
+ return (!onlyFree || !isComponentConnected(*gateway));
+ }
+ else if(am_RoutingNodeData_s::CONVERTER==nodeData.type)
+ {
+ const am_Converter_s * converter = nodeData.data.converter;
+ return (!onlyFree || !isComponentConnected(*converter));
+ }
+ return true;
+ }
+ return false;
+ };
+ auto cbWillVisitNode = [&visitedDomains](const CAmRoutingNode * node)
+ { visitedDomains.push_back(node->getData().domainID());};
+ auto cbDidVisitNode = [&visitedDomains](const CAmRoutingNode * node)
+ { visitedDomains.erase(visitedDomains.end()-1);};
+ auto cbDidFinish = [&resultPath, &nodes, &paths, &sinkID, &sourceID](const std::vector<CAmRoutingNode*> & path)
+ {
+ int index = CAmRouter::insertPostion(path, nodes);
+ nodes.emplace(nodes.begin()+index);
+ paths.emplace(paths.begin()+index);
+ nodes[index] = path;
+ am_Route_s & nextRoute = paths[index];
+ nextRoute.sinkID = sinkID;
+ nextRoute.sourceID = sourceID;
+ am_RoutingElement_s * element;
+ for(auto it = path.begin(); it!=path.end(); it++)
+ {
+ am_RoutingNodeData_s & routingData = (*it)->getData();
+ if(routingData.type==CAmNodeDataType::SOURCE)
+ {
+ auto iter = nextRoute.route.emplace(nextRoute.route.end());
+ element = &(*iter);
+ element->domainID = routingData.data.source->domainID;
+ element->sourceID = routingData.data.source->sourceID;
+ element->connectionFormat = CF_UNKNOWN;
+ }
+ else if(routingData.type==CAmNodeDataType::SINK)
+ {
+ element->domainID = routingData.data.sink->domainID;
+ element->sinkID = routingData.data.sink->sinkID;
+ element->connectionFormat = CF_UNKNOWN;
+ }
+ }
+ };
+
+ mRoutingGraph.getAllPaths(aSource, aSink, cbShouldVisitNode, cbWillVisitNode, cbDidVisitNode, cbDidFinish);
+ unsigned pathsFound = 0;
+ am_Error_e cfError = E_OK;
+ for (auto it = paths.begin(); pathsFound < maxPathCount && it != paths.end(); it++)
+ {
+ cfError = cfPermutationsForPath(*it, nodes[it - paths.begin()], resultPath);
+ if (E_OK == cfError)
+ {
+ pathsFound += (resultPath.size() > 0);
+ }
+ }
+ if (pathsFound)
+ return E_OK;
+ else
+ return E_NOT_POSSIBLE;
+ }
-am_Error_e CAmRouter::getAllPaths(CAmRoutingNode & aSource,
- CAmRoutingNode & aSink,
- std::vector<am_Route_s> & resultPath,
- std::vector<std::vector<CAmRoutingNode*>> & resultNodesPath,
- const bool includeCycles)
-{
+ bool CAmRouter::shouldGoInDomain(const std::vector<am_domainID_t> & visitedDomains, const am_domainID_t nodeDomainID, const unsigned maxCyclesNumber)
+ {
+ unsigned recourseCounter(0);
+ if (visitedDomains.size())
+ {
+ if (visitedDomains.back() == nodeDomainID)
+ return true;
+ unsigned count = 0;
+ am_domainID_t lastDomain = 0;
+ for (auto it = visitedDomains.begin(); it != visitedDomains.end() - 1; it++)
+ {
+ if (lastDomain != *it)
+ {
+ if (nodeDomainID == *it)
+ {
+ recourseCounter++;
+ if (recourseCounter > maxCyclesNumber)
+ return false;
+ }
+ lastDomain = *it;
+ }
+ }
+ }
+ return true;
+ }
- if( aSource.getData().type!=CAmNodeDataType::SOURCE || aSink.getData().type!=CAmNodeDataType::SINK )
- return E_NOT_POSSIBLE;
-
- unsigned cycles;
- if(includeCycles)
- cycles = UINT_MAX;
- else
- cycles = 0;
-
- uint8_t errorsCount = 0, successCount = 0;
- const am_sinkID_t sinkID = aSink.getData().data.sink->sinkID;
- const am_sourceID_t sourceID = aSource.getData().data.source->sourceID;
- std::vector<am_Route_s> paths;
- std::vector<am_domainID_t> visitedDomains;
- visitedDomains.push_back(((CAmRoutingNode*)&aSource)->getData().domainID());
- mRoutingGraph.getAllPaths(aSource,
- aSink,
- [&visitedDomains, &cycles](const CAmRoutingNode * node)->bool{ return CAmRouter::shouldGoInDomain(visitedDomains, node->getData().domainID(), cycles); },
- [&visitedDomains](const CAmRoutingNode * node){ visitedDomains.push_back(node->getData().domainID()); },
- [&visitedDomains](const CAmRoutingNode * node){ visitedDomains.erase(visitedDomains.end()-1); },
- [&resultPath, &resultNodesPath, &paths, &errorsCount, &successCount, &sinkID, &sourceID](const std::vector<CAmRoutingNode*> & path) {
- int index = CAmRouter::insertPostion(path, resultNodesPath);
- resultNodesPath.emplace(resultNodesPath.begin()+index);
- paths.emplace(paths.begin()+index);
- resultNodesPath[index] = path;
- am_Route_s & nextRoute = paths[index];
- nextRoute.sinkID = sinkID;
- nextRoute.sourceID = sourceID;
- am_RoutingElement_s * element;
- for(auto it = path.begin(); it!=path.end(); it++)
- {
- am_RoutingNodeData_s & routingData = (*it)->getData();
- if(routingData.type==CAmNodeDataType::SOURCE)
- {
- auto iter = nextRoute.route.emplace(nextRoute.route.end());
- element = &(*iter);
- element->domainID = routingData.data.source->domainID;
- element->sourceID = routingData.data.source->sourceID;
- element->connectionFormat = CF_UNKNOWN;
- }
- else if(routingData.type==CAmNodeDataType::SINK)
- {
- element->domainID = routingData.data.sink->domainID;
- element->sinkID = routingData.data.sink->sinkID;
- element->connectionFormat = CF_UNKNOWN;
- }
- }
- });
-
- for(auto it = paths.begin(); successCount<mMaxPathCount && it!=paths.end(); it++)
- {
- if(cfPermutationsForPath(*it, resultNodesPath[it-paths.begin()], resultPath)==E_UNKNOWN)
- errorsCount++;
- else
- successCount++;
- }
-
- if(successCount)
- return E_OK;
- if(errorsCount)
- return E_NOT_POSSIBLE;
- return E_OK;
-}
+ bool CAmRouter::shouldGoInDomain(const std::vector<am_domainID_t> & visitedDomains, const am_domainID_t nodeDomainID)
+ {
+ return CAmRouter::shouldGoInDomain(visitedDomains, nodeDomainID, mMaxAllowedCycles);
+ }
-am_Error_e CAmRouter::getFirstNShortestPaths(CAmRoutingNode & aSource, CAmRoutingNode & aSink, std::vector<am_Route_s> & resultPath)
-{
- if( aSource.getData().type!=CAmNodeDataType::SOURCE || aSink.getData().type!=CAmNodeDataType::SINK )
- return E_NOT_POSSIBLE;
- const unsigned cycles = mMaxAllowedCycles;
- const am_sinkID_t sinkID = aSink.getData().data.sink->sinkID;
- const am_sourceID_t sourceID = aSource.getData().data.source->sourceID;
- std::vector<am_Route_s> paths;
- std::vector<std::vector<CAmRoutingNode*>> nodes;
- std::vector<am_domainID_t> visitedDomains;
- visitedDomains.push_back(((CAmRoutingNode*)&aSource)->getData().domainID());
- mRoutingGraph.getAllPaths(aSource,
- aSink,
- [&visitedDomains, &cycles](const CAmRoutingNode * node)->bool{ return CAmRouter::shouldGoInDomain(visitedDomains, node->getData().domainID(), cycles); },
- [&visitedDomains](const CAmRoutingNode * node){ visitedDomains.push_back(node->getData().domainID()); },
- [&visitedDomains](const CAmRoutingNode * node){ visitedDomains.erase(visitedDomains.end()-1); },
- [&resultPath, &nodes, &paths, &sinkID, &sourceID](const std::vector<CAmRoutingNode*> & path) {
- int index = CAmRouter::insertPostion(path, nodes);
- nodes.emplace(nodes.begin()+index);
- paths.emplace(paths.begin()+index);
- nodes[index] = path;
- am_Route_s & nextRoute = paths[index];
- nextRoute.sinkID = sinkID;
- nextRoute.sourceID = sourceID;
- am_RoutingElement_s * element;
- for(auto it = path.begin(); it!=path.end(); it++)
- {
- am_RoutingNodeData_s & routingData = (*it)->getData();
- if(routingData.type==CAmNodeDataType::SOURCE)
- {
- auto iter = nextRoute.route.emplace(nextRoute.route.end());
- element = &(*iter);
- element->domainID = routingData.data.source->domainID;
- element->sourceID = routingData.data.source->sourceID;
- element->connectionFormat = CF_UNKNOWN;
- }
- else if(routingData.type==CAmNodeDataType::SINK)
- {
- element->domainID = routingData.data.sink->domainID;
- element->sinkID = routingData.data.sink->sinkID;
- element->connectionFormat = CF_UNKNOWN;
- }
- }
- });
- unsigned pathsFound = 0;
- am_Error_e cfError = E_OK;
- for(auto it = paths.begin(); pathsFound<mMaxPathCount && it!=paths.end(); it++)
- {
- cfError = cfPermutationsForPath(*it, nodes[it-paths.begin()], resultPath);
- if(E_OK==cfError)
- {
- pathsFound += (resultPath.size()>0);
- }
- }
- if(pathsFound)
- return E_OK;
- else
- return E_NOT_POSSIBLE;
-}
+ bool CAmRouter::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)
+ {
+ const size_t sizeSourceFormats = listSourceFormats.size();
+ const size_t sizeSinkFormats = listSinkFormats.size();
+ const size_t sizeConvertionMatrix = convertionMatrix.size();
-bool CAmRouter::shouldGoInDomain(const std::vector<am_domainID_t> & visitedDomains, const am_domainID_t nodeDomainID, const unsigned maxCyclesNumber)
-{
- unsigned recourseCounter(0);
- if(visitedDomains.size())
- {
- if(visitedDomains.back()==nodeDomainID)
- return true;
- unsigned count = 0;
- am_domainID_t lastDomain = 0;
- for(auto it=visitedDomains.begin(); it!=visitedDomains.end()-1; it++)
- {
- if(lastDomain!=*it)
- {
- if(nodeDomainID==*it)
- {
- recourseCounter++;
- if (recourseCounter>maxCyclesNumber)
- return false;
- }
- lastDomain=*it;
- }
- }
- }
- return true;
-}
+ if (sizeSourceFormats == 0 || sizeSinkFormats == 0 || sizeConvertionMatrix == 0 || sizeConvertionMatrix != sizeSinkFormats * sizeSourceFormats)
+ {
+ return false;
+ }
-bool CAmRouter::shouldGoInDomain(const std::vector<am_domainID_t> & visitedDomains, const am_domainID_t nodeDomainID)
-{
- return CAmRouter::shouldGoInDomain(visitedDomains, nodeDomainID, mMaxAllowedCycles);
-}
+ std::vector<bool>::const_iterator iterator = convertionMatrix.begin();
+ for (; iterator != convertionMatrix.end(); ++iterator)
+ {
+ if (true == *iterator)
+ {
+ const size_t index = iterator - convertionMatrix.begin();
+ size_t idx = index % sizeSourceFormats;
+ sourceFormats.push_back(listSourceFormats.at(idx));
+ idx = index / sizeSourceFormats;
+ sinkFormats.push_back(listSinkFormats.at(idx));
+ }
+ }
+ return sourceFormats.size() > 0;
+ }
-bool CAmRouter::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)
-{
- const size_t sizeSourceFormats = listSourceFormats.size();
- const size_t sizeSinkFormats = listSinkFormats.size();
- const size_t sizeConvertionMatrix = convertionMatrix.size();
-
- if(sizeSourceFormats==0||sizeSinkFormats==0||sizeConvertionMatrix==0||sizeConvertionMatrix!=sizeSinkFormats*sizeSourceFormats)
- {
- return false;
- }
-
- std::vector<bool>::const_iterator iterator = convertionMatrix.begin();
- for (; iterator != convertionMatrix.end(); ++iterator)
- {
- if( true == *iterator )
- {
- const size_t index = iterator-convertionMatrix.begin();
- size_t idx = index%sizeSourceFormats;
- sourceFormats.push_back(listSourceFormats.at(idx));
- idx = index/sizeSourceFormats;
- sinkFormats.push_back(listSinkFormats.at(idx));
- }
- }
- return sourceFormats.size()>0;
-}
+ void CAmRouter::listPossibleConnectionFormats(std::vector<am_CustomConnectionFormat_t> & inListSourceFormats,
+ std::vector<am_CustomConnectionFormat_t> & inListSinkFormats, std::vector<am_CustomConnectionFormat_t> & outListFormats)
+ {
+ std::sort(inListSourceFormats.begin(), inListSourceFormats.end());
+ std::sort(inListSinkFormats.begin(), inListSinkFormats.end());
+ std::insert_iterator<std::vector<am_CustomConnectionFormat_t> > inserter(outListFormats, outListFormats.begin());
+ set_intersection(inListSourceFormats.begin(), inListSourceFormats.end(), inListSinkFormats.begin(), inListSinkFormats.end(), inserter);
+ }
-void CAmRouter::listPossibleConnectionFormats(std::vector<am_CustomConnectionFormat_t> & inListSourceFormats,
- std::vector<am_CustomConnectionFormat_t> & inListSinkFormats,
- std::vector<am_CustomConnectionFormat_t> & outListFormats)
-{
- std::sort(inListSourceFormats.begin(), inListSourceFormats.end());
- std::sort(inListSinkFormats.begin(), inListSinkFormats.end());
- std::insert_iterator<std::vector<am_CustomConnectionFormat_t> > inserter(outListFormats, outListFormats.begin());
- set_intersection(inListSourceFormats.begin(), inListSourceFormats.end(), inListSinkFormats.begin(), inListSinkFormats.end(), inserter);
-}
+ bool CAmRouter::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)
+ {
+ listFormats.clear();
+ std::vector<am_CustomConnectionFormat_t>::const_iterator rowSinkIterator = listSinkFormats.begin();
+ std::vector<bool>::const_iterator matrixIterator = convertionMatrix.begin();
+ //find the row number of the sink
+ rowSinkIterator = find(listSinkFormats.begin(), listSinkFormats.end(), connectionFormat);
+ int rowNumberSink = rowSinkIterator - listSinkFormats.begin();
-bool CAmRouter::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)
-{
- listFormats.clear();
- std::vector<am_CustomConnectionFormat_t>::const_iterator rowSinkIterator = listSinkFormats.begin();
- std::vector<bool>::const_iterator matrixIterator = convertionMatrix.begin();
+ //go through the convertionMatrix and find out if the conversion is possible, if yes, add connectionFormat ...
+ std::advance(matrixIterator, rowNumberSink);
- //find the row number of the sink
- rowSinkIterator = find(listSinkFormats.begin(), listSinkFormats.end(), connectionFormat);
- int rowNumberSink = rowSinkIterator - listSinkFormats.begin();
+ //iterate line-wise through the matrix and add more formats
+ do
+ {
+ if (*matrixIterator)
+ {
+ listFormats.push_back(listSourceFormats.at((matrixIterator - convertionMatrix.begin()) / listSinkFormats.size()));
+ }
+ std::advance(matrixIterator, listSinkFormats.size());
+ } while (convertionMatrix.end() - matrixIterator > 0);
+
+ return listFormats.size();
+ }
- //go through the convertionMatrix and find out if the conversion is possible, if yes, add connectionFormat ...
- std::advance(matrixIterator, rowNumberSink);
+ am_Error_e CAmRouter::getSourceSinkPossibleConnectionFormats(std::vector<CAmRoutingNode*>::iterator iteratorSource,
+ std::vector<CAmRoutingNode*>::iterator iteratorSink, std::vector<am_CustomConnectionFormat_t> & outConnectionFormats)
+ {
+ CAmRoutingNode * nodeSink = *iteratorSink;
+ if (nodeSink->getData().type != CAmNodeDataType::SINK)
+ return (E_UNKNOWN);
+
+ CAmRoutingNode * nodeSource = *iteratorSource;
+ if (nodeSource->getData().type != CAmNodeDataType::SOURCE)
+ return (E_UNKNOWN);
+
+ am_Source_s *source = nodeSource->getData().data.source;
+ am_Sink_s *sink = nodeSink->getData().data.sink;
+ listPossibleConnectionFormats(source->listConnectionFormats, sink->listConnectionFormats, outConnectionFormats);
+ return (E_OK);
+ }
- //iterate line-wise through the matrix and add more formats
- do
+ am_Error_e CAmRouter::getAllPaths(CAmRoutingNode & aSource, CAmRoutingNode & aSink, std::vector<am_Route_s> & resultPath,
+ std::vector<std::vector<CAmRoutingNode*>> & resultNodesPath, const bool includeCycles, const bool onlyFree)
{
- if (*matrixIterator)
+
+ if (aSource.getData().type != CAmNodeDataType::SOURCE || aSink.getData().type != CAmNodeDataType::SINK)
+ return E_NOT_POSSIBLE;
+
+ unsigned cycles;
+ if (includeCycles)
+ cycles = UINT_MAX;
+ else
+ cycles = 0;
+
+ uint8_t errorsCount = 0, successCount = 0;
+ const am_sinkID_t sinkID = aSink.getData().data.sink->sinkID;
+ const am_sourceID_t sourceID = aSource.getData().data.source->sourceID;
+ std::vector<am_Route_s> paths;
+ std::vector<am_domainID_t> visitedDomains;
+ visitedDomains.push_back(((CAmRoutingNode*) &aSource)->getData().domainID());
+ mRoutingGraph.getAllPaths(aSource, aSink, [&visitedDomains, &cycles, &onlyFree, this](const CAmRoutingNode * node)->bool
+ {
+ if(CAmRouter::shouldGoInDomain(visitedDomains, node->getData().domainID(), cycles))
+ {
+ const am_RoutingNodeData_s & nodeData = node->getData();
+ if(am_RoutingNodeData_s::GATEWAY==nodeData.type)
+ {
+ const am_Gateway_s * gateway = nodeData.data.gateway;
+ return (!onlyFree || !isComponentConnected(*gateway));
+ }
+ else if(am_RoutingNodeData_s::CONVERTER==nodeData.type)
+ {
+ const am_Converter_s * converter = nodeData.data.converter;
+ return (!onlyFree || !isComponentConnected(*converter));
+ }
+ return true;
+ }
+ return false;
+ }, [&visitedDomains](const CAmRoutingNode * node)
+ {
+ visitedDomains.push_back(node->getData().domainID());
+ }, [&visitedDomains](const CAmRoutingNode * node)
+ { visitedDomains.erase(visitedDomains.end()-1);},
+ [&resultPath, &resultNodesPath, &paths, &errorsCount, &successCount, &sinkID, &sourceID](const std::vector<CAmRoutingNode*> & path)
+ {
+ int index = CAmRouter::insertPostion(path, resultNodesPath);
+ resultNodesPath.emplace(resultNodesPath.begin()+index);
+ paths.emplace(paths.begin()+index);
+ resultNodesPath[index] = path;
+ am_Route_s & nextRoute = paths[index];
+ nextRoute.sinkID = sinkID;
+ nextRoute.sourceID = sourceID;
+ am_RoutingElement_s * element;
+ for(auto it = path.begin(); it!=path.end(); it++)
+ {
+ am_RoutingNodeData_s & routingData = (*it)->getData();
+ if(routingData.type==CAmNodeDataType::SOURCE)
+ {
+ auto iter = nextRoute.route.emplace(nextRoute.route.end());
+ element = &(*iter);
+ element->domainID = routingData.data.source->domainID;
+ element->sourceID = routingData.data.source->sourceID;
+ element->connectionFormat = CF_UNKNOWN;
+ }
+ else if(routingData.type==CAmNodeDataType::SINK)
+ {
+ element->domainID = routingData.data.sink->domainID;
+ element->sinkID = routingData.data.sink->sinkID;
+ element->connectionFormat = CF_UNKNOWN;
+ }
+ }
+ });
+
+ for (auto it = paths.begin(); successCount < mMaxPathCount && it != paths.end(); it++)
{
- listFormats.push_back(listSourceFormats.at((matrixIterator - convertionMatrix.begin()) / listSinkFormats.size()));
+ if (cfPermutationsForPath(*it, resultNodesPath[it - paths.begin()], resultPath) == E_UNKNOWN)
+ errorsCount++;
+ else
+ successCount++;
}
- std::advance(matrixIterator, listSinkFormats.size());
- } while (convertionMatrix.end() - matrixIterator > 0);
-
- return listFormats.size();
-}
-
-
-am_Error_e CAmRouter::getSourceSinkPossibleConnectionFormats(std::vector<CAmRoutingNode*>::iterator iteratorSource,
- std::vector<CAmRoutingNode*>::iterator iteratorSink,
- std::vector<am_CustomConnectionFormat_t> & outConnectionFormats)
-{
- CAmRoutingNode * nodeSink = *iteratorSink;
- if(nodeSink->getData().type!=CAmNodeDataType::SINK)
- return (E_UNKNOWN);
-
- CAmRoutingNode * nodeSource = *iteratorSource;
- if(nodeSource->getData().type!=CAmNodeDataType::SOURCE)
- return (E_UNKNOWN);
-
- am_Source_s *source = nodeSource->getData().data.source;
- am_Sink_s *sink = nodeSink->getData().data.sink;
- listPossibleConnectionFormats(source->listConnectionFormats, sink->listConnectionFormats, outConnectionFormats);
- return (E_OK);
-}
+ if (successCount)
+ return E_OK;
+ if (errorsCount)
+ return E_NOT_POSSIBLE;
+ return E_OK;
+ }
}
diff --git a/AudioManagerCore/test/AmRouterMapTest/CAmRouterMapTest.cpp b/AudioManagerCore/test/AmRouterMapTest/CAmRouterMapTest.cpp
index fbba011..11d8c3c 100644
--- a/AudioManagerCore/test/AmRouterMapTest/CAmRouterMapTest.cpp
+++ b/AudioManagerCore/test/AmRouterMapTest/CAmRouterMapTest.cpp
@@ -27,32 +27,32 @@
#include "CAmDltWrapper.h"
#include "CAmCommandLineSingleton.h"
-TCLAP::SwitchArg enableDebug ("V","logDlt","print DLT logs to stdout or dlt-daemon default off",false);
-
+TCLAP::SwitchArg enableDebug("V", "logDlt", "print DLT logs to stdout or dlt-daemon default off", false);
using namespace am;
using namespace testing;
CAmRouterMapTest::CAmRouterMapTest() :
- plistRoutingPluginDirs(), //
- plistCommandPluginDirs(), //
- pSocketHandler(), //
- pControlSender(), //
- pDatabaseHandler(),
- pRouter(&pDatabaseHandler, &pControlSender), //
- pRoutingSender(plistRoutingPluginDirs,dynamic_cast<IAmDatabaseHandler*>( &pDatabaseHandler )), //
- pCommandSender(plistCommandPluginDirs, &pSocketHandler), //
- pMockInterface(), //
- pMockControlInterface(), //
- pRoutingInterfaceBackdoor(), //
- pCommandInterfaceBackdoor(), //
- pControlInterfaceBackdoor(), //
- pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender,&pSocketHandler, &pRouter)
+ plistRoutingPluginDirs(), //
+ plistCommandPluginDirs(), //
+ pSocketHandler(), //
+ pControlSender(), //
+ pDatabaseHandler(),
+ pRouter(&pDatabaseHandler, &pControlSender), //
+ pRoutingSender(plistRoutingPluginDirs, dynamic_cast<IAmDatabaseHandler*>(&pDatabaseHandler)), //
+ pCommandSender(plistCommandPluginDirs, &pSocketHandler), //
+ pMockInterface(), //
+ pMockControlInterface(), //
+ pRoutingInterfaceBackdoor(), //
+ pCommandInterfaceBackdoor(), //
+ pControlInterfaceBackdoor(), //
+ pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pSocketHandler, &pRouter)
{
- pDatabaseHandler.registerObserver(&pRoutingSender);
- pDatabaseHandler.registerObserver(&pCommandSender);
- pCommandInterfaceBackdoor.injectInterface(&pCommandSender, &pMockInterface);
- pControlInterfaceBackdoor.replaceController(&pControlSender, &pMockControlInterface);
+ pDatabaseHandler.registerObserver(&pRoutingSender);
+ pDatabaseHandler.registerObserver(&pCommandSender);
+ pDatabaseHandler.registerObserver(&pRouter);
+ pCommandInterfaceBackdoor.injectInterface(&pCommandSender, &pMockInterface);
+ pControlInterfaceBackdoor.replaceController(&pControlSender, &pMockControlInterface);
}
CAmRouterMapTest::~CAmRouterMapTest()
@@ -62,22 +62,22 @@ CAmRouterMapTest::~CAmRouterMapTest()
void CAmRouterMapTest::SetUp()
{
- logInfo("Routing Test started ");
- am_Domain_s domain;
- pCF.createDomain(domain);
+ logInfo("Routing Test started ");
+ am_Domain_s domain;
+ pCF.createDomain(domain);
am_domainID_t forgetDomain;
am_sinkClass_t forgetSinkClassID;
am_SinkClass_s sinkClass;
- sinkClass.name="TestSinkClass";
- sinkClass.sinkClassID=1;
+ sinkClass.name = "TestSinkClass";
+ sinkClass.sinkClassID = 1;
am_sourceClass_t forgetSourceClassID;
am_SourceClass_s sourceClass;
- sourceClass.name="TestSourceClass";
- sourceClass.sourceClassID=1;
- domain.domainID=4;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,forgetDomain));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,forgetSinkClassID));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(forgetSourceClassID,sourceClass));
+ sourceClass.name = "TestSourceClass";
+ sourceClass.sourceClassID = 1;
+ domain.domainID = 4;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain, forgetDomain));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass, forgetSinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(forgetSourceClassID, sourceClass));
}
void CAmRouterMapTest::TearDown()
@@ -85,161 +85,146 @@ void CAmRouterMapTest::TearDown()
}
ACTION(returnConnectionFormat){
- arg4=arg3;
+arg4=arg3;
}
void CAmRouterMapTest::enterDomainDB(const std::string & domainName, am_domainID_t & domainID)
{
- am_Domain_s domain1;
- domain1.domainID = 0;
- domain1.name = domainName;
- domain1.busname = "domain1bus";
- domain1.state = DS_CONTROLLED;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID));
+ am_Domain_s domain1;
+ domain1.domainID = 0;
+ domain1.name = domainName;
+ domain1.busname = "domain1bus";
+ domain1.state = DS_CONTROLLED;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1, domainID));
}
-void CAmRouterMapTest::enterSourceDB(const std::string & sourceName, const am_domainID_t domainID, const std::vector<am_CustomConnectionFormat_t> & connectionFormats, am_sourceID_t & sourceID)
+void CAmRouterMapTest::enterSourceDB(const std::string & sourceName, const am_domainID_t domainID,
+ const std::vector<am_CustomConnectionFormat_t> & connectionFormats, am_sourceID_t & sourceID)
{
- am_Source_s source;
- source.domainID = domainID;
- source.name = sourceName;
- source.sourceState = SS_ON;
- source.sourceID = 0;
- source.sourceClassID = 5;
- source.listConnectionFormats = connectionFormats;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+ am_Source_s source;
+ source.domainID = domainID;
+ source.name = sourceName;
+ source.sourceState = SS_ON;
+ source.sourceID = 0;
+ source.sourceClassID = 5;
+ source.listConnectionFormats = connectionFormats;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, sourceID));
}
-void CAmRouterMapTest::enterSinkDB(const std::string & sinkName, const am_domainID_t domainID, const std::vector<am_CustomConnectionFormat_t> & connectionFormats, am_sinkID_t & sinkID)
+void CAmRouterMapTest::enterSinkDB(const std::string & sinkName, const am_domainID_t domainID,
+ const std::vector<am_CustomConnectionFormat_t> & connectionFormats, am_sinkID_t & sinkID)
{
- am_Sink_s sink;
- sink.domainID = domainID;
- sink.name = sinkName;
- sink.sinkID = 0;
- sink.sinkClassID = 5;
- sink.muteState = MS_MUTED;
- sink.listConnectionFormats = connectionFormats;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+ am_Sink_s sink;
+ sink.domainID = domainID;
+ sink.name = sinkName;
+ sink.sinkID = 0;
+ sink.sinkClassID = 5;
+ sink.muteState = MS_MUTED;
+ sink.listConnectionFormats = connectionFormats;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, sinkID));
}
-void CAmRouterMapTest::enterGatewayDB(const std::string & gwName,
- const am_domainID_t domainSourceID,
- const am_domainID_t domainSinkID,
- const std::vector<am_CustomConnectionFormat_t> & sourceConnectionFormats,
- const std::vector<am_CustomConnectionFormat_t> & sinkConnectionFormats,
- const std::vector<bool> & matrix,
- const am_sourceID_t & sourceID,
- const am_sinkID_t & sinkID,
- am_gatewayID_t & gatewayID)
+void CAmRouterMapTest::enterGatewayDB(const std::string & gwName, const am_domainID_t domainSourceID, const am_domainID_t domainSinkID,
+ const std::vector<am_CustomConnectionFormat_t> & sourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t> & sinkConnectionFormats,
+ const std::vector<bool> & matrix, const am_sourceID_t & sourceID, const am_sinkID_t & sinkID, am_gatewayID_t & gatewayID)
{
- am_Gateway_s gateway;
- gateway.controlDomainID = domainSourceID;
- gateway.gatewayID = 0;
- gateway.sinkID = sinkID;
- gateway.sourceID = sourceID;
- gateway.domainSourceID = domainSourceID;
- gateway.domainSinkID = domainSinkID;
- gateway.listSinkFormats = sinkConnectionFormats;
- gateway.listSourceFormats = sourceConnectionFormats;
- gateway.convertionMatrix = matrix;
- gateway.name = gwName;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
+ am_Gateway_s gateway;
+ gateway.controlDomainID = domainSourceID;
+ gateway.gatewayID = 0;
+ gateway.sinkID = sinkID;
+ gateway.sourceID = sourceID;
+ gateway.domainSourceID = domainSourceID;
+ gateway.domainSinkID = domainSinkID;
+ gateway.listSinkFormats = sinkConnectionFormats;
+ gateway.listSourceFormats = sourceConnectionFormats;
+ gateway.convertionMatrix = matrix;
+ gateway.name = gwName;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway, gatewayID));
}
-void CAmRouterMapTest::enterConverterDB(const std::string & gwName,
- const am_domainID_t domainID,
- const std::vector<am_CustomConnectionFormat_t> & sourceConnectionFormats,
- const std::vector<am_CustomConnectionFormat_t> & sinkConnectionFormats,
- const std::vector<bool> & matrix,
- const am_sourceID_t & sourceID,
- const am_sinkID_t & sinkID,
- am_converterID_t & converterID)
+void CAmRouterMapTest::enterConverterDB(const std::string & gwName, const am_domainID_t domainID,
+ const std::vector<am_CustomConnectionFormat_t> & sourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t> & sinkConnectionFormats,
+ const std::vector<bool> & matrix, const am_sourceID_t & sourceID, const am_sinkID_t & sinkID, am_converterID_t & converterID)
{
- am_Converter_s converter;
- converter.converterID = 0;
- converter.sinkID = sinkID;
- converter.sourceID = sourceID;
- converter.domainID = domainID;
- converter.listSinkFormats = sinkConnectionFormats;
- converter.listSourceFormats = sourceConnectionFormats;
- converter.convertionMatrix = matrix;
- converter.name = gwName;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterConverterDB(converter,converterID));
+ am_Converter_s converter;
+ converter.converterID = 0;
+ converter.sinkID = sinkID;
+ converter.sourceID = sourceID;
+ converter.domainID = domainID;
+ converter.listSinkFormats = sinkConnectionFormats;
+ converter.listSourceFormats = sourceConnectionFormats;
+ converter.convertionMatrix = matrix;
+ converter.name = gwName;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterConverterDB(converter, converterID));
}
-am_Error_e CAmRouterMapTest::getRoute(const bool onlyfree, const bool shouldReload, const am_Source_s & aSource, const am_Sink_s & aSink, std::vector<am_Route_s> & listRoutes, const unsigned countCycles, const unsigned pathsCount)
+am_Error_e CAmRouterMapTest::getRoute(const bool onlyfree, const bool shouldReload, const am_Source_s & aSource, const am_Sink_s & aSink,
+ std::vector<am_Route_s> & listRoutes, const unsigned countCycles, const unsigned pathsCount)
{
- pRouter.setMaxAllowedCycles(countCycles);
- pRouter.setMaxPathCount(pathsCount);
- std::ios_base::fmtflags oldflags = std::cout.flags();
- std::streamsize oldprecision = std::cout.precision();
- auto t_start = std::chrono::high_resolution_clock::now();
- if(shouldReload)
- pRouter.load(onlyfree);
- am_Error_e error = pRouter.getRouteFromLoadedNodes(aSource, aSink, listRoutes);
- auto t_end = std::chrono::high_resolution_clock::now();
- std::cout << std::fixed << std::setprecision(2);
- std::cout << listRoutes.size() <<" routes from " << aSource.sourceID << " to " << aSink.sinkID;
- std::cout << " in " << std::chrono::duration<double, std::milli>(t_end-t_start).count() << " ms\n";
- std::cout.flags (oldflags);
- std::cout.precision (oldprecision);
- return error;
+ return getRoute(onlyfree, shouldReload, aSource.sourceID, aSink.sinkID, listRoutes, countCycles, pathsCount);
}
-am_Error_e CAmRouterMapTest::getRoute(const bool onlyfree, const bool shouldReload, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s>& returnList, const unsigned countCycles, const unsigned pathsCount)
+am_Error_e CAmRouterMapTest::getRoute(const bool onlyfree, const bool shouldReload, const am_sourceID_t sourceID, const am_sinkID_t sinkID,
+ std::vector<am_Route_s>& returnList, const unsigned countCycles, const unsigned pathsCount)
{
- pRouter.setMaxAllowedCycles(countCycles);
- pRouter.setMaxPathCount(pathsCount);
- std::ios_base::fmtflags oldflags = std::cout.flags();
- std::streamsize oldprecision = std::cout.precision();
- auto t_start = std::chrono::high_resolution_clock::now();
- if(shouldReload)
- pRouter.load(onlyfree);
- am_Error_e error = pRouter.getRouteFromLoadedNodes(sourceID, sinkID, returnList);
- auto t_end = std::chrono::high_resolution_clock::now();
- std::cout << std::fixed << std::setprecision(2);
- std::cout << returnList.size() <<" routes from " << sourceID << " to " << sinkID;
- std::cout << " in " << std::chrono::duration<double, std::milli>(t_end-t_start).count() << " ms\n";
- std::cout.flags (oldflags);
- std::cout.precision (oldprecision);
- return error;
+ pRouter.setMaxAllowedCycles(countCycles);
+ pRouter.setMaxPathCount(pathsCount);
+ std::ios_base::fmtflags oldflags = std::cout.flags();
+ std::streamsize oldprecision = std::cout.precision();
+ auto t_start = std::chrono::high_resolution_clock::now();
+ if (shouldReload)
+ pRouter.load();
+
+ am_Error_e error = pRouter.getRoute(onlyfree, sourceID, sinkID, returnList);
+ auto t_end = std::chrono::high_resolution_clock::now();
+ std::cout << std::fixed << std::setprecision(2);
+ std::cout << returnList.size() << " routes from " << sourceID << " to " << sinkID;
+ std::cout << " in " << std::chrono::duration<double, std::milli>(t_end - t_start).count() << " ms\n";
+ std::cout.flags(oldflags);
+ std::cout.precision(oldprecision);
+ return error;
}
-am_Error_e CAmRouterMapTest::getAllPaths(CAmRoutingNode & aSource, CAmRoutingNode & aSink, std::vector<am_Route_s> & resultPath, const unsigned countCycles, const unsigned pathsCount)
+am_Error_e CAmRouterMapTest::getAllPaths(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s> & resultPath,
+ const unsigned countCycles, const unsigned pathsCount)
{
- pRouter.setMaxAllowedCycles(countCycles);
- pRouter.setMaxPathCount(pathsCount);
- std::ios_base::fmtflags oldflags = std::cout.flags();
- std::streamsize oldprecision = std::cout.precision();
- auto t_start = std::chrono::high_resolution_clock::now();
- am_Error_e error = pRouter.getFirstNShortestPaths(aSource, aSink, resultPath);
- auto t_end = std::chrono::high_resolution_clock::now();
- std::cout << std::fixed << std::setprecision(2);
- std::cout << resultPath.size()
- << " routes from " << aSource.getData().data.source->sourceID
- << " to " << aSink.getData().data.sink->sinkID;
- std::cout << " in " << std::chrono::duration<double, std::milli>(t_end-t_start).count() << " ms\n";
- std::cout.flags (oldflags);
- std::cout.precision (oldprecision);
- return error;
+ std::ios_base::fmtflags oldflags = std::cout.flags();
+ std::streamsize oldprecision = std::cout.precision();
+ auto t_start = std::chrono::high_resolution_clock::now();
+ if (pRouter.getUpdateGraphNodesAction())
+ pRouter.load();
+ CAmRoutingNode* sourceNode = pRouter.sourceNodeWithID(sourceID);
+ CAmRoutingNode* sinkNode = pRouter.sinkNodeWithID(sinkID);
+
+ if (!sourceNode || !sinkNode)
+ return E_NON_EXISTENT;
+
+ am_Error_e error = pRouter.getFirstNShortestPaths(onlyfree, countCycles, pathsCount, *sourceNode, *sinkNode, resultPath);
+ auto t_end = std::chrono::high_resolution_clock::now();
+ std::cout << std::fixed << std::setprecision(2);
+ std::cout << resultPath.size() << " routes from " << sourceNode->getData().data.source->sourceID << " to " << sinkNode->getData().data.sink->sinkID;
+ std::cout << " in " << std::chrono::duration<double, std::milli>(t_end - t_start).count() << " ms\n";
+ std::cout.flags(oldflags);
+ std::cout.precision(oldprecision);
+ return error;
}
TEST_F(CAmRouterMapTest,checkInsertedDomain)
{
- std::vector<am_domainID_t> domains;
- ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 22, 0));
- domains.push_back(22);
- ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 22, 0));
- domains.push_back(22);
- ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 22, 0));
- ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 50, 0));
- domains.push_back(30);
- ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 30, 0));
- ASSERT_FALSE(CAmRouter::shouldGoInDomain(domains, 22, 0));
- domains.push_back(30);
- ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 30, 0));
- ASSERT_FALSE(CAmRouter::shouldGoInDomain(domains, 22, 0));
- ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 60, 0));
+ std::vector<am_domainID_t> domains;
+ ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 22, 0));
+ domains.push_back(22);
+ ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 22, 0));
+ domains.push_back(22);
+ ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 22, 0));
+ ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 50, 0));
+ domains.push_back(30);
+ ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 30, 0));
+ ASSERT_FALSE(CAmRouter::shouldGoInDomain(domains, 22, 0));
+ domains.push_back(30);
+ ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 30, 0));
+ ASSERT_FALSE(CAmRouter::shouldGoInDomain(domains, 22, 0));
+ ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 60, 0));
}
//test that checks just sinks and source in a domain but connectionformats do not match
@@ -256,14 +241,14 @@ TEST_F(CAmRouterMapTest,simpleRoute2withDomainNoMatchFormats)
domain1.busname = "domain1bus";
domain1.state = DS_CONTROLLED;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1, domainID1));
am_Source_s source;
am_sourceID_t sourceID;
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
source.domainID = domainID1;
source.name = "source1";
@@ -272,15 +257,14 @@ TEST_F(CAmRouterMapTest,simpleRoute2withDomainNoMatchFormats)
source.sourceClassID = 5;
source.listConnectionFormats.push_back(CF_GENIVI_MONO);
-
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID,sourceclass));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID, sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, sourceID));
am_Sink_s sink;
am_sinkID_t sinkID;
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
sink.domainID = domainID1;
sink.name = "sink1";
@@ -289,8 +273,8 @@ TEST_F(CAmRouterMapTest,simpleRoute2withDomainNoMatchFormats)
sink.muteState = MS_MUTED;
sink.listConnectionFormats.push_back(CF_GENIVI_ANALOG);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, sinkID));
std::vector<am_Route_s> listRoutes;
std::vector<am_RoutingElement_s> listRoutingElements;
@@ -309,12 +293,12 @@ TEST_F(CAmRouterMapTest,simpleRoute2withDomainNoMatchFormats)
compareRoute.sourceID = sourceID;
am::am_Source_s sourceDb;
- am::am_Sink_s sinkDb;
- pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
- pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
- listRoutes.clear();
- ASSERT_EQ(getRoute(true, true, sourceDb, sinkDb, listRoutes), E_NOT_POSSIBLE);
- ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ listRoutes.clear();
+ ASSERT_EQ(getRoute(true, false, sourceDb, sinkDb, listRoutes), E_NOT_POSSIBLE);
+ ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
}
//test that checks just sinks and source in a domain
@@ -331,14 +315,14 @@ TEST_F(CAmRouterMapTest,simpleRoute2withDomain)
domain1.busname = "domain1bus";
domain1.state = DS_CONTROLLED;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1, domainID1));
am_Source_s source;
am_sourceID_t sourceID;
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
source.domainID = domainID1;
source.name = "source1";
@@ -347,15 +331,14 @@ TEST_F(CAmRouterMapTest,simpleRoute2withDomain)
source.sourceClassID = 5;
source.listConnectionFormats.push_back(CF_GENIVI_ANALOG);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID,sourceclass));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID, sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, sourceID));
am_Sink_s sink;
am_sinkID_t sinkID;
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
-
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
sink.domainID = domainID1;
sink.name = "sink1";
@@ -364,8 +347,8 @@ TEST_F(CAmRouterMapTest,simpleRoute2withDomain)
sink.muteState = MS_MUTED;
sink.listConnectionFormats.push_back(CF_GENIVI_ANALOG);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, sinkID));
std::vector<am_Route_s> listRoutes;
std::vector<am_RoutingElement_s> listRoutingElements;
@@ -384,13 +367,13 @@ TEST_F(CAmRouterMapTest,simpleRoute2withDomain)
compareRoute.sourceID = sourceID;
am::am_Source_s sourceDb;
- am::am_Sink_s sinkDb;
- pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
- pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
- listRoutes.clear();
- ASSERT_EQ(getRoute(true, true, sourceDb, sinkDb, listRoutes), E_OK);
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ listRoutes.clear();
+ ASSERT_EQ(getRoute(true, false, sourceDb, sinkDb, listRoutes), E_OK);
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute, listRoutes[0]));
}
//test that checks just 2 domains, one sink one source with only one connection format each
@@ -411,15 +394,15 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsOnlyFree)
domain2.busname = "domain2bus";
domain2.state = DS_CONTROLLED;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1, domainID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2, domainID2));
am_Source_s source, gwSource;
am_sourceID_t sourceID, gwSourceID;
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
source.domainID = domainID1;
source.name = "source1";
@@ -435,15 +418,15 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsOnlyFree)
gwSource.sourceClassID = 5;
gwSource.listConnectionFormats.push_back(CF_GENIVI_MONO);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID,sourceclass));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID, sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource, gwSourceID));
am_Sink_s sink, gwSink;
am_sinkID_t sinkID, gwSinkID;
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
sink.domainID = domainID2;
sink.name = "sink1";
@@ -459,9 +442,9 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsOnlyFree)
gwSink.muteState = MS_MUTED;
gwSink.listConnectionFormats.push_back(CF_GENIVI_ANALOG);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink, gwSinkID));
am_Gateway_s gateway;
am_gatewayID_t gatewayID;
@@ -477,7 +460,7 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsOnlyFree)
gateway.convertionMatrix.push_back(true);
gateway.name = "gateway";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway, gatewayID));
std::vector<am_Route_s> listRoutes;
std::vector<am_RoutingElement_s> listRoutingElements;
@@ -507,12 +490,11 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsOnlyFree)
pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
- ASSERT_EQ(getRoute(true, true,sourceID,sinkID,listRoutes), E_OK);
+ ASSERT_EQ(getRoute(true, false, sourceID, sinkID, listRoutes), E_OK);
ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ ASSERT_TRUE(pCF.compareRoute(compareRoute, listRoutes[0]));
}
-
//test that checks just 2 domains, one sink one source with only one connection format each
TEST_F(CAmRouterMapTest,simpleRoute2DomainsOnlyFreeNotFree)
{
@@ -531,15 +513,15 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsOnlyFreeNotFree)
domain2.busname = "domain2bus";
domain2.state = DS_CONTROLLED;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1, domainID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2, domainID2));
am_Source_s source, gwSource;
am_sourceID_t sourceID, gwSourceID;
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
source.domainID = domainID1;
source.name = "source1";
@@ -555,16 +537,15 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsOnlyFreeNotFree)
gwSource.sourceClassID = 5;
gwSource.listConnectionFormats.push_back(CF_GENIVI_MONO);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID,sourceclass));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID, sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource, gwSourceID));
am_Sink_s sink, gwSink;
am_sinkID_t sinkID, gwSinkID;
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
-
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
sink.domainID = domainID2;
sink.name = "sink1";
@@ -580,9 +561,9 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsOnlyFreeNotFree)
gwSink.muteState = MS_MUTED;
gwSink.listConnectionFormats.push_back(CF_GENIVI_ANALOG);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink, gwSinkID));
am_Gateway_s gateway;
am_gatewayID_t gatewayID;
@@ -598,7 +579,7 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsOnlyFreeNotFree)
gateway.convertionMatrix.push_back(true);
gateway.name = "gateway";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway, gatewayID));
std::vector<am_Route_s> listRoutes;
std::vector<am_RoutingElement_s> listRoutingElements;
@@ -623,32 +604,32 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsOnlyFreeNotFree)
compareRoute.sinkID = sinkID;
compareRoute.sourceID = sourceID;
- am_Connection_s connection,connection1;
- am_connectionID_t id1,id2;
- connection.sourceID=sourceID;
- connection.sinkID=gwSinkID;
- connection.connectionFormat=CF_GENIVI_ANALOG;
- connection.connectionID=0;
- connection1.sourceID=gwSourceID;
- connection1.sinkID=sinkID;
- connection1.connectionFormat=CF_GENIVI_ANALOG;
- connection1.connectionID=0;
+ am_Connection_s connection, connection1;
+ am_connectionID_t id1, id2;
+ connection.sourceID = sourceID;
+ connection.sinkID = gwSinkID;
+ connection.connectionFormat = CF_GENIVI_ANALOG;
+ connection.connectionID = 0;
+ connection1.sourceID = gwSourceID;
+ connection1.sinkID = sinkID;
+ connection1.connectionFormat = CF_GENIVI_ANALOG;
+ connection1.connectionID = 0;
- ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,id1));
- ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection1,id2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterConnectionDB(connection, id1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterConnectionDB(connection1, id2));
am::am_Source_s sourceDb;
- am::am_Sink_s sinkDb;
- pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
- pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
- listRoutes.clear();
- ASSERT_EQ(getRoute(true, true, sourceDb, sinkDb, listRoutes), E_NOT_POSSIBLE);
- ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
-
- listRoutes.clear();
- ASSERT_EQ(getRoute(false, true, sourceDb, sinkDb, listRoutes), E_OK);
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ listRoutes.clear();
+ ASSERT_EQ(getRoute(true, false, sourceDb, sinkDb, listRoutes), E_NOT_POSSIBLE);
+ ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
+
+ listRoutes.clear();
+ ASSERT_EQ(getRoute(false, false, sourceDb, sinkDb, listRoutes), E_OK);
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute, listRoutes[0]));
}
//test that checks just 2 domains, with gateway for each direction (possible circular route)
@@ -669,15 +650,15 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsCircularGWOnlyFree)
domain2.busname = "domain2bus";
domain2.state = DS_CONTROLLED;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1, domainID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2, domainID2));
am_Source_s source, gwSource, gwSource2;
am_sourceID_t sourceID, gwSourceID, gwSourceID2;
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
source.domainID = domainID1;
source.name = "source1";
@@ -700,16 +681,16 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsCircularGWOnlyFree)
gwSource2.sourceClassID = 5;
gwSource2.listConnectionFormats.push_back(CF_GENIVI_MONO);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID,sourceclass));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource2,gwSourceID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID, sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource, gwSourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource2, gwSourceID2));
am_Sink_s sink, gwSink, gwSink2;
am_sinkID_t sinkID, gwSinkID, gwSinkID2;
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
sink.domainID = domainID2;
sink.name = "sink1";
@@ -732,10 +713,10 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsCircularGWOnlyFree)
gwSink2.muteState = MS_MUTED;
gwSink2.listConnectionFormats.push_back(CF_GENIVI_MONO);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink2,gwSinkID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink, gwSinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink2, gwSinkID2));
am_Gateway_s gateway, gateway2;
am_gatewayID_t gatewayID, gatewayID2;
@@ -762,8 +743,8 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsCircularGWOnlyFree)
gateway2.convertionMatrix.push_back(true);
gateway2.name = "gateway2";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway, gatewayID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway2, gatewayID2));
std::vector<am_Route_s> listRoutes;
std::vector<am_RoutingElement_s> listRoutingElements;
@@ -789,13 +770,13 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsCircularGWOnlyFree)
compareRoute.sourceID = sourceID;
am::am_Source_s sourceDb;
- am::am_Sink_s sinkDb;
- pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
- pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
- listRoutes.clear();
- ASSERT_EQ(getRoute(true, true, sourceDb, sinkDb, listRoutes), E_OK);
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ listRoutes.clear();
+ ASSERT_EQ(getRoute(true, false, sourceDb, sinkDb, listRoutes), E_OK);
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute, listRoutes[0]));
}
//test that checks 3 domains, one sink one source, longer lists of connectionformats.
@@ -820,17 +801,16 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats_2)
domain3.busname = "domain3bus";
domain3.state = DS_CONTROLLED;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1, domainID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2, domainID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3, domainID3));
am_Source_s source, gwSource, gwSource1;
am_sourceID_t sourceID, gwSourceID, gwSourceID1;
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
-
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
source.domainID = domainID1;
source.name = "source1";
@@ -857,10 +837,10 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats_2)
gwSource1.listConnectionFormats.push_back(CF_GENIVI_STEREO);
gwSource1.listConnectionFormats.push_back(CF_GENIVI_MONO);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID,sourceclass));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID, sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource, gwSourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1, gwSourceID1));
am_Sink_s sink, gwSink, gwSink1;
am_sinkID_t sinkID, gwSinkID, gwSinkID1;
@@ -872,8 +852,8 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats_2)
sink.muteState = MS_MUTED;
sink.listConnectionFormats.push_back(CF_GENIVI_MONO);
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
gwSink.domainID = domainID1;
gwSink.name = "gwSink";
@@ -891,10 +871,10 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats_2)
gwSink1.listConnectionFormats.push_back(CF_GENIVI_ANALOG);
gwSink1.listConnectionFormats.push_back(CF_GENIVI_STEREO);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink, gwSinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1, gwSinkID1));
am_Gateway_s gateway, gateway1;
am_gatewayID_t gatewayID, gatewayID1;
@@ -929,8 +909,8 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats_2)
gateway1.convertionMatrix.push_back(true);
gateway1.name = "gateway1";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway, gatewayID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1, gatewayID1));
std::vector<am_Route_s> listRoutes;
std::vector<am_RoutingElement_s> listRoutingElements;
@@ -963,12 +943,12 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats_2)
compareRoute.sourceID = sourceID;
am::am_Source_s sourceDb;
- am::am_Sink_s sinkDb;
- pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
- pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
- ASSERT_EQ(getRoute(false, true, sourceDb, sinkDb, listRoutes, 0), E_OK);
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ ASSERT_EQ(getRoute(false, false, sourceDb, sinkDb, listRoutes, 0), E_OK);
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute, listRoutes[0]));
}
//test that checks 3 domains, one sink one source, longer lists of connectionformats.
@@ -993,9 +973,9 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats_1)
domain3.busname = "domain3bus";
domain3.state = DS_CONTROLLED;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1, domainID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2, domainID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3, domainID3));
am_Source_s source, gwSource, gwSource1;
am_sourceID_t sourceID, gwSourceID, gwSourceID1;
@@ -1009,8 +989,8 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats_1)
source.listConnectionFormats.push_back(CF_GENIVI_MONO);
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
gwSource.domainID = domainID2;
gwSource.name = "gwsource1";
@@ -1028,16 +1008,16 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats_1)
gwSource1.sourceClassID = 5;
gwSource1.listConnectionFormats.push_back(CF_GENIVI_MONO);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID,sourceclass));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID, sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource, gwSourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1, gwSourceID1));
am_Sink_s sink, gwSink, gwSink1;
am_sinkID_t sinkID, gwSinkID, gwSinkID1;
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
sink.domainID = domainID3;
sink.name = "sink1";
@@ -1061,10 +1041,10 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats_1)
gwSink1.muteState = MS_MUTED;
gwSink1.listConnectionFormats.push_back(CF_GENIVI_ANALOG);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink, gwSinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1, gwSinkID1));
am_Gateway_s gateway, gateway1;
am_gatewayID_t gatewayID, gatewayID1;
@@ -1096,8 +1076,8 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats_1)
gateway1.convertionMatrix.push_back(true);
gateway1.name = "gateway";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway, gatewayID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1, gatewayID1));
std::vector<am_Route_s> listRoutes;
std::vector<am_RoutingElement_s> listRoutingElements;
@@ -1130,12 +1110,12 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats_1)
compareRoute.sourceID = sourceID;
am::am_Source_s sourceDb;
- am::am_Sink_s sinkDb;
- pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
- pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
- ASSERT_EQ(getRoute(false, true, sourceDb, sinkDb, listRoutes, 0), E_OK);
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ ASSERT_EQ(getRoute(false, false, sourceDb, sinkDb, listRoutes, 0), E_OK);
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute, listRoutes[0]));
}
//test that checks 3 domains, one sink one source, longer lists of connectionformats.
@@ -1160,16 +1140,16 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats)
domain3.busname = "domain3bus";
domain3.state = DS_CONTROLLED;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1, domainID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2, domainID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3, domainID3));
am_Source_s source, gwSource, gwSource1;
am_sourceID_t sourceID, gwSourceID, gwSourceID1;
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
source.domainID = domainID1;
source.name = "source1";
@@ -1193,17 +1173,17 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats)
gwSource1.sourceClassID = 5;
gwSource1.listConnectionFormats.push_back(CF_GENIVI_MONO);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID,sourceclass));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID, sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource, gwSourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1, gwSourceID1));
am_Sink_s sink, gwSink, gwSink1;
am_sinkID_t sinkID, gwSinkID, gwSinkID1;
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
sink.domainID = domainID3;
sink.name = "sink1";
@@ -1227,10 +1207,10 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats)
gwSink1.muteState = MS_MUTED;
gwSink1.listConnectionFormats.push_back(CF_GENIVI_ANALOG);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink, gwSinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1, gwSinkID1));
am_Gateway_s gateway, gateway1;
am_gatewayID_t gatewayID, gatewayID1;
@@ -1258,8 +1238,8 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats)
gateway1.convertionMatrix.push_back(true);
gateway1.name = "gateway";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway, gatewayID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1, gatewayID1));
std::vector<am_Route_s> listRoutes;
std::vector<am_RoutingElement_s> listRoutingElements;
@@ -1292,12 +1272,12 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats)
compareRoute.sourceID = sourceID;
am::am_Source_s sourceDb;
- am::am_Sink_s sinkDb;
- pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
- pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
- ASSERT_EQ(getRoute(false, true, sourceDb, sinkDb, listRoutes, 0), E_OK);
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ ASSERT_EQ(getRoute(false, false, sourceDb, sinkDb, listRoutes, 0), E_OK);
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute, listRoutes[0]));
}
//test that checks 4 domains, one sink and one source but there are 2 routes because there are 2 gateways
@@ -1326,17 +1306,17 @@ TEST_F(CAmRouterMapTest,simpleRoute4Domains2Routes)
domain4.busname = "domain4bus";
domain4.state = DS_CONTROLLED;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain4,domainID4));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1, domainID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2, domainID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3, domainID3));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain4, domainID4));
am_Source_s source, gwSource, gwSource1, gwSource2, gwSource3;
am_sourceID_t sourceID, gwSourceID, gwSourceID1, gwSourceID2, gwSourceID3;
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
source.domainID = domainID1;
source.name = "source1";
@@ -1373,12 +1353,12 @@ TEST_F(CAmRouterMapTest,simpleRoute4Domains2Routes)
gwSource3.sourceClassID = 5;
gwSource3.listConnectionFormats.push_back(CF_GENIVI_MONO);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID,sourceclass));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource2,gwSourceID2));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource3,gwSourceID3));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID, sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource, gwSourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1, gwSourceID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource2, gwSourceID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource3, gwSourceID3));
am_Sink_s sink, gwSink, gwSink1, gwSink2, gwSink3;
am_sinkID_t sinkID, gwSinkID, gwSinkID1, gwSinkID2, gwSinkID3;
@@ -1418,15 +1398,15 @@ TEST_F(CAmRouterMapTest,simpleRoute4Domains2Routes)
sink.muteState = MS_MUTED;
sink.listConnectionFormats.push_back(CF_GENIVI_STEREO);
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink2,gwSinkID2));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink3,gwSinkID3));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink, gwSinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1, gwSinkID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink2, gwSinkID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink3, gwSinkID3));
am_Gateway_s gateway, gateway1, gateway2, gateway3;
am_gatewayID_t gatewayID, gatewayID1, gatewayID2, gatewayID3;
@@ -1475,10 +1455,10 @@ TEST_F(CAmRouterMapTest,simpleRoute4Domains2Routes)
gateway3.convertionMatrix.push_back(true);
gateway3.name = "gateway3";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway3,gatewayID3));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway, gatewayID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1, gatewayID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway2, gatewayID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway3, gatewayID3));
std::vector<am_Route_s> listRoutes;
std::vector<am_RoutingElement_s> listRoutingElements, listRoutingElements1;
@@ -1538,20 +1518,22 @@ TEST_F(CAmRouterMapTest,simpleRoute4Domains2Routes)
compareRoute1.sourceID = sourceID;
am::am_Source_s sourceDb;
- am::am_Sink_s sinkDb;
- pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
- pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
- ASSERT_EQ(getRoute(false, true, sourceDb, sinkDb, listRoutes, 0), E_OK);
- ASSERT_EQ(static_cast<uint>(2), listRoutes.size());
-
- bool containsRoute1 = std::find_if(listRoutes.begin(), listRoutes.end(), [&](const am_Route_s & ref) {
- return pCF.compareRoute(compareRoute, ref);
- })!=listRoutes.end();
- bool containsRoute2 = std::find_if(listRoutes.begin(), listRoutes.end(), [&](const am_Route_s & ref) {
- return pCF.compareRoute(compareRoute1, ref);
- })!=listRoutes.end();
-
- ASSERT_TRUE(containsRoute1);
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ ASSERT_EQ(getRoute(false, false, sourceDb, sinkDb, listRoutes, 0), E_OK);
+ ASSERT_EQ(static_cast<uint>(2), listRoutes.size());
+
+ bool containsRoute1 = std::find_if(listRoutes.begin(), listRoutes.end(), [&](const am_Route_s & ref)
+ {
+ return pCF.compareRoute(compareRoute, ref);
+ }) != listRoutes.end();
+ bool containsRoute2 = std::find_if(listRoutes.begin(), listRoutes.end(), [&](const am_Route_s & ref)
+ {
+ return pCF.compareRoute(compareRoute1, ref);
+ }) != listRoutes.end();
+
+ ASSERT_TRUE(containsRoute1);
ASSERT_TRUE(containsRoute2);
}
@@ -1577,9 +1559,9 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsNoConnection)
domain3.busname = "domain3bus";
domain3.state = DS_CONTROLLED;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1, domainID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2, domainID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3, domainID3));
am_Source_s source, gwSource, gwSource1;
am_sourceID_t sourceID, gwSourceID, gwSourceID1;
@@ -1592,8 +1574,8 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsNoConnection)
source.listConnectionFormats.push_back(CF_GENIVI_MONO);
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
gwSource.domainID = domainID2;
gwSource.name = "gwsource1";
@@ -1609,10 +1591,10 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsNoConnection)
gwSource1.sourceClassID = 5;
gwSource1.listConnectionFormats.push_back(CF_GENIVI_MONO);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID,sourceclass));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID, sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource, gwSourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1, gwSourceID1));
am_Sink_s sink, gwSink, gwSink1;
am_sinkID_t sinkID, gwSinkID, gwSinkID1;
@@ -1624,8 +1606,8 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsNoConnection)
sink.muteState = MS_MUTED;
sink.listConnectionFormats.push_back(CF_GENIVI_STEREO);
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
gwSink.domainID = domainID1;
gwSink.name = "gwSink";
@@ -1641,10 +1623,10 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsNoConnection)
gwSink1.muteState = MS_MUTED;
gwSink1.listConnectionFormats.push_back(CF_GENIVI_ANALOG);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink, gwSinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1, gwSinkID1));
am_Gateway_s gateway, gateway1;
am_gatewayID_t gatewayID, gatewayID1;
@@ -1671,8 +1653,8 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsNoConnection)
gateway1.convertionMatrix.push_back(true);
gateway1.name = "gateway";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway, gatewayID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1, gatewayID1));
std::vector<am_Route_s> listRoutes;
std::vector<am_RoutingElement_s> listRoutingElements;
@@ -1705,12 +1687,12 @@ TEST_F(CAmRouterMapTest,simpleRoute3DomainsNoConnection)
compareRoute.sourceID = sourceID;
am::am_Source_s sourceDb;
- am::am_Sink_s sinkDb;
- pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
- pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
- listRoutes.clear();
- ASSERT_EQ(getRoute(false, true, sourceDb, sinkDb, listRoutes, 0), E_NOT_POSSIBLE);
- ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ listRoutes.clear();
+ ASSERT_EQ(getRoute(false, false, sourceDb, sinkDb, listRoutes, 0), E_NOT_POSSIBLE);
+ ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
}
//test that checks just 2 domains, one sink one source with only one connection format each
@@ -1731,8 +1713,8 @@ TEST_F(CAmRouterMapTest,simpleRoute2Domains)
domain2.busname = "domain2bus";
domain2.state = DS_CONTROLLED;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1, domainID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2, domainID2));
am_Source_s source, gwSource;
am_sourceID_t sourceID, gwSourceID;
@@ -1745,8 +1727,8 @@ TEST_F(CAmRouterMapTest,simpleRoute2Domains)
source.listConnectionFormats.push_back(CF_GENIVI_ANALOG);
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
gwSource.domainID = domainID2;
gwSource.name = "gwsource1";
@@ -1755,16 +1737,15 @@ TEST_F(CAmRouterMapTest,simpleRoute2Domains)
gwSource.sourceClassID = 5;
gwSource.listConnectionFormats.push_back(CF_GENIVI_MONO);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID,sourceclass));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID, sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource, gwSourceID));
am_Sink_s sink, gwSink;
am_sinkID_t sinkID, gwSinkID;
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
-
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
sink.domainID = domainID2;
sink.name = "sink1";
@@ -1780,10 +1761,9 @@ TEST_F(CAmRouterMapTest,simpleRoute2Domains)
gwSink.muteState = MS_MUTED;
gwSink.listConnectionFormats.push_back(CF_GENIVI_ANALOG);
-
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink, gwSinkID));
am_Gateway_s gateway;
am_gatewayID_t gatewayID;
@@ -1799,7 +1779,7 @@ TEST_F(CAmRouterMapTest,simpleRoute2Domains)
gateway.convertionMatrix.push_back(true);
gateway.name = "gateway";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway, gatewayID));
std::vector<am_Route_s> listRoutes;
std::vector<am_RoutingElement_s> listRoutingElements;
@@ -1825,12 +1805,12 @@ TEST_F(CAmRouterMapTest,simpleRoute2Domains)
compareRoute.sourceID = sourceID;
am::am_Source_s sourceDb;
- am::am_Sink_s sinkDb;
- pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
- pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
- ASSERT_EQ(getRoute(false, true, sourceDb, sinkDb, listRoutes, 0), E_OK);
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ ASSERT_EQ(getRoute(false, false, sourceDb, sinkDb, listRoutes, 0), E_OK);
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute, listRoutes[0]));
}
//test that checks just 2 domains, one sink one source but the connectionformat of source
@@ -1851,8 +1831,8 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsNoMatchConnectionFormats)
domain2.busname = "domain2bus";
domain2.state = DS_CONTROLLED;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1, domainID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2, domainID2));
am_Source_s source, gwSource;
am_sourceID_t sourceID, gwSourceID;
@@ -1865,8 +1845,8 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsNoMatchConnectionFormats)
source.listConnectionFormats.push_back(CF_GENIVI_STEREO);
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
gwSource.domainID = domainID2;
gwSource.name = "gwsource1";
@@ -1875,15 +1855,15 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsNoMatchConnectionFormats)
gwSource.sourceClassID = 5;
gwSource.listConnectionFormats.push_back(CF_GENIVI_MONO);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID,sourceclass));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID, sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource, gwSourceID));
am_Sink_s sink, gwSink;
am_sinkID_t sinkID, gwSinkID;
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
sink.domainID = domainID2;
sink.name = "sink1";
@@ -1899,9 +1879,9 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsNoMatchConnectionFormats)
gwSink.muteState = MS_MUTED;
gwSink.listConnectionFormats.push_back(CF_GENIVI_ANALOG);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink, gwSinkID));
am_Gateway_s gateway;
am_gatewayID_t gatewayID;
@@ -1917,17 +1897,17 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsNoMatchConnectionFormats)
gateway.convertionMatrix.push_back(true);
gateway.name = "gateway";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway, gatewayID));
std::vector<am_Route_s> listRoutes;
am::am_Source_s sourceDb;
- am::am_Sink_s sinkDb;
- pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
- pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
- ASSERT_EQ(getRoute(false, true, sourceDb, sinkDb, listRoutes, 0), E_NOT_POSSIBLE);
- ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
- }
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ ASSERT_EQ(getRoute(false, false, sourceDb, sinkDb, listRoutes, 0), E_NOT_POSSIBLE);
+ ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
+}
//test that checks 3 domains, one sink one source.
TEST_F(CAmRouterMapTest,simpleRoute3Domains)
@@ -1951,16 +1931,16 @@ TEST_F(CAmRouterMapTest,simpleRoute3Domains)
domain3.busname = "domain3bus";
domain3.state = DS_CONTROLLED;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1, domainID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2, domainID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3, domainID3));
am_Source_s source, gwSource, gwSource1;
am_sourceID_t sourceID, gwSourceID, gwSourceID1;
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
source.domainID = domainID1;
source.name = "source1";
@@ -1983,17 +1963,16 @@ TEST_F(CAmRouterMapTest,simpleRoute3Domains)
gwSource1.sourceClassID = 5;
gwSource1.listConnectionFormats.push_back(CF_GENIVI_MONO);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID,sourceclass));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID, sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource, gwSourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1, gwSourceID1));
am_Sink_s sink, gwSink, gwSink1;
am_sinkID_t sinkID, gwSinkID, gwSinkID1;
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
-
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
sink.domainID = domainID3;
sink.name = "sink1";
@@ -2016,10 +1995,10 @@ TEST_F(CAmRouterMapTest,simpleRoute3Domains)
gwSink1.muteState = MS_MUTED;
gwSink1.listConnectionFormats.push_back(CF_GENIVI_ANALOG);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink, gwSinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1, gwSinkID1));
am_Gateway_s gateway, gateway1;
am_gatewayID_t gatewayID, gatewayID1;
@@ -2046,8 +2025,8 @@ TEST_F(CAmRouterMapTest,simpleRoute3Domains)
gateway1.convertionMatrix.push_back(true);
gateway1.name = "gateway";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway, gatewayID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1, gatewayID1));
std::vector<am_Route_s> listRoutes;
std::vector<am_RoutingElement_s> listRoutingElements;
@@ -2080,13 +2059,13 @@ TEST_F(CAmRouterMapTest,simpleRoute3Domains)
compareRoute.sourceID = sourceID;
am::am_Source_s sourceDb;
- am::am_Sink_s sinkDb;
- pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
- pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
- listRoutes.clear();
- ASSERT_EQ(getRoute(false, true, sourceDb, sinkDb, listRoutes, 0), E_OK);
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ listRoutes.clear();
+ ASSERT_EQ(getRoute(false, false, sourceDb, sinkDb, listRoutes, 0), E_OK);
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute, listRoutes[0]));
}
//test that checks 4 domains, one sink and one source.
@@ -2115,17 +2094,17 @@ TEST_F(CAmRouterMapTest,simpleRoute4Domains)
domain4.busname = "domain4bus";
domain4.state = DS_CONTROLLED;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain4,domainID4));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1, domainID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2, domainID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3, domainID3));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain4, domainID4));
am_Source_s source, gwSource, gwSource1, gwSource2;
am_sourceID_t sourceID, gwSourceID, gwSourceID1, gwSourceID2;
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
source.domainID = domainID1;
source.name = "source1";
@@ -2155,11 +2134,11 @@ TEST_F(CAmRouterMapTest,simpleRoute4Domains)
gwSource2.sourceClassID = 5;
gwSource2.listConnectionFormats.push_back(CF_GENIVI_STEREO);
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID,sourceclass));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource2,gwSourceID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(source.sourceClassID, sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource, gwSourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1, gwSourceID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource2, gwSourceID2));
am_Sink_s sink, gwSink, gwSink1, gwSink2;
am_sinkID_t sinkID, gwSinkID, gwSinkID1, gwSinkID2;
@@ -2192,14 +2171,14 @@ TEST_F(CAmRouterMapTest,simpleRoute4Domains)
sink.muteState = MS_MUTED;
sink.listConnectionFormats.push_back(CF_GENIVI_STEREO);
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink2,gwSinkID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink, gwSinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1, gwSinkID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink2, gwSinkID2));
am_Gateway_s gateway, gateway1, gateway2;
am_gatewayID_t gatewayID, gatewayID1, gatewayID2;
@@ -2237,9 +2216,9 @@ TEST_F(CAmRouterMapTest,simpleRoute4Domains)
gateway2.convertionMatrix.push_back(true);
gateway2.name = "gateway2";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway2,gatewayID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway, gatewayID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1, gatewayID1));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway2, gatewayID2));
std::vector<am_Route_s> listRoutes;
std::vector<am_RoutingElement_s> listRoutingElements;
@@ -2279,112 +2258,112 @@ TEST_F(CAmRouterMapTest,simpleRoute4Domains)
compareRoute.sourceID = sourceID;
am::am_Source_s sourceDb;
- am::am_Sink_s sinkDb;
- pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
- pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
- listRoutes.clear();
- ASSERT_EQ(getRoute(false, true, sourceDb, sinkDb, listRoutes, 0), E_OK);
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ am::am_Sink_s sinkDb;
+ pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
+ pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
+ listRoutes.clear();
+ ASSERT_EQ(getRoute(false, false, sourceDb, sinkDb, listRoutes, 0), E_OK);
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute, listRoutes[0]));
}
TEST_F(CAmRouterMapTest,getAllowedFormatsFromConvMatrix)
{
- std::vector<bool> convertionMatrix;
- convertionMatrix.push_back(1);
- convertionMatrix.push_back(0);
- convertionMatrix.push_back(0);
- convertionMatrix.push_back(1);
- convertionMatrix.push_back(1);
- convertionMatrix.push_back(0);
-
- std::vector<am_CustomConnectionFormat_t> listSourceFormats;
- listSourceFormats.push_back(CF_GENIVI_ANALOG);
- listSourceFormats.push_back(CF_GENIVI_STEREO);
-
- std::vector<am_CustomConnectionFormat_t> listSinkFormats;
- listSinkFormats.push_back(CF_GENIVI_MONO);
- listSinkFormats.push_back(CF_GENIVI_AUTO);
- listSinkFormats.push_back(CF_GENIVI_STEREO);
-
- std::vector<am_CustomConnectionFormat_t> sourceFormats;
- std::vector<am_CustomConnectionFormat_t> sinkFormats;
-
- ASSERT_TRUE(CAmRouter::getAllowedFormatsFromConvMatrix(convertionMatrix, listSourceFormats, listSinkFormats, sourceFormats, sinkFormats));
-
- ASSERT_TRUE(sourceFormats.size()==3);
- ASSERT_TRUE(sinkFormats.size()==3);
- ASSERT_TRUE(sourceFormats.at(0)==CF_GENIVI_ANALOG);
- ASSERT_TRUE(sourceFormats.at(1)==CF_GENIVI_STEREO);
- ASSERT_TRUE(sourceFormats.at(2)==CF_GENIVI_ANALOG);
- ASSERT_TRUE(sinkFormats.at(0)==CF_GENIVI_MONO);
- ASSERT_TRUE(sinkFormats.at(1)==CF_GENIVI_AUTO);
- ASSERT_TRUE(sinkFormats.at(2)==CF_GENIVI_STEREO);
-
- sinkFormats.clear();
- sourceFormats.clear();
- convertionMatrix.clear();
- listSinkFormats.clear();
- listSourceFormats.clear();
-
- convertionMatrix.push_back(1);
- listSinkFormats.push_back(CF_GENIVI_STEREO);
- listSourceFormats.push_back(CF_GENIVI_STEREO);
-
- ASSERT_TRUE(CAmRouter::getAllowedFormatsFromConvMatrix(convertionMatrix, listSourceFormats, listSinkFormats, sourceFormats, sinkFormats));
-
- sinkFormats.clear();
- sourceFormats.clear();
- convertionMatrix.clear();
- listSinkFormats.clear();
- listSourceFormats.clear();
-
- convertionMatrix.push_back(1);
- convertionMatrix.push_back(0);
- listSourceFormats.push_back(CF_GENIVI_STEREO);
- listSinkFormats.push_back(CF_GENIVI_STEREO);
-
- ASSERT_FALSE(CAmRouter::getAllowedFormatsFromConvMatrix(convertionMatrix, listSourceFormats, listSinkFormats, sourceFormats, sinkFormats));
-
- sinkFormats.clear();
- sourceFormats.clear();
- convertionMatrix.clear();
- listSinkFormats.clear();
- listSourceFormats.clear();
-
- convertionMatrix.push_back(1);
- listSinkFormats.push_back(CF_GENIVI_STEREO);
-
- ASSERT_FALSE(CAmRouter::getAllowedFormatsFromConvMatrix(convertionMatrix, listSourceFormats, listSinkFormats, sourceFormats, sinkFormats));
+ std::vector<bool> convertionMatrix;
+ convertionMatrix.push_back(1);
+ convertionMatrix.push_back(0);
+ convertionMatrix.push_back(0);
+ convertionMatrix.push_back(1);
+ convertionMatrix.push_back(1);
+ convertionMatrix.push_back(0);
+
+ std::vector<am_CustomConnectionFormat_t> listSourceFormats;
+ listSourceFormats.push_back(CF_GENIVI_ANALOG);
+ listSourceFormats.push_back(CF_GENIVI_STEREO);
+
+ std::vector<am_CustomConnectionFormat_t> listSinkFormats;
+ listSinkFormats.push_back(CF_GENIVI_MONO);
+ listSinkFormats.push_back(CF_GENIVI_AUTO);
+ listSinkFormats.push_back(CF_GENIVI_STEREO);
+
+ std::vector<am_CustomConnectionFormat_t> sourceFormats;
+ std::vector<am_CustomConnectionFormat_t> sinkFormats;
+
+ ASSERT_TRUE(CAmRouter::getAllowedFormatsFromConvMatrix(convertionMatrix, listSourceFormats, listSinkFormats, sourceFormats, sinkFormats));
+
+ ASSERT_TRUE(sourceFormats.size() == 3);
+ ASSERT_TRUE(sinkFormats.size() == 3);
+ ASSERT_TRUE(sourceFormats.at(0) == CF_GENIVI_ANALOG);
+ ASSERT_TRUE(sourceFormats.at(1) == CF_GENIVI_STEREO);
+ ASSERT_TRUE(sourceFormats.at(2) == CF_GENIVI_ANALOG);
+ ASSERT_TRUE(sinkFormats.at(0) == CF_GENIVI_MONO);
+ ASSERT_TRUE(sinkFormats.at(1) == CF_GENIVI_AUTO);
+ ASSERT_TRUE(sinkFormats.at(2) == CF_GENIVI_STEREO);
+
+ sinkFormats.clear();
+ sourceFormats.clear();
+ convertionMatrix.clear();
+ listSinkFormats.clear();
+ listSourceFormats.clear();
+
+ convertionMatrix.push_back(1);
+ listSinkFormats.push_back(CF_GENIVI_STEREO);
+ listSourceFormats.push_back(CF_GENIVI_STEREO);
+
+ ASSERT_TRUE(CAmRouter::getAllowedFormatsFromConvMatrix(convertionMatrix, listSourceFormats, listSinkFormats, sourceFormats, sinkFormats));
+
+ sinkFormats.clear();
+ sourceFormats.clear();
+ convertionMatrix.clear();
+ listSinkFormats.clear();
+ listSourceFormats.clear();
+
+ convertionMatrix.push_back(1);
+ convertionMatrix.push_back(0);
+ listSourceFormats.push_back(CF_GENIVI_STEREO);
+ listSinkFormats.push_back(CF_GENIVI_STEREO);
+
+ ASSERT_FALSE(CAmRouter::getAllowedFormatsFromConvMatrix(convertionMatrix, listSourceFormats, listSinkFormats, sourceFormats, sinkFormats));
+
+ sinkFormats.clear();
+ sourceFormats.clear();
+ convertionMatrix.clear();
+ listSinkFormats.clear();
+ listSourceFormats.clear();
+
+ convertionMatrix.push_back(1);
+ listSinkFormats.push_back(CF_GENIVI_STEREO);
+
+ ASSERT_FALSE(CAmRouter::getAllowedFormatsFromConvMatrix(convertionMatrix, listSourceFormats, listSinkFormats, sourceFormats, sinkFormats));
}
TEST_F(CAmRouterMapTest,route1Domain1Source1Sink)
{
- EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
- am_domainID_t domainID1;
- enterDomainDB("domain1", domainID1);
+ am_domainID_t domainID1;
+ enterDomainDB("domain1", domainID1);
- am_sourceID_t sourceID;
- std::vector<am_CustomConnectionFormat_t> cf1;
- cf1.push_back(CF_GENIVI_STEREO);
- cf1.push_back(CF_GENIVI_ANALOG);
+ am_sourceID_t sourceID;
+ std::vector<am_CustomConnectionFormat_t> cf1;
+ cf1.push_back(CF_GENIVI_STEREO);
+ cf1.push_back(CF_GENIVI_ANALOG);
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID,sourceclass));
- enterSourceDB("source1", domainID1, cf1, sourceID);
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID, sourceclass));
+ enterSourceDB("source1", domainID1, cf1, sourceID);
- am_sinkID_t sinkID;
- std::vector<am_CustomConnectionFormat_t> cf2;
- cf2.push_back(CF_GENIVI_ANALOG);
- cf2.push_back(CF_GENIVI_MONO);
+ am_sinkID_t sinkID;
+ std::vector<am_CustomConnectionFormat_t> cf2;
+ cf2.push_back(CF_GENIVI_ANALOG);
+ cf2.push_back(CF_GENIVI_MONO);
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
- enterSinkDB("sink1", domainID1, cf2, sinkID);
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+ enterSinkDB("sink1", domainID1, cf2, sinkID);
am::am_Source_s source;
am::am_Sink_s sink;
@@ -2393,75 +2372,74 @@ TEST_F(CAmRouterMapTest,route1Domain1Source1Sink)
pDatabaseHandler.getSourceInfoDB(sourceID, source);
std::vector<am_Route_s> listRoutes;
- std::vector<am_RoutingElement_s> listRoutingElements;
- am_RoutingElement_s hopp1;
+ std::vector<am_RoutingElement_s> listRoutingElements;
+ am_RoutingElement_s hopp1;
- hopp1.sourceID = sourceID;
- hopp1.sinkID = sinkID;
- hopp1.domainID = domainID1;
- hopp1.connectionFormat = cf2[0];
+ hopp1.sourceID = sourceID;
+ hopp1.sinkID = sinkID;
+ hopp1.domainID = domainID1;
+ hopp1.connectionFormat = cf2[0];
- listRoutingElements.push_back(hopp1);
+ listRoutingElements.push_back(hopp1);
- am_Route_s compareRoute;
- compareRoute.route = listRoutingElements;
- compareRoute.sinkID = sinkID;
- compareRoute.sourceID = sourceID;
+ am_Route_s compareRoute;
+ compareRoute.route = listRoutingElements;
+ compareRoute.sinkID = sinkID;
+ compareRoute.sourceID = sourceID;
- ASSERT_EQ(getRoute(false, true, source, sink, listRoutes, 0), E_OK);
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ ASSERT_EQ(getRoute(false, false, source, sink, listRoutes, 0), E_OK);
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute, listRoutes[0]));
}
TEST_F(CAmRouterMapTest,route1Domain1Source1Converter1Sink)
{
- EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
- am_domainID_t domainID1;
- enterDomainDB("domain1", domainID1);
+ am_domainID_t domainID1;
+ enterDomainDB("domain1", domainID1);
- am_sourceID_t sourceID;
- std::vector<am_CustomConnectionFormat_t> cf1;
- cf1.push_back(CF_GENIVI_STEREO);
- cf1.push_back(CF_GENIVI_AUTO);
+ am_sourceID_t sourceID;
+ std::vector<am_CustomConnectionFormat_t> cf1;
+ cf1.push_back(CF_GENIVI_STEREO);
+ cf1.push_back(CF_GENIVI_AUTO);
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID,sourceclass));
- enterSourceDB("source1", domainID1, cf1, sourceID);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID, sourceclass));
+ enterSourceDB("source1", domainID1, cf1, sourceID);
- am_sinkID_t sinkID1, sinkID2;
- std::vector<am_CustomConnectionFormat_t> cf2;
- cf2.push_back(CF_GENIVI_MONO);
- cf2.push_back(CF_GENIVI_ANALOG);
+ am_sinkID_t sinkID1, sinkID2;
+ std::vector<am_CustomConnectionFormat_t> cf2;
+ cf2.push_back(CF_GENIVI_MONO);
+ cf2.push_back(CF_GENIVI_ANALOG);
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
-
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
- enterSinkDB("sink1", domainID1, cf2, sinkID1);
- enterSinkDB("sink2", domainID1, cf2, sinkID2);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+ enterSinkDB("sink1", domainID1, cf2, sinkID1);
+ enterSinkDB("sink2", domainID1, cf2, sinkID2);
- am_sourceID_t gwSourceID;
- std::vector<am_CustomConnectionFormat_t> cf3;
- cf3.push_back(CF_GENIVI_MONO);
- cf3.push_back(CF_GENIVI_ANALOG);
- enterSourceDB("gwSource1", domainID1, cf3, gwSourceID);
+ am_sourceID_t gwSourceID;
+ std::vector<am_CustomConnectionFormat_t> cf3;
+ cf3.push_back(CF_GENIVI_MONO);
+ cf3.push_back(CF_GENIVI_ANALOG);
+ enterSourceDB("gwSource1", domainID1, cf3, gwSourceID);
- am_sinkID_t gwSinkID;
- std::vector<am_CustomConnectionFormat_t> cf4;
- cf4.push_back(CF_GENIVI_STEREO);
- cf4.push_back(CF_GENIVI_ANALOG);
- enterSinkDB("gwSink1", domainID1, cf4, gwSinkID);
+ am_sinkID_t gwSinkID;
+ std::vector<am_CustomConnectionFormat_t> cf4;
+ cf4.push_back(CF_GENIVI_STEREO);
+ cf4.push_back(CF_GENIVI_ANALOG);
+ enterSinkDB("gwSink1", domainID1, cf4, gwSinkID);
am_converterID_t converterID;
std::vector<bool> matrix;
matrix.resize(4, false);
- matrix[0]=(true);
- matrix[1]=(true);
+ matrix[0] = (true);
+ matrix[1] = (true);
enterConverterDB("converter", domainID1, cf3, cf4, matrix, gwSourceID, gwSinkID, converterID);
am::am_Source_s source;
@@ -2471,87 +2449,86 @@ TEST_F(CAmRouterMapTest,route1Domain1Source1Converter1Sink)
pDatabaseHandler.getSourceInfoDB(sourceID, source);
std::vector<am_Route_s> listRoutes;
- std::vector<am_RoutingElement_s> listRoutingElements;
- am_RoutingElement_s hopp1;
- am_RoutingElement_s hopp2;
-
- hopp1.sourceID = sourceID;
- hopp1.sinkID = gwSinkID;
- hopp1.domainID = domainID1;
- hopp1.connectionFormat = CF_GENIVI_STEREO;
-
- hopp2.sourceID = gwSourceID;
- hopp2.sinkID = sinkID1;
- hopp2.domainID = domainID1;
- hopp2.connectionFormat = CF_GENIVI_MONO;
-
- listRoutingElements.push_back(hopp1);
- listRoutingElements.push_back(hopp2);
-
- am_Route_s compareRoute;
- compareRoute.route = listRoutingElements;
- compareRoute.sinkID = sinkID1;
- compareRoute.sourceID = sourceID;
-
- ASSERT_EQ(getRoute(false, true, source, sink, listRoutes, 0), E_OK);
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ std::vector<am_RoutingElement_s> listRoutingElements;
+ am_RoutingElement_s hopp1;
+ am_RoutingElement_s hopp2;
+
+ hopp1.sourceID = sourceID;
+ hopp1.sinkID = gwSinkID;
+ hopp1.domainID = domainID1;
+ hopp1.connectionFormat = CF_GENIVI_STEREO;
+
+ hopp2.sourceID = gwSourceID;
+ hopp2.sinkID = sinkID1;
+ hopp2.domainID = domainID1;
+ hopp2.connectionFormat = CF_GENIVI_MONO;
+
+ listRoutingElements.push_back(hopp1);
+ listRoutingElements.push_back(hopp2);
+
+ am_Route_s compareRoute;
+ compareRoute.route = listRoutingElements;
+ compareRoute.sinkID = sinkID1;
+ compareRoute.sourceID = sourceID;
+
+ ASSERT_EQ(getRoute(false, false, source, sink, listRoutes, 0), E_OK);
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute, listRoutes[0]));
}
TEST_F(CAmRouterMapTest,route1Domain1Source3Converters1Sink)
{
- EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID,sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID, sourceclass));
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
-
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
- am_domainID_t domainID1;
- enterDomainDB("domain1", domainID1);
+ am_domainID_t domainID1;
+ enterDomainDB("domain1", domainID1);
- std::vector<am_CustomConnectionFormat_t> cf1;
- cf1.push_back(CF_GENIVI_STEREO);
- std::vector<am_CustomConnectionFormat_t> cf2;
- cf2.push_back(CF_GENIVI_MONO);
- std::vector<am_CustomConnectionFormat_t> cf3;
- cf3.push_back(CF_GENIVI_AUTO);
+ std::vector<am_CustomConnectionFormat_t> cf1;
+ cf1.push_back(CF_GENIVI_STEREO);
+ std::vector<am_CustomConnectionFormat_t> cf2;
+ cf2.push_back(CF_GENIVI_MONO);
+ std::vector<am_CustomConnectionFormat_t> cf3;
+ cf3.push_back(CF_GENIVI_AUTO);
- am_sourceID_t sourceID;
- enterSourceDB("source1", domainID1, cf1, sourceID);
+ am_sourceID_t sourceID;
+ enterSourceDB("source1", domainID1, cf1, sourceID);
- am_sinkID_t sinkID;
- enterSinkDB("sink1", domainID1, cf3, sinkID);
+ am_sinkID_t sinkID;
+ enterSinkDB("sink1", domainID1, cf3, sinkID);
- am_sourceID_t gwSourceID;
- enterSourceDB("gwSource1", domainID1, cf2, gwSourceID);
- am_sinkID_t gwSinkID;
- enterSinkDB("gwSink1", domainID1, cf1, gwSinkID);
+ am_sourceID_t gwSourceID;
+ enterSourceDB("gwSource1", domainID1, cf2, gwSourceID);
+ am_sinkID_t gwSinkID;
+ enterSinkDB("gwSink1", domainID1, cf1, gwSinkID);
am_converterID_t converterID;
std::vector<bool> matrix;
matrix.push_back(true);
enterConverterDB("converter1", domainID1, cf2, cf1, matrix, gwSourceID, gwSinkID, converterID);
- am_sourceID_t gwSourceID1;
- enterSourceDB("gwSource2", domainID1, cf2, gwSourceID1);
- am_sinkID_t gwSinkID1;
- enterSinkDB("gwSink2", domainID1, cf1, gwSinkID1);
+ am_sourceID_t gwSourceID1;
+ enterSourceDB("gwSource2", domainID1, cf2, gwSourceID1);
+ am_sinkID_t gwSinkID1;
+ enterSinkDB("gwSink2", domainID1, cf1, gwSinkID1);
am_converterID_t converterID1;
enterConverterDB("converter2", domainID1, cf2, cf1, matrix, gwSourceID1, gwSinkID1, converterID1);
- am_sourceID_t gwSourceID2;
- enterSourceDB("gwSource3", domainID1, cf3, gwSourceID2);
- am_sinkID_t gwSinkID2;
- enterSinkDB("gwSink3", domainID1, cf2, gwSinkID2);
+ am_sourceID_t gwSourceID2;
+ enterSourceDB("gwSource3", domainID1, cf3, gwSourceID2);
+ am_sinkID_t gwSinkID2;
+ enterSinkDB("gwSink3", domainID1, cf2, gwSinkID2);
am_converterID_t converterID2;
enterConverterDB("converter3", domainID1, cf3, cf2, matrix, gwSourceID2, gwSinkID2, converterID2);
@@ -2560,106 +2537,104 @@ TEST_F(CAmRouterMapTest,route1Domain1Source3Converters1Sink)
pDatabaseHandler.getSinkInfoDB(sinkID, sink);
pDatabaseHandler.getSourceInfoDB(sourceID, source);
-
std::vector<am_Route_s> listRoutes;
- std::vector<am_RoutingElement_s> listRoutingElements1;
- std::vector<am_RoutingElement_s> listRoutingElements2;
- am_RoutingElement_s hopp11;
- am_RoutingElement_s hopp12;
- am_RoutingElement_s hopp13;
- am_RoutingElement_s hopp21;
- am_RoutingElement_s hopp22;
-
- hopp11.sourceID = sourceID;
- hopp11.sinkID = gwSinkID;
- hopp11.domainID = domainID1;
- hopp11.connectionFormat = CF_GENIVI_STEREO;
-
- hopp12.sourceID = gwSourceID;
- hopp12.sinkID = gwSinkID2;
- hopp12.domainID = domainID1;
- hopp12.connectionFormat = CF_GENIVI_MONO;
-
- hopp21.sourceID = sourceID;
- hopp21.sinkID = gwSinkID1;
- hopp21.domainID = domainID1;
- hopp21.connectionFormat = CF_GENIVI_STEREO;
-
- hopp22.sourceID = gwSourceID1;
- hopp22.sinkID = gwSinkID2;
- hopp22.domainID = domainID1;
- hopp22.connectionFormat = CF_GENIVI_MONO;
-
- hopp13.sourceID = gwSourceID2;
- hopp13.sinkID = sinkID;
- hopp13.domainID = domainID1;
- hopp13.connectionFormat = CF_GENIVI_AUTO;
-
- listRoutingElements1.push_back(hopp11);
- listRoutingElements1.push_back(hopp12);
- listRoutingElements1.push_back(hopp13);
-
- listRoutingElements2.push_back(hopp21);
- listRoutingElements2.push_back(hopp22);
- listRoutingElements2.push_back(hopp13);
-
- am_Route_s compareRoute1;
- compareRoute1.route = listRoutingElements1;
- compareRoute1.sinkID = sinkID;
- compareRoute1.sourceID = sourceID;
-
- ASSERT_EQ(getRoute(false, true, source, sink, listRoutes, 0), E_OK);
- ASSERT_EQ(static_cast<uint>(2), listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[0])||pCF.compareRoute(compareRoute1,listRoutes[1]));
-
- am_Route_s compareRoute2;
- compareRoute2.route = listRoutingElements2;
- compareRoute2.sinkID = sinkID;
- compareRoute2.sourceID = sourceID;
- ASSERT_TRUE(pCF.compareRoute(compareRoute2,listRoutes[1])||pCF.compareRoute(compareRoute2,listRoutes[0]));
+ std::vector<am_RoutingElement_s> listRoutingElements1;
+ std::vector<am_RoutingElement_s> listRoutingElements2;
+ am_RoutingElement_s hopp11;
+ am_RoutingElement_s hopp12;
+ am_RoutingElement_s hopp13;
+ am_RoutingElement_s hopp21;
+ am_RoutingElement_s hopp22;
+
+ hopp11.sourceID = sourceID;
+ hopp11.sinkID = gwSinkID;
+ hopp11.domainID = domainID1;
+ hopp11.connectionFormat = CF_GENIVI_STEREO;
+
+ hopp12.sourceID = gwSourceID;
+ hopp12.sinkID = gwSinkID2;
+ hopp12.domainID = domainID1;
+ hopp12.connectionFormat = CF_GENIVI_MONO;
+
+ hopp21.sourceID = sourceID;
+ hopp21.sinkID = gwSinkID1;
+ hopp21.domainID = domainID1;
+ hopp21.connectionFormat = CF_GENIVI_STEREO;
+
+ hopp22.sourceID = gwSourceID1;
+ hopp22.sinkID = gwSinkID2;
+ hopp22.domainID = domainID1;
+ hopp22.connectionFormat = CF_GENIVI_MONO;
+
+ hopp13.sourceID = gwSourceID2;
+ hopp13.sinkID = sinkID;
+ hopp13.domainID = domainID1;
+ hopp13.connectionFormat = CF_GENIVI_AUTO;
+
+ listRoutingElements1.push_back(hopp11);
+ listRoutingElements1.push_back(hopp12);
+ listRoutingElements1.push_back(hopp13);
+
+ listRoutingElements2.push_back(hopp21);
+ listRoutingElements2.push_back(hopp22);
+ listRoutingElements2.push_back(hopp13);
+
+ am_Route_s compareRoute1;
+ compareRoute1.route = listRoutingElements1;
+ compareRoute1.sinkID = sinkID;
+ compareRoute1.sourceID = sourceID;
+
+ ASSERT_EQ(getRoute(false, false, source, sink, listRoutes, 0), E_OK);
+ ASSERT_EQ(static_cast<uint>(2), listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute1, listRoutes[0]) || pCF.compareRoute(compareRoute1, listRoutes[1]));
+
+ am_Route_s compareRoute2;
+ compareRoute2.route = listRoutingElements2;
+ compareRoute2.sinkID = sinkID;
+ compareRoute2.sourceID = sourceID;
+ ASSERT_TRUE(pCF.compareRoute(compareRoute2, listRoutes[1]) || pCF.compareRoute(compareRoute2, listRoutes[0]));
}
TEST_F(CAmRouterMapTest,route2Domains1Source1Sink)
{
- EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID,sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID, sourceclass));
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
-
- am_domainID_t domainID1, domainID2;
- enterDomainDB("domain1", domainID1);
- enterDomainDB("domain2", domainID2);
+ am_domainID_t domainID1, domainID2;
+ enterDomainDB("domain1", domainID1);
+ enterDomainDB("domain2", domainID2);
- am_sourceID_t sourceID;
- std::vector<am_CustomConnectionFormat_t> cf1;
- cf1.push_back(CF_GENIVI_STEREO);
- enterSourceDB("source1", domainID1, cf1, sourceID);
+ am_sourceID_t sourceID;
+ std::vector<am_CustomConnectionFormat_t> cf1;
+ cf1.push_back(CF_GENIVI_STEREO);
+ enterSourceDB("source1", domainID1, cf1, sourceID);
- am_sinkID_t sinkID;
- std::vector<am_CustomConnectionFormat_t> cf2;
- cf2.push_back(CF_GENIVI_ANALOG);
- enterSinkDB("sink1", domainID2, cf2, sinkID);
+ am_sinkID_t sinkID;
+ std::vector<am_CustomConnectionFormat_t> cf2;
+ cf2.push_back(CF_GENIVI_ANALOG);
+ enterSinkDB("sink1", domainID2, cf2, sinkID);
- am_sourceID_t gwSourceID;
- std::vector<am_CustomConnectionFormat_t> cf3;
- cf3.push_back(CF_GENIVI_ANALOG);
- enterSourceDB("gwSource1", domainID2, cf3, gwSourceID);
+ am_sourceID_t gwSourceID;
+ std::vector<am_CustomConnectionFormat_t> cf3;
+ cf3.push_back(CF_GENIVI_ANALOG);
+ enterSourceDB("gwSource1", domainID2, cf3, gwSourceID);
- am_sinkID_t gwSinkID;
- std::vector<am_CustomConnectionFormat_t> cf4;
- cf4.push_back(CF_GENIVI_STEREO);
- enterSinkDB("gwSink1", domainID1, cf4, gwSinkID);
+ am_sinkID_t gwSinkID;
+ std::vector<am_CustomConnectionFormat_t> cf4;
+ cf4.push_back(CF_GENIVI_STEREO);
+ enterSinkDB("gwSink1", domainID1, cf4, gwSinkID);
am_gatewayID_t gatewayID;
std::vector<bool> matrix;
@@ -2673,58 +2648,59 @@ TEST_F(CAmRouterMapTest,route2Domains1Source1Sink)
pDatabaseHandler.getSourceInfoDB(sourceID, source);
std::vector<am_Route_s> listRoutes;
- ASSERT_EQ(getRoute(false, true, source, sink, listRoutes, 0), E_OK);
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_EQ(getRoute(false, false, source, sink, listRoutes, 0), E_OK);
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- am_Route_s compareRoute1;
- compareRoute1.sinkID = sinkID;
- compareRoute1.sourceID = sourceID;
- compareRoute1.route.push_back({sourceID, gwSinkID, domainID1, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gwSourceID, sinkID, domainID2, CF_GENIVI_ANALOG});
- ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[0]));
+ am_Route_s compareRoute1;
+ compareRoute1.sinkID = sinkID;
+ compareRoute1.sourceID = sourceID;
+ compareRoute1.route.push_back(
+ { sourceID, gwSinkID, domainID1, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gwSourceID, sinkID, domainID2, CF_GENIVI_ANALOG });
+ ASSERT_TRUE(pCF.compareRoute(compareRoute1, listRoutes[0]));
}
TEST_F(CAmRouterMapTest,route3Domains1Source1Sink)
{
- EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID,sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID, sourceclass));
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
-
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
- am_domainID_t domainID1, domainID2, domainID3;
- enterDomainDB("domain1", domainID1);
- enterDomainDB("domain2", domainID2);
- enterDomainDB("domain3", domainID3);
+ am_domainID_t domainID1, domainID2, domainID3;
+ enterDomainDB("domain1", domainID1);
+ enterDomainDB("domain2", domainID2);
+ enterDomainDB("domain3", domainID3);
- std::vector<am_CustomConnectionFormat_t> cfStereo;
- cfStereo.push_back(CF_GENIVI_STEREO);
- std::vector<am_CustomConnectionFormat_t> cfAnalog;
- cfAnalog.push_back(CF_GENIVI_ANALOG);
- std::vector<am_CustomConnectionFormat_t> cfMono;
- cfMono.push_back(CF_GENIVI_MONO);
+ std::vector<am_CustomConnectionFormat_t> cfStereo;
+ cfStereo.push_back(CF_GENIVI_STEREO);
+ std::vector<am_CustomConnectionFormat_t> cfAnalog;
+ cfAnalog.push_back(CF_GENIVI_ANALOG);
+ std::vector<am_CustomConnectionFormat_t> cfMono;
+ cfMono.push_back(CF_GENIVI_MONO);
- am_sourceID_t sourceID;
- enterSourceDB("source1", domainID1, cfStereo, sourceID);
+ am_sourceID_t sourceID;
+ enterSourceDB("source1", domainID1, cfStereo, sourceID);
- am_sinkID_t gwSinkID1;
- enterSinkDB("gwSink1", domainID1, cfStereo, gwSinkID1);
+ am_sinkID_t gwSinkID1;
+ enterSinkDB("gwSink1", domainID1, cfStereo, gwSinkID1);
- am_sourceID_t gwSourceID1;
- enterSourceDB("gwSource1", domainID2, cfMono, gwSourceID1);
+ am_sourceID_t gwSourceID1;
+ enterSourceDB("gwSource1", domainID2, cfMono, gwSourceID1);
- std::vector<bool> matrix;
- matrix.push_back(true);
+ std::vector<bool> matrix;
+ matrix.push_back(true);
am_gatewayID_t gatewayID;
enterGatewayDB("gateway", domainID2, domainID1, cfMono, cfStereo, matrix, gwSourceID1, gwSinkID1, gatewayID);
@@ -2735,8 +2711,8 @@ TEST_F(CAmRouterMapTest,route3Domains1Source1Sink)
am_sinkID_t gwSinkID2;
enterSinkDB("gwSink2", domainID2, cfMono, gwSinkID2);
- am_sinkID_t sinkID;
- enterSinkDB("sink1", domainID3, cfStereo, sinkID);
+ am_sinkID_t sinkID;
+ enterSinkDB("sink1", domainID3, cfStereo, sinkID);
am_gatewayID_t gatewayID1;
enterGatewayDB("gateway", domainID3, domainID2, cfStereo, cfMono, matrix, gwSourceID2, gwSinkID2, gatewayID1);
@@ -2749,65 +2725,67 @@ TEST_F(CAmRouterMapTest,route3Domains1Source1Sink)
std::vector<am_Route_s> listRoutes;
- ASSERT_EQ(getRoute(false, true, source, sink, listRoutes, 0), E_OK);
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_EQ(getRoute(false, false, source, sink, listRoutes, 0), E_OK);
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- am_Route_s compareRoute1;
- compareRoute1.sinkID = sinkID;
- compareRoute1.sourceID = sourceID;
- compareRoute1.route.push_back({sourceID, gwSinkID1, domainID1, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gwSourceID1, gwSinkID2, domainID2, CF_GENIVI_MONO});
- compareRoute1.route.push_back({gwSourceID2, sinkID, domainID3, CF_GENIVI_STEREO});
- ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[0]));
+ am_Route_s compareRoute1;
+ compareRoute1.sinkID = sinkID;
+ compareRoute1.sourceID = sourceID;
+ compareRoute1.route.push_back(
+ { sourceID, gwSinkID1, domainID1, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gwSourceID1, gwSinkID2, domainID2, CF_GENIVI_MONO });
+ compareRoute1.route.push_back(
+ { gwSourceID2, sinkID, domainID3, CF_GENIVI_STEREO });
+ ASSERT_TRUE(pCF.compareRoute(compareRoute1, listRoutes[0]));
}
TEST_F(CAmRouterMapTest,routeSource1Sink2PathThroughConv1Gate1)
{
- EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID,sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID, sourceclass));
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
-
-
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
- std::vector<bool> matrix;
- matrix.push_back(true);
- am_domainID_t domainID1, domainID2;
- enterDomainDB("domain1", domainID1);
- enterDomainDB("domain2", domainID2);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
- std::vector<am_CustomConnectionFormat_t> cfStereo;
- cfStereo.push_back(CF_GENIVI_STEREO);
- std::vector<am_CustomConnectionFormat_t> cfAnalog;
- cfAnalog.push_back(CF_GENIVI_ANALOG);
- std::vector<am_CustomConnectionFormat_t> cfMono;
- cfMono.push_back(CF_GENIVI_MONO);
- std::vector<am_CustomConnectionFormat_t> cfAuto;
- cfAuto.push_back(CF_GENIVI_AUTO);
+ std::vector<bool> matrix;
+ matrix.push_back(true);
+ am_domainID_t domainID1, domainID2;
+ enterDomainDB("domain1", domainID1);
+ enterDomainDB("domain2", domainID2);
+
+ std::vector<am_CustomConnectionFormat_t> cfStereo;
+ cfStereo.push_back(CF_GENIVI_STEREO);
+ std::vector<am_CustomConnectionFormat_t> cfAnalog;
+ cfAnalog.push_back(CF_GENIVI_ANALOG);
+ std::vector<am_CustomConnectionFormat_t> cfMono;
+ cfMono.push_back(CF_GENIVI_MONO);
+ std::vector<am_CustomConnectionFormat_t> cfAuto;
+ cfAuto.push_back(CF_GENIVI_AUTO);
- am_sourceID_t sourceID;
- enterSourceDB("source1", domainID1, cfStereo, sourceID);
+ am_sourceID_t sourceID;
+ enterSourceDB("source1", domainID1, cfStereo, sourceID);
- am_sinkID_t gwSinkID1;
- enterSinkDB("gwSink1", domainID1, cfMono, gwSinkID1);
+ am_sinkID_t gwSinkID1;
+ enterSinkDB("gwSink1", domainID1, cfMono, gwSinkID1);
- am_sinkID_t coSinkID21;
+ am_sinkID_t coSinkID21;
enterSinkDB("coSink21", domainID1, cfStereo, coSinkID21);
- am_sourceID_t coSourceID21;
- enterSourceDB("coSource21", domainID1, cfMono, coSourceID21);
+ am_sourceID_t coSourceID21;
+ enterSourceDB("coSource21", domainID1, cfMono, coSourceID21);
- am_converterID_t converterID1;
- enterConverterDB("converter1", domainID1, cfMono, cfStereo, matrix, coSourceID21, coSinkID21, converterID1);
+ am_converterID_t converterID1;
+ enterConverterDB("converter1", domainID1, cfMono, cfStereo, matrix, coSourceID21, coSinkID21, converterID1);
am_sourceID_t gwSourceID1;
enterSourceDB("gwSource21", domainID2, cfAuto, gwSourceID1);
@@ -2815,11 +2793,11 @@ TEST_F(CAmRouterMapTest,routeSource1Sink2PathThroughConv1Gate1)
am_gatewayID_t gatewayID;
enterGatewayDB("gateway1", domainID2, domainID1, cfAuto, cfMono, matrix, gwSourceID1, gwSinkID1, gatewayID);
- am_sinkID_t sinkID1;
- enterSinkDB("sink1", domainID2, cfAuto, sinkID1);
+ am_sinkID_t sinkID1;
+ enterSinkDB("sink1", domainID2, cfAuto, sinkID1);
- am_sinkID_t sinkID2;
- enterSinkDB("sink2", domainID1, cfAuto, sinkID2);
+ am_sinkID_t sinkID2;
+ enterSinkDB("sink2", domainID1, cfAuto, sinkID2);
am::am_Source_s source;
am::am_Sink_s sink1;
@@ -2830,76 +2808,78 @@ TEST_F(CAmRouterMapTest,routeSource1Sink2PathThroughConv1Gate1)
std::vector<am_Route_s> listRoutes;
- ASSERT_EQ(getRoute(false, true, source, sink1, listRoutes, 0), E_OK);
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
-
- am_Route_s compareRoute1;
- compareRoute1.sinkID = sinkID1;
- compareRoute1.sourceID = sourceID;
- compareRoute1.route.push_back({sourceID, coSinkID21, domainID1, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({coSourceID21, gwSinkID1, domainID1, CF_GENIVI_MONO});
- compareRoute1.route.push_back({gwSourceID1, sinkID1, domainID2, CF_GENIVI_AUTO});
- ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[0]));
+ ASSERT_EQ(getRoute(false, false, source, sink1, listRoutes, 0), E_OK);
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- listRoutes.clear();
- ASSERT_EQ(getRoute(false, true, source, sink2, listRoutes, 0), E_NOT_POSSIBLE);
- ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
+ am_Route_s compareRoute1;
+ compareRoute1.sinkID = sinkID1;
+ compareRoute1.sourceID = sourceID;
+ compareRoute1.route.push_back(
+ { sourceID, coSinkID21, domainID1, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { coSourceID21, gwSinkID1, domainID1, CF_GENIVI_MONO });
+ compareRoute1.route.push_back(
+ { gwSourceID1, sinkID1, domainID2, CF_GENIVI_AUTO });
+ ASSERT_TRUE(pCF.compareRoute(compareRoute1, listRoutes[0]));
+
+ listRoutes.clear();
+ ASSERT_EQ(getRoute(false, false, source, sink2, listRoutes, 0), E_NOT_POSSIBLE);
+ ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
}
TEST_F(CAmRouterMapTest, routeSource1Sink1PathThroughDomain2)
{
- EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID,sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID, sourceclass));
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
-
-
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
- std::vector<bool> matrix;
- matrix.push_back(true);
- am_domainID_t domainID1, domainID2;
- enterDomainDB("domain1", domainID1);
- enterDomainDB("domain2", domainID2);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
- std::vector<am_CustomConnectionFormat_t> cfStereo;
- cfStereo.push_back(CF_GENIVI_STEREO);
- std::vector<am_CustomConnectionFormat_t> cfAnalog;
- cfAnalog.push_back(CF_GENIVI_ANALOG);
- std::vector<am_CustomConnectionFormat_t> cfMono;
- cfMono.push_back(CF_GENIVI_MONO);
- std::vector<am_CustomConnectionFormat_t> cfAuto;
- cfAuto.push_back(CF_GENIVI_AUTO);
+ std::vector<bool> matrix;
+ matrix.push_back(true);
+ am_domainID_t domainID1, domainID2;
+ enterDomainDB("domain1", domainID1);
+ enterDomainDB("domain2", domainID2);
+
+ std::vector<am_CustomConnectionFormat_t> cfStereo;
+ cfStereo.push_back(CF_GENIVI_STEREO);
+ std::vector<am_CustomConnectionFormat_t> cfAnalog;
+ cfAnalog.push_back(CF_GENIVI_ANALOG);
+ std::vector<am_CustomConnectionFormat_t> cfMono;
+ cfMono.push_back(CF_GENIVI_MONO);
+ std::vector<am_CustomConnectionFormat_t> cfAuto;
+ cfAuto.push_back(CF_GENIVI_AUTO);
- am_sourceID_t sourceID;
- enterSourceDB("source1", domainID1, cfStereo, sourceID);
+ am_sourceID_t sourceID;
+ enterSourceDB("source1", domainID1, cfStereo, sourceID);
- am_sinkID_t gwSinkID11;
+ am_sinkID_t gwSinkID11;
enterSinkDB("gwSink11", domainID1, cfStereo, gwSinkID11);
- am_sourceID_t gwSourceID11;
- enterSourceDB("gwSource11", domainID2, cfAnalog, gwSourceID11);
- am_converterID_t gatewayID1;
- enterGatewayDB("gateway1", domainID2, domainID1, cfAnalog, cfStereo, matrix, gwSourceID11, gwSinkID11, gatewayID1);
+ am_sourceID_t gwSourceID11;
+ enterSourceDB("gwSource11", domainID2, cfAnalog, gwSourceID11);
+ am_converterID_t gatewayID1;
+ enterGatewayDB("gateway1", domainID2, domainID1, cfAnalog, cfStereo, matrix, gwSourceID11, gwSinkID11, gatewayID1);
- am_sinkID_t gwSinkID21;
+ am_sinkID_t gwSinkID21;
enterSinkDB("gwSink21", domainID2, cfAnalog, gwSinkID21);
am_sourceID_t gwSourceID12;
enterSourceDB("gwSource12", domainID1, cfAuto, gwSourceID12);
am_gatewayID_t gatewayID2;
enterGatewayDB("gateway2", domainID1, domainID2, cfAuto, cfAnalog, matrix, gwSourceID12, gwSinkID21, gatewayID2);
- am_sinkID_t sink1ID;
- enterSinkDB("sink1", domainID1, cfAuto, sink1ID);
- am_sinkID_t sink2ID;
- enterSinkDB("sink2", domainID2, cfAnalog, sink2ID);
+ am_sinkID_t sink1ID;
+ enterSinkDB("sink1", domainID1, cfAuto, sink1ID);
+ am_sinkID_t sink2ID;
+ enterSinkDB("sink2", domainID2, cfAnalog, sink2ID);
std::vector<am_Route_s> listRoutes;
@@ -2908,90 +2888,91 @@ TEST_F(CAmRouterMapTest, routeSource1Sink1PathThroughDomain2)
pDatabaseHandler.getSinkInfoDB(sink1ID, sink1);
pDatabaseHandler.getSourceInfoDB(sourceID, source);
- ASSERT_EQ(getRoute(false, true, source, sink1, listRoutes, 0), E_NOT_POSSIBLE);
- ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
+ ASSERT_EQ(getRoute(false, false, source, sink1, listRoutes, 0), E_NOT_POSSIBLE);
+ ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
am::am_Sink_s sink2;
pDatabaseHandler.getSinkInfoDB(sink2ID, sink2);
- ASSERT_EQ(getRoute(false, true, source, sink2, listRoutes, 0), E_OK);
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ ASSERT_EQ(getRoute(false, false, source, sink2, listRoutes, 0), E_OK);
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- am_Route_s compareRoute1;
- compareRoute1.sinkID = sink2ID;
- compareRoute1.sourceID = sourceID;
- compareRoute1.route.push_back({sourceID, gwSinkID11, domainID1, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gwSourceID11, sink2ID, domainID2, CF_GENIVI_ANALOG});
- ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[0]));
+ am_Route_s compareRoute1;
+ compareRoute1.sinkID = sink2ID;
+ compareRoute1.sourceID = sourceID;
+ compareRoute1.route.push_back(
+ { sourceID, gwSinkID11, domainID1, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gwSourceID11, sink2ID, domainID2, CF_GENIVI_ANALOG });
+ ASSERT_TRUE(pCF.compareRoute(compareRoute1, listRoutes[0]));
}
TEST_F(CAmRouterMapTest, routeSource1Sink1PathThroughGate1Conv2Gate2)
{
- EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID,sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID, sourceclass));
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
-
-
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
- std::vector<bool> matrix;
- matrix.push_back(true);
- am_domainID_t domainID1, domainID2;
- enterDomainDB("domain1", domainID1);
- enterDomainDB("domain2", domainID2);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
- std::vector<am_CustomConnectionFormat_t> cfStereo;
- cfStereo.push_back(CF_GENIVI_STEREO);
- std::vector<am_CustomConnectionFormat_t> cfAnalog;
- cfAnalog.push_back(CF_GENIVI_ANALOG);
- std::vector<am_CustomConnectionFormat_t> cfMono;
- cfMono.push_back(CF_GENIVI_MONO);
- std::vector<am_CustomConnectionFormat_t> cfAuto;
- cfAuto.push_back(CF_GENIVI_AUTO);
+ std::vector<bool> matrix;
+ matrix.push_back(true);
+ am_domainID_t domainID1, domainID2;
+ enterDomainDB("domain1", domainID1);
+ enterDomainDB("domain2", domainID2);
+
+ std::vector<am_CustomConnectionFormat_t> cfStereo;
+ cfStereo.push_back(CF_GENIVI_STEREO);
+ std::vector<am_CustomConnectionFormat_t> cfAnalog;
+ cfAnalog.push_back(CF_GENIVI_ANALOG);
+ std::vector<am_CustomConnectionFormat_t> cfMono;
+ cfMono.push_back(CF_GENIVI_MONO);
+ std::vector<am_CustomConnectionFormat_t> cfAuto;
+ cfAuto.push_back(CF_GENIVI_AUTO);
- am_sourceID_t sourceID;
- enterSourceDB("source1", domainID1, cfStereo, sourceID);
+ am_sourceID_t sourceID;
+ enterSourceDB("source1", domainID1, cfStereo, sourceID);
- am_sinkID_t gwSinkID11;
+ am_sinkID_t gwSinkID11;
enterSinkDB("gwSink11", domainID1, cfStereo, gwSinkID11);
- am_sourceID_t gwSourceID21;
- enterSourceDB("gwSource21", domainID2, cfAnalog, gwSourceID21);
+ am_sourceID_t gwSourceID21;
+ enterSourceDB("gwSource21", domainID2, cfAnalog, gwSourceID21);
- am_converterID_t gatewayID1;
- enterGatewayDB("gateway1", domainID2, domainID1, cfAnalog, cfStereo, matrix, gwSourceID21, gwSinkID11, gatewayID1);
+ am_converterID_t gatewayID1;
+ enterGatewayDB("gateway1", domainID2, domainID1, cfAnalog, cfStereo, matrix, gwSourceID21, gwSinkID11, gatewayID1);
- am_sinkID_t gwSinkID21;
+ am_sinkID_t gwSinkID21;
enterSinkDB("gwSink21", domainID2, cfStereo, gwSinkID21);
am_sourceID_t gwSourceID12;
enterSourceDB("gwSource12", domainID1, cfAuto, gwSourceID12);
am_sinkID_t coSinkID21;
- enterSinkDB("coSink21", domainID2, cfAnalog, coSinkID21);
+ enterSinkDB("coSink21", domainID2, cfAnalog, coSinkID21);
- am_sourceID_t coSourceID21;
- enterSourceDB("coSource21", domainID2, cfStereo, coSourceID21);
+ am_sourceID_t coSourceID21;
+ enterSourceDB("coSource21", domainID2, cfStereo, coSourceID21);
- am_converterID_t converterID2;
- enterConverterDB("converter2", domainID2, cfStereo, cfAnalog, matrix, coSourceID21, coSinkID21, converterID2);
+ am_converterID_t converterID2;
+ enterConverterDB("converter2", domainID2, cfStereo, cfAnalog, matrix, coSourceID21, coSinkID21, converterID2);
am_gatewayID_t gatewayID2;
enterGatewayDB("gateway2", domainID1, domainID2, cfAuto, cfStereo, matrix, gwSourceID12, gwSinkID21, gatewayID2);
- am_sinkID_t sink1ID;
- enterSinkDB("sink1", domainID1, cfAuto, sink1ID);
- am_sinkID_t sink2ID;
- enterSinkDB("sink2", domainID2, cfStereo, sink2ID);
+ am_sinkID_t sink1ID;
+ enterSinkDB("sink1", domainID1, cfAuto, sink1ID);
+ am_sinkID_t sink2ID;
+ enterSinkDB("sink2", domainID2, cfStereo, sink2ID);
am::am_Source_s source;
am::am_Sink_s sink;
@@ -3001,112 +2982,113 @@ TEST_F(CAmRouterMapTest, routeSource1Sink1PathThroughGate1Conv2Gate2)
std::vector<am_Route_s> listRoutes;
- ASSERT_EQ(getRoute(false, true, source, sink, listRoutes, 0), E_NOT_POSSIBLE);
- ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
+ ASSERT_EQ(getRoute(false, false, source, sink, listRoutes, 0), E_NOT_POSSIBLE);
+ ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
am::am_Sink_s sink1;
pDatabaseHandler.getSinkInfoDB(sink2ID, sink1);
- ASSERT_EQ(getRoute(false, true, source, sink1, listRoutes, 0), E_OK);
-
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- am_Route_s compareRoute1;
- compareRoute1.sinkID = sink2ID;
- compareRoute1.sourceID = sourceID;
- compareRoute1.route.push_back({sourceID, gwSinkID11, domainID1, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gwSourceID21, coSinkID21, domainID2, CF_GENIVI_ANALOG});
- compareRoute1.route.push_back({coSourceID21, sink2ID, domainID2, CF_GENIVI_STEREO});
- ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[0]));
+ ASSERT_EQ(getRoute(false, false, source, sink1, listRoutes, 0), E_OK);
+
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ am_Route_s compareRoute1;
+ compareRoute1.sinkID = sink2ID;
+ compareRoute1.sourceID = sourceID;
+ compareRoute1.route.push_back(
+ { sourceID, gwSinkID11, domainID1, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gwSourceID21, coSinkID21, domainID2, CF_GENIVI_ANALOG });
+ compareRoute1.route.push_back(
+ { coSourceID21, sink2ID, domainID2, CF_GENIVI_STEREO });
+ ASSERT_TRUE(pCF.compareRoute(compareRoute1, listRoutes[0]));
}
TEST_F(CAmRouterMapTest, routeSource1Sink1PathThroughConv1Gate1Conv2Gate2)
{
- EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID,sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID, sourceclass));
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
-
-
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
-
- std::vector<bool> matrix;
- matrix.push_back(true);
- am_domainID_t domainID1, domainID2;
- enterDomainDB("domain1", domainID1);
- enterDomainDB("domain2", domainID2);
-
- std::vector<am_CustomConnectionFormat_t> cfStereo;
- cfStereo.push_back(CF_GENIVI_STEREO);
- std::vector<am_CustomConnectionFormat_t> cfAnalog;
- cfAnalog.push_back(CF_GENIVI_ANALOG);
- std::vector<am_CustomConnectionFormat_t> cfMono;
- cfMono.push_back(CF_GENIVI_MONO);
- std::vector<am_CustomConnectionFormat_t> cfAuto;
- cfAuto.push_back(CF_GENIVI_AUTO);
- std::vector<am_CustomConnectionFormat_t> cfFuture1;
- cfFuture1.push_back(5);
- std::vector<am_CustomConnectionFormat_t> cfFuture2;
- cfFuture2.push_back(6);
-
- am_sourceID_t sourceID;
- enterSourceDB("source1", domainID1, cfStereo, sourceID);
-
- am_sinkID_t coSinkID11;
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+
+ std::vector<bool> matrix;
+ matrix.push_back(true);
+ am_domainID_t domainID1, domainID2;
+ enterDomainDB("domain1", domainID1);
+ enterDomainDB("domain2", domainID2);
+
+ std::vector<am_CustomConnectionFormat_t> cfStereo;
+ cfStereo.push_back(CF_GENIVI_STEREO);
+ std::vector<am_CustomConnectionFormat_t> cfAnalog;
+ cfAnalog.push_back(CF_GENIVI_ANALOG);
+ std::vector<am_CustomConnectionFormat_t> cfMono;
+ cfMono.push_back(CF_GENIVI_MONO);
+ std::vector<am_CustomConnectionFormat_t> cfAuto;
+ cfAuto.push_back(CF_GENIVI_AUTO);
+ std::vector<am_CustomConnectionFormat_t> cfFuture1;
+ cfFuture1.push_back(5);
+ std::vector<am_CustomConnectionFormat_t> cfFuture2;
+ cfFuture2.push_back(6);
+
+ am_sourceID_t sourceID;
+ enterSourceDB("source1", domainID1, cfStereo, sourceID);
+
+ am_sinkID_t coSinkID11;
enterSinkDB("coSink11", domainID1, cfStereo, coSinkID11);
- am_sourceID_t coSourceID11;
- enterSourceDB("coSource11", domainID1, cfFuture1, coSourceID11);
- am_converterID_t converterID11;
- enterConverterDB("converter11", domainID1, cfFuture1, cfStereo, matrix, coSourceID11, coSinkID11, converterID11);
+ am_sourceID_t coSourceID11;
+ enterSourceDB("coSource11", domainID1, cfFuture1, coSourceID11);
+ am_converterID_t converterID11;
+ enterConverterDB("converter11", domainID1, cfFuture1, cfStereo, matrix, coSourceID11, coSinkID11, converterID11);
- am_sinkID_t coSinkID12;
+ am_sinkID_t coSinkID12;
enterSinkDB("coSink12", domainID1, cfStereo, coSinkID12);
- am_sourceID_t coSourceID12;
- enterSourceDB("coSource12", domainID1, cfFuture2, coSourceID12);
- am_converterID_t converterID12;
- enterConverterDB("converter12", domainID1, cfFuture2, cfStereo, matrix, coSourceID12, coSinkID12, converterID12);
+ am_sourceID_t coSourceID12;
+ enterSourceDB("coSource12", domainID1, cfFuture2, coSourceID12);
+ am_converterID_t converterID12;
+ enterConverterDB("converter12", domainID1, cfFuture2, cfStereo, matrix, coSourceID12, coSinkID12, converterID12);
- am_sinkID_t coSinkID13;
+ am_sinkID_t coSinkID13;
enterSinkDB("coSink13", domainID1, cfFuture2, coSinkID13);
- am_sourceID_t coSourceID13;
- enterSourceDB("coSource13", domainID1, cfFuture1, coSourceID13);
- am_converterID_t converterID13;
- enterConverterDB("converter13", domainID1, cfFuture1, cfFuture2, matrix, coSourceID13, coSinkID13, converterID13);
+ am_sourceID_t coSourceID13;
+ enterSourceDB("coSource13", domainID1, cfFuture1, coSourceID13);
+ am_converterID_t converterID13;
+ enterConverterDB("converter13", domainID1, cfFuture1, cfFuture2, matrix, coSourceID13, coSinkID13, converterID13);
- am_sinkID_t gwSinkID11;
+ am_sinkID_t gwSinkID11;
enterSinkDB("gwSink11", domainID1, cfFuture1, gwSinkID11);
- am_sourceID_t gwSourceID21;
- enterSourceDB("gwSource21", domainID2, cfAnalog, gwSourceID21);
- am_converterID_t gatewayID1;
- enterGatewayDB("gateway1", domainID2, domainID1, cfAnalog, cfFuture1, matrix, gwSourceID21, gwSinkID11, gatewayID1);
+ am_sourceID_t gwSourceID21;
+ enterSourceDB("gwSource21", domainID2, cfAnalog, gwSourceID21);
+ am_converterID_t gatewayID1;
+ enterGatewayDB("gateway1", domainID2, domainID1, cfAnalog, cfFuture1, matrix, gwSourceID21, gwSinkID11, gatewayID1);
- am_sinkID_t gwSinkID21;
+ am_sinkID_t gwSinkID21;
enterSinkDB("gwSink21", domainID2, cfStereo, gwSinkID21);
am_sourceID_t gwSourceID12;
enterSourceDB("gwSource12", domainID1, cfAuto, gwSourceID12);
am_sinkID_t coSinkID21;
- enterSinkDB("coSink21", domainID2, cfAnalog, coSinkID21);
-
- am_sourceID_t coSourceID21;
- enterSourceDB("coSource21", domainID2, cfStereo, coSourceID21);
+ enterSinkDB("coSink21", domainID2, cfAnalog, coSinkID21);
- am_converterID_t converterID2;
- enterConverterDB("converter2", domainID2, cfStereo, cfAnalog, matrix, coSourceID21, coSinkID21, converterID2);
+ am_sourceID_t coSourceID21;
+ enterSourceDB("coSource21", domainID2, cfStereo, coSourceID21);
+ am_converterID_t converterID2;
+ enterConverterDB("converter2", domainID2, cfStereo, cfAnalog, matrix, coSourceID21, coSinkID21, converterID2);
am_gatewayID_t gatewayID2;
enterGatewayDB("gateway2", domainID1, domainID2, cfAuto, cfStereo, matrix, gwSourceID12, gwSinkID21, gatewayID2);
- am_sinkID_t sinkID;
- enterSinkDB("sink1", domainID1, cfAuto, sinkID);
+ am_sinkID_t sinkID;
+ enterSinkDB("sink1", domainID1, cfAuto, sinkID);
am::am_Source_s source;
am::am_Sink_s sink;
@@ -3115,120 +3097,118 @@ TEST_F(CAmRouterMapTest, routeSource1Sink1PathThroughConv1Gate1Conv2Gate2)
std::vector<am_Route_s> listRoutes;
- ASSERT_EQ(getRoute(false, true, source, sink, listRoutes, 0), E_NOT_POSSIBLE);
- ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
+ ASSERT_EQ(getRoute(false, false, source, sink, listRoutes, 0), E_NOT_POSSIBLE);
+ ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
am::am_Sink_s sink2;
pDatabaseHandler.getSinkInfoDB(coSinkID21, sink2);
- ASSERT_EQ(getRoute(false, true, source, sink2, listRoutes, 0), E_OK);
- ASSERT_EQ(static_cast<uint>(2), listRoutes.size());
-
- am_Route_s compareRoute1;
- compareRoute1.sinkID = coSinkID21;
- compareRoute1.sourceID = sourceID;
- compareRoute1.route.push_back({sourceID, coSinkID11, domainID1, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({coSourceID11, gwSinkID11, domainID1, 5});
- compareRoute1.route.push_back({gwSourceID21, coSinkID21, domainID2, CF_GENIVI_ANALOG});
-
- am_Route_s compareRoute2;
- compareRoute2.sinkID = coSinkID21;
- compareRoute2.sourceID = sourceID;
- compareRoute2.route.push_back({sourceID, coSinkID12, domainID1, CF_GENIVI_STEREO});
- compareRoute2.route.push_back({coSourceID12, coSinkID13, domainID1, 6});
- compareRoute2.route.push_back({coSourceID13, gwSinkID11, domainID1, 5});
- compareRoute2.route.push_back({gwSourceID21, coSinkID21, domainID2, CF_GENIVI_ANALOG});
-
- ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[1])||pCF.compareRoute(compareRoute1,listRoutes[0]));
- ASSERT_TRUE(pCF.compareRoute(compareRoute2,listRoutes[0])||pCF.compareRoute(compareRoute2,listRoutes[1]));
+ ASSERT_EQ(getRoute(false, false, source, sink2, listRoutes, 0), E_OK);
+ ASSERT_EQ(static_cast<uint>(2), listRoutes.size());
+
+ am_Route_s compareRoute1;
+ compareRoute1.sinkID = coSinkID21;
+ compareRoute1.sourceID = sourceID;
+ compareRoute1.route.push_back(
+ { sourceID, coSinkID11, domainID1, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { coSourceID11, gwSinkID11, domainID1, 5 });
+ compareRoute1.route.push_back(
+ { gwSourceID21, coSinkID21, domainID2, CF_GENIVI_ANALOG });
+
+ am_Route_s compareRoute2;
+ compareRoute2.sinkID = coSinkID21;
+ compareRoute2.sourceID = sourceID;
+ compareRoute2.route.push_back(
+ { sourceID, coSinkID12, domainID1, CF_GENIVI_STEREO });
+ compareRoute2.route.push_back(
+ { coSourceID12, coSinkID13, domainID1, 6 });
+ compareRoute2.route.push_back(
+ { coSourceID13, gwSinkID11, domainID1, 5 });
+ compareRoute2.route.push_back(
+ { gwSourceID21, coSinkID21, domainID2, CF_GENIVI_ANALOG });
+
+ ASSERT_TRUE(pCF.compareRoute(compareRoute1, listRoutes[1]) || pCF.compareRoute(compareRoute1, listRoutes[0]));
+ ASSERT_TRUE(pCF.compareRoute(compareRoute2, listRoutes[0]) || pCF.compareRoute(compareRoute2, listRoutes[1]));
}
TEST_F(CAmRouterMapTest,route3Domains1Source1SinkGwCycles)
{
- EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID,sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID, sourceclass));
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
-
-
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
-
- am_domainID_t domain1ID, domain2ID, domain3ID;
- enterDomainDB("domain1", domain1ID);
- enterDomainDB("domain2", domain2ID);
- enterDomainDB("domain3", domain3ID);
-
- //just make so many cycles as possible
- std::vector<am_CustomConnectionFormat_t> cfStereo;
- cfStereo.push_back(CF_GENIVI_STEREO);
- std::vector<am_CustomConnectionFormat_t> cfAnalog = cfStereo;
- std::vector<am_CustomConnectionFormat_t> cfMono = cfStereo;
- std::vector<am_CustomConnectionFormat_t> cfAuto;
- cfAuto.push_back(CF_GENIVI_AUTO);
-
- am_sourceID_t source1ID;
- enterSourceDB("source1", domain1ID, cfStereo, source1ID);
- am_sinkID_t gw1SinkID;
- enterSinkDB("gw1Sink", domain1ID, cfStereo, gw1SinkID);
- am_sinkID_t gw2SinkID;
- enterSinkDB("gw2Sink", domain1ID, cfStereo, gw2SinkID);
- am_sourceID_t gw3SourceID;
- enterSourceDB("gw3Source", domain1ID, cfAnalog, gw3SourceID);
- am_sourceID_t gw4SourceID;
- enterSourceDB("gw4Source", domain1ID, cfAnalog, gw4SourceID);
- am_sinkID_t gw5SinkID;
- enterSinkDB("gw5Sink", domain1ID, cfAnalog, gw5SinkID);
-
- am_sourceID_t gw1SourceID;
- enterSourceDB("gw1Source", domain2ID, cfMono, gw1SourceID);
- am_sourceID_t gw2SourceID;
- enterSourceDB("gw2Source", domain2ID, cfMono, gw2SourceID);
- am_sinkID_t gw3SinkID;
- enterSinkDB("gw3Sink", domain2ID, cfMono, gw3SinkID);
- am_sinkID_t gw4SinkID;
- enterSinkDB("gw4Sink", domain2ID, cfMono, gw4SinkID);
-
- am_sourceID_t gw5SourceID;
- enterSourceDB("gw5Source", domain3ID, cfStereo, gw5SourceID);
- am_sinkID_t sink1ID;
- enterSinkDB("sink1", domain3ID, cfStereo, sink1ID);
-
- std::vector<bool> matrixT;
- matrixT.push_back(true);
- std::vector<bool> matrixF;
- matrixF.push_back(false);
-
- am_gatewayID_t gateway1ID;
- enterGatewayDB("gateway1", domain2ID, domain1ID, cfMono, cfStereo, matrixT, gw1SourceID, gw1SinkID, gateway1ID);
- am_gatewayID_t gateway2ID;
- enterGatewayDB("gateway2", domain2ID, domain1ID, cfMono, cfStereo, matrixT, gw2SourceID, gw2SinkID, gateway2ID);
- am_gatewayID_t gateway3ID;
- enterGatewayDB("gateway3", domain1ID, domain2ID, cfAnalog, cfMono, matrixT, gw3SourceID, gw3SinkID, gateway3ID);
- am_gatewayID_t gateway4ID;
- enterGatewayDB("gateway4", domain1ID, domain2ID, cfAnalog, cfMono, matrixT, gw4SourceID, gw4SinkID, gateway4ID);
- am_gatewayID_t gateway5ID;
- enterGatewayDB("gateway5", domain3ID, domain1ID, cfStereo, cfAnalog, matrixT, gw5SourceID, gw5SinkID, gateway5ID);
-
- pRouter.load(false);
-
- CAmRoutingNode* sourceNode = pRouter.sourceNodeWithID(source1ID);
- CAmRoutingNode* sinkNode = pRouter.sinkNodeWithID(sink1ID);
-
- ASSERT_TRUE(sourceNode);
- ASSERT_TRUE(sinkNode);
-
- std::vector<am_Route_s> listRoutes;
-
- am_Route_s compareRoute1;
- compareRoute1.sinkID = sink1ID;
- compareRoute1.sourceID = source1ID;
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+
+ am_domainID_t domain1ID, domain2ID, domain3ID;
+ enterDomainDB("domain1", domain1ID);
+ enterDomainDB("domain2", domain2ID);
+ enterDomainDB("domain3", domain3ID);
+
+ //just make so many cycles as possible
+ std::vector<am_CustomConnectionFormat_t> cfStereo;
+ cfStereo.push_back(CF_GENIVI_STEREO);
+ std::vector<am_CustomConnectionFormat_t> cfAnalog = cfStereo;
+ std::vector<am_CustomConnectionFormat_t> cfMono = cfStereo;
+ std::vector<am_CustomConnectionFormat_t> cfAuto;
+ cfAuto.push_back(CF_GENIVI_AUTO);
+
+ am_sourceID_t source1ID;
+ enterSourceDB("source1", domain1ID, cfStereo, source1ID);
+ am_sinkID_t gw1SinkID;
+ enterSinkDB("gw1Sink", domain1ID, cfStereo, gw1SinkID);
+ am_sinkID_t gw2SinkID;
+ enterSinkDB("gw2Sink", domain1ID, cfStereo, gw2SinkID);
+ am_sourceID_t gw3SourceID;
+ enterSourceDB("gw3Source", domain1ID, cfAnalog, gw3SourceID);
+ am_sourceID_t gw4SourceID;
+ enterSourceDB("gw4Source", domain1ID, cfAnalog, gw4SourceID);
+ am_sinkID_t gw5SinkID;
+ enterSinkDB("gw5Sink", domain1ID, cfAnalog, gw5SinkID);
+
+ am_sourceID_t gw1SourceID;
+ enterSourceDB("gw1Source", domain2ID, cfMono, gw1SourceID);
+ am_sourceID_t gw2SourceID;
+ enterSourceDB("gw2Source", domain2ID, cfMono, gw2SourceID);
+ am_sinkID_t gw3SinkID;
+ enterSinkDB("gw3Sink", domain2ID, cfMono, gw3SinkID);
+ am_sinkID_t gw4SinkID;
+ enterSinkDB("gw4Sink", domain2ID, cfMono, gw4SinkID);
+
+ am_sourceID_t gw5SourceID;
+ enterSourceDB("gw5Source", domain3ID, cfStereo, gw5SourceID);
+ am_sinkID_t sink1ID;
+ enterSinkDB("sink1", domain3ID, cfStereo, sink1ID);
+
+ std::vector<bool> matrixT;
+ matrixT.push_back(true);
+ std::vector<bool> matrixF;
+ matrixF.push_back(false);
+
+ am_gatewayID_t gateway1ID;
+ enterGatewayDB("gateway1", domain2ID, domain1ID, cfMono, cfStereo, matrixT, gw1SourceID, gw1SinkID, gateway1ID);
+ am_gatewayID_t gateway2ID;
+ enterGatewayDB("gateway2", domain2ID, domain1ID, cfMono, cfStereo, matrixT, gw2SourceID, gw2SinkID, gateway2ID);
+ am_gatewayID_t gateway3ID;
+ enterGatewayDB("gateway3", domain1ID, domain2ID, cfAnalog, cfMono, matrixT, gw3SourceID, gw3SinkID, gateway3ID);
+ am_gatewayID_t gateway4ID;
+ enterGatewayDB("gateway4", domain1ID, domain2ID, cfAnalog, cfMono, matrixT, gw4SourceID, gw4SinkID, gateway4ID);
+ am_gatewayID_t gateway5ID;
+ enterGatewayDB("gateway5", domain3ID, domain1ID, cfStereo, cfAnalog, matrixT, gw5SourceID, gw5SinkID, gateway5ID);
+
+ std::vector<am_Route_s> listRoutes;
+
+ am_Route_s compareRoute1;
+ compareRoute1.sinkID = sink1ID;
+ compareRoute1.sourceID = source1ID;
#define DO_ASSERT() \
{\
@@ -3238,210 +3218,261 @@ TEST_F(CAmRouterMapTest,route3Domains1Source1SinkGwCycles)
ASSERT_TRUE(didMatch); \
}
- getAllPaths(*sourceNode, *sinkNode, listRoutes, UINT_MAX, 10);
- ASSERT_EQ(static_cast<uint>(9), listRoutes.size());
-
- compareRoute1.route.clear();
- compareRoute1.route.push_back({source1ID, gw2SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw2SourceID, gw4SinkID, domain2ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw4SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO});
- DO_ASSERT()
-
- compareRoute1.route.clear();
- compareRoute1.route.push_back({source1ID, gw1SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw1SourceID, gw3SinkID, domain2ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw3SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO});
- DO_ASSERT()
-
- compareRoute1.route.clear();
- compareRoute1.route.push_back({source1ID, gw2SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw2SourceID, gw3SinkID, domain2ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw3SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO});
- DO_ASSERT()
-
- compareRoute1.route.clear();
- compareRoute1.route.push_back({source1ID, gw1SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw1SourceID, gw4SinkID, domain2ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw4SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO});
- DO_ASSERT()
-
- compareRoute1.route.clear();
- compareRoute1.route.push_back({source1ID, gw2SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw2SourceID, gw4SinkID, domain2ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw4SourceID, gw1SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw1SourceID, gw3SinkID, domain2ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw3SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO});
- DO_ASSERT()
-
- compareRoute1.route.clear();
- compareRoute1.route.push_back({source1ID, gw2SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw2SourceID, gw3SinkID, domain2ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw3SourceID, gw1SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw1SourceID, gw4SinkID, domain2ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw4SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO});
- DO_ASSERT()
-
- compareRoute1.route.clear();
- compareRoute1.route.push_back({source1ID, gw1SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw1SourceID, gw3SinkID, domain2ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw3SourceID, gw2SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw2SourceID, gw4SinkID, domain2ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw4SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO});
- DO_ASSERT()
-
- compareRoute1.route.clear();
- compareRoute1.route.push_back({source1ID, gw1SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw1SourceID, gw4SinkID, domain2ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw4SourceID, gw2SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw2SourceID, gw3SinkID, domain2ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw3SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO});
- DO_ASSERT()
-
- compareRoute1.route.clear();
- compareRoute1.route.push_back({source1ID, gw5SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO});
- DO_ASSERT()
-
- listRoutes.clear();
-
- getAllPaths(*sourceNode, *sinkNode, listRoutes, 1, 10);
- ASSERT_EQ(static_cast<uint>(5), listRoutes.size());
-
- compareRoute1.route.clear();
- compareRoute1.route.push_back({source1ID, gw2SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw2SourceID, gw4SinkID, domain2ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw4SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO});
- DO_ASSERT()
-
- compareRoute1.route.clear();
- compareRoute1.route.push_back({source1ID, gw1SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw1SourceID, gw3SinkID, domain2ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw3SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO});
- DO_ASSERT()
-
- compareRoute1.route.clear();
- compareRoute1.route.push_back({source1ID, gw2SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw2SourceID, gw3SinkID, domain2ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw3SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO});
- DO_ASSERT()
-
- compareRoute1.route.clear();
- compareRoute1.route.push_back({source1ID, gw1SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw1SourceID, gw4SinkID, domain2ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw4SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO});
- DO_ASSERT()
-
- compareRoute1.route.clear();
- compareRoute1.route.push_back({source1ID, gw5SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO});
- DO_ASSERT()
-
- listRoutes.clear();
-
- getAllPaths(*sourceNode, *sinkNode, listRoutes);
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- DO_ASSERT()
+ ASSERT_EQ(getAllPaths(false, source1ID, sink1ID, listRoutes, UINT_MAX, 10), E_OK);
+ ASSERT_EQ(static_cast<uint>(9), listRoutes.size());
+
+ compareRoute1.route.clear();
+ compareRoute1.route.push_back(
+ { source1ID, gw2SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw2SourceID, gw4SinkID, domain2ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw4SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO });
+ DO_ASSERT()
+
+ compareRoute1.route.clear();
+ compareRoute1.route.push_back(
+ { source1ID, gw1SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw1SourceID, gw3SinkID, domain2ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw3SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO });
+ DO_ASSERT()
+
+ compareRoute1.route.clear();
+ compareRoute1.route.push_back(
+ { source1ID, gw2SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw2SourceID, gw3SinkID, domain2ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw3SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO });
+ DO_ASSERT()
+
+ compareRoute1.route.clear();
+ compareRoute1.route.push_back(
+ { source1ID, gw1SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw1SourceID, gw4SinkID, domain2ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw4SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO });
+ DO_ASSERT()
+
+ compareRoute1.route.clear();
+ compareRoute1.route.push_back(
+ { source1ID, gw2SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw2SourceID, gw4SinkID, domain2ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw4SourceID, gw1SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw1SourceID, gw3SinkID, domain2ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw3SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO });
+ DO_ASSERT()
+
+ compareRoute1.route.clear();
+ compareRoute1.route.push_back(
+ { source1ID, gw2SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw2SourceID, gw3SinkID, domain2ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw3SourceID, gw1SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw1SourceID, gw4SinkID, domain2ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw4SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO });
+ DO_ASSERT()
+
+ compareRoute1.route.clear();
+ compareRoute1.route.push_back(
+ { source1ID, gw1SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw1SourceID, gw3SinkID, domain2ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw3SourceID, gw2SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw2SourceID, gw4SinkID, domain2ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw4SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO });
+ DO_ASSERT()
+
+ compareRoute1.route.clear();
+ compareRoute1.route.push_back(
+ { source1ID, gw1SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw1SourceID, gw4SinkID, domain2ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw4SourceID, gw2SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw2SourceID, gw3SinkID, domain2ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw3SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO });
+ DO_ASSERT()
+
+ compareRoute1.route.clear();
+ compareRoute1.route.push_back(
+ { source1ID, gw5SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO });
+ DO_ASSERT()
+
+ listRoutes.clear();
+
+ ASSERT_EQ(getAllPaths(false, source1ID, sink1ID, listRoutes, 1, 10), E_OK);
+ ASSERT_EQ(static_cast<uint>(5), listRoutes.size());
+
+ compareRoute1.route.clear();
+ compareRoute1.route.push_back(
+ { source1ID, gw2SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw2SourceID, gw4SinkID, domain2ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw4SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO });
+ DO_ASSERT()
+
+ compareRoute1.route.clear();
+ compareRoute1.route.push_back(
+ { source1ID, gw1SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw1SourceID, gw3SinkID, domain2ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw3SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO });
+ DO_ASSERT()
+
+ compareRoute1.route.clear();
+ compareRoute1.route.push_back(
+ { source1ID, gw2SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw2SourceID, gw3SinkID, domain2ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw3SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO });
+ DO_ASSERT()
+
+ compareRoute1.route.clear();
+ compareRoute1.route.push_back(
+ { source1ID, gw1SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw1SourceID, gw4SinkID, domain2ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw4SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO });
+ DO_ASSERT()
+
+ compareRoute1.route.clear();
+ compareRoute1.route.push_back(
+ { source1ID, gw5SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO });
+ DO_ASSERT()
+
+ listRoutes.clear();
+
+ ASSERT_EQ(getAllPaths(false, source1ID, sink1ID, listRoutes), E_OK);
+ ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
+ DO_ASSERT()
}
TEST_F(CAmRouterMapTest,route3Domains1Source1SinkGwCycles2)
{
- EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID,sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID, sourceclass));
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
-
-
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
-
- am_domainID_t domain1ID, domain2ID, domain3ID;
- enterDomainDB("domain1", domain1ID);
- enterDomainDB("domain2", domain2ID);
- enterDomainDB("domain3", domain3ID);
-
- //just make so many cycles as possible
- std::vector<am_CustomConnectionFormat_t> cfStereo;
- cfStereo.push_back(CF_GENIVI_STEREO);
- std::vector<am_CustomConnectionFormat_t> cfOther;
- cfOther.push_back(CF_GENIVI_AUTO);
- std::vector<am_CustomConnectionFormat_t> cfMono;
- cfMono.push_back(CF_GENIVI_MONO);
-
- am_sourceID_t source1ID;
- enterSourceDB("source1", domain1ID, cfMono, source1ID);
- am_sinkID_t gw1SinkID;
- enterSinkDB("gw1Sink", domain1ID, cfStereo, gw1SinkID);
- am_sinkID_t gw2SinkID;
- enterSinkDB("gw2Sink", domain1ID, cfMono, gw2SinkID);
- am_sourceID_t gw3SourceID;
- enterSourceDB("gw3Source", domain1ID, cfStereo, gw3SourceID);
- am_sourceID_t gw4SourceID;
- enterSourceDB("gw4Source", domain1ID, cfStereo, gw4SourceID);
- am_sinkID_t gw5SinkID;
- enterSinkDB("gw5Sink", domain1ID, cfStereo, gw5SinkID);
-
- am_sourceID_t gw1SourceID;
- enterSourceDB("gw1Source", domain2ID, cfStereo, gw1SourceID);
- am_sourceID_t gw2SourceID;
- enterSourceDB("gw2Source", domain2ID, cfStereo, gw2SourceID);
- am_sinkID_t gw3SinkID;
- enterSinkDB("gw3Sink", domain2ID, cfStereo, gw3SinkID);
- am_sinkID_t gw4SinkID;
- enterSinkDB("gw4Sink", domain2ID, cfStereo, gw4SinkID);
-
- am_sourceID_t gw5SourceID;
- enterSourceDB("gw5Source", domain3ID, cfOther, gw5SourceID);
- am_sinkID_t sink1ID;
- enterSinkDB("sink1", domain3ID, cfOther, sink1ID);
-
- std::vector<bool> matrixT;
- matrixT.push_back(true);
- std::vector<bool> matrixF;
- matrixF.push_back(false);
-
- am_gatewayID_t gateway1ID;
- enterGatewayDB("gateway1", domain2ID, domain1ID, cfStereo, cfStereo, matrixT, gw1SourceID, gw1SinkID, gateway1ID);
- am_gatewayID_t gateway2ID;
- enterGatewayDB("gateway2", domain2ID, domain1ID, cfStereo, cfMono, matrixT, gw2SourceID, gw2SinkID, gateway2ID);
- am_gatewayID_t gateway3ID;
- enterGatewayDB("gateway3", domain1ID, domain2ID, cfStereo, cfStereo, matrixT, gw3SourceID, gw3SinkID, gateway3ID);
- am_gatewayID_t gateway4ID;
- enterGatewayDB("gateway4", domain1ID, domain2ID, cfStereo, cfStereo, matrixT, gw4SourceID, gw4SinkID, gateway4ID);
- am_gatewayID_t gateway5ID;
- enterGatewayDB("gateway5", domain3ID, domain1ID, cfOther, cfStereo, matrixT, gw5SourceID, gw5SinkID, gateway5ID);
-
- pRouter.load(false);
-
- CAmRoutingNode* sourceNode = pRouter.sourceNodeWithID(source1ID);
- CAmRoutingNode* sinkNode = pRouter.sinkNodeWithID(sink1ID);
-
- ASSERT_TRUE(sourceNode);
- ASSERT_TRUE(sinkNode);
-
- std::vector<am_Route_s> listRoutes;
-
- am_Route_s compareRoute1;
- compareRoute1.sinkID = sink1ID;
- compareRoute1.sourceID = source1ID;
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+
+ am_domainID_t domain1ID, domain2ID, domain3ID;
+ enterDomainDB("domain1", domain1ID);
+ enterDomainDB("domain2", domain2ID);
+ enterDomainDB("domain3", domain3ID);
+
+ //just make so many cycles as possible
+ std::vector<am_CustomConnectionFormat_t> cfStereo;
+ cfStereo.push_back(CF_GENIVI_STEREO);
+ std::vector<am_CustomConnectionFormat_t> cfOther;
+ cfOther.push_back(CF_GENIVI_AUTO);
+ std::vector<am_CustomConnectionFormat_t> cfMono;
+ cfMono.push_back(CF_GENIVI_MONO);
+
+ am_sourceID_t source1ID;
+ enterSourceDB("source1", domain1ID, cfMono, source1ID);
+ am_sinkID_t gw1SinkID;
+ enterSinkDB("gw1Sink", domain1ID, cfStereo, gw1SinkID);
+ am_sinkID_t gw2SinkID;
+ enterSinkDB("gw2Sink", domain1ID, cfMono, gw2SinkID);
+ am_sourceID_t gw3SourceID;
+ enterSourceDB("gw3Source", domain1ID, cfStereo, gw3SourceID);
+ am_sourceID_t gw4SourceID;
+ enterSourceDB("gw4Source", domain1ID, cfStereo, gw4SourceID);
+ am_sinkID_t gw5SinkID;
+ enterSinkDB("gw5Sink", domain1ID, cfStereo, gw5SinkID);
+
+ am_sourceID_t gw1SourceID;
+ enterSourceDB("gw1Source", domain2ID, cfStereo, gw1SourceID);
+ am_sourceID_t gw2SourceID;
+ enterSourceDB("gw2Source", domain2ID, cfStereo, gw2SourceID);
+ am_sinkID_t gw3SinkID;
+ enterSinkDB("gw3Sink", domain2ID, cfStereo, gw3SinkID);
+ am_sinkID_t gw4SinkID;
+ enterSinkDB("gw4Sink", domain2ID, cfStereo, gw4SinkID);
+
+ am_sourceID_t gw5SourceID;
+ enterSourceDB("gw5Source", domain3ID, cfOther, gw5SourceID);
+ am_sinkID_t sink1ID;
+ enterSinkDB("sink1", domain3ID, cfOther, sink1ID);
+
+ std::vector<bool> matrixT;
+ matrixT.push_back(true);
+ std::vector<bool> matrixF;
+ matrixF.push_back(false);
+
+ am_gatewayID_t gateway1ID;
+ enterGatewayDB("gateway1", domain2ID, domain1ID, cfStereo, cfStereo, matrixT, gw1SourceID, gw1SinkID, gateway1ID);
+ am_gatewayID_t gateway2ID;
+ enterGatewayDB("gateway2", domain2ID, domain1ID, cfStereo, cfMono, matrixT, gw2SourceID, gw2SinkID, gateway2ID);
+ am_gatewayID_t gateway3ID;
+ enterGatewayDB("gateway3", domain1ID, domain2ID, cfStereo, cfStereo, matrixT, gw3SourceID, gw3SinkID, gateway3ID);
+ am_gatewayID_t gateway4ID;
+ enterGatewayDB("gateway4", domain1ID, domain2ID, cfStereo, cfStereo, matrixT, gw4SourceID, gw4SinkID, gateway4ID);
+ am_gatewayID_t gateway5ID;
+ enterGatewayDB("gateway5", domain3ID, domain1ID, cfOther, cfStereo, matrixT, gw5SourceID, gw5SinkID, gateway5ID);
+
+ std::vector<am_Route_s> listRoutes;
+
+ am_Route_s compareRoute1;
+ compareRoute1.sinkID = sink1ID;
+ compareRoute1.sourceID = source1ID;
#define DO_ASSERT() \
{\
@@ -3451,68 +3482,75 @@ TEST_F(CAmRouterMapTest,route3Domains1Source1SinkGwCycles2)
ASSERT_TRUE(didMatch); \
}
- ASSERT_EQ(getRoute(false, false, source1ID, sink1ID, listRoutes, 0, 10), E_NOT_POSSIBLE);
- ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
-
- ASSERT_EQ(getRoute(false, false, source1ID, sink1ID, listRoutes, 1, 10), E_OK);
- ASSERT_EQ(static_cast<uint>(2), listRoutes.size());
-
- compareRoute1.route.clear();
- compareRoute1.route.push_back({source1ID, gw2SinkID, domain1ID, CF_GENIVI_MONO});
- compareRoute1.route.push_back({gw2SourceID, gw4SinkID, domain2ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw4SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw5SourceID, sink1ID, domain3ID, CF_GENIVI_AUTO});
- DO_ASSERT()
-
- compareRoute1.route.clear();
- compareRoute1.route.push_back({source1ID, gw2SinkID, domain1ID, CF_GENIVI_MONO});
- compareRoute1.route.push_back({gw2SourceID, gw3SinkID, domain2ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw3SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw5SourceID, sink1ID, domain3ID, CF_GENIVI_AUTO});
- DO_ASSERT()
+ ASSERT_EQ(getRoute(false, false, source1ID, sink1ID, listRoutes, 0, 10), E_NOT_POSSIBLE);
+ ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
+
+ ASSERT_EQ(getRoute(false, false, source1ID, sink1ID, listRoutes, 1, 10), E_OK);
+ ASSERT_EQ(static_cast<uint>(2), listRoutes.size());
+
+ compareRoute1.route.clear();
+ compareRoute1.route.push_back(
+ { source1ID, gw2SinkID, domain1ID, CF_GENIVI_MONO });
+ compareRoute1.route.push_back(
+ { gw2SourceID, gw4SinkID, domain2ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw4SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw5SourceID, sink1ID, domain3ID, CF_GENIVI_AUTO });
+ DO_ASSERT()
+
+ compareRoute1.route.clear();
+ compareRoute1.route.push_back(
+ { source1ID, gw2SinkID, domain1ID, CF_GENIVI_MONO });
+ compareRoute1.route.push_back(
+ { gw2SourceID, gw3SinkID, domain2ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw3SourceID, gw5SinkID, domain1ID, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gw5SourceID, sink1ID, domain3ID, CF_GENIVI_AUTO });
+ DO_ASSERT()
}
TEST_F(CAmRouterMapTest,route3Domains1Source3Gateways3Convertres1Sink)
{
- EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID,sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID, sourceclass));
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
-
-
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
-
- am_domainID_t domainID1, domainID2, domainID3;
- enterDomainDB("domain1", domainID1);
- enterDomainDB("domain2", domainID2);
- enterDomainDB("domain3", domainID3);
-
- std::vector<am_CustomConnectionFormat_t> cfStereo;
- cfStereo.push_back(CF_GENIVI_STEREO);
- std::vector<am_CustomConnectionFormat_t> cfAnalog;
- cfAnalog.push_back(CF_GENIVI_ANALOG);
- std::vector<am_CustomConnectionFormat_t> cfMono;
- cfMono.push_back(CF_GENIVI_MONO);
- std::vector<am_CustomConnectionFormat_t> cfAuto;
- cfAuto.push_back(CF_GENIVI_AUTO);
-
- am_sourceID_t sourceID;
- enterSourceDB("source1", domainID1, cfStereo, sourceID);
- am_sinkID_t gwSinkID1;
- enterSinkDB("gwSink1", domainID1, cfStereo, gwSinkID1);
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
+
+ am_domainID_t domainID1, domainID2, domainID3;
+ enterDomainDB("domain1", domainID1);
+ enterDomainDB("domain2", domainID2);
+ enterDomainDB("domain3", domainID3);
+
+ std::vector<am_CustomConnectionFormat_t> cfStereo;
+ cfStereo.push_back(CF_GENIVI_STEREO);
+ std::vector<am_CustomConnectionFormat_t> cfAnalog;
+ cfAnalog.push_back(CF_GENIVI_ANALOG);
+ std::vector<am_CustomConnectionFormat_t> cfMono;
+ cfMono.push_back(CF_GENIVI_MONO);
+ std::vector<am_CustomConnectionFormat_t> cfAuto;
+ cfAuto.push_back(CF_GENIVI_AUTO);
+
+ am_sourceID_t sourceID;
+ enterSourceDB("source1", domainID1, cfStereo, sourceID);
+ am_sinkID_t gwSinkID1;
+ enterSinkDB("gwSink1", domainID1, cfStereo, gwSinkID1);
am_sinkID_t gwSinkID21;
enterSinkDB("gwSink21", domainID1, cfStereo, gwSinkID21);
- am_sourceID_t gwSourceID1;
- enterSourceDB("gwSource1", domainID2, cfMono, gwSourceID1);
+ am_sourceID_t gwSourceID1;
+ enterSourceDB("gwSource1", domainID2, cfMono, gwSourceID1);
am_sinkID_t gwSinkID22;
enterSinkDB("gwSink22", domainID2, cfMono, gwSinkID22);
@@ -3521,35 +3559,35 @@ TEST_F(CAmRouterMapTest,route3Domains1Source3Gateways3Convertres1Sink)
am_sourceID_t gwSourceID22;
enterSourceDB("gwSource22", domainID3, cfAuto, gwSourceID22);
- am_sourceID_t cSourceID5;
- enterSourceDB("cSource5", domainID3, cfStereo, cSourceID5);
- am_sinkID_t cSinkID5;
- enterSinkDB("cSink5", domainID3, cfAnalog, cSinkID5);
+ am_sourceID_t cSourceID5;
+ enterSourceDB("cSource5", domainID3, cfStereo, cSourceID5);
+ am_sinkID_t cSinkID5;
+ enterSinkDB("cSink5", domainID3, cfAnalog, cSinkID5);
am_sourceID_t cSourceID3;
- enterSourceDB("cSource3", domainID3, cfAnalog, cSourceID3);
- am_sinkID_t cSinkID3;
- enterSinkDB("cSinkID3", domainID3, cfAuto, cSinkID3);
- am_sourceID_t cSourceID4;
- enterSourceDB("cSource4", domainID3, cfStereo, cSourceID4);
- am_sinkID_t cSinkID4;
- enterSinkDB("cSink4", domainID3, cfAnalog, cSinkID4);
- am_sinkID_t sinkID;
- enterSinkDB("sink1", domainID3, cfStereo, sinkID);
-
- std::vector<bool> matrix;
- matrix.push_back(true);
+ enterSourceDB("cSource3", domainID3, cfAnalog, cSourceID3);
+ am_sinkID_t cSinkID3;
+ enterSinkDB("cSinkID3", domainID3, cfAuto, cSinkID3);
+ am_sourceID_t cSourceID4;
+ enterSourceDB("cSource4", domainID3, cfStereo, cSourceID4);
+ am_sinkID_t cSinkID4;
+ enterSinkDB("cSink4", domainID3, cfAnalog, cSinkID4);
+ am_sinkID_t sinkID;
+ enterSinkDB("sink1", domainID3, cfStereo, sinkID);
+
+ std::vector<bool> matrix;
+ matrix.push_back(true);
am_gatewayID_t gatewayID;
enterGatewayDB("gateway1", domainID2, domainID1, cfMono, cfStereo, matrix, gwSourceID1, gwSinkID1, gatewayID);
am_gatewayID_t gatewayID22;
enterGatewayDB("gateway22", domainID3, domainID2, cfAuto, cfMono, matrix, gwSourceID22, gwSinkID22, gatewayID22);
am_gatewayID_t gatewayID21;
enterGatewayDB("gateway21", domainID3, domainID1, cfAuto, cfStereo, matrix, gwSourceID21, gwSinkID21, gatewayID21);
- am_converterID_t converterID1;
- enterConverterDB("converter1", domainID3, cfAnalog, cfAuto, matrix, cSourceID3, cSinkID3, converterID1);
- am_converterID_t converterID2;
- enterConverterDB("converter2", domainID3, cfStereo, cfAnalog, matrix, cSourceID4, cSinkID4, converterID2);
- am_converterID_t converterID3;
- enterConverterDB("converter3", domainID3, cfStereo, cfAnalog, matrix, cSourceID5, cSinkID5, converterID3);
+ am_converterID_t converterID1;
+ enterConverterDB("converter1", domainID3, cfAnalog, cfAuto, matrix, cSourceID3, cSinkID3, converterID1);
+ am_converterID_t converterID2;
+ enterConverterDB("converter2", domainID3, cfStereo, cfAnalog, matrix, cSourceID4, cSinkID4, converterID2);
+ am_converterID_t converterID3;
+ enterConverterDB("converter3", domainID3, cfStereo, cfAnalog, matrix, cSourceID5, cSinkID5, converterID3);
am::am_Source_s source;
am::am_Sink_s sink;
@@ -3559,115 +3597,128 @@ TEST_F(CAmRouterMapTest,route3Domains1Source3Gateways3Convertres1Sink)
std::vector<am_Route_s> listRoutes;
- ASSERT_EQ(getRoute(false, true, source, sink, listRoutes), E_OK);
- ASSERT_EQ(static_cast<uint>(4), listRoutes.size());
-
- am_Route_s compareRoute1;
- compareRoute1.sinkID = sinkID;
- compareRoute1.sourceID = sourceID;
- compareRoute1.route.push_back({sourceID, gwSinkID1, domainID1, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gwSourceID1, gwSinkID22, domainID2, CF_GENIVI_MONO});
- compareRoute1.route.push_back({gwSourceID22, cSinkID3, domainID3, CF_GENIVI_AUTO});
- compareRoute1.route.push_back({cSourceID3, cSinkID4, domainID3, CF_GENIVI_ANALOG});
- compareRoute1.route.push_back({cSourceID4, sinkID, domainID3, CF_GENIVI_STEREO});
-
- am_Route_s compareRoute2;
- compareRoute2.sinkID = sinkID;
- compareRoute2.sourceID = sourceID;
- compareRoute2.route.push_back({sourceID, gwSinkID1, domainID1, CF_GENIVI_STEREO});
- compareRoute2.route.push_back({gwSourceID1, gwSinkID22, domainID2, CF_GENIVI_MONO});
- compareRoute2.route.push_back({gwSourceID22, cSinkID3, domainID3, CF_GENIVI_AUTO});
- compareRoute2.route.push_back({cSourceID3, cSinkID5, domainID3, CF_GENIVI_ANALOG});
- compareRoute2.route.push_back({cSourceID5, sinkID, domainID3, CF_GENIVI_STEREO});
-
- am_Route_s compareRoute3;
- compareRoute3.sinkID = sinkID;
- compareRoute3.sourceID = sourceID;
- compareRoute3.route.push_back({sourceID, gwSinkID21, domainID1, CF_GENIVI_STEREO});
- compareRoute3.route.push_back({gwSourceID21, cSinkID3, domainID3, CF_GENIVI_AUTO});
- compareRoute3.route.push_back({cSourceID3, cSinkID4, domainID3, CF_GENIVI_ANALOG});
- compareRoute3.route.push_back({cSourceID4, sinkID, domainID3, CF_GENIVI_STEREO});
-
- am_Route_s compareRoute4;
- compareRoute4.sinkID = sinkID;
- compareRoute4.sourceID = sourceID;
- compareRoute4.route.push_back({sourceID, gwSinkID21, domainID1, CF_GENIVI_STEREO});
- compareRoute4.route.push_back({gwSourceID21, cSinkID3, domainID3, CF_GENIVI_AUTO});
- compareRoute4.route.push_back({cSourceID3, cSinkID5, domainID3, CF_GENIVI_ANALOG});
- compareRoute4.route.push_back({cSourceID5, sinkID, domainID3, CF_GENIVI_STEREO});
-
- ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[0])||
- pCF.compareRoute(compareRoute1,listRoutes[1])||
- pCF.compareRoute(compareRoute1,listRoutes[2])||
- pCF.compareRoute(compareRoute1,listRoutes[3]));
-
- ASSERT_TRUE(pCF.compareRoute(compareRoute2,listRoutes[0])||
- pCF.compareRoute(compareRoute2,listRoutes[1])||
- pCF.compareRoute(compareRoute2,listRoutes[2])||
- pCF.compareRoute(compareRoute2,listRoutes[3]));
-
- ASSERT_TRUE(pCF.compareRoute(compareRoute3,listRoutes[0])||
- pCF.compareRoute(compareRoute3,listRoutes[1])||
- pCF.compareRoute(compareRoute3,listRoutes[2])||
- pCF.compareRoute(compareRoute3,listRoutes[3]));
-
- ASSERT_TRUE(pCF.compareRoute(compareRoute4,listRoutes[0])||
- pCF.compareRoute(compareRoute4,listRoutes[1])||
- pCF.compareRoute(compareRoute4,listRoutes[2])||
- pCF.compareRoute(compareRoute4,listRoutes[3]));
+ ASSERT_EQ(getRoute(false, false, source, sink, listRoutes), E_OK);
+ ASSERT_EQ(static_cast<uint>(4), listRoutes.size());
+
+ am_Route_s compareRoute1;
+ compareRoute1.sinkID = sinkID;
+ compareRoute1.sourceID = sourceID;
+ compareRoute1.route.push_back(
+ { sourceID, gwSinkID1, domainID1, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gwSourceID1, gwSinkID22, domainID2, CF_GENIVI_MONO });
+ compareRoute1.route.push_back(
+ { gwSourceID22, cSinkID3, domainID3, CF_GENIVI_AUTO });
+ compareRoute1.route.push_back(
+ { cSourceID3, cSinkID4, domainID3, CF_GENIVI_ANALOG });
+ compareRoute1.route.push_back(
+ { cSourceID4, sinkID, domainID3, CF_GENIVI_STEREO });
+
+ am_Route_s compareRoute2;
+ compareRoute2.sinkID = sinkID;
+ compareRoute2.sourceID = sourceID;
+ compareRoute2.route.push_back(
+ { sourceID, gwSinkID1, domainID1, CF_GENIVI_STEREO });
+ compareRoute2.route.push_back(
+ { gwSourceID1, gwSinkID22, domainID2, CF_GENIVI_MONO });
+ compareRoute2.route.push_back(
+ { gwSourceID22, cSinkID3, domainID3, CF_GENIVI_AUTO });
+ compareRoute2.route.push_back(
+ { cSourceID3, cSinkID5, domainID3, CF_GENIVI_ANALOG });
+ compareRoute2.route.push_back(
+ { cSourceID5, sinkID, domainID3, CF_GENIVI_STEREO });
+
+ am_Route_s compareRoute3;
+ compareRoute3.sinkID = sinkID;
+ compareRoute3.sourceID = sourceID;
+ compareRoute3.route.push_back(
+ { sourceID, gwSinkID21, domainID1, CF_GENIVI_STEREO });
+ compareRoute3.route.push_back(
+ { gwSourceID21, cSinkID3, domainID3, CF_GENIVI_AUTO });
+ compareRoute3.route.push_back(
+ { cSourceID3, cSinkID4, domainID3, CF_GENIVI_ANALOG });
+ compareRoute3.route.push_back(
+ { cSourceID4, sinkID, domainID3, CF_GENIVI_STEREO });
+
+ am_Route_s compareRoute4;
+ compareRoute4.sinkID = sinkID;
+ compareRoute4.sourceID = sourceID;
+ compareRoute4.route.push_back(
+ { sourceID, gwSinkID21, domainID1, CF_GENIVI_STEREO });
+ compareRoute4.route.push_back(
+ { gwSourceID21, cSinkID3, domainID3, CF_GENIVI_AUTO });
+ compareRoute4.route.push_back(
+ { cSourceID3, cSinkID5, domainID3, CF_GENIVI_ANALOG });
+ compareRoute4.route.push_back(
+ { cSourceID5, sinkID, domainID3, CF_GENIVI_STEREO });
+
+ ASSERT_TRUE(
+ pCF.compareRoute(compareRoute1, listRoutes[0]) || pCF.compareRoute(compareRoute1, listRoutes[1]) || pCF.compareRoute(compareRoute1, listRoutes[2])
+ || pCF.compareRoute(compareRoute1, listRoutes[3]));
+
+ ASSERT_TRUE(
+ pCF.compareRoute(compareRoute2, listRoutes[0]) || pCF.compareRoute(compareRoute2, listRoutes[1]) || pCF.compareRoute(compareRoute2, listRoutes[2])
+ || pCF.compareRoute(compareRoute2, listRoutes[3]));
+
+ ASSERT_TRUE(
+ pCF.compareRoute(compareRoute3, listRoutes[0]) || pCF.compareRoute(compareRoute3, listRoutes[1]) || pCF.compareRoute(compareRoute3, listRoutes[2])
+ || pCF.compareRoute(compareRoute3, listRoutes[3]));
+
+ ASSERT_TRUE(
+ pCF.compareRoute(compareRoute4, listRoutes[0]) || pCF.compareRoute(compareRoute4, listRoutes[1]) || pCF.compareRoute(compareRoute4, listRoutes[2])
+ || pCF.compareRoute(compareRoute4, listRoutes[3]));
}
TEST_F(CAmRouterMapTest, routeTunerHeadphonePathThroughGWPlus2OtherSinks)
{
- EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
+ EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(), Return(E_OK)));
am_SourceClass_s sourceclass;
- sourceclass.name="sClass";
- sourceclass.sourceClassID=5;
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID,sourceclass));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceclass.sourceClassID, sourceclass));
am_SinkClass_s sinkclass;
- sinkclass.sinkClassID=5;
- sinkclass.name="sname";
+ sinkclass.sinkClassID = 5;
+ sinkclass.name = "sname";
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass,sinkclass.sinkClassID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkclass, sinkclass.sinkClassID));
- std::vector<bool> matrix;
- matrix.push_back(true);
- matrix.push_back(false);
- matrix.push_back(false);
- matrix.push_back(true);
-
- am_domainID_t domainID1, domainID2;
- enterDomainDB("domain1", domainID1);
- enterDomainDB("domain2", domainID2);
+ std::vector<bool> matrix;
+ matrix.push_back(true);
+ matrix.push_back(false);
+ matrix.push_back(false);
+ matrix.push_back(true);
- std::vector<am_CustomConnectionFormat_t> cfStereo;
- cfStereo.push_back(CF_GENIVI_STEREO);
+ am_domainID_t domainID1, domainID2;
+ enterDomainDB("domain1", domainID1);
+ enterDomainDB("domain2", domainID2);
- std::vector<am_CustomConnectionFormat_t> cfMulti;
- cfMulti.push_back(CF_GENIVI_STEREO);
- cfMulti.push_back(CF_GENIVI_ANALOG);
+ std::vector<am_CustomConnectionFormat_t> cfStereo;
+ cfStereo.push_back(CF_GENIVI_STEREO);
+ std::vector<am_CustomConnectionFormat_t> cfMulti;
+ cfMulti.push_back(CF_GENIVI_STEREO);
+ cfMulti.push_back(CF_GENIVI_ANALOG);
- am_sourceID_t tunerID;
- enterSourceDB("Tuner", domainID1, cfStereo, tunerID);
+ am_sourceID_t tunerID;
+ enterSourceDB("Tuner", domainID1, cfStereo, tunerID);
- am_sinkID_t gwSinkID1;
+ am_sinkID_t gwSinkID1;
enterSinkDB("gwSink1", domainID1, cfStereo, gwSinkID1);
- am_sourceID_t gwSourceID1;
- enterSourceDB("gwSource1", domainID2, cfMulti, gwSourceID1);
- am_converterID_t gatewayID1;
- enterGatewayDB("gateway1", domainID2, domainID1, cfMulti, cfMulti, matrix, gwSourceID1, gwSinkID1, gatewayID1);
-
- am_sinkID_t rseLeftID;
- enterSinkDB("RSE Left", domainID2, cfMulti, rseLeftID);
- am_sinkID_t rseRightID;
- enterSinkDB("RSE Right", domainID2, cfMulti, rseRightID);
- am_sinkID_t rseHeadphoneID;
- enterSinkDB("Headphone", domainID2, cfMulti, rseHeadphoneID);
+ am_sourceID_t gwSourceID1;
+ enterSourceDB("gwSource1", domainID2, cfMulti, gwSourceID1);
+ am_converterID_t gatewayID1;
+ enterGatewayDB("gateway1", domainID2, domainID1, cfMulti, cfMulti, matrix, gwSourceID1, gwSinkID1, gatewayID1);
+
+ am_sinkID_t rseLeftID;
+ enterSinkDB("RSE Left", domainID2, cfMulti, rseLeftID);
+ am_sinkID_t rseRightID;
+ enterSinkDB("RSE Right", domainID2, cfMulti, rseRightID);
+ am_sinkID_t rseHeadphoneID;
+ enterSinkDB("Headphone", domainID2, cfMulti, rseHeadphoneID);
am::am_Source_s source;
am::am_Sink_s sink;
@@ -3675,52 +3726,57 @@ TEST_F(CAmRouterMapTest, routeTunerHeadphonePathThroughGWPlus2OtherSinks)
pDatabaseHandler.getSourceInfoDB(tunerID, source);
std::vector<am_Route_s> listRoutes;
- ASSERT_EQ(getRoute(false, true, source, sink, listRoutes), E_OK);
- ASSERT_EQ(listRoutes.size(), static_cast<uint>(1));
-
- am_Route_s compareRoute1;
- compareRoute1.sinkID = rseLeftID;
- compareRoute1.sourceID = tunerID;
- compareRoute1.route.push_back({tunerID, gwSinkID1, domainID1, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gwSourceID1, rseLeftID, domainID2, CF_GENIVI_STEREO});
-
- ASSERT_TRUE(pCF.compareRoute(compareRoute1,listRoutes[0]));
-
- listRoutes.clear();
-
- am::am_Source_s gwSource;
- am::am_Sink_s sink2;
- pDatabaseHandler.getSinkInfoDB(rseHeadphoneID, sink2);
- pDatabaseHandler.getSourceInfoDB(gwSourceID1, gwSource);
- ASSERT_EQ(getRoute(false, true, gwSource, sink2, listRoutes), E_OK);
- ASSERT_GT(listRoutes.size(), static_cast<uint>(0));
-
- am_Route_s compareRoute2;
- compareRoute2.sinkID = rseHeadphoneID;
- compareRoute2.sourceID = gwSourceID1;
- compareRoute2.route.push_back({gwSourceID1, rseHeadphoneID, domainID2, CF_GENIVI_STEREO});
- am_Route_s compareRoute3;
- compareRoute3.sinkID = rseHeadphoneID;
- compareRoute3.sourceID = gwSourceID1;
- compareRoute3.route.push_back({gwSourceID1, rseHeadphoneID, domainID2, CF_GENIVI_ANALOG});
-
- ASSERT_TRUE(pCF.compareRoute(compareRoute2,listRoutes[0])||pCF.compareRoute(compareRoute2,listRoutes[1]));
- ASSERT_TRUE(pCF.compareRoute(compareRoute3,listRoutes[0])||pCF.compareRoute(compareRoute3,listRoutes[1]));
+ ASSERT_EQ(getRoute(false, false, source, sink, listRoutes), E_OK);
+ ASSERT_EQ(listRoutes.size(), static_cast<uint>(1));
+
+ am_Route_s compareRoute1;
+ compareRoute1.sinkID = rseLeftID;
+ compareRoute1.sourceID = tunerID;
+ compareRoute1.route.push_back(
+ { tunerID, gwSinkID1, domainID1, CF_GENIVI_STEREO });
+ compareRoute1.route.push_back(
+ { gwSourceID1, rseLeftID, domainID2, CF_GENIVI_STEREO });
+
+ ASSERT_TRUE(pCF.compareRoute(compareRoute1, listRoutes[0]));
+
+ listRoutes.clear();
+
+ am::am_Source_s gwSource;
+ am::am_Sink_s sink2;
+ pDatabaseHandler.getSinkInfoDB(rseHeadphoneID, sink2);
+ pDatabaseHandler.getSourceInfoDB(gwSourceID1, gwSource);
+ ASSERT_EQ(getRoute(false, false, gwSource, sink2, listRoutes), E_OK);
+ ASSERT_GT(listRoutes.size(), static_cast<uint>(0));
+
+ am_Route_s compareRoute2;
+ compareRoute2.sinkID = rseHeadphoneID;
+ compareRoute2.sourceID = gwSourceID1;
+ compareRoute2.route.push_back(
+ { gwSourceID1, rseHeadphoneID, domainID2, CF_GENIVI_STEREO });
+ am_Route_s compareRoute3;
+ compareRoute3.sinkID = rseHeadphoneID;
+ compareRoute3.sourceID = gwSourceID1;
+ compareRoute3.route.push_back(
+ { gwSourceID1, rseHeadphoneID, domainID2, CF_GENIVI_ANALOG });
+
+ ASSERT_TRUE(pCF.compareRoute(compareRoute2, listRoutes[0]) || pCF.compareRoute(compareRoute2, listRoutes[1]));
+ ASSERT_TRUE(pCF.compareRoute(compareRoute3, listRoutes[0]) || pCF.compareRoute(compareRoute3, listRoutes[1]));
}
int main(int argc, char **argv)
{
- try
- {
- TCLAP::CmdLine* cmd(CAmCommandLineSingleton::instanciateOnce("The team of the AudioManager wishes you a nice day!",' ',DAEMONVERSION,true));
- cmd->add(enableDebug);
- }
- catch (TCLAP::ArgException &e) // catch any exceptions
- { std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl; }
- CAmCommandLineSingleton::instance()->preparse(argc,argv);
- CAmDltWrapper::instanctiateOnce("rTEST","RouterMap Test",enableDebug.getValue(),CAmDltWrapper::logDestination::DAEMON);
- logInfo("Routing Test started ");
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
+ try
+ {
+ TCLAP::CmdLine* cmd(CAmCommandLineSingleton::instanciateOnce("The team of the AudioManager wishes you a nice day!", ' ', DAEMONVERSION, true));
+ cmd->add(enableDebug);
+ } catch (TCLAP::ArgException &e) // catch any exceptions
+ {
+ std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl;
+ }
+ CAmCommandLineSingleton::instance()->preparse(argc, argv);
+ CAmDltWrapper::instanctiateOnce("rTEST", "RouterMap Test", enableDebug.getValue(), CAmDltWrapper::logDestination::DAEMON);
+ logInfo("Routing Test started ");
+ ::testing::InitGoogleTest(&argc, argv);
+ return RUN_ALL_TESTS();
}
diff --git a/AudioManagerCore/test/AmRouterMapTest/CAmRouterMapTest.h b/AudioManagerCore/test/AmRouterMapTest/CAmRouterMapTest.h
index 879f47c..6ecaeaa 100644
--- a/AudioManagerCore/test/AmRouterMapTest/CAmRouterMapTest.h
+++ b/AudioManagerCore/test/AmRouterMapTest/CAmRouterMapTest.h
@@ -14,7 +14,7 @@
* this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
*
-* \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013, 2014
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013, 2014
*
* For further information see http://www.genivi.org/.
*
@@ -43,59 +43,54 @@
#include "../MockIAmControlSend.h"
#include "../MockIAmCommandSend.h"
-
namespace am
{
-class CAmRouterMapTest: public ::testing::Test
-{
-public:
- CAmRouterMapTest();
- ~CAmRouterMapTest();
- std::vector<std::string> plistRoutingPluginDirs;
- std::vector<std::string> plistCommandPluginDirs;
- CAmSocketHandler pSocketHandler;
- CAmControlSender pControlSender;
- CAmDatabaseHandlerMap pDatabaseHandler;
- CAmRouter pRouter;
- CAmRoutingSender pRoutingSender;
- CAmCommandSender pCommandSender;
- MockIAmCommandSend pMockInterface;
- MockIAmControlSend pMockControlInterface;
- IAmRoutingBackdoor pRoutingInterfaceBackdoor;
- IAmCommandBackdoor pCommandInterfaceBackdoor;
- IAmControlBackdoor pControlInterfaceBackdoor;
- CAmControlReceiver pControlReceiver;
- CAmCommonFunctions pCF;
- void SetUp();
- void TearDown();
+ class CAmRouterMapTest: public ::testing::Test
+ {
+ public:
+ CAmRouterMapTest();
+ ~CAmRouterMapTest();
+ std::vector<std::string> plistRoutingPluginDirs;
+ std::vector<std::string> plistCommandPluginDirs;
+ CAmSocketHandler pSocketHandler;
+ CAmControlSender pControlSender;
+ CAmDatabaseHandlerMap pDatabaseHandler;
+ CAmRouter pRouter;
+ CAmRoutingSender pRoutingSender;
+ CAmCommandSender pCommandSender;
+ MockIAmCommandSend pMockInterface;
+ MockIAmControlSend pMockControlInterface;
+ IAmRoutingBackdoor pRoutingInterfaceBackdoor;
+ IAmCommandBackdoor pCommandInterfaceBackdoor;
+ IAmControlBackdoor pControlInterfaceBackdoor;
+ CAmControlReceiver pControlReceiver;
+ CAmCommonFunctions pCF;
+ void SetUp();
+ void TearDown();
- void createMainConnectionSetup();
+ void createMainConnectionSetup();
- void enterDomainDB(const std::string & domainName, am_domainID_t & domainID);
- void enterSourceDB(const std::string & sourceName, const am_domainID_t domainID, const std::vector<am_CustomConnectionFormat_t> & connectionFormats, am_sourceID_t & sourceID);
- void enterSinkDB(const std::string & sinkName, const am_domainID_t domainID, const std::vector<am_CustomConnectionFormat_t> & connectionFormats, am_sinkID_t & sinkID);
- void enterGatewayDB(const std::string & gwName,
- const am_domainID_t domainSourceID,
- const am_domainID_t domainSinkID,
- const std::vector<am_CustomConnectionFormat_t> & sourceConnectionFormats,
- const std::vector<am_CustomConnectionFormat_t> & sinkConnectionFormats,
- const std::vector<bool> & matrix,
- const am_sourceID_t & sourceID,
- const am_sinkID_t & sinkID,
- am_gatewayID_t & gatewayID);
- void enterConverterDB(const std::string & gwName,
- const am_domainID_t domainID,
- const std::vector<am_CustomConnectionFormat_t> & sourceConnectionFormats,
- const std::vector<am_CustomConnectionFormat_t> & sinkConnectionFormats,
- const std::vector<bool> & matrix,
- const am_sourceID_t & sourceID,
- const am_sinkID_t & sinkID,
- am_converterID_t & converterID);
- am_Error_e getRoute(const bool onlyfree, const bool shouldReload, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s>& returnList, const unsigned countCycles=0, const unsigned pathsCount=MAX_ROUTING_PATHS);
- am_Error_e getRoute(const bool onlyfree, const bool shouldReload, const am_Source_s & aSource, const am_Sink_s & aSink, std::vector<am_Route_s> & listRoutes, const unsigned countCycles=0, const unsigned pathsCount=MAX_ROUTING_PATHS);
- am_Error_e getAllPaths(CAmRoutingNode & aSource, CAmRoutingNode & aSink, std::vector<am_Route_s> & resultPath, const unsigned countCycles=0, const unsigned pathsCount=MAX_ROUTING_PATHS);
-};
+ void enterDomainDB(const std::string & domainName, am_domainID_t & domainID);
+ void enterSourceDB(const std::string & sourceName, const am_domainID_t domainID, const std::vector<am_CustomConnectionFormat_t> & connectionFormats,
+ am_sourceID_t & sourceID);
+ void enterSinkDB(const std::string & sinkName, const am_domainID_t domainID, const std::vector<am_CustomConnectionFormat_t> & connectionFormats,
+ am_sinkID_t & sinkID);
+ void enterGatewayDB(const std::string & gwName, const am_domainID_t domainSourceID, const am_domainID_t domainSinkID,
+ const std::vector<am_CustomConnectionFormat_t> & sourceConnectionFormats,
+ const std::vector<am_CustomConnectionFormat_t> & sinkConnectionFormats, const std::vector<bool> & matrix, const am_sourceID_t & sourceID,
+ const am_sinkID_t & sinkID, am_gatewayID_t & gatewayID);
+ void enterConverterDB(const std::string & gwName, const am_domainID_t domainID,
+ const std::vector<am_CustomConnectionFormat_t> & sourceConnectionFormats,
+ const std::vector<am_CustomConnectionFormat_t> & sinkConnectionFormats, const std::vector<bool> & matrix, const am_sourceID_t & sourceID,
+ const am_sinkID_t & sinkID, am_converterID_t & converterID);
+ am_Error_e getRoute(const bool onlyfree, const bool shouldReload, const am_sourceID_t sourceID, const am_sinkID_t sinkID,
+ std::vector<am_Route_s>& returnList, const unsigned countCycles = 0, const unsigned pathsCount = MAX_ROUTING_PATHS);
+ am_Error_e getRoute(const bool onlyfree, const bool shouldReload, const am_Source_s & aSource, const am_Sink_s & aSink,
+ std::vector<am_Route_s> & listRoutes, const unsigned countCycles = 0, const unsigned pathsCount = MAX_ROUTING_PATHS);
+ am_Error_e getAllPaths(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s> & resultPath,
+ const unsigned countCycles = 0, const unsigned pathsCount = MAX_ROUTING_PATHS);
+ };
}