summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGENIVI Audio Manager Maintainer <genivi-maint-audiomanager@smtp1.genivi.org>2017-03-07 10:44:54 +0100
committerGitHub <noreply@github.com>2017-03-07 10:44:54 +0100
commit71eab93f9cd67b2e0343700552adf988c420f174 (patch)
tree9f08492872ce7de767f66535178bd0575b72a5b7
parent41b1249b1fc3b211dd56333bdc01f7eb8977f674 (diff)
parentff7a091bd6500413853f381d14be55de2e3affa3 (diff)
downloadaudiomanager-71eab93f9cd67b2e0343700552adf988c420f174.tar.gz
Merge pull request #14 from GENIVI/Router_adaptions
after phoneconference merged
-rw-r--r--AudioManagerCore/CMakeLists.txt1
-rw-r--r--AudioManagerCore/include/CAmCommandSender.h13
-rw-r--r--AudioManagerCore/include/CAmDatabaseHandlerMap.h168
-rw-r--r--AudioManagerCore/include/CAmDatabaseObserver.h87
-rw-r--r--AudioManagerCore/include/CAmGraph.h161
-rw-r--r--AudioManagerCore/include/CAmRouter.h606
-rw-r--r--AudioManagerCore/include/CAmRoutingSender.h5
-rw-r--r--AudioManagerCore/include/IAmDatabaseHandler.h34
-rw-r--r--AudioManagerCore/src/CAmCommandSender.cpp94
-rw-r--r--AudioManagerCore/src/CAmDatabaseHandlerMap.cpp325
-rw-r--r--AudioManagerCore/src/CAmDatabaseObserver.cpp241
-rw-r--r--AudioManagerCore/src/CAmRouter.cpp1685
-rw-r--r--AudioManagerCore/src/CAmRoutingSender.cpp286
-rw-r--r--AudioManagerCore/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp6
-rw-r--r--AudioManagerCore/test/AmControlInterfaceTest/CAmControlInterfaceTest.h3
-rw-r--r--AudioManagerCore/test/AmMapHandlerTest/CAmMapHandlerTest.cpp352
-rw-r--r--AudioManagerCore/test/AmMapHandlerTest/CAmMapHandlerTest.h20
-rw-r--r--AudioManagerCore/test/AmMapHandlerTest/CAmTestDatabaseObserver.cpp129
-rw-r--r--AudioManagerCore/test/AmMapHandlerTest/CAmTestDatabaseObserver.h53
-rw-r--r--AudioManagerCore/test/AmMapHandlerTest/MockDatabaseObserver.h2
-rw-r--r--AudioManagerCore/test/AmRouterMapTest/CAmRouterMapTest.cpp2923
-rw-r--r--AudioManagerCore/test/AmRouterMapTest/CAmRouterMapTest.h99
-rw-r--r--AudioManagerCore/test/AmRouterTest/CAmRouterTest.cpp16
-rw-r--r--AudioManagerCore/test/AmRouterTest/CAmRouterTest.h2
-rw-r--r--AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp103
-rw-r--r--AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.h2
-rw-r--r--AudioManagerCore/test/CMakeLists.txt2
-rwxr-xr-xAudioManagerDaemon/src/main.cpp12
-rw-r--r--AudioManagerUtilities/src/CAmDltWrapper.cpp2
-rwxr-xr-x[-rw-r--r--]docx/images/dependencies.pngbin38376 -> 35437 bytes
-rwxr-xr-x[-rw-r--r--]docx/images/dependencies_test.pngbin59908 -> 59372 bytes
-rwxr-xr-x[-rw-r--r--]docx/images/dependency_created.pngbin119569 -> 34858 bytes
32 files changed, 4065 insertions, 3367 deletions
diff --git a/AudioManagerCore/CMakeLists.txt b/AudioManagerCore/CMakeLists.txt
index 464a934..7be36e9 100644
--- a/AudioManagerCore/CMakeLists.txt
+++ b/AudioManagerCore/CMakeLists.txt
@@ -46,7 +46,6 @@ set(AUDIOMAN_CORE_SRCS_CXX
src/CAmCommandSender.cpp
src/CAmControlReceiver.cpp
src/CAmControlSender.cpp
- src/CAmDatabaseObserver.cpp
src/CAmRoutingReceiver.cpp
src/CAmRoutingSender.cpp
src/CAmRouter.cpp
diff --git a/AudioManagerCore/include/CAmCommandSender.h b/AudioManagerCore/include/CAmCommandSender.h
index 82363de..caa72ad 100644
--- a/AudioManagerCore/include/CAmCommandSender.h
+++ b/AudioManagerCore/include/CAmCommandSender.h
@@ -29,21 +29,24 @@
#endif
#include "IAmCommand.h"
+#include "CAmDatabaseHandlerMap.h"
+#include "CAmSerializer.h"
namespace am
{
class CAmCommandReceiver;
+class CAmCommandSender;
/**
* This class is used to send data to the CommandInterface.
* All loaded plugins will be called when a callback is invoked.
*/
-class CAmCommandSender
+class CAmCommandSender: public CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks
{
public:
- CAmCommandSender(const std::vector<std::string>& listOfPluginDirectories);
+ CAmCommandSender(const std::vector<std::string>& listOfPluginDirectories, CAmSocketHandler *iSocketHandler);
~CAmCommandSender();
am_Error_e startupInterfaces(CAmCommandReceiver* iCommandReceiver);
void setCommandReady();
@@ -78,14 +81,18 @@ public:
friend class IAmCommandBackdoor; //this is to get access to the loaded plugins and be able to exchange the interfaces
#endif
private:
+
void unloadLibraries(void); //!< unload the shared libraries
std::vector<IAmCommandSend*> mListInterfaces; //!< list of all interfaces
std::vector<void*> mListLibraryHandles; //!< list of all library handles. This information is used to unload the plugins correctly.
std::vector<std::string> mListLibraryNames; //!< list of all library names. This information is used for getListPlugins.
-
+
CAmCommandReceiver *mCommandReceiver;
+ CAmSerializer mSerializer;
};
+
+
}
#endif /* COMMANDSENDER_H_ */
diff --git a/AudioManagerCore/include/CAmDatabaseHandlerMap.h b/AudioManagerCore/include/CAmDatabaseHandlerMap.h
index 05443b1..3909b05 100644
--- a/AudioManagerCore/include/CAmDatabaseHandlerMap.h
+++ b/AudioManagerCore/include/CAmDatabaseHandlerMap.h
@@ -74,6 +74,51 @@ class CAmDatabaseHandlerMap : public IAmDatabaseHandler
public:
CAmDatabaseHandlerMap();
virtual ~CAmDatabaseHandlerMap();
+
+ /**
+ * Database observer.
+ */
+ struct AmDatabaseObserverCallbacks: public IAmDatabaseObserver
+ {
+ protected:
+ std::function<void()> dboNumberOfSinkClassesChanged;
+ std::function<void()> dboNumberOfSourceClassesChanged;
+ std::function<void(const am_Sink_s&)> dboNewSink;
+ std::function<void(const am_Source_s&)> dboNewSource;
+ std::function<void(const am_Domain_s& )> dboNewDomain;
+ std::function<void (const am_Gateway_s& )> dboNewGateway;
+ std::function<void (const am_Converter_s& )> dboNewConverter;
+ std::function<void (const am_Crossfader_s& )> dboNewCrossfader;
+ std::function<void (const am_MainConnectionType_s& )> dboNewMainConnection;
+ std::function<void (const am_mainConnectionID_t )> dboRemovedMainConnection;
+ std::function<void (const am_sinkID_t , const bool )> dboRemovedSink;
+ std::function<void (const am_sourceID_t , const bool )> dboRemovedSource;
+ std::function<void (const am_domainID_t )> dboRemoveDomain;
+ std::function<void (const am_gatewayID_t )> dboRemoveGateway;
+ std::function<void (const am_converterID_t )> dboRemoveConverter;
+ std::function<void (const am_crossfaderID_t )> dboRemoveCrossfader;
+ std::function<void (const am_mainConnectionID_t , const am_ConnectionState_e )> dboMainConnectionStateChanged;
+ std::function<void (const am_sinkID_t , const am_MainSoundProperty_s& )> dboMainSinkSoundPropertyChanged;
+ std::function<void (const am_sourceID_t , const am_MainSoundProperty_s& )> dboMainSourceSoundPropertyChanged;
+ std::function<void (const am_sinkID_t , const am_Availability_s& )> dboSinkAvailabilityChanged;
+ std::function<void (const am_sourceID_t , const am_Availability_s& )> dboSourceAvailabilityChanged;
+ std::function<void (const am_sinkID_t , const am_mainVolume_t )> dboVolumeChanged;
+ std::function<void (const am_sinkID_t , const am_MuteState_e )> dboSinkMuteStateChanged;
+ std::function<void (const am_SystemProperty_s& )>dboSystemPropertyChanged;
+ std::function<void (const am_mainConnectionID_t , const am_timeSync_t )>dboTimingInformationChanged;
+ std::function<void (const am_sinkID_t , const am_sinkClass_t , const std::vector<am_MainSoundProperty_s>& , const bool )>dboSinkUpdated;
+ std::function<void (const am_sourceID_t , const am_sourceClass_t , const std::vector<am_MainSoundProperty_s>& , const bool )>dboSourceUpdated;
+ std::function<void (const am_sinkID_t , const am_NotificationConfiguration_s )> dboSinkMainNotificationConfigurationChanged;
+ std::function<void (const am_sourceID_t , const am_NotificationConfiguration_s )> dboSourceMainNotificationConfigurationChanged;
+ public:
+ friend class CAmDatabaseHandlerMap;
+ AmDatabaseObserverCallbacks():IAmDatabaseObserver(), mpDatabaseHandler(nullptr) {}
+ virtual ~AmDatabaseObserverCallbacks(){ if(mpDatabaseHandler) mpDatabaseHandler->unregisterObserver(this);}
+ protected:
+ CAmDatabaseHandlerMap *mpDatabaseHandler;
+
+ };
+
am_Error_e enterDomainDB(const am_Domain_s& domainData, am_domainID_t& domainID);
am_Error_e enterMainConnectionDB(const am_MainConnection_s& mainConnectionData, am_mainConnectionID_t& connectionID);
am_Error_e enterSinkDB(const am_Sink_s& sinkData, am_sinkID_t& sinkID);
@@ -196,7 +241,6 @@ public:
bool existConverter(const am_converterID_t converterID) const;
bool existSinkClass(const am_sinkClass_t sinkClassID) const;
bool existSourceClass(const am_sourceClass_t sourceClassID) const;
- void registerObserver(CAmDatabaseObserver *iObserver);
bool sourceVisible(const am_sourceID_t sourceID) const;
bool sinkVisible(const am_sinkID_t sinkID) const;
bool isComponentConnected(const am_Gateway_s & gateway) const;
@@ -206,6 +250,11 @@ public:
am_Error_e enumerateSinks(std::function<void(const am_Sink_s & element)> cb) const;
am_Error_e enumerateGateways(std::function<void(const am_Gateway_s & element)> cb) const;
am_Error_e enumerateConverters(std::function<void(const am_Converter_s & element)> cb) const;
+
+ bool registerObserver(IAmDatabaseObserver * iObserver);
+ bool unregisterObserver(IAmDatabaseObserver * iObserver);
+ unsigned countObservers();
+
/**
* The following structures extend the base structures with the field 'reserved'.
*/
@@ -276,55 +325,55 @@ public:
AM_SUBCLASS_COPY_OP_END()\
AM_SUBCLASS_OP(Subclass, Class)\
-
+private:
AM_TYPEDEF_SUBCLASS_RESERVED_FLAG_BEGIN(am_Domain_Database_s,am_Domain_s)
- AM_SUBCLASS_END(CAmDomain)
+ AM_SUBCLASS_END(AmDomain)
AM_TYPEDEF_SUBCLASS_SOUND_PROPERTIES_BEGIN(am_Sink_Database_s,am_Sink_s)
void getSinkType(am_SinkType_s & sinkType) const;\
- AM_SUBCLASS_END(CAmSink)
+ AM_SUBCLASS_END(AmSink)
AM_TYPEDEF_SUBCLASS_SOUND_PROPERTIES_BEGIN(am_Source_Database_s,am_Source_s)
void getSourceType(am_SourceType_s & sourceType) const;\
- AM_SUBCLASS_END(CAmSource)
+ AM_SUBCLASS_END(AmSource)
AM_TYPEDEF_SUBCLASS_RESERVED_FLAG_BEGIN(am_Connection_Database_s,am_Connection_s)
- AM_SUBCLASS_END(CAmConnection)
+ AM_SUBCLASS_END(AmConnection)
/**
* The following structures extend the base structures with print capabilities.
*/
AM_TYPEDEF_SUBCLASS_BEGIN(am_MainConnection_Database_s, am_MainConnection_s)
void getMainConnectionType(am_MainConnectionType_s & connectionType) const;\
- AM_SUBCLASS_END(CAmMainConnection)
+ AM_SUBCLASS_END(AmMainConnection)
AM_TYPEDEF_SUBCLASS_BEGIN(am_SourceClass_Database_s, am_SourceClass_s)
- AM_SUBCLASS_END(CAmSourceClass)
+ AM_SUBCLASS_END(AmSourceClass)
AM_TYPEDEF_SUBCLASS_BEGIN(am_SinkClass_Database_s, am_SinkClass_s)
- AM_SUBCLASS_END(CAmSinkClass)
+ AM_SUBCLASS_END(AmSinkClass)
AM_TYPEDEF_SUBCLASS_BEGIN(am_Gateway_Database_s, am_Gateway_s)
- AM_SUBCLASS_END(CAmGateway)
+ AM_SUBCLASS_END(AmGateway)
AM_TYPEDEF_SUBCLASS_BEGIN(am_Converter_Database_s, am_Converter_s)
- AM_SUBCLASS_END(CAmConverter)
+ AM_SUBCLASS_END(AmConverter)
AM_TYPEDEF_SUBCLASS_BEGIN(am_Crossfader_Database_s, am_Crossfader_s)
- AM_SUBCLASS_END(CAmCrossfader)
-
- private:
- typedef std::unordered_map<am_domainID_t, CAmDomain> CAmMapDomain;
- typedef std::unordered_map<am_sourceClass_t, CAmSourceClass> CAmMapSourceClass;
- typedef std::unordered_map<am_sinkClass_t, CAmSinkClass> CAmMapSinkClass;
- typedef std::unordered_map<am_sinkID_t, CAmSink> CAmMapSink;
- typedef std::unordered_map<am_sourceID_t, CAmSource> CAmMapSource;
- typedef std::unordered_map<am_gatewayID_t, CAmGateway> CAmMapGateway;
- typedef std::unordered_map<am_converterID_t, CAmConverter> CAmMapConverter;
- typedef std::unordered_map<am_crossfaderID_t, CAmCrossfader> CAmMapCrossfader;
- typedef std::unordered_map<am_connectionID_t, CAmConnection> CAmMapConnection;
- typedef std::unordered_map<am_mainConnectionID_t, CAmMainConnection> CAmMapMainConnection;
- typedef std::vector<am_SystemProperty_s> CAmVectorSystemProperties;
+ AM_SUBCLASS_END(AmCrossfader)
+
+
+ typedef std::unordered_map<am_domainID_t, AmDomain> AmMapDomain;
+ typedef std::unordered_map<am_sourceClass_t, AmSourceClass> AmMapSourceClass;
+ typedef std::unordered_map<am_sinkClass_t, AmSinkClass> AmMapSinkClass;
+ typedef std::unordered_map<am_sinkID_t, AmSink> AmMapSink;
+ typedef std::unordered_map<am_sourceID_t, AmSource> AmMapSource;
+ typedef std::unordered_map<am_gatewayID_t, AmGateway> AmMapGateway;
+ typedef std::unordered_map<am_converterID_t, AmConverter> AmMapConverter;
+ typedef std::unordered_map<am_crossfaderID_t, AmCrossfader> AmMapCrossfader;
+ typedef std::unordered_map<am_connectionID_t, AmConnection> AmMapConnection;
+ typedef std::unordered_map<am_mainConnectionID_t, AmMainConnection> AmMapMainConnection;
+ typedef std::vector<am_SystemProperty_s> AmVectorSystemProperties;
/**
* The following structure groups the map objects needed for the implementation.
* Every map object is coupled with an identifier, which hold the current value.
@@ -332,46 +381,46 @@ public:
* The IDs can be increased through the method increaseID(...), which follows the AudioManager logic.
* For more information about the static and dynamic IDs, please see the documentation.
*/
- typedef struct CAmMappedData
+ struct AmMappedData
{
/**
* The structure encapsulates the id boundary and the current id value.
* It defines a range within the id can vary.
*/
- struct am_Identifier_s
+ struct AmIdentifier
{
int16_t mMin; //!< min possible value
int16_t mMax; //!< max possible value
int16_t mCurrentValue; //!< current value
- am_Identifier_s():mMin(DYNAMIC_ID_BOUNDARY), mMax(SHRT_MAX), mCurrentValue(mMin){};
- am_Identifier_s(const int16_t & min, const int16_t & max):mMin(min), mMax(max), mCurrentValue(mMin){assert(min<max);};
+ AmIdentifier():mMin(DYNAMIC_ID_BOUNDARY), mMax(SHRT_MAX), mCurrentValue(mMin){};
+ AmIdentifier(const int16_t & min, const int16_t & max):mMin(min), mMax(max), mCurrentValue(mMin){assert(min<max);};
};
- am_Identifier_s mCurrentDomainID; //!< domain ID
- am_Identifier_s mCurrentSourceClassesID; //!< source classes ID
- am_Identifier_s mCurrentSinkClassesID; //!< sink classes ID
- am_Identifier_s mCurrentSinkID; //!< sink ID
- am_Identifier_s mCurrentSourceID; //!< source ID
- am_Identifier_s mCurrentGatewayID; //!< gateway ID
- am_Identifier_s mCurrentConverterID; //!< converter ID
- am_Identifier_s mCurrentCrossfaderID; //!< crossfader ID
- am_Identifier_s mCurrentConnectionID; //!< connection ID
- am_Identifier_s mCurrentMainConnectionID; //!< mainconnection ID
-
- CAmVectorSystemProperties mSystemProperties; //!< vector with system properties
- CAmMapDomain mDomainMap; //!< map for domain structures
- CAmMapSourceClass mSourceClassesMap; //!< map for source classes structures
- CAmMapSinkClass mSinkClassesMap; //!< map for sink classes structures
- CAmMapSink mSinkMap; //!< map for sink structures
- CAmMapSource mSourceMap; //!< map for source structures
- CAmMapGateway mGatewayMap; //!< map for gateway structures
- CAmMapConverter mConverterMap; //!< map for converter structures
- CAmMapCrossfader mCrossfaderMap; //!< map for crossfader structures
- CAmMapConnection mConnectionMap; //!< map for connection structures
- CAmMapMainConnection mMainConnectionMap; //!< map for main connection structures
-
- CAmMappedData(): //For Domain, MainConnections, Connections we don't have static IDs.
+ AmIdentifier mCurrentDomainID; //!< domain ID
+ AmIdentifier mCurrentSourceClassesID; //!< source classes ID
+ AmIdentifier mCurrentSinkClassesID; //!< sink classes ID
+ AmIdentifier mCurrentSinkID; //!< sink ID
+ AmIdentifier mCurrentSourceID; //!< source ID
+ AmIdentifier mCurrentGatewayID; //!< gateway ID
+ AmIdentifier mCurrentConverterID; //!< converter ID
+ AmIdentifier mCurrentCrossfaderID; //!< crossfader ID
+ AmIdentifier mCurrentConnectionID; //!< connection ID
+ AmIdentifier mCurrentMainConnectionID; //!< mainconnection ID
+
+ AmVectorSystemProperties mSystemProperties; //!< vector with system properties
+ AmMapDomain mDomainMap; //!< map for domain structures
+ AmMapSourceClass mSourceClassesMap; //!< map for source classes structures
+ AmMapSinkClass mSinkClassesMap; //!< map for sink classes structures
+ AmMapSink mSinkMap; //!< map for sink structures
+ AmMapSource mSourceMap; //!< map for source structures
+ AmMapGateway mGatewayMap; //!< map for gateway structures
+ AmMapConverter mConverterMap; //!< map for converter structures
+ AmMapCrossfader mCrossfaderMap; //!< map for crossfader structures
+ AmMapConnection mConnectionMap; //!< map for connection structures
+ AmMapMainConnection mMainConnectionMap; //!< map for main connection structures
+
+ AmMappedData(): //For Domain, MainConnections, Connections we don't have static IDs.
mCurrentDomainID(DYNAMIC_ID_BOUNDARY, SHRT_MAX),
mCurrentSourceClassesID(DYNAMIC_ID_BOUNDARY, SHRT_MAX),
mCurrentSinkClassesID(DYNAMIC_ID_BOUNDARY, SHRT_MAX),
@@ -399,7 +448,7 @@ public:
* @param preferedStaticIDBoundary A limit for a given dynamic ID. Default is DYNAMIC_ID_BOUNDARY.
* @return TRUE on successfully changed ID.
*/
- bool increaseID(int16_t & resultID, am_Identifier_s & sourceID, int16_t const desiredStaticID);
+ bool increaseID(int16_t & resultID, AmIdentifier & sourceID, int16_t const desiredStaticID);
/**
* \brief Increases the main connection ID.
*
@@ -426,12 +475,13 @@ public:
{
typename std::unordered_map<TPrintMapKey, TPrintMapObject>::const_iterator iter = t.begin();
for(; iter!=t.end(); iter++)
- CAmMappedData::print(iter->second, output);
+ AmMappedData::print(iter->second, output);
}
private:
- template <typename TMapKey,class TMapObject> bool getNextConnectionID(int16_t & resultID, am_Identifier_s & sourceID,
+ template <typename TMapKey,class TMapObject> bool getNextConnectionID(int16_t & resultID, AmIdentifier & sourceID,
const std::unordered_map<TMapKey, TMapObject> & map);
- } CAmMappedData;
+ };
+
/*
* Helper methods.
*/
@@ -469,9 +519,9 @@ public:
} );
}
- CAmDatabaseObserver *mpDatabaseObserver; //!< pointer to the Observer
ListConnectionFormat mListConnectionFormat; //!< list of connection formats
- CAmMappedData mMappedData; //!< Internal structure encapsulating all the maps used in this class
+ AmMappedData mMappedData; //!< Internal structure encapsulating all the maps used in this class
+ std::vector<AmDatabaseObserverCallbacks*> mDatabaseObservers;
#ifdef UNIT_TEST
public:
diff --git a/AudioManagerCore/include/CAmDatabaseObserver.h b/AudioManagerCore/include/CAmDatabaseObserver.h
deleted file mode 100644
index 7d18be4..0000000
--- a/AudioManagerCore/include/CAmDatabaseObserver.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * SPDX license identifier: MPL-2.0
- *
- * Copyright (C) 2012, BMW AG
- *
- * This file is part of GENIVI Project AudioManager.
- *
- * Contributions are licensed to the GENIVI Alliance under one or more
- * Contribution License Agreements.
- *
- * \copyright
- * This Source Code Form is subject to the terms of the
- * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
- * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- *
- * \author Christian Linke, christian.linke@bmw.de BMW 2011,2012
- *
- * \file CAmDatabaseObserver.h
- * For further information see http://www.genivi.org/.
- *
- */
-
-#ifndef DATABASEOBSERVER_H_
-#define DATABASEOBSERVER_H_
-
-#include "audiomanagertypes.h"
-#include <queue>
-#include "CAmSerializer.h"
-
-namespace am
-{
-
-class CAmTelnetServer;
-class CAmCommandSender;
-class CAmRoutingSender;
-class CAmSocketHandler;
-
-/**
- * This class observes the Database and notifies other classes about important events, mainly the CommandSender.
- */
-class CAmDatabaseObserver
-{
-public:
- CAmDatabaseObserver(CAmCommandSender *iCommandSender, CAmRoutingSender *iRoutingSender, CAmSocketHandler *iSocketHandler);
- CAmDatabaseObserver(CAmCommandSender *iCommandSender, CAmRoutingSender *iRoutingSender, CAmSocketHandler *iSocketHandler, CAmTelnetServer *iTelnetServer);
- ~CAmDatabaseObserver();
- void numberOfSinkClassesChanged();
- void numberOfSourceClassesChanged();
- void newSink(const am_Sink_s& sink);
- void newSource(const am_Source_s& source);
- void newDomain(const am_Domain_s& domain);
- void newGateway(const am_Gateway_s& gateway);
- void newConverter(const am_Converter_s& coverter);
- void newCrossfader(const am_Crossfader_s& crossfader);
- void newMainConnection(const am_MainConnectionType_s& mainConnection);
- void removedMainConnection(const am_mainConnectionID_t mainConnection);
- void removedSink(const am_sinkID_t sinkID, const bool visible);
- void removedSource(const am_sourceID_t sourceID, const bool visible);
- void removeDomain(const am_domainID_t domainID);
- void removeGateway(const am_gatewayID_t gatewayID);
- void removeConverter(const am_converterID_t converterID);
- void removeCrossfader(const am_crossfaderID_t crossfaderID);
- void mainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState);
- void mainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s& SoundProperty);
- void mainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s& SoundProperty);
- void sinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s& availability);
- void sourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s& availability);
- void volumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume);
- void sinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState);
- void systemPropertyChanged(const am_SystemProperty_s& SystemProperty);
- void timingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time);
- void sinkUpdated(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties, const bool visible);
- void sourceUpdated(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties, const bool visible);
- void sinkMainNotificationConfigurationChanged(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration);
- void sourceMainNotificationConfigurationChanged(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration);
-
-private:
- CAmCommandSender *mCommandSender; //!< pointer to the comandSender
- CAmRoutingSender* mRoutingSender; //!< pointer to the routingSender
- CAmTelnetServer* mTelnetServer; //!< pointer to the telnetserver
- CAmSerializer mSerializer; //!< serializer to handle the CommandInterface via the mainloop
-};
-
-}
-
-#endif /* DATABASEOBSERVER_H_ */
diff --git a/AudioManagerCore/include/CAmGraph.h b/AudioManagerCore/include/CAmGraph.h
index ff4a09c..45043f7 100644
--- a/AudioManagerCore/include/CAmGraph.h
+++ b/AudioManagerCore/include/CAmGraph.h
@@ -89,6 +89,7 @@ namespace am
* Setters and getters.
*/
NodeData & getData() { return mData; }
+ const NodeData & getData() const { return mData; }
uint16_t getIndex() const { return mIndex; }
void setIndex(uint16_t index) { mIndex = index; }
};
@@ -120,13 +121,13 @@ namespace am
typedef typename std::vector<CAmNode<T>*> CAmListNodePtrs;
typedef typename std::list<CAmVertex<T,V>> CAmListVertices;
typedef typename std::list<CAmVertex<T,V>>::iterator CAmListVerticesItr;
- typedef typename std::list<CAmVertex<T,V>>::const_iterator CAmListVerticesItrConst;
- typedef typename std::list<CAmListVertices> CAmNodesAdjList;
- typedef typename std::list<CAmListVertices>::iterator CAmNodesAdjListItr;
- typedef typename std::list<CAmListVertices>::const_iterator CAmNodesAdjListItrConst;
- typedef typename std::list<CAmNode<T>> CAmListNodes;
- typedef typename std::list<CAmNode<T>>::iterator CAmListNodesItr;
- typedef typename std::list<CAmNode<T>>::const_iterator CAmListNodesItrConst;
+ typedef typename std::list<CAmVertex<T,V>>::const_iterator CAmListVerticesItrConst;
+ typedef typename std::list<CAmListVertices> CAmNodesAdjList;
+ typedef typename std::list<CAmListVertices>::iterator CAmNodesAdjListItr;
+ typedef typename std::list<CAmListVertices>::const_iterator CAmNodesAdjListItrConst;
+ typedef typename std::list<CAmNode<T>> CAmListNodes;
+ typedef typename std::list<CAmNode<T>>::iterator CAmListNodesItr;
+ typedef typename std::list<CAmNode<T>>::const_iterator CAmListNodesItrConst;
typedef typename std::vector<CAmNode<T>*> CAmNodeReferenceList;
typedef typename std::vector<CAmListVertices*> CAmVertexReferenceList;
@@ -136,6 +137,24 @@ namespace am
CAmVertexReferenceList mPointersAdjList; //!< CAmVertexReferenceList vector with pointers to vertices for direct access
bool mIsCyclic; //!< bool the graph has cycles or not
+ struct IterateThroughAllNodesDelegate
+ {
+ CAmNode<T> * source;
+ CAmNode<T> * destination;
+ CAmNodeReferenceList visited;
+ std::function<bool(const CAmNode<T> * )> shouldVisitNode;
+ std::function<void(const CAmNode<T> *)> willVisitNode;
+ std::function<void(const CAmNode<T> *)> didVisitNode;
+ std::function<void(const CAmNodeReferenceList & path)> didFindPath;
+ };
+
+ struct VisitNodeDelegate
+ {
+ CAmNode<T> * source;
+ CAmNode<T> * destination;
+ std::function<void(const am_GraphPathPosition_e, CAmNode<T> &)> visitedNode;
+ };
+
/**
* Updates the node indexes after adding or removing nodes.
*
@@ -162,7 +181,7 @@ namespace am
typedef uint16_t vertex_t;
typedef uint16_t weight_t;
- void findShortestsPathsFromNode(const CAmNode<T> & node, std::vector<weight_t> &minDistance, std::vector<CAmNode<T> *> &previous)
+ void findShortestPathsFromNode(const CAmNode<T> & node, std::vector<weight_t> &minDistance, std::vector<CAmNode<T> *> &previous)
{
typename CAmListVertices::const_iterator nIter;
CAmListVertices * neighbors;
@@ -256,32 +275,40 @@ namespace am
}
/**
- * Generates list with all possible paths to given destination node after findShortestsPathsFromNode has been called.
- * Finding paths is observed through the callback. The caller is informed after a new path has been found.
+ * Iterate through the nodes and generate all paths to given node.
*
* @param dst end node.
* @param visited vector with current path.
- * @param cb callback which is mostly used for constructing.
+ * @param delegate enumeration delegate.
*/
- void goThroughAllPaths(const CAmNode<T> & dst, std::vector<CAmNode<T>*> & visited, std::function<void(const CAmNodeReferenceList & path)> cb)
+ void findAllPaths(IterateThroughAllNodesDelegate & delegate)
{
- CAmListVertices * nodes = mPointersAdjList[visited.back()->getIndex()];
+ CAmListVertices * nodes = mPointersAdjList[delegate.visited.back()->getIndex()];
CAmListVerticesItrConst vItr(nodes->begin());
+
+ CAmVertex<T,V> * pNextVertex;
+ CAmNode<T> * pNextNode;
for (; vItr != nodes->end(); ++vItr)
{
- const CAmVertex<T,V> & vertex = (*vItr);
- if(vertex.getNode()->getStatus()!=GES_NOT_VISITED)
+ pNextVertex = (CAmVertex<T,V> *)&(*vItr);
+ pNextNode = pNextVertex->getNode();
+ if(
+ pNextNode->getStatus()!=GES_NOT_VISITED ||
+ !delegate.shouldVisitNode(pNextNode)
+ )
continue;
- if (vertex.getNode()==&dst)
+ if (pNextNode==delegate.destination)
{
- vertex.getNode()->setStatus(GES_IN_PROGRESS);
- visited.push_back(vertex.getNode());
+ delegate.willVisitNode(pNextNode);
+ pNextNode->setStatus(GES_IN_PROGRESS);
+ delegate.visited.push_back(pNextNode);
//notify observer
- cb(visited);
+ delegate.didFindPath(delegate.visited);
//remove last node from the list
- auto last = visited.end()-1;
- visited.erase(last);
- vertex.getNode()->setStatus(GES_NOT_VISITED);
+ auto last = delegate.visited.end()-1;
+ delegate.visited.erase(last);
+ pNextNode->setStatus(GES_NOT_VISITED);
+ delegate.didVisitNode(pNextNode);
break;
}
}
@@ -289,20 +316,28 @@ namespace am
//bfs like loop
for (; vItr != nodes->end(); ++vItr)
{
- const CAmVertex<T,V> & vertex = (*vItr);
- if(vertex.getNode()->getStatus()!=GES_NOT_VISITED||vertex.getNode()==&dst)
+ pNextVertex = (CAmVertex<T,V> *)&(*vItr);
+ pNextNode = pNextVertex->getNode();
+
+ if(pNextNode->getStatus()!=GES_NOT_VISITED ||
+ pNextNode==delegate.destination ||
+ !delegate.shouldVisitNode(pNextNode)
+ )
continue;
- vertex.getNode()->setStatus(GES_IN_PROGRESS);
- visited.push_back(vertex.getNode());
- goThroughAllPaths(dst, visited, cb);
+ delegate.willVisitNode(pNextNode);
+ pNextNode->setStatus(GES_IN_PROGRESS);
+ delegate.visited.push_back(pNextNode);
+ findAllPaths(delegate);
//remove last node from the list
- auto last = visited.end()-1;
- visited.erase(last);
- vertex.getNode()->setStatus(GES_NOT_VISITED);
+ auto last = delegate.visited.end()-1;
+ delegate.visited.erase(last);
+ pNextNode->setStatus(GES_NOT_VISITED);
+ delegate.didVisitNode(pNextNode);
}
}
public:
+
explicit CAmGraph(const std::vector<T> &v):mStoreNodes(), mStoreAdjList(), mPointersNodes(), mPointersAdjList()
{
typedef typename std::vector<T>::const_iterator inItr;
@@ -374,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();
}
/**
@@ -428,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);
}
/**
@@ -524,7 +559,7 @@ namespace am
std::vector<weight_t> min_distance;
std::vector<CAmNode<T>*> previous;
- findShortestsPathsFromNode(source, min_distance, previous);
+ findShortestPathsFromNode(source, min_distance, previous);
for(auto it=listTargets.begin(); it!=listTargets.end(); it++)
{
@@ -554,7 +589,7 @@ namespace am
return;
std::vector<weight_t> min_distance;
std::vector<CAmNode<T>*> previous;
- findShortestsPathsFromNode(source, min_distance, previous);
+ findShortestPathsFromNode(source, min_distance, previous);
constructShortestPathTo(destination, previous, resultPath);
}
@@ -576,7 +611,7 @@ namespace am
std::vector<weight_t> min_distance;
std::vector<CAmNode<T>*> previous;
- findShortestsPathsFromNode(source, min_distance, previous);
+ findShortestPathsFromNode(source, min_distance, previous);
for(auto it=listTargets.begin(); it!=listTargets.end(); it++)
{
@@ -603,7 +638,7 @@ namespace am
std::vector<weight_t> min_distance;
std::vector<CAmNode<T>*> previous;
- findShortestsPathsFromNode(source, min_distance, previous);
+ findShortestPathsFromNode(source, min_distance, previous);
constructShortestPathTo(destination, previous, cb);
}
@@ -613,15 +648,29 @@ namespace am
*
* @param src start node.
* @param dst destination node.
- * @param cb callabck.
+ * @param cbShouldVisitNode ask the delegate if we should proceed with the current node.
+ * @param cbWillVisitNode tell the delegate the current node will be visited.
+ * @param cbDidVisitNode tell the delegate the current node was visited.
+ * @param cbDidFindPath return the path to the delegate.
*/
- void getAllPaths(const CAmNode<T> & src, const CAmNode<T> & dst, std::function<void(const CAmNodeReferenceList & path)> cb)
+ void getAllPaths(CAmNode<T> & src,
+ CAmNode<T> & dst,
+ std::function<bool(const CAmNode<T> * )> cbShouldVisitNode,
+ std::function<void(const CAmNode<T> *)> cbWillVisitNode,
+ std::function<void(const CAmNode<T> *)> cbDidVisitNode,
+ std::function<void(const CAmNodeReferenceList & path)> cbDidFindPath)
{
- CAmNodeReferenceList visited;
- visited.push_back((CAmNode<T>*)&src);
+ IterateThroughAllNodesDelegate delegate;
+ delegate.source = &src;
+ delegate.destination = &dst;
+ delegate.shouldVisitNode = cbShouldVisitNode;
+ delegate.willVisitNode = cbWillVisitNode;
+ delegate.didVisitNode = cbDidVisitNode;
+ delegate.didFindPath = cbDidFindPath;
+ delegate.visited.push_back((CAmNode<T>*)&src);
((CAmNode<T>*)&src)->setStatus(GES_VISITED);
- goThroughAllPaths(dst, visited, cb);
- reset();
+ findAllPaths(delegate);
+ ((CAmNode<T>*)&src)->setStatus(GES_NOT_VISITED);
}
};
diff --git a/AudioManagerCore/include/CAmRouter.h b/AudioManagerCore/include/CAmRouter.h
index 7e52b7c..88f73ea 100644
--- a/AudioManagerCore/include/CAmRouter.h
+++ b/AudioManagerCore/include/CAmRouter.h
@@ -27,293 +27,353 @@
#include <assert.h>
#include <vector>
+#include <iomanip>
#include <functional>
#include "audiomanagertypes.h"
#include "CAmGraph.h"
-#include "IAmDatabaseHandler.h"
-
+#include "CAmDatabaseHandlerMap.h"
namespace am
{
-#define ROUTING_BUILD_CONNECTIONS 1
-
-/**
- * Optimal path search between a source and a sink is implemented with a 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.
- */
-#if !defined(ROUTING_BUILD_CONNECTIONS)
- #undef TRACE_GRAPH
-#endif
-/**
- * Default behavior is to do the search in one step without connections, which are identified during the search.
- * Alternatively the search can be done in two steps.
- */
-#if !defined(ROUTING_BUILD_CONNECTIONS)
- #undef ROUTING_BUILD_CONNECTIONS
-#endif
-
-#if defined(TRACE_GRAPH)
-#if !defined(ROUTING_BUILD_CONNECTIONS)
-#warning "You should define ROUTING_BUILD_CONNECTIONS in order to be able to see the connections in the trace."
+ /**
+ * 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
+ */
+#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.
+ *
+ */
+#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
- void trace() const
- {
- if(type==SINK)
- std::cout << "[SINK:" << data.sink->sinkID << ":" << data.sink->name << "(" << data.sink->domainID << ")"
- << "]";
- else if(type==SOURCE)
- std::cout << "[SOUR:" << data.source->sourceID << ":" << data.source->name << "(" << data.source->domainID << ")"
- << "]";
- else if(type==GATEWAY)
- std::cout << "[GATE:" << data.gateway->gatewayID << ":" << data.gateway->name << "(" << data.gateway->controlDomainID << ")"
- << "]";
- else if(type==CONVERTER)
- std::cout << "[CONV:" << data.converter->converterID << ":" << data.converter->name << "(" << data.converter->domainID << ")"
- << "]";
- };
-#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
-{
- 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
- 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
-
- am_Error_e determineConnectionFormatsForPath(am_Route_s & routeObjects, std::vector<CAmRoutingNode*> & nodes);
- am_Error_e doConnectionFormatsForPath(am_Route_s & routeObjects,
- std::vector<CAmRoutingNode*> & route,
- std::vector<am_RoutingElement_s>::iterator routingElementIterator,
- std::vector<CAmRoutingNode*>::iterator routeIterator);
-
-
- /**
- * 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);
- }
- void generateAllPaths(const CAmRoutingNode & src,
- const CAmRoutingNode & dst,
- const bool includeCycles,
- std::function<void(const std::vector<CAmRoutingNode*> & path)> cb);
- void goThroughAllPaths(const CAmRoutingNode & dst,
- std::vector<CAmRoutingNode*> & visited,
- std::vector<am_domainID_t> & visitedDomains,
- std::function<void(const std::vector<CAmRoutingNode*> & path)> cb);
-
-#ifdef ROUTING_BUILD_CONNECTIONS
- /**
- * Connects all converters to its sink and sources if possible.
- *
- */
- void constructConverterConnections();
-
- /**
- * Connects all gateways to its sink and sources if possible.
- *
- */
- void constructGatewayConnections();
-
- /**
- * Connects all sources to the sinks if possible.
- *
- */
- void constructSourceSinkConnections();
-#else
- /**
- * Construct a list with all vertices
- */
- void getVerticesForNode(const CAmRoutingNode & node, CAmRoutingListVertices & list);
-
- /**
- * Construct a list with all vertices from given source.
- */
- void getVerticesForSource(const CAmRoutingNode & node, CAmRoutingListVertices & list);
-
- /**
- * Construct a list with all vertices from given sink.
- */
- void getVerticesForSink(const CAmRoutingNode & node, CAmRoutingListVertices & list);
-
- /**
- * Construct a list with all vertices from given converter.
- */
- void getVerticesForConverter(const CAmRoutingNode & node, CAmRoutingListVertices & list);
-
- /**
- * Construct a list with all vertices from given gateway.
- */
- void getVerticesForGateway(const CAmRoutingNode & node, CAmRoutingListVertices & list);
-#endif
-
-public:
- CAmRouter(IAmDatabaseHandler* iDatabaseHandler, CAmControlSender* iSender);
- ~CAmRouter();
-
- /**
- * Finds all possible paths between given source and sink.
- *
- * @param onlyfree only disconnected elements should be included or not.
- * @param sourceID starting point.
- * @param sinkID ending point.
- * @param returnList list with all possible paths
- * @return E_OK on success(0 or more paths) or E_NOT_POSSIBLE on failure.
- */
- 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 & aSource, const am_Sink_s & aSink, std::vector<am_Route_s> & listRoutes);
-
- am_Error_e getAllPaths(CAmRoutingNode & aSource, CAmRoutingNode & aSink,
- std::vector<am_Route_s> & resultPath, std::vector<std::vector<CAmRoutingNode*>> & resultNodesPath,
-#if !defined(ROUTING_BUILD_CONNECTIONS)
- __attribute__((unused))
-#endif
- const bool includeCycles = false);
-#ifdef ROUTING_BUILD_CONNECTIONS
- void getShortestPath(const CAmRoutingNode & source, const CAmRoutingNode & destination, std::vector<CAmRoutingNode*> & resultPath);
- void getShortestPath(CAmRoutingNode & aSource, CAmRoutingNode & aSink, am_Route_s & resultPath, std::vector<CAmRoutingNode*> & resultNodesPath);
+#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 )
+ };
#endif
- 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 void 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);
-
- /**
- * 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();
-};
+ 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/include/CAmRoutingSender.h b/AudioManagerCore/include/CAmRoutingSender.h
index 8804d90..8d8a063 100644
--- a/AudioManagerCore/include/CAmRoutingSender.h
+++ b/AudioManagerCore/include/CAmRoutingSender.h
@@ -32,16 +32,17 @@
#include "../test/IAmRoutingBackdoor.h"
#endif
+#include "CAmDatabaseHandlerMap.h"
+
namespace am
{
class CAmRoutingReceiver;
-class IAmDatabaseHandler;
/**
* Implements the RoutingSendInterface. Loads all plugins and dispatches calls to the plugins
*/
-class CAmRoutingSender
+class CAmRoutingSender: public CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks
{
public:
CAmRoutingSender(const std::vector<std::string>& listOfPluginDirectories, IAmDatabaseHandler* databaseHandler);
diff --git a/AudioManagerCore/include/IAmDatabaseHandler.h b/AudioManagerCore/include/IAmDatabaseHandler.h
index aa275db..f4fe8a1 100644
--- a/AudioManagerCore/include/IAmDatabaseHandler.h
+++ b/AudioManagerCore/include/IAmDatabaseHandler.h
@@ -30,18 +30,14 @@
#include <string>
#include <iostream>
#include <functional>
+#include <memory>
+#include <assert.h>
+#include <algorithm>
#include "audiomanagerconfig.h"
namespace am
{
-class CAmDatabaseObserver;
-class CAmRoutingTree;
-class CAmRoutingTreeItem;
-
-
-//enum { DYNAMIC_ID_BOUNDARY = 100 }; //!< the value below is reserved for staticIDs, the value above will be assigned to dynamically registered items
-
//todo: check the enum values before entering & changing in the database.
//todo: change asserts for dynamic boundary checks into failure answers.#
//todo: check autoincrement boundary and set to 16bit limits
@@ -59,8 +55,12 @@ typedef std::map<am_gatewayID_t, std::vector<bool> > ListConnectionFormat; //!<
class IAmDatabaseHandler
{
public:
- IAmDatabaseHandler () {};
- virtual ~IAmDatabaseHandler () {};
+ IAmDatabaseHandler (){}
+ virtual ~IAmDatabaseHandler (){}
+
+ /**
+ * The following interface methods must be implemented by the subclass.
+ */
virtual am_Error_e enterDomainDB(const am_Domain_s& domainData, am_domainID_t& domainID) = 0;
virtual am_Error_e enterMainConnectionDB(const am_MainConnection_s& mainConnectionData, am_mainConnectionID_t& connectionID) = 0;
virtual am_Error_e enterSinkDB(const am_Sink_s& sinkData, am_sinkID_t& sinkID) = 0;
@@ -117,7 +117,7 @@ public:
virtual am_Error_e getSourceVolume(const am_sourceID_t sourceID, am_volume_t& volume) const = 0;
virtual am_Error_e getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const = 0;
virtual am_Error_e getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const = 0;
- virtual am_Error_e getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s>& listSoundproperties) const =0;
+ virtual am_Error_e getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s>& listSoundproperties) const =0;
virtual am_Error_e getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s>& listSoundproperties) const =0;
virtual am_Error_e getMainSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const = 0;
virtual am_Error_e getMainSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const = 0;
@@ -166,7 +166,6 @@ public:
virtual am_Error_e changeConverterDB(const am_converterID_t converterID, const std::vector<am_CustomConnectionFormat_t>& listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t>& listSinkConnectionFormats, const std::vector<bool>& convertionMatrix) = 0;
virtual am_Error_e changeSinkNotificationConfigurationDB(const am_sinkID_t sinkID,const am_NotificationConfiguration_s notificationConfiguration) = 0;
virtual am_Error_e changeSourceNotificationConfigurationDB(const am_sourceID_t sourceID,const am_NotificationConfiguration_s notificationConfiguration) = 0;
-
virtual bool existMainConnection(const am_mainConnectionID_t mainConnectionID) const = 0;
virtual bool existCrossFader(const am_crossfaderID_t crossfaderID) const = 0;
virtual bool existConnection(const am_Connection_s & connection) const = 0;
@@ -181,7 +180,6 @@ public:
virtual bool existGateway(const am_gatewayID_t gatewayID) const = 0;
virtual bool existSinkClass(const am_sinkClass_t sinkClassID) const = 0;
virtual bool existSourceClass(const am_sourceClass_t sourceClassID) const = 0;
- virtual void registerObserver(CAmDatabaseObserver *iObserver) = 0;
virtual bool sourceVisible(const am_sourceID_t sourceID) const = 0;
virtual bool sinkVisible(const am_sinkID_t sinkID) const = 0;
virtual bool isComponentConnected(const am_Gateway_s & gateway) const = 0;
@@ -192,7 +190,19 @@ public:
virtual am_Error_e enumerateSinks(std::function<void(const am_Sink_s & element)> cb) const = 0 ;
virtual am_Error_e enumerateGateways(std::function<void(const am_Gateway_s & element)> cb) const = 0 ;
virtual am_Error_e enumerateConverters(std::function<void(const am_Converter_s & element)> cb) const = 0 ;
+ /**
+ * Database observer protocol
+ */
+ class IAmDatabaseObserver
+ {
+ public:
+ IAmDatabaseObserver() {}
+ virtual ~IAmDatabaseObserver(){}
+ };
+ virtual bool registerObserver(IAmDatabaseObserver * iObserver) = 0;
+ virtual bool unregisterObserver(IAmDatabaseObserver * iObserver) = 0;
+ virtual unsigned countObservers() = 0;
};
diff --git a/AudioManagerCore/src/CAmCommandSender.cpp b/AudioManagerCore/src/CAmCommandSender.cpp
index 2e60109..ea0d749 100644
--- a/AudioManagerCore/src/CAmCommandSender.cpp
+++ b/AudioManagerCore/src/CAmCommandSender.cpp
@@ -51,11 +51,13 @@ namespace am
(*iter)->__VA_ARGS__; \
}
-CAmCommandSender::CAmCommandSender(const std::vector<std::string>& listOfPluginDirectories) :
+CAmCommandSender::CAmCommandSender(const std::vector<std::string>& listOfPluginDirectories, CAmSocketHandler *iSocketHandler) :
+ CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks(),
mListInterfaces(), //
mListLibraryHandles(), //
mListLibraryNames(), //
- mCommandReceiver()
+ mCommandReceiver(),
+ mSerializer(iSocketHandler)
{
if (listOfPluginDirectories.empty())
{
@@ -159,6 +161,93 @@ CAmCommandSender::CAmCommandSender(const std::vector<std::string>& listOfPluginD
mListLibraryHandles.push_back(tempLibHandle);
mListLibraryNames.push_back(iter->c_str());
}
+
+ dboNewMainConnection = [&](const am_MainConnectionType_s& mainConnection) {
+ mSerializer.asyncCall<CAmCommandSender, const am_MainConnectionType_s>(this, &CAmCommandSender::cbNewMainConnection, mainConnection);
+ };
+ dboRemovedMainConnection = [&](const am_mainConnectionID_t mainConnection) {
+ mSerializer.asyncCall<CAmCommandSender, const am_mainConnectionID_t>(this, &CAmCommandSender::cbRemovedMainConnection, mainConnection);
+ };
+ dboNewSink = [&](const am_Sink_s& sink) {
+ if (sink.visible)
+ {
+ am_SinkType_s s;
+ s.availability = sink.available;
+ s.muteState = sink.muteState;
+ s.name = sink.name;
+ s.sinkClassID = sink.sinkClassID;
+ s.sinkID = sink.sinkID;
+ s.volume = sink.mainVolume;
+ mSerializer.asyncCall<CAmCommandSender, const am_SinkType_s>(this, &CAmCommandSender::cbNewSink, s);
+ }
+ };
+ dboNewSource = [&](const am_Source_s& source) {
+ if (source.visible)
+ {
+ am_SourceType_s s;
+ s.availability = source.available;
+ s.name = source.name;
+ s.sourceClassID = source.sourceClassID;
+ s.sourceID = source.sourceID;
+ mSerializer.asyncCall<CAmCommandSender, const am_SourceType_s>(this, &CAmCommandSender::cbNewSource, s);
+ }
+ };
+
+ dboRemovedSink = [&](const am_sinkID_t sinkID, const bool visible) {
+ if (visible)
+ mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t>(this, &CAmCommandSender::cbRemovedSink, sinkID);
+ };
+ dboRemovedSource = [&](const am_sourceID_t sourceID, const bool visible) {
+ if (visible)
+ mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t>(this, &CAmCommandSender::cbRemovedSource, sourceID);
+ };
+ dboNumberOfSinkClassesChanged = [&]() {
+ mSerializer.asyncCall<CAmCommandSender>(this, &CAmCommandSender::cbNumberOfSinkClassesChanged);
+ };
+ dboNumberOfSourceClassesChanged = [&]() {
+ mSerializer.asyncCall<CAmCommandSender>(this, &CAmCommandSender::cbNumberOfSourceClassesChanged);
+ };
+ dboMainConnectionStateChanged = [&](const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState) {
+ mSerializer.asyncCall<CAmCommandSender, const am_connectionID_t, const am_ConnectionState_e>(this, &CAmCommandSender::cbMainConnectionStateChanged, connectionID, connectionState);
+ };
+ dboMainSinkSoundPropertyChanged = [&](const am_sinkID_t sinkID, const am_MainSoundProperty_s& SoundProperty) {
+ mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_MainSoundProperty_s>(this, &CAmCommandSender::cbMainSinkSoundPropertyChanged, sinkID, SoundProperty);
+ };
+ dboMainSourceSoundPropertyChanged = [&](const am_sourceID_t sourceID, const am_MainSoundProperty_s& SoundProperty) {
+ mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t, const am_MainSoundProperty_s>(this, &CAmCommandSender::cbMainSourceSoundPropertyChanged, sourceID, SoundProperty);
+ };
+ dboSinkAvailabilityChanged = [&](const am_sinkID_t sinkID, const am_Availability_s & availability) {
+ mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_Availability_s>(this, &CAmCommandSender::cbSinkAvailabilityChanged, sinkID, availability);
+ };
+ dboSourceAvailabilityChanged = [&](const am_sourceID_t sourceID, const am_Availability_s & availability) {
+ mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t, const am_Availability_s>(this, &CAmCommandSender::cbSourceAvailabilityChanged, sourceID, availability);
+ };
+ dboVolumeChanged = [&](const am_sinkID_t sinkID, const am_mainVolume_t volume) {
+ mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_mainVolume_t>(this, &CAmCommandSender::cbVolumeChanged, sinkID, volume);
+ };
+ dboSinkMuteStateChanged = [&](const am_sinkID_t sinkID, const am_MuteState_e muteState) {
+ mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_MuteState_e>(this, &CAmCommandSender::cbSinkMuteStateChanged, sinkID, muteState);
+ };
+ dboSystemPropertyChanged = [&](const am_SystemProperty_s& SystemProperty) {
+ mSerializer.asyncCall<CAmCommandSender, const am_SystemProperty_s>(this, &CAmCommandSender::cbSystemPropertyChanged, SystemProperty);
+ };
+ dboTimingInformationChanged = [&](const am_mainConnectionID_t mainConnection, const am_timeSync_t time) {
+ mSerializer.asyncCall<CAmCommandSender, const am_mainConnectionID_t, const am_timeSync_t>(this, &CAmCommandSender::cbTimingInformationChanged, mainConnection, time);
+ };
+ dboSinkUpdated = [&](const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties, const bool visible) {
+ if (visible)
+ mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_sinkClass_t, const std::vector<am_MainSoundProperty_s> >(this, &CAmCommandSender::cbSinkUpdated, sinkID, sinkClassID, listMainSoundProperties);
+ };
+ dboSourceUpdated = [&](const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties, const bool visible) {
+ if (visible)
+ mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t, const am_sourceClass_t, const std::vector<am_MainSoundProperty_s> >(this, &CAmCommandSender::cbSinkUpdated, sourceID, sourceClassID, listMainSoundProperties);
+ };
+ dboSinkMainNotificationConfigurationChanged = [&](const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration) {
+ mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_NotificationConfiguration_s> (this, &CAmCommandSender::cbSinkMainNotificationConfigurationChanged, sinkID, mainNotificationConfiguration);
+ };
+ dboSourceMainNotificationConfigurationChanged = [&](const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration) {
+ mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t, const am_NotificationConfiguration_s>(this, &CAmCommandSender::cbSourceMainNotificationConfigurationChanged, sourceID, mainNotificationConfiguration);
+ };
}
CAmCommandSender::~CAmCommandSender()
@@ -366,4 +455,5 @@ void CAmCommandSender::unloadLibraries(void)
}
mListLibraryHandles.clear();
}
+
}
diff --git a/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp b/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp
index fa7f5fc..83419b9 100644
--- a/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp
+++ b/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp
@@ -30,7 +30,6 @@
#include <string>
#include <limits>
#include "CAmDatabaseHandlerMap.h"
-#include "CAmDatabaseObserver.h"
#include "CAmRouter.h"
#include "CAmDltWrapper.h"
@@ -56,6 +55,30 @@
(true)
#endif
+#define NOTIFY_OBSERVERS(CALL)\
+ for(AmDatabaseObserverCallbacks * nextObserver: mDatabaseObservers)\
+ if(nextObserver->CALL)\
+ nextObserver->CALL();
+
+#define NOTIFY_OBSERVERS1(CALL, ARG1)\
+ for(AmDatabaseObserverCallbacks * nextObserver: mDatabaseObservers)\
+ if(nextObserver->CALL)\
+ nextObserver->CALL(ARG1);
+
+#define NOTIFY_OBSERVERS2(CALL, ARG1, ARG2)\
+ for(AmDatabaseObserverCallbacks * nextObserver: mDatabaseObservers)\
+ if(nextObserver->CALL)\
+ nextObserver->CALL(ARG1, ARG2);
+
+#define NOTIFY_OBSERVERS3(CALL, ARG1, ARG2, ARG3)\
+ for(AmDatabaseObserverCallbacks * nextObserver: mDatabaseObservers)\
+ if(nextObserver->CALL)\
+ nextObserver->CALL(ARG1, ARG2, ARG3);
+
+#define NOTIFY_OBSERVERS4(CALL, ARG1, ARG2, ARG3, ARG4)\
+ for(AmDatabaseObserverCallbacks * nextObserver: mDatabaseObservers)\
+ if(nextObserver->CALL)\
+ nextObserver->CALL(ARG1, ARG2, ARG3, ARG4);
namespace am
{
@@ -117,7 +140,7 @@ template <class TReturn, typename TIdentifier> const TReturn * objectMatchingPr
/* Domain */
-void CAmDatabaseHandlerMap::CAmDomain::getDescription (std::string & outString) const
+void CAmDatabaseHandlerMap::AmDomain::getDescription (std::string & outString) const
{
std::ostringstream fmt;
fmt << "Domain(" << name.c_str() << ") id(" << domainID << ")" << std::endl <<
@@ -133,7 +156,7 @@ void CAmDatabaseHandlerMap::CAmDomain::getDescription (std::string & outString)
/* Source */
-void CAmDatabaseHandlerMap::CAmSource::getSourceType(am_SourceType_s & sourceType) const
+void CAmDatabaseHandlerMap::AmSource::getSourceType(am_SourceType_s & sourceType) const
{
sourceType.name = name;
sourceType.sourceClassID = sourceClassID;
@@ -141,7 +164,7 @@ void CAmDatabaseHandlerMap::CAmSource::getSourceType(am_SourceType_s & sourceTyp
sourceType.sourceID = sourceID;
}
-void CAmDatabaseHandlerMap::CAmSource::getDescription (std::string & outString) const
+void CAmDatabaseHandlerMap::AmSource::getDescription (std::string & outString) const
{
std::ostringstream fmt;
fmt << "Source(" << name.c_str() << ") id(" << sourceID << ")" << std::endl <<
@@ -179,7 +202,7 @@ void CAmDatabaseHandlerMap::CAmSource::getDescription (std::string & outString)
/* Sink */
-void CAmDatabaseHandlerMap::CAmSink::getDescription (std::string & outString) const
+void CAmDatabaseHandlerMap::AmSink::getDescription (std::string & outString) const
{
std::ostringstream fmt;
fmt << "Sink(" << name.c_str() << ") id(" << sinkID << ")" << std::endl <<
@@ -215,7 +238,7 @@ void CAmDatabaseHandlerMap::CAmSink::getDescription (std::string & outString) co
outString = fmt.str();
}
-void CAmDatabaseHandlerMap::CAmSink::getSinkType(am_SinkType_s & sinkType) const
+void CAmDatabaseHandlerMap::AmSink::getSinkType(am_SinkType_s & sinkType) const
{
sinkType.name = name;
sinkType.sinkID = sinkID;
@@ -227,7 +250,7 @@ void CAmDatabaseHandlerMap::CAmSink::getSinkType(am_SinkType_s & sinkType) const
/* Connection */
-void CAmDatabaseHandlerMap::CAmConnection::getDescription (std::string & outString) const
+void CAmDatabaseHandlerMap::AmConnection::getDescription (std::string & outString) const
{
std::ostringstream fmt;
fmt << "Connection id(" << connectionID << ") " << std::endl <<
@@ -241,7 +264,7 @@ void CAmDatabaseHandlerMap::CAmConnection::getDescription (std::string & outStri
/* Main Connection */
-void CAmDatabaseHandlerMap::CAmMainConnection::getDescription (std::string & outString) const
+void CAmDatabaseHandlerMap::AmMainConnection::getDescription (std::string & outString) const
{
std::ostringstream fmt;
fmt << "MainConnection id(" << mainConnectionID << ") " << std::endl <<
@@ -268,7 +291,7 @@ void CAmDatabaseHandlerMap::am_MainConnection_Database_s::getMainConnectionType(
/* Source Class */
-void CAmDatabaseHandlerMap::CAmSourceClass::getDescription (std::string & outString) const
+void CAmDatabaseHandlerMap::AmSourceClass::getDescription (std::string & outString) const
{
std::ostringstream fmt;
fmt << "Source class(" << name.c_str() << ") id(" << sourceClassID << ")\n" <<
@@ -282,7 +305,7 @@ void CAmDatabaseHandlerMap::CAmSourceClass::getDescription (std::string & outStr
/* Sink Class */
-void CAmDatabaseHandlerMap::CAmSinkClass::getDescription (std::string & outString) const
+void CAmDatabaseHandlerMap::AmSinkClass::getDescription (std::string & outString) const
{
std::ostringstream fmt;
fmt << "Sink class(" << name.c_str() << ") id(" << sinkClassID << ")\n" <<
@@ -297,7 +320,7 @@ void CAmDatabaseHandlerMap::CAmSinkClass::getDescription (std::string & outStrin
/* Gateway */
-void CAmDatabaseHandlerMap::CAmGateway::getDescription (std::string & outString) const
+void CAmDatabaseHandlerMap::AmGateway::getDescription (std::string & outString) const
{
std::ostringstream fmt;
fmt << "Gateway(" << name.c_str() << ") id(" << gatewayID << ")\n" <<
@@ -322,9 +345,34 @@ void CAmDatabaseHandlerMap::CAmGateway::getDescription (std::string & outString)
outString = fmt.str();
}
+/* Converter */
+
+void CAmDatabaseHandlerMap::AmConverter::getDescription (std::string & outString) const
+{
+ std::ostringstream fmt;
+ fmt << "Converter(" << name.c_str() << ") id(" << converterID << ")\n" <<
+ "sinkID(" << sinkID <<
+ ") sourceID(" << sourceID <<
+ ") domainSinkID(" << domainID <<
+ ") listSourceFormats (";
+ std::for_each(listSourceFormats.begin(), listSourceFormats.end(), [&](const am_CustomConnectionFormat_t & ref) {
+ fmt << "[" << ref << "]";
+ });
+ fmt << ") listSinkFormats (";
+ std::for_each(listSinkFormats.begin(), listSinkFormats.end(), [&](const am_CustomConnectionFormat_t & ref) {
+ fmt << "[" << ref << "]";
+ });
+ fmt << ") convertionMatrix (";
+ std::for_each(convertionMatrix.begin(), convertionMatrix.end(), [&](const bool & ref) {
+ fmt << "[" << ref << "]";
+ });
+ fmt << ")" << std::endl;
+ outString = fmt.str();
+}
+
/* Crossfader */
-void CAmDatabaseHandlerMap::CAmCrossfader::getDescription (std::string & outString) const
+void CAmDatabaseHandlerMap::AmCrossfader::getDescription (std::string & outString) const
{
std::ostringstream fmt;
fmt << "Crossfader(" << name.c_str() << ") id(" << crossfaderID << ")\n" <<
@@ -336,7 +384,7 @@ void CAmDatabaseHandlerMap::CAmCrossfader::getDescription (std::string & outStri
outString = fmt.str();
}
-bool CAmDatabaseHandlerMap::CAmMappedData::increaseID(int16_t & resultID, am_Identifier_s & sourceID,
+bool CAmDatabaseHandlerMap::AmMappedData::increaseID(int16_t & resultID, AmIdentifier & sourceID,
int16_t const desiredStaticID = 0)
{
if( desiredStaticID > 0 && desiredStaticID < sourceID.mMin )
@@ -356,7 +404,7 @@ bool CAmDatabaseHandlerMap::CAmMappedData::increaseID(int16_t & resultID, am_Ide
}
}
-template <typename TMapKey,class TMapObject> bool CAmDatabaseHandlerMap::CAmMappedData::getNextConnectionID(int16_t & resultID, am_Identifier_s & sourceID,
+template <typename TMapKey,class TMapObject> bool CAmDatabaseHandlerMap::AmMappedData::getNextConnectionID(int16_t & resultID, AmIdentifier & sourceID,
const std::unordered_map<TMapKey, TMapObject> & map)
{
TMapKey nextID;
@@ -393,27 +441,28 @@ template <typename TMapKey,class TMapObject> bool CAmDatabaseHandlerMap::CAmMapp
return true;
}
-bool CAmDatabaseHandlerMap::CAmMappedData::increaseMainConnectionID(int16_t & resultID)
+bool CAmDatabaseHandlerMap::AmMappedData::increaseMainConnectionID(int16_t & resultID)
{
return getNextConnectionID(resultID, mCurrentMainConnectionID, mMainConnectionMap);
}
-bool CAmDatabaseHandlerMap::CAmMappedData::increaseConnectionID(int16_t & resultID)
+bool CAmDatabaseHandlerMap::AmMappedData::increaseConnectionID(int16_t & resultID)
{
return getNextConnectionID(resultID, mCurrentConnectionID, mConnectionMap);
}
-CAmDatabaseHandlerMap::CAmDatabaseHandlerMap(): mFirstStaticSink(true), //
- mFirstStaticSource(true), //
- mFirstStaticGateway(true), //
- mFirstStaticConverter(true), //
- mFirstStaticSinkClass(true), //
- mFirstStaticSourceClass(true), //
- mFirstStaticCrossfader(true), //
- mpDatabaseObserver(NULL), //
- mListConnectionFormat(), //
- mMappedData()
+CAmDatabaseHandlerMap::CAmDatabaseHandlerMap(): IAmDatabaseHandler(),
+ mFirstStaticSink(true), //
+ mFirstStaticSource(true), //
+ mFirstStaticGateway(true), //
+ mFirstStaticConverter(true), //
+ mFirstStaticSinkClass(true), //
+ mFirstStaticSourceClass(true), //
+ mFirstStaticCrossfader(true), //
+ mListConnectionFormat(), //
+ mMappedData(),
+ mDatabaseObservers()
{
logVerbose(__METHOD_NAME__,"Init ");
}
@@ -421,7 +470,8 @@ CAmDatabaseHandlerMap::CAmDatabaseHandlerMap(): mFirstStaticSink(true), //
CAmDatabaseHandlerMap::~CAmDatabaseHandlerMap()
{
logVerbose(__METHOD_NAME__,"Destroy");
- mpDatabaseObserver = NULL;
+ for(AmDatabaseObserverCallbacks * ptr: mDatabaseObservers)
+ ptr->mpDatabaseHandler=nullptr;
}
am_Error_e CAmDatabaseHandlerMap::enterDomainDB(const am_Domain_s & domainData, am_domainID_t & domainID)
@@ -442,7 +492,7 @@ am_Error_e CAmDatabaseHandlerMap::enterDomainDB(const am_Domain_s & domainData,
return (E_NOT_POSSIBLE);
}
//first check for a reserved domain
- am_Domain_s const *reservedDomain = objectMatchingPredicate<CAmDomain, am_domainID_t>(mMappedData.mDomainMap, [&](const CAmDomain & obj){
+ am_Domain_s const *reservedDomain = objectMatchingPredicate<AmDomain, am_domainID_t>(mMappedData.mDomainMap, [&](const AmDomain & obj){
return domainData.name.compare(obj.name)==0;
});
@@ -456,8 +506,9 @@ am_Error_e CAmDatabaseHandlerMap::enterDomainDB(const am_Domain_s & domainData,
mMappedData.mDomainMap[nextID].domainID = nextID;
mMappedData.mDomainMap[nextID].reserved = 0;
logVerbose("DatabaseHandler::enterDomainDB entered reserved domain with name=", domainData.name, "busname=", domainData.busname, "nodename=", domainData.nodename, "reserved ID:", domainID);
- if (mpDatabaseObserver)
- mpDatabaseObserver->newDomain(mMappedData.mDomainMap[nextID]);
+
+ NOTIFY_OBSERVERS1(dboNewDomain, mMappedData.mDomainMap[nextID])
+
return (E_OK);
}
else
@@ -468,8 +519,9 @@ am_Error_e CAmDatabaseHandlerMap::enterDomainDB(const am_Domain_s & domainData,
mMappedData.mDomainMap[nextID] = domainData;
mMappedData.mDomainMap[nextID].domainID = nextID;
logVerbose("DatabaseHandler::enterDomainDB entered new domain with name=", domainData.name, "busname=", domainData.busname, "nodename=", domainData.nodename, "assigned ID:", domainID);
- if (mpDatabaseObserver)
- mpDatabaseObserver->newDomain(mMappedData.mDomainMap[nextID]);
+
+ NOTIFY_OBSERVERS1(dboNewDomain, mMappedData.mDomainMap[nextID])
+
return (E_OK);
}
else
@@ -543,12 +595,14 @@ am_Error_e CAmDatabaseHandlerMap::enterMainConnectionDB(const am_MainConnection_
delay = calculateDelayForRoute(mainConnectionData.listConnectionID);
logVerbose("DatabaseHandler::enterMainConnectionDB entered new mainConnection with sourceID", mainConnectionData.sourceID, "sinkID:", mainConnectionData.sinkID, "delay:", delay, "assigned ID:", connectionID);
- if (mpDatabaseObserver)
+
+ if (mDatabaseObservers.size())
{
- am_MainConnectionType_s mainConnection;
- mMappedData.mMainConnectionMap[nextID].getMainConnectionType(mainConnection);
- mpDatabaseObserver->newMainConnection(mainConnection);
- mpDatabaseObserver->mainConnectionStateChanged(connectionID, mMappedData.mMainConnectionMap[nextID].connectionState);
+ am_MainConnectionType_s mainConnection;
+ mMappedData.mMainConnectionMap[nextID].getMainConnectionType(mainConnection);
+
+ NOTIFY_OBSERVERS1(dboNewMainConnection, mainConnection)
+ NOTIFY_OBSERVERS2(dboMainConnectionStateChanged, connectionID, mMappedData.mMainConnectionMap[nextID].connectionState)
}
//finally, we update the delay value for the maintable
@@ -615,7 +669,7 @@ am_Error_e CAmDatabaseHandlerMap::enterSinkDB(const am_Sink_s & sinkData, am_sin
am_sinkID_t temp_SinkID = 0;
am_sinkID_t temp_SinkIndex = 0;
//if sinkID is zero and the first Static Sink was already entered, the ID is created
- am_Sink_s const *reservedDomain = objectMatchingPredicate<CAmSink, am_sinkID_t>(mMappedData.mSinkMap, [&](const CAmSink & obj){
+ am_Sink_s const *reservedDomain = objectMatchingPredicate<AmSink, am_sinkID_t>(mMappedData.mSinkMap, [&](const AmSink & obj){
return true==obj.reserved && obj.name.compare(sinkData.name)==0;
});
if( NULL!=reservedDomain )
@@ -654,11 +708,9 @@ am_Error_e CAmDatabaseHandlerMap::enterSinkDB(const am_Sink_s & sinkData, am_sin
am_Sink_s & sink = mMappedData.mSinkMap[temp_SinkID];
logVerbose("DatabaseHandler::enterSinkDB entered new sink with name", sink.name, "domainID:", sink.domainID, "classID:", sink.sinkClassID, "volume:", sink.volume, "assigned ID:", sink.sinkID);
- if (mpDatabaseObserver != NULL)
- {
- sink.sinkID=sinkID;
- mpDatabaseObserver->newSink(sink);
- }
+ sink.sinkID=sinkID;
+ NOTIFY_OBSERVERS1(dboNewSink, sink)
+
return (E_OK);
}
@@ -744,8 +796,8 @@ am_Error_e CAmDatabaseHandlerMap::enterCrossfaderDB(const am_Crossfader_s & cros
crossfaderID = temp_CrossfaderID;
logVerbose("DatabaseHandler::enterCrossfaderDB entered new crossfader with name=", crossfaderData.name, "sinkA= ", crossfaderData.sinkID_A, "sinkB=", crossfaderData.sinkID_B, "source=", crossfaderData.sourceID, "assigned ID:", crossfaderID);
- if (mpDatabaseObserver)
- mpDatabaseObserver->newCrossfader(mMappedData.mCrossfaderMap[temp_CrossfaderIndex]);
+ NOTIFY_OBSERVERS1(dboNewCrossfader, mMappedData.mCrossfaderMap[temp_CrossfaderIndex])
+
return (E_OK);
}
@@ -819,8 +871,8 @@ am_Error_e CAmDatabaseHandlerMap::enterGatewayDB(const am_Gateway_s & gatewayDat
gatewayID = temp_GatewayID;
logVerbose("DatabaseHandler::enterGatewayDB entered new gateway with name", gatewayData.name, "sourceID:", gatewayData.sourceID, "sinkID:", gatewayData.sinkID, "assigned ID:", gatewayID);
- if (mpDatabaseObserver)
- mpDatabaseObserver->newGateway(mMappedData.mGatewayMap[temp_GatewayIndex]);
+
+ NOTIFY_OBSERVERS1(dboNewGateway, mMappedData.mGatewayMap[temp_GatewayIndex])
return (E_OK);
}
@@ -905,24 +957,24 @@ am_Error_e CAmDatabaseHandlerMap::enterConverterDB(const am_Converter_s & conver
converterID = tempID;
logVerbose("DatabaseHandler::enterConverterDB entered new converter with name", converterData.name, "sourceID:", converterData.sourceID, "sinkID:", converterData.sinkID, "assigned ID:", converterID);
- if (mpDatabaseObserver)
- mpDatabaseObserver->newConverter(mMappedData.mConverterMap[tempIndex]);
+ NOTIFY_OBSERVERS1(dboNewConverter, mMappedData.mConverterMap[tempIndex])
+
return (E_OK);
}
void CAmDatabaseHandlerMap::dump( std::ostream & output ) const
{
output << std::endl << "****************** DUMP START ******************" << std::endl;
- CAmMappedData::printMap(mMappedData.mDomainMap, output);
- CAmMappedData::printMap(mMappedData.mSourceMap, output);
- CAmMappedData::printMap(mMappedData.mSinkMap, output);
- CAmMappedData::printMap(mMappedData.mSourceClassesMap, output);
- CAmMappedData::printMap(mMappedData.mSinkClassesMap, output);
- CAmMappedData::printMap(mMappedData.mConnectionMap, output);
- CAmMappedData::printMap(mMappedData.mMainConnectionMap, output);
- CAmMappedData::printMap(mMappedData.mCrossfaderMap, output);
- CAmMappedData::printMap(mMappedData.mGatewayMap, output);
- CAmVectorSystemProperties::const_iterator iter = mMappedData.mSystemProperties.begin();
+ AmMappedData::printMap(mMappedData.mDomainMap, output);
+ AmMappedData::printMap(mMappedData.mSourceMap, output);
+ AmMappedData::printMap(mMappedData.mSinkMap, output);
+ AmMappedData::printMap(mMappedData.mSourceClassesMap, output);
+ AmMappedData::printMap(mMappedData.mSinkClassesMap, output);
+ AmMappedData::printMap(mMappedData.mConnectionMap, output);
+ AmMappedData::printMap(mMappedData.mMainConnectionMap, output);
+ AmMappedData::printMap(mMappedData.mCrossfaderMap, output);
+ AmMappedData::printMap(mMappedData.mGatewayMap, output);
+ AmVectorSystemProperties::const_iterator iter = mMappedData.mSystemProperties.begin();
output << "System properties" << "\n";
for(; iter!=mMappedData.mSystemProperties.end(); iter++)
output << "[type:" << iter->type << " value:" << iter->value << "]";
@@ -981,7 +1033,7 @@ am_Error_e CAmDatabaseHandlerMap::enterSourceDB(const am_Source_s & sourceData,
bool isFirstStatic = sourceData.sourceID == 0 && mFirstStaticSource;
am_sourceID_t temp_SourceID = 0;
am_sourceID_t temp_SourceIndex = 0;
- CAmSource const *reservedSource = objectMatchingPredicate<CAmSource, am_sourceID_t>(mMappedData.mSourceMap, [&](const CAmSource & obj){
+ AmSource const *reservedSource = objectMatchingPredicate<AmSource, am_sourceID_t>(mMappedData.mSourceMap, [&](const AmSource & obj){
return true==obj.reserved && obj.name.compare(sourceData.name)==0;
});
if( NULL != reservedSource )
@@ -1020,8 +1072,8 @@ am_Error_e CAmDatabaseHandlerMap::enterSourceDB(const am_Source_s & sourceData,
logVerbose("DatabaseHandler::enterSourceDB entered new source with name", sourceData.name, "domainID:", sourceData.domainID, "classID:", sourceData.sourceClassID, "visible:", sourceData.visible, "assigned ID:", sourceID);
- if (mpDatabaseObserver)
- mpDatabaseObserver->newSource(mMappedData.mSourceMap[temp_SourceIndex]);
+ NOTIFY_OBSERVERS1(dboNewSource, mMappedData.mSourceMap[temp_SourceIndex])
+
return (E_OK);
}
@@ -1124,8 +1176,7 @@ am_Error_e CAmDatabaseHandlerMap::enterSinkClassDB(const am_SinkClass_s & sinkCl
//todo:change last_insert implementations for multithreaded usage...
logVerbose("DatabaseHandler::enterSinkClassDB entered new sinkClass");
- if (mpDatabaseObserver)
- mpDatabaseObserver->numberOfSinkClassesChanged();
+ NOTIFY_OBSERVERS(dboNumberOfSinkClassesChanged)
return (E_OK);
}
@@ -1192,8 +1243,8 @@ am_Error_e CAmDatabaseHandlerMap::enterSourceClassDB(am_sourceClass_t & sourceCl
logVerbose("DatabaseHandler::enterSourceClassDB entered new sourceClass");
- if (mpDatabaseObserver)
- mpDatabaseObserver->numberOfSourceClassesChanged();
+ NOTIFY_OBSERVERS(dboNumberOfSourceClassesChanged)
+
return (E_OK);
}
@@ -1260,8 +1311,7 @@ am_Error_e CAmDatabaseHandlerMap::changeMainConnectionStateDB(const am_mainConne
DB_COND_UPDATE_RIE(mMappedData.mMainConnectionMap[mainconnectionID].connectionState, connectionState);
logVerbose("DatabaseHandler::changeMainConnectionStateDB changed mainConnectionState of MainConnection:", mainconnectionID, "to:", connectionState);
- if (mpDatabaseObserver)
- mpDatabaseObserver->mainConnectionStateChanged(mainconnectionID, connectionState);
+ NOTIFY_OBSERVERS2(dboMainConnectionStateChanged, mainconnectionID, connectionState)
return (E_OK);
}
@@ -1277,8 +1327,7 @@ am_Error_e CAmDatabaseHandlerMap::changeSinkMainVolumeDB(const am_mainVolume_t m
logVerbose("DatabaseHandler::changeSinkMainVolumeDB changed mainVolume of sink:", sinkID, "to:", mainVolume);
- if (mpDatabaseObserver)
- mpDatabaseObserver->volumeChanged(sinkID, mainVolume);
+ NOTIFY_OBSERVERS2(dboVolumeChanged, sinkID, mainVolume)
return (E_OK);
}
@@ -1301,8 +1350,10 @@ am_Error_e CAmDatabaseHandlerMap::changeSinkAvailabilityDB(const am_Availability
logVerbose("DatabaseHandler::changeSinkAvailabilityDB changed sinkAvailability of sink:", sinkID, "to:", availability.availability, "Reason:", availability.availabilityReason);
- if (mpDatabaseObserver && sinkVisible(sinkID))
- mpDatabaseObserver->sinkAvailabilityChanged(sinkID, availability);
+ if (sinkVisible(sinkID))
+ {
+ NOTIFY_OBSERVERS2(dboSinkAvailabilityChanged,sinkID, availability)
+ }
return (E_OK);
}
@@ -1346,8 +1397,7 @@ am_Error_e CAmDatabaseHandlerMap::changeSinkMuteStateDB(const am_MuteState_e mut
logVerbose("DatabaseHandler::changeSinkMuteStateDB changed sinkMuteState of sink:", sinkID, "to:", muteState);
- if (mpDatabaseObserver)
- mpDatabaseObserver->sinkMuteStateChanged(sinkID, muteState);
+ NOTIFY_OBSERVERS2(dboSinkMuteStateChanged, sinkID, muteState)
return (E_OK);
}
@@ -1374,8 +1424,7 @@ am_Error_e CAmDatabaseHandlerMap::changeMainSinkSoundPropertyDB(const am_MainSou
}
logVerbose("DatabaseHandler::changeMainSinkSoundPropertyDB changed MainSinkSoundProperty of sink:", sinkID, "type:", soundProperty.type, "to:", soundProperty.value);
- if (mpDatabaseObserver)
- mpDatabaseObserver->mainSinkSoundPropertyChanged(sinkID, soundProperty);
+ NOTIFY_OBSERVERS2(dboMainSinkSoundPropertyChanged, sinkID, soundProperty)
return (E_OK);
}
@@ -1402,8 +1451,7 @@ am_Error_e CAmDatabaseHandlerMap::changeMainSourceSoundPropertyDB(const am_MainS
logVerbose("DatabaseHandler::changeMainSourceSoundPropertyDB changed MainSinkSoundProperty of source:", sourceID, "type:", soundProperty.type, "to:", soundProperty.value);
- if (mpDatabaseObserver)
- mpDatabaseObserver->mainSourceSoundPropertyChanged(sourceID, soundProperty);
+ NOTIFY_OBSERVERS2(dboMainSourceSoundPropertyChanged, sourceID, soundProperty)
return (E_OK);
}
@@ -1425,8 +1473,10 @@ am_Error_e CAmDatabaseHandlerMap::changeSourceAvailabilityDB(const am_Availabili
logVerbose("DatabaseHandler::changeSourceAvailabilityDB changed changeSourceAvailabilityDB of source:", sourceID, "to:", availability.availability, "Reason:", availability.availabilityReason);
- if (mpDatabaseObserver && sourceVisible(sourceID))
- mpDatabaseObserver->sourceAvailabilityChanged(sourceID, availability);
+ if (sourceVisible(sourceID))
+ {
+ NOTIFY_OBSERVERS2(dboSourceAvailabilityChanged, sourceID, availability)
+ }
return (E_OK);
}
@@ -1441,8 +1491,7 @@ am_Error_e CAmDatabaseHandlerMap::changeSystemPropertyDB(const am_SystemProperty
logVerbose("DatabaseHandler::changeSystemPropertyDB changed system property");
- if (mpDatabaseObserver)
- mpDatabaseObserver->systemPropertyChanged(property);
+ NOTIFY_OBSERVERS1(dboSystemPropertyChanged, property)
return (E_OK);
}
@@ -1459,11 +1508,10 @@ am_Error_e CAmDatabaseHandlerMap::removeMainConnectionDB(const am_mainConnection
mMappedData.mMainConnectionMap.erase(mainConnectionID);
logVerbose("DatabaseHandler::removeMainConnectionDB removed:", mainConnectionID);
- if (mpDatabaseObserver)
- {
- mpDatabaseObserver->mainConnectionStateChanged(mainConnectionID, CS_DISCONNECTED);
- mpDatabaseObserver->removedMainConnection(mainConnectionID);
- }
+
+ NOTIFY_OBSERVERS2(dboMainConnectionStateChanged, mainConnectionID, CS_DISCONNECTED)
+ NOTIFY_OBSERVERS1(dboRemovedMainConnection, mainConnectionID)
+
return (E_OK);
}
@@ -1483,8 +1531,7 @@ am_Error_e CAmDatabaseHandlerMap::removeSinkDB(const am_sinkID_t sinkID)
//if visible is true then delete SinkMainSoundProperty and SinkMainNotificationConfiguration ????
logVerbose("DatabaseHandler::removeSinkDB removed:", sinkID);
- if (mpDatabaseObserver != NULL)
- mpDatabaseObserver->removedSink(sinkID, visible);
+ NOTIFY_OBSERVERS2(dboRemovedSink, sinkID, visible)
return (E_OK);
}
@@ -1506,8 +1553,7 @@ am_Error_e CAmDatabaseHandlerMap::removeSourceDB(const am_sourceID_t sourceID)
//if visible is true then delete SourceMainSoundProperty and SourceMainNotificationConfiguration ????
logVerbose("DatabaseHandler::removeSourceDB removed:", sourceID);
- if (mpDatabaseObserver)
- mpDatabaseObserver->removedSource(sourceID, visible);
+ NOTIFY_OBSERVERS2(dboRemovedSource, sourceID, visible)
return (E_OK);
}
@@ -1523,8 +1569,7 @@ am_Error_e CAmDatabaseHandlerMap::removeGatewayDB(const am_gatewayID_t gatewayID
mMappedData.mGatewayMap.erase(gatewayID);
logVerbose("DatabaseHandler::removeGatewayDB removed:", gatewayID);
- if (mpDatabaseObserver)
- mpDatabaseObserver->removeGateway(gatewayID);
+ NOTIFY_OBSERVERS1(dboRemoveGateway, gatewayID)
return (E_OK);
}
@@ -1540,8 +1585,7 @@ am_Error_e CAmDatabaseHandlerMap::removeConverterDB(const am_converterID_t conve
mMappedData.mConverterMap.erase(converterID);
logVerbose("DatabaseHandler::removeConverterDB removed:", converterID);
- if (mpDatabaseObserver)
- mpDatabaseObserver->removeConverter(converterID);
+ NOTIFY_OBSERVERS1(dboRemoveConverter, converterID)
return (E_OK);
}
@@ -1556,8 +1600,8 @@ am_Error_e CAmDatabaseHandlerMap::removeCrossfaderDB(const am_crossfaderID_t cro
mMappedData.mCrossfaderMap.erase(crossfaderID);
logVerbose("DatabaseHandler::removeCrossfaderDB removed:", crossfaderID);
- if (mpDatabaseObserver)
- mpDatabaseObserver->removeCrossfader(crossfaderID);
+ NOTIFY_OBSERVERS1(dboRemoveCrossfader, crossfaderID)
+
return (E_OK);
}
@@ -1572,8 +1616,8 @@ am_Error_e CAmDatabaseHandlerMap::removeDomainDB(const am_domainID_t domainID)
mMappedData.mDomainMap.erase(domainID);
logVerbose("DatabaseHandler::removeDomainDB removed:", domainID);
- if (mpDatabaseObserver)
- mpDatabaseObserver->removeDomain(domainID);
+ NOTIFY_OBSERVERS1(dboRemoveDomain, domainID)
+
return (E_OK);
}
@@ -1589,9 +1633,7 @@ am_Error_e CAmDatabaseHandlerMap::removeSinkClassDB(const am_sinkClass_t sinkCla
mMappedData.mSinkClassesMap.erase(sinkClassID);
logVerbose("DatabaseHandler::removeSinkClassDB removed:", sinkClassID);
- if (mpDatabaseObserver)
- mpDatabaseObserver->numberOfSinkClassesChanged();
-
+ NOTIFY_OBSERVERS(dboNumberOfSinkClassesChanged)
return (E_OK);
}
@@ -1606,8 +1648,7 @@ am_Error_e CAmDatabaseHandlerMap::removeSourceClassDB(const am_sourceClass_t sou
mMappedData.mSourceClassesMap.erase(sourceClassID);
logVerbose("DatabaseHandler::removeSourceClassDB removed:", sourceClassID);
- if (mpDatabaseObserver)
- mpDatabaseObserver->numberOfSourceClassesChanged();
+ NOTIFY_OBSERVERS(dboNumberOfSourceClassesChanged)
return (E_OK);
}
@@ -1825,7 +1866,7 @@ am_Error_e CAmDatabaseHandlerMap::getListSourcesOfDomain(const am_domainID_t dom
logWarning(__METHOD_NAME__,"domainID must exist");
return (E_NON_EXISTENT);
}
- CAmMapSource::const_iterator elementIterator = mMappedData.mSourceMap.begin();
+ AmMapSource::const_iterator elementIterator = mMappedData.mSourceMap.begin();
for (;elementIterator != mMappedData.mSourceMap.end(); ++elementIterator)
{
if (0==elementIterator->second.reserved && domainID==elementIterator->second.domainID)
@@ -1844,12 +1885,12 @@ am_Error_e CAmDatabaseHandlerMap::getListCrossfadersOfDomain(const am_domainID_t
return (E_NON_EXISTENT);
}
- CAmMapSource::const_iterator sourceIterator = mMappedData.mSourceMap.begin();
+ AmMapSource::const_iterator sourceIterator = mMappedData.mSourceMap.begin();
for (;sourceIterator != mMappedData.mSourceMap.end(); ++sourceIterator)
{
if (domainID==sourceIterator->second.domainID)
{
- CAmMapCrossfader::const_iterator elementIterator = mMappedData.mCrossfaderMap.begin();
+ AmMapCrossfader::const_iterator elementIterator = mMappedData.mCrossfaderMap.begin();
for (;elementIterator != mMappedData.mCrossfaderMap.end(); ++elementIterator)
{
if ( sourceIterator->second.sourceID==elementIterator->second.sourceID )
@@ -1871,7 +1912,7 @@ am_Error_e CAmDatabaseHandlerMap::getListGatewaysOfDomain(const am_domainID_t do
return (E_NON_EXISTENT);
}
- CAmMapGateway::const_iterator elementIterator = mMappedData.mGatewayMap.begin();
+ AmMapGateway::const_iterator elementIterator = mMappedData.mGatewayMap.begin();
for (;elementIterator != mMappedData.mGatewayMap.end(); ++elementIterator)
{
if (domainID==elementIterator->second.controlDomainID)
@@ -1889,7 +1930,7 @@ am_Error_e CAmDatabaseHandlerMap::getListConvertersOfDomain(const am_domainID_t
return (E_NON_EXISTENT);
}
- CAmMapConverter::const_iterator elementIterator = mMappedData.mConverterMap.begin();
+ AmMapConverter::const_iterator elementIterator = mMappedData.mConverterMap.begin();
for (;elementIterator != mMappedData.mConverterMap.end(); ++elementIterator)
{
if (domainID==elementIterator->second.domainID)
@@ -1902,7 +1943,7 @@ am_Error_e CAmDatabaseHandlerMap::getListMainConnections(std::vector<am_MainConn
{
listMainConnections.clear();
- CAmMapMainConnection::const_iterator elementIterator = mMappedData.mMainConnectionMap.begin();
+ AmMapMainConnection::const_iterator elementIterator = mMappedData.mMainConnectionMap.begin();
for (;elementIterator != mMappedData.mMainConnectionMap.end(); ++elementIterator)
{
listMainConnections.push_back(elementIterator->second);
@@ -1915,7 +1956,7 @@ am_Error_e CAmDatabaseHandlerMap::getListDomains(std::vector<am_Domain_s> & list
{
listDomains.clear();
- CAmMapDomain::const_iterator elementIterator = mMappedData.mDomainMap.begin();
+ AmMapDomain::const_iterator elementIterator = mMappedData.mDomainMap.begin();
for (;elementIterator != mMappedData.mDomainMap.end(); ++elementIterator)
{
if( 0==elementIterator->second.reserved )
@@ -1929,7 +1970,7 @@ am_Error_e CAmDatabaseHandlerMap::getListConnections(std::vector<am_Connection_s
{
listConnections.clear();
- CAmMapConnection::const_iterator elementIterator = mMappedData.mConnectionMap.begin();
+ AmMapConnection::const_iterator elementIterator = mMappedData.mConnectionMap.begin();
for (;elementIterator != mMappedData.mConnectionMap.end(); ++elementIterator)
{
if( 0==elementIterator->second.reserved )
@@ -1943,7 +1984,7 @@ am_Error_e CAmDatabaseHandlerMap::getListConnectionsReserved(std::vector<am_Conn
{
listConnections.clear();
- CAmMapConnection::const_iterator elementIterator = mMappedData.mConnectionMap.begin();
+ AmMapConnection::const_iterator elementIterator = mMappedData.mConnectionMap.begin();
for (;elementIterator != mMappedData.mConnectionMap.end(); ++elementIterator)
{
if( elementIterator->second.reserved )
@@ -2205,8 +2246,7 @@ am_Error_e CAmDatabaseHandlerMap::changeDelayMainConnection(const am_timeSync_t
return E_NON_EXISTENT;
}
DB_COND_UPDATE_RIE(mMappedData.mMainConnectionMap[connectionID].delay, delay);
- if (mpDatabaseObserver)
- mpDatabaseObserver->timingInformationChanged(connectionID, delay);
+ NOTIFY_OBSERVERS2(dboTimingInformationChanged, connectionID, delay)
return (E_OK);
}
@@ -2263,7 +2303,7 @@ bool CAmDatabaseHandlerMap::existSourceName(const std::string & name) const
bool CAmDatabaseHandlerMap::existSink(const am_sinkID_t sinkID) const
{
bool returnVal = false;
- CAmMapSink::const_iterator elementIterator = mMappedData.mSinkMap.begin();
+ AmMapSink::const_iterator elementIterator = mMappedData.mSinkMap.begin();
for (;elementIterator != mMappedData.mSinkMap.end(); ++elementIterator)
{
if( 0==elementIterator->second.reserved &&
@@ -2429,7 +2469,7 @@ am_Error_e CAmDatabaseHandlerMap::changeConnectionTimingInformation(const am_con
//first get all route tables for all mainconnections
am_Error_e error = E_OK;
- CAmMapMainConnection::const_iterator iter = mMappedData.mMainConnectionMap.begin();
+ AmMapMainConnection::const_iterator iter = mMappedData.mMainConnectionMap.begin();
for(; iter != mMappedData.mMainConnectionMap.end(); ++iter)
{
const am_MainConnection_s & mainConnection = iter->second;
@@ -2477,11 +2517,6 @@ am_timeSync_t CAmDatabaseHandlerMap::calculateMainConnectionDelay(const am_mainC
* registers the Observer at the Database
* @param iObserver pointer to the observer
*/
-void CAmDatabaseHandlerMap::registerObserver(CAmDatabaseObserver *iObserver)
-{
- assert(iObserver!=NULL);
- mpDatabaseObserver = iObserver;
-}
/**
* gives information about the visibility of a source
@@ -3038,10 +3073,8 @@ am_Error_e CAmDatabaseHandlerMap::changeSourceDB(const am_sourceID_t sourceID, c
{
logVerbose("DatabaseHandler::changeSource changed changeSource of source:", sourceID);
- if (mpDatabaseObserver != NULL)
- {
- mpDatabaseObserver->sourceUpdated(sourceID,sourceClassOut,listMainSoundPropertiesOut,sourceVisible(sourceID));
- }
+ NOTIFY_OBSERVERS4(dboSourceUpdated, sourceID,sourceClassOut,listMainSoundPropertiesOut,sourceVisible(sourceID))
+
}
return (E_OK);
@@ -3109,10 +3142,7 @@ am_Error_e CAmDatabaseHandlerMap::changeSinkDB(const am_sinkID_t sinkID, const a
{
logVerbose("DatabaseHandler::changeSink changed changeSink of sink:", sinkID);
- if (mpDatabaseObserver != NULL)
- {
- mpDatabaseObserver->sinkUpdated(sinkID,sinkClassOut,listMainSoundPropertiesOut,sinkVisible(sinkID));
- }
+ NOTIFY_OBSERVERS4(dboSinkUpdated, sinkID,sinkClassOut,listMainSoundPropertiesOut,sinkVisible(sinkID))
}
return (E_OK);
@@ -3179,8 +3209,8 @@ am_Error_e CAmDatabaseHandlerMap::changeMainSinkNotificationConfigurationDB(cons
logVerbose("DatabaseHandler::changeMainSinkNotificationConfigurationDB changed MainNotificationConfiguration of source:", sinkID, "type:", mainNotificationConfiguration.type, "to status=", mainNotificationConfiguration.status, "and parameter=",mainNotificationConfiguration.parameter);
- if (mpDatabaseObserver)
- mpDatabaseObserver->sinkMainNotificationConfigurationChanged(sinkID, mainNotificationConfiguration);
+ NOTIFY_OBSERVERS2(dboSinkMainNotificationConfigurationChanged, sinkID, mainNotificationConfiguration)
+
return (E_OK);
}
@@ -3198,8 +3228,8 @@ am_Error_e CAmDatabaseHandlerMap::changeMainSourceNotificationConfigurationDB(co
logVerbose("DatabaseHandler::changeMainSourceNotificationConfigurationDB changed MainNotificationConfiguration of source:", sourceID, "type:", mainNotificationConfiguration.type, "to status=", mainNotificationConfiguration.status, "and parameter=",mainNotificationConfiguration.parameter);
- if (mpDatabaseObserver)
- mpDatabaseObserver->sourceMainNotificationConfigurationChanged(sourceID, mainNotificationConfiguration);
+ NOTIFY_OBSERVERS2(dboSourceMainNotificationConfigurationChanged, sourceID, mainNotificationConfiguration)
+
return (E_OK);
}
@@ -3358,4 +3388,31 @@ am_Error_e CAmDatabaseHandlerMap::enumerateConverters(std::function<void(const a
return E_OK;
}
+bool CAmDatabaseHandlerMap::registerObserver(IAmDatabaseObserver * iObserver) {
+ assert(iObserver!=NULL);
+ if (std::find(mDatabaseObservers.begin(), mDatabaseObservers.end(),
+ iObserver) == mDatabaseObservers.end()) {
+ mDatabaseObservers.push_back(
+ dynamic_cast<AmDatabaseObserverCallbacks*>(iObserver)), dynamic_cast<AmDatabaseObserverCallbacks*>(iObserver)->mpDatabaseHandler =
+ nullptr;
+ return true;
+ }
+ return false;
+}
+bool CAmDatabaseHandlerMap::unregisterObserver(IAmDatabaseObserver * iObserver) {
+ assert(iObserver!=NULL);
+ auto it = std::find(mDatabaseObservers.begin(), mDatabaseObservers.end(),
+ iObserver);
+ if (it != mDatabaseObservers.end()) {
+ mDatabaseObservers.erase(it), dynamic_cast<AmDatabaseObserverCallbacks*>(iObserver)->mpDatabaseHandler =
+ nullptr;
+ return true;
+ }
+ return false;
+}
+
+unsigned CAmDatabaseHandlerMap::countObservers() {
+ return mDatabaseObservers.size();
+}
+
}
diff --git a/AudioManagerCore/src/CAmDatabaseObserver.cpp b/AudioManagerCore/src/CAmDatabaseObserver.cpp
deleted file mode 100644
index d9ced92..0000000
--- a/AudioManagerCore/src/CAmDatabaseObserver.cpp
+++ /dev/null
@@ -1,241 +0,0 @@
-/**
- * SPDX license identifier: MPL-2.0
- *
- * Copyright (C) 2012, BMW AG
- *
- * This file is part of GENIVI Project AudioManager.
- *
- * Contributions are licensed to the GENIVI Alliance under one or more
- * Contribution License Agreements.
- *
- * \copyright
- * This Source Code Form is subject to the terms of the
- * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
- * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- *
- * \author Christian Linke, christian.linke@bmw.de BMW 2011,2012
- *
- * \file CAmDatabaseObserver.cpp
- * For further information see http://www.genivi.org/.
- *
- */
-
-#include "CAmDatabaseObserver.h"
-#include <string.h>
-#include <cassert>
-#include <errno.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include "CAmCommandSender.h"
-#include "CAmRoutingSender.h"
-#include "CAmDltWrapper.h"
-#include "CAmSerializer.h"
-
-namespace am {
-
-CAmDatabaseObserver::CAmDatabaseObserver(CAmCommandSender *iCommandSender, CAmRoutingSender *iRoutingSender, CAmSocketHandler *iSocketHandler) :
- mCommandSender(iCommandSender), //
- mRoutingSender(iRoutingSender), //
- mTelnetServer(NULL), //
- mSerializer(iSocketHandler) //
-{
- assert(mCommandSender!=0);
- assert(mRoutingSender!=0);
- assert(iSocketHandler!=0);
-}
-
-CAmDatabaseObserver::CAmDatabaseObserver(CAmCommandSender *iCommandSender, CAmRoutingSender *iRoutingSender, CAmSocketHandler *iSocketHandler, CAmTelnetServer *iTelnetServer) :
- mCommandSender(iCommandSender), //
- mRoutingSender(iRoutingSender), //
- mTelnetServer(iTelnetServer), //
- mSerializer(iSocketHandler) //
-{
- assert(mTelnetServer!=0);
- assert(mCommandSender!=0);
- assert(mRoutingSender!=0);
- assert(iSocketHandler!=0);
-}
-
-CAmDatabaseObserver::~CAmDatabaseObserver()
-{
-}
-
-void CAmDatabaseObserver::newMainConnection(const am_MainConnectionType_s& mainConnection)
-{
- mSerializer.asyncCall<CAmCommandSender, const am_MainConnectionType_s>(mCommandSender, &CAmCommandSender::cbNewMainConnection, mainConnection);
-}
-
-void CAmDatabaseObserver::removedMainConnection(const am_mainConnectionID_t mainConnection)
-{
- mSerializer.asyncCall<CAmCommandSender, const am_mainConnectionID_t>(mCommandSender, &CAmCommandSender::cbRemovedMainConnection, mainConnection);
-}
-
-void CAmDatabaseObserver::newSink(const am_Sink_s& sink)
-{
- mRoutingSender->addSinkLookup(sink);
- if (sink.visible)
- {
- am_SinkType_s s;
- s.availability = sink.available;
- s.muteState = sink.muteState;
- s.name = sink.name;
- s.sinkClassID = sink.sinkClassID;
- s.sinkID = sink.sinkID;
- s.volume = sink.mainVolume;
- mSerializer.asyncCall<CAmCommandSender, const am_SinkType_s>(mCommandSender, &CAmCommandSender::cbNewSink, s);
- }
-}
-
-void CAmDatabaseObserver::newSource(const am_Source_s& source)
-{
- mRoutingSender->addSourceLookup(source);
- if (source.visible)
- {
- am_SourceType_s s;
- s.availability = source.available;
- s.name = source.name;
- s.sourceClassID = source.sourceClassID;
- s.sourceID = source.sourceID;
- mSerializer.asyncCall<CAmCommandSender, const am_SourceType_s>(mCommandSender, &CAmCommandSender::cbNewSource, s);
- }
-}
-
-void CAmDatabaseObserver::newDomain(const am_Domain_s& domain)
-{
- mRoutingSender->addDomainLookup(domain);
-}
-
-void CAmDatabaseObserver::newGateway(const am_Gateway_s& gateway)
-{
- (void) gateway;
- //todo: implement something
-}
-
-void CAmDatabaseObserver::newConverter(const am_Converter_s& coverter)
-{
- (void) coverter;
- //todo: implement something
-}
-
-void CAmDatabaseObserver::newCrossfader(const am_Crossfader_s& crossfader)
-{
- mRoutingSender->addCrossfaderLookup(crossfader);
-}
-
-void CAmDatabaseObserver::removedSink(const am_sinkID_t sinkID, const bool visible)
-{
- mRoutingSender->removeSinkLookup(sinkID);
-
- if (visible)
- mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t>(mCommandSender, &CAmCommandSender::cbRemovedSink, sinkID);
-}
-
-void CAmDatabaseObserver::removedSource(const am_sourceID_t sourceID, const bool visible)
-{
- mRoutingSender->removeSourceLookup(sourceID);
-
- if (visible)
- mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t>(mCommandSender, &CAmCommandSender::cbRemovedSource, sourceID);
-}
-
-void CAmDatabaseObserver::removeDomain(const am_domainID_t domainID)
-{
- mRoutingSender->removeDomainLookup(domainID);
-}
-
-void CAmDatabaseObserver::removeGateway(const am_gatewayID_t gatewayID)
-{
- (void) gatewayID;
- //todo: implement something?
-}
-
-void CAmDatabaseObserver::removeConverter(const am_converterID_t converterID)
-{
- (void) converterID;
- //todo: implement something?
-}
-
-void CAmDatabaseObserver::removeCrossfader(const am_crossfaderID_t crossfaderID)
-{
- mRoutingSender->removeCrossfaderLookup(crossfaderID);
-}
-
-void CAmDatabaseObserver::numberOfSinkClassesChanged()
-{
- mSerializer.asyncCall<CAmCommandSender>(mCommandSender, &CAmCommandSender::cbNumberOfSinkClassesChanged);
-}
-
-void CAmDatabaseObserver::numberOfSourceClassesChanged()
-{
- mSerializer.asyncCall<CAmCommandSender>(mCommandSender, &CAmCommandSender::cbNumberOfSourceClassesChanged);
-}
-
-void CAmDatabaseObserver::mainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState)
-{
- mSerializer.asyncCall<CAmCommandSender, const am_connectionID_t, const am_ConnectionState_e>(mCommandSender, &CAmCommandSender::cbMainConnectionStateChanged, connectionID, connectionState);
-}
-
-void CAmDatabaseObserver::mainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s& SoundProperty)
-{
- mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_MainSoundProperty_s>(mCommandSender, &CAmCommandSender::cbMainSinkSoundPropertyChanged, sinkID, SoundProperty);
-}
-
-void CAmDatabaseObserver::mainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s & SoundProperty)
-{
- mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t, const am_MainSoundProperty_s>(mCommandSender, &CAmCommandSender::cbMainSourceSoundPropertyChanged, sourceID, SoundProperty);
-}
-
-void CAmDatabaseObserver::sinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s & availability)
-{
- mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_Availability_s>(mCommandSender, &CAmCommandSender::cbSinkAvailabilityChanged, sinkID, availability);
-}
-
-void CAmDatabaseObserver::sourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s & availability)
-{
- mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t, const am_Availability_s>(mCommandSender, &CAmCommandSender::cbSourceAvailabilityChanged, sourceID, availability);
-}
-
-void CAmDatabaseObserver::volumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume)
-{
- mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_mainVolume_t>(mCommandSender, &CAmCommandSender::cbVolumeChanged, sinkID, volume);
-}
-
-void CAmDatabaseObserver::sinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState)
-{
- mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_MuteState_e>(mCommandSender, &CAmCommandSender::cbSinkMuteStateChanged, sinkID, muteState);
-}
-
-void CAmDatabaseObserver::systemPropertyChanged(const am_SystemProperty_s& SystemProperty)
-{
- mSerializer.asyncCall<CAmCommandSender, const am_SystemProperty_s>(mCommandSender, &CAmCommandSender::cbSystemPropertyChanged, SystemProperty);
-}
-
-void CAmDatabaseObserver::timingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time)
-{
- mSerializer.asyncCall<CAmCommandSender, const am_mainConnectionID_t, const am_timeSync_t>(mCommandSender, &CAmCommandSender::cbTimingInformationChanged, mainConnection, time);
-}
-
-void CAmDatabaseObserver::sinkUpdated(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties, const bool visible)
-{
- if (visible)
- mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_sinkClass_t, const std::vector<am_MainSoundProperty_s> >(mCommandSender, &CAmCommandSender::cbSinkUpdated, sinkID, sinkClassID, listMainSoundProperties);
-}
-
-void CAmDatabaseObserver::sourceUpdated(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties, const bool visible)
-{
- if (visible)
- mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t, const am_sourceClass_t, const std::vector<am_MainSoundProperty_s> >(mCommandSender, &CAmCommandSender::cbSinkUpdated, sourceID, sourceClassID, listMainSoundProperties);
-}
-
-void CAmDatabaseObserver::sinkMainNotificationConfigurationChanged(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration)
-{
- mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_NotificationConfiguration_s> (mCommandSender, &CAmCommandSender::cbSinkMainNotificationConfigurationChanged, sinkID, mainNotificationConfiguration);
-}
-
-void CAmDatabaseObserver::sourceMainNotificationConfigurationChanged(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration)
-{
- mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t, const am_NotificationConfiguration_s>(mCommandSender, &CAmCommandSender::cbSourceMainNotificationConfigurationChanged, sourceID, mainNotificationConfiguration);
-}
-
-}
diff --git a/AudioManagerCore/src/CAmRouter.cpp b/AudioManagerCore/src/CAmRouter.cpp
index f98bf11..6f1fe61 100644
--- a/AudioManagerCore/src/CAmRouter.cpp
+++ b/AudioManagerCore/src/CAmRouter.cpp
@@ -31,854 +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)
+ {
+ 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);
+ }
-namespace am {
+ 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);
+ 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;
+ };
+ }
-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()
+ {
+ }
+ /**
+ * 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);
+ }
-CAmRouter::CAmRouter(IAmDatabaseHandler* iDatabaseHandler, CAmControlSender* iSender) :
- mpDatabaseHandler(iDatabaseHandler), //
- mpControlSender(iSender),
- mOnlyFreeConversionNodes(false),
- mRoutingGraph(),
- mNodeListSources(),
- mNodeListSinks(),
- mNodeListGateways(),
- mNodeListConverters()
-{
- assert(mpDatabaseHandler);
- assert(mpControlSender);
-}
+ 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);
+ }
-CAmRouter::~CAmRouter()
-{
-}
+ 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();
-/**
- * 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)
-{
- returnList.clear();
- am_Source_s source;
- am_Sink_s sink;
- am_Error_e error = mpDatabaseHandler->getSourceInfoDB(sourceID, source);
- if(error!=E_OK)
- return error;
- error = mpDatabaseHandler->getSinkInfoDB(sinkID, sink);
- if(error!=E_OK)
- return error;
- error = getRoute(onlyfree, source, sink, returnList);
- return error;
-}
+ CAmRoutingNode* pRootSource = sourceNodeWithID(sourceID);
+ CAmRoutingNode* pRootSink = sinkNodeWithID(sinkID);
+ if (!pRootSource || !pRootSink)
+ return E_NON_EXISTENT;
-am_Error_e CAmRouter::getRoute(const bool onlyfree, const am_Source_s & aSource, const am_Sink_s & aSink, std::vector<am_Route_s> & listRoutes)
-{
- am_Error_e error;
- load(onlyfree);
+ //try to find paths without cycles
+ am_Error_e error = getFirstNShortestPaths(onlyfree, 0, mMaxPathCount, *pRootSource, *pRootSink, returnList);
- CAmRoutingNode* pRootSource = sourceNodeWithID(aSource.sourceID);
- CAmRoutingNode* pRootSink = sinkNodeWithID(aSink.sinkID);
+ //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);
+ }
- assert(pRootSource);
- assert(pRootSink);
+ /* For shortest path use the following call:
+ *
+ * error = getShortestPath(*pRootSource, *pRootSink, listRoutes);
+ */
+ return error;
+ }
-#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 << "-->";
- std::for_each(list.begin(), list.end(), [&](const CAmVertex<am_RoutingNodeData_s,uint16_t>* refVertex){
- am::CAmNode<am::am_RoutingNodeData_s>* data = refVertex->getNode();
- std::cout << "Node " << data->getIndex() << " :";
- data->getData().trace();
- });
- std::cout << std::endl;
- });
-#endif
+ am_Error_e CAmRouter::getRouteFromLoadedNodes(const bool onlyfree, const am_Source_s & aSource, const am_Sink_s & aSink,
+ std::vector<am_Route_s> & listRoutes)
+ {
+ return getRouteFromLoadedNodes(onlyfree, aSource.sourceID, aSink.sinkID, listRoutes);
+ }
- std::vector<std::vector<CAmRoutingNode*>> pathNodes;
- error = getAllPaths(*pRootSource, *pRootSink, listRoutes, pathNodes);
- return error;
-}
+ void CAmRouter::load()
+ {
+ clear();
-void CAmRouter::load(const bool onlyFree)
-{
- clear();
- mOnlyFreeConversionNodes = onlyFree;
-
-#if defined (WITH_DATABASE_STORAGE)
- std::deque<am_Source_s> listSources;
- std::deque<am_Sink_s> listSinks;
- std::deque<am_Gateway_s> listGateways;
- std::deque<am_Converter_s> listConverters;
-#endif
- am_RoutingNodeData_s nodeDataSrc;
- nodeDataSrc.type = CAmNodeDataType::SOURCE;
- mpDatabaseHandler->enumerateSources([&](const am_Source_s & obj){
-#if defined (WITH_DATABASE_STORAGE)
- listSources.push_back(obj);
- nodeDataSrc.data.source = &listSources.back();
-#else
- nodeDataSrc.data.source = (am_Source_s*)&obj;
-#endif
- mNodeListSources[nodeDataSrc.data.source->domainID].push_back(&mRoutingGraph.addNode(nodeDataSrc));
- });
- am_RoutingNodeData_s nodeDataSink;
- nodeDataSink.type = CAmNodeDataType::SINK;
- mpDatabaseHandler->enumerateSinks([&](const am_Sink_s & obj){
-#if defined (WITH_DATABASE_STORAGE)
- listSinks.push_back(obj);
- nodeDataSrc.data.sink = &listSinks.back();
-#else
- nodeDataSink.data.sink = (am_Sink_s*)&obj;
-#endif
- mNodeListSinks[nodeDataSink.data.sink->domainID].push_back(&mRoutingGraph.addNode(nodeDataSink));
- });
- am_RoutingNodeData_s nodeDataGateway;
- nodeDataGateway.type = CAmNodeDataType::GATEWAY;
- mpDatabaseHandler->enumerateGateways([&](const am_Gateway_s & obj){
-#if defined (WITH_DATABASE_STORAGE)
- listGateways.push_back(obj);
- nodeDataSrc.data.gateway = &listGateways.back();
-#else
- nodeDataGateway.data.gateway = (am_Gateway_s*)&obj;
-#endif
- mNodeListGateways[nodeDataGateway.data.gateway->controlDomainID].push_back(&mRoutingGraph.addNode(nodeDataGateway));
- });
- am_RoutingNodeData_s nodeDataConverter;
- nodeDataConverter.type = CAmNodeDataType::CONVERTER;
- mpDatabaseHandler->enumerateConverters([&](const am_Converter_s & obj){
-#if defined (WITH_DATABASE_STORAGE)
- listConverters.push_back(obj);
- nodeDataSrc.data.converter = &listConverters.back();
-#else
- nodeDataConverter.data.converter = (am_Converter_s*)&obj;
-#endif
- mNodeListConverters[nodeDataConverter.data.converter->domainID].push_back(&mRoutingGraph.addNode(nodeDataConverter));
- });
+ 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();
-#ifdef ROUTING_BUILD_CONNECTIONS
- 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;
+ });
#endif
-}
-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;
-}
+ void CAmRouter::clear()
+ {
+ mRoutingGraph.clear();
+ mNodeListSources.clear();
+ mNodeListSinks.clear();
+ mNodeListGateways.clear();
+ mNodeListConverters.clear();
+ }
-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)
+ {
+ 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::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::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, 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)
+ {
+ 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::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::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::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::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;
+ }
-#ifdef ROUTING_BUILD_CONNECTIONS
+ 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);
- }
- }
- }
- }
- }
- }
-}
-#else
+ 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);
- }
-}
+ }
-#endif
+ 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::determineConnectionFormatsForPath(am_Route_s & routeObjects, std::vector<CAmRoutingNode*> & nodes)
-{
- 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);
- 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::doConnectionFormatsForPath(am_Route_s & routeObjects,
- std::vector<CAmRoutingNode*> & nodes,
- std::vector<am_RoutingElement_s>::iterator routingElementIterator,
- std::vector<CAmRoutingNode*>::iterator nodeIterator)
-{
- 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;
- getSourceSinkPossibleConnectionFormats(currentNodeIterator+1, currentNodeIterator+2, listConnectionFormats);
-
- 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);
- }
- currentNodeIterator+=3;
- }
- else
- {
- CAmRoutingNode * currentNode = *currentNodeIterator;
- assert(currentNode->getData().type==CAmNodeDataType::SOURCE);
-
- currentNodeIterator++;
- assert(currentNodeIterator!=nodes.end());
-
- CAmRoutingNode * nodeSink = *currentNodeIterator;
- assert(nodeSink->getData().type==CAmNodeDataType::SINK);
-
- 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;
- mpControlSender->getConnectionFormatChoice(currentRoutingElementIterator->sourceID, currentRoutingElementIterator->sinkID, routeObjects,
- listMergeConnectionFormats, listPriorityConnectionFormats);
-
- //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())
- {
- if (!listPriorityConnectionFormats.empty())
- {
- currentRoutingElementIterator->connectionFormat = listPriorityConnectionFormats.front();
- return (E_OK);
- }
- else
- return (E_NOT_POSSIBLE);
- }
-
- for (; connectionFormatIterator != listPriorityConnectionFormats.end(); ++connectionFormatIterator)
- {
- currentRoutingElementIterator->connectionFormat = *connectionFormatIterator;
- if ((returnError = doConnectionFormatsForPath(routeObjects, nodes, nextIterator, currentNodeIterator)) == E_OK)
- {
- break;
- }
- }
- return (returnError);
-}
+ 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);
+ }
+ }
-#ifdef ROUTING_BUILD_CONNECTIONS
+ 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::getShortestPath(const CAmRoutingNode & source,
- const CAmRoutingNode & destination,
- std::vector<CAmRoutingNode*> & resultPath)
-{
- mRoutingGraph.getShortestPath(source, destination, resultPath);
-}
+ 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;
-void CAmRouter::getShortestPath(CAmRoutingNode & aSource, CAmRoutingNode & aSink,
- am_Route_s & resultPath, std::vector<CAmRoutingNode*> & resultNodesPath)
-{
- am_RoutingElement_s * element;
- am_RoutingNodeData_s & sinkNodeData = aSink.getData();
- am_RoutingNodeData_s & sourceNodeData = aSource.getData();
- resultPath.sinkID = sinkNodeData.data.sink->sinkID;
- resultPath.sourceID = sourceNodeData.data.source->sourceID;
-
- std::function<void(const am_GraphPathPosition_e, CAmRoutingNode &)> cb = [&](const am_GraphPathPosition_e, CAmRoutingNode & object)
- {
- resultNodesPath.insert(resultNodesPath.begin(), (CAmRoutingNode*)&object);
- am_RoutingNodeData_s & routingData = object.getData();
- if(routingData.type==CAmNodeDataType::SINK)
- {
- auto iter = resultPath.route.emplace(resultPath.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;
- }
- };
- mRoutingGraph.getShortestPath(aSource, aSink, cb);
-}
+ std::vector<CAmRoutingNode*>::iterator currentNodeIterator = nodeIterator;
+ std::vector<am_RoutingElement_s>::iterator currentRoutingElementIterator = routingElementIterator;
-#endif
+ 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::getAllPaths(CAmRoutingNode & aSource,
- CAmRoutingNode & aSink,
- std::vector<am_Route_s> & resultPath,
- std::vector<std::vector<CAmRoutingNode*>> & resultNodesPath,
- const bool includeCycles)
-{
-#ifndef ROUTING_BUILD_CONNECTIONS
- bool cycles = false;
-#else
- bool cycles = includeCycles;
-#endif
- if(((CAmRoutingNode*)&aSource)->getData().type!=CAmNodeDataType::SOURCE ||
- ((CAmRoutingNode*)&aSink)->getData().type!=CAmNodeDataType::SINK)
- return E_NOT_POSSIBLE;
-
- uint8_t errorsCount = 0, successCount = 0;
- generateAllPaths(aSource, aSink, cycles, [&](const std::vector<CAmRoutingNode*> & path) {
- resultNodesPath.push_back(path);
- resultPath.emplace_back();
- am_Route_s & nextRoute = resultPath.back();
- nextRoute.sinkID = aSink.getData().data.sink->sinkID;
- nextRoute.sourceID = aSource.getData().data.source->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;
- }
- }
-
- am_Error_e err = determineConnectionFormatsForPath(nextRoute, (std::vector<CAmRoutingNode*> &)path);
- if(err!=E_OK)
- {
- errorsCount++;
- auto last = resultPath.end()-1;
- resultPath.erase(last);
+ 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<<"Error by determining connection formats for path from source:"<<nextRoute.sourceID<<" to sink:"<<nextRoute.sinkID<<"\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
- }
- else
- {
+ }
#ifdef TRACE_GRAPH
- std::cout<<"\nSuccessfully determined connection formats for path from source:"<<nextRoute.sourceID<<" to sink:"<<nextRoute.sinkID<<"\n";
- for(auto it = nextRoute.route.begin(); it!=nextRoute.route.end(); it++)
- {
- am_RoutingElement_s & routingElement = *it;
- std::cout<<"["
- <<routingElement.sourceID
- <<"->"
- <<routingElement.sinkID
- <<" cf:"
- <<routingElement.connectionFormat
- <<" d:"
- <<routingElement.domainID
- <<"]";
- }
- std::cout<<"\n";
+ else
+ {
+ std::cout
+ << "Error by determining connection formats for path from source:"
+ << shortestRoute.sourceID << " to sink:" << shortestRoute.sinkID
+ << "\n";
+ }
#endif
- successCount++;
- }
- });
- if(successCount)
- return E_OK;
- if(errorsCount)
- return E_NOT_POSSIBLE;
- return E_OK;
-}
+ return err;
+ }
-bool CAmRouter::shouldGoInDomain(const std::vector<am_domainID_t> & visitedDomains, const am_domainID_t nodeDomainID)
-{
- if(visitedDomains.size())
- {
- if(visitedDomains.back()==nodeDomainID)
- return true;
-
- for(auto it=visitedDomains.begin();it!=visitedDomains.end()-1; it++)
- {
- if(nodeDomainID==*it)
- return false;
- }
- }
- return true;
-}
+ 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::generateAllPaths(const CAmRoutingNode & src,
- const CAmRoutingNode & dst,
- const bool includeCycles,
- std::function<void(const std::vector<CAmRoutingNode*> & path)> cb)
-{
- if(!includeCycles)
- {
- std::vector<CAmRoutingNode*> visited;
- std::vector<am_domainID_t> visitedDomains;
- visited.push_back((CAmRoutingNode*)&src);
- visitedDomains.push_back(((CAmRoutingNode*)&src)->getData().domainID());
- ((CAmRoutingNode*)&src)->setStatus(GES_VISITED);
- goThroughAllPaths(dst, visited, visitedDomains, cb);
- }
- else
- mRoutingGraph.getAllPaths(src, dst, cb);
-}
+ 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;
+ }
-void CAmRouter::goThroughAllPaths(const CAmRoutingNode & dst,
- std::vector<CAmRoutingNode*> & visited,
- std::vector<am_domainID_t> & visitedDomains,
- std::function<void(const std::vector<CAmRoutingNode*> & path)> cb)
-{
-#ifndef ROUTING_BUILD_CONNECTIONS
- CAmRoutingListVertices vertices;
- getVerticesForNode(*visited.back(), vertices);
- const CAmRoutingListVertices * nodes = &vertices;
-#else
- const CAmRoutingListVertices * nodes = mRoutingGraph.getVertexList()[visited.back()->getIndex()];
-#endif
- CAmRoutingListVertices::const_iterator vItr(nodes->begin());
- for (; vItr != nodes->end(); ++vItr)
- {
- const CAmRoutingVertex & vertex = (*vItr);
- if(vertex.getNode()->getStatus()!=GES_NOT_VISITED || !shouldGoInDomain(visitedDomains, vertex.getNode()->getData().domainID()))
- continue;
- if (vertex.getNode()==&dst)
- {
- vertex.getNode()->setStatus(GES_IN_PROGRESS);
- visited.push_back(vertex.getNode());
- visitedDomains.push_back(vertex.getNode()->getData().domainID());
- //notify observer
- cb(visited);
- //remove last node from the list
- auto last = visited.end()-1;
- visited.erase(last);
- visitedDomains.erase(visitedDomains.end()-1);
- vertex.getNode()->setStatus(GES_NOT_VISITED);
- break;
- }
- }
- vItr = nodes->begin();
- //bfs like loop
- for (; vItr != nodes->end(); ++vItr)
- {
- const CAmRoutingVertex & vertex = (*vItr);
- if(vertex.getNode()->getStatus()!=GES_NOT_VISITED
- ||vertex.getNode()==&dst ||
- !shouldGoInDomain(visitedDomains, vertex.getNode()->getData().domainID()))
- continue;
- vertex.getNode()->setStatus(GES_IN_PROGRESS);
- visited.push_back(vertex.getNode());
- visitedDomains.push_back(vertex.getNode()->getData().domainID());
- goThroughAllPaths(dst, visited, visitedDomains, cb);
- //remove last node from the list
- auto last = visited.end()-1;
- visited.erase(last);
- visitedDomains.erase(visitedDomains.end()-1);
- vertex.getNode()->setStatus(GES_NOT_VISITED);
- }
-}
+ 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;
+ }
-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;
-}
+ 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;
+ }
-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::shouldGoInDomain(const std::vector<am_domainID_t> & visitedDomains, const am_domainID_t nodeDomainID)
+ {
+ return CAmRouter::shouldGoInDomain(visitedDomains, nodeDomainID, mMaxAllowedCycles);
+ }
+ 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::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();
+ if (sizeSourceFormats == 0 || sizeSinkFormats == 0 || sizeConvertionMatrix == 0 || sizeConvertionMatrix != sizeSinkFormats * sizeSourceFormats)
+ {
+ return false;
+ }
- //find the row number of the sink
- rowSinkIterator = find(listSinkFormats.begin(), listSinkFormats.end(), connectionFormat);
- int rowNumberSink = rowSinkIterator - listSinkFormats.begin();
+ 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;
+ }
- //go through the convertionMatrix and find out if the conversion is possible, if yes, add connectionFormat ...
- std::advance(matrixIterator, rowNumberSink);
+ 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);
+ }
- //iterate line-wise through the matrix and add more formats
- do
+ 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)
{
- if (*matrixIterator)
- {
- listFormats.push_back(listSourceFormats.at((matrixIterator - convertionMatrix.begin()) / listSinkFormats.size()));
- }
- std::advance(matrixIterator, listSinkFormats.size());
- } while (convertionMatrix.end() - matrixIterator > 0);
+ listFormats.clear();
+ std::vector<am_CustomConnectionFormat_t>::const_iterator rowSinkIterator = listSinkFormats.begin();
+ std::vector<bool>::const_iterator matrixIterator = convertionMatrix.begin();
- return listFormats.size();
-}
+ //find the row number of the sink
+ rowSinkIterator = find(listSinkFormats.begin(), listSinkFormats.end(), connectionFormat);
+ int rowNumberSink = rowSinkIterator - listSinkFormats.begin();
+ //go through the convertionMatrix and find out if the conversion is possible, if yes, add connectionFormat ...
+ std::advance(matrixIterator, rowNumberSink);
-void CAmRouter::getSourceSinkPossibleConnectionFormats(std::vector<CAmRoutingNode*>::iterator iteratorSource,
- std::vector<CAmRoutingNode*>::iterator iteratorSink,
- std::vector<am_CustomConnectionFormat_t> & outConnectionFormats)
-{
- CAmRoutingNode * nodeSink = *iteratorSink;
- assert(nodeSink->getData().type==CAmNodeDataType::SINK);
+ //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();
+ }
- CAmRoutingNode * nodeSource = *iteratorSource;
- assert(nodeSource->getData().type==CAmNodeDataType::SOURCE);
+ 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);
+ }
- am_Source_s *source = nodeSource->getData().data.source;
- am_Sink_s *sink = nodeSink->getData().data.sink;
- listPossibleConnectionFormats(source->listConnectionFormats, sink->listConnectionFormats, outConnectionFormats);
-}
+ 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 (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++)
+ {
+ 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;
+ }
}
diff --git a/AudioManagerCore/src/CAmRoutingSender.cpp b/AudioManagerCore/src/CAmRoutingSender.cpp
index fc0953f..9cc013d 100644
--- a/AudioManagerCore/src/CAmRoutingSender.cpp
+++ b/AudioManagerCore/src/CAmRoutingSender.cpp
@@ -45,133 +45,160 @@ namespace am
#define __METHOD_NAME__ std::string (std::string("CAmRoutingSender::") + __func__)
-CAmRoutingSender::CAmRoutingSender(const std::vector<std::string>& listOfPluginDirectories, IAmDatabaseHandler* databaseHandler) :
- mHandleCount(0), //
- mlistActiveHandles(), //
- mListInterfaces(), //
- mMapConnectionInterface(), //
- mMapCrossfaderInterface(), //
- mMapDomainInterface(), //
- mMapSinkInterface(), //
- mMapSourceInterface(), //
- mpRoutingReceiver(), //
- mpDatabaseHandler(databaseHandler)
-{
+CAmRoutingSender::CAmRoutingSender(
+ const std::vector<std::string>& listOfPluginDirectories,
+ IAmDatabaseHandler* databaseHandler) :
+ mHandleCount(0), //
+ mlistActiveHandles(), //
+ mListInterfaces(), //
+ mMapConnectionInterface(), //
+ mMapCrossfaderInterface(), //
+ mMapDomainInterface(), //
+ mMapSinkInterface(), //
+ mMapSourceInterface(), //
+ mpRoutingReceiver(), //
+ mpDatabaseHandler(databaseHandler) {
+
+ if (listOfPluginDirectories.empty()) {
+ logError(__METHOD_NAME__,"List of routingplugins is empty");
+ }
- if (listOfPluginDirectories.empty())
- {
- logError(__METHOD_NAME__,"List of routingplugins is empty");
- }
+ std::vector<std::string> sharedLibraryNameList;
+ std::vector<std::string>::const_iterator dirIter = listOfPluginDirectories.begin();
+ std::vector<std::string>::const_iterator dirIterEnd = listOfPluginDirectories.end();
- std::vector<std::string> sharedLibraryNameList;
- std::vector<std::string>::const_iterator dirIter = listOfPluginDirectories.begin();
- std::vector<std::string>::const_iterator dirIterEnd = listOfPluginDirectories.end();
+ // search communicator plugins in configured directories
+ for (; dirIter < dirIterEnd; ++dirIter)
+ {
+ const char* directoryName = dirIter->c_str();
+ logInfo(__METHOD_NAME__,"Searching for HookPlugins in", directoryName);
+ DIR *directory = opendir(directoryName);
- // search communicator plugins in configured directories
- for (; dirIter < dirIterEnd; ++dirIter)
- {
- const char* directoryName = dirIter->c_str();
- logInfo(__METHOD_NAME__,"Searching for HookPlugins in", directoryName);
- DIR *directory = opendir(directoryName);
+ if (!directory)
+ {
+ logError(__METHOD_NAME__,"Error opening directory: ", directoryName);
+ continue;
+ }
- if (!directory)
- {
- logError(__METHOD_NAME__,"Error opening directory: ", directoryName);
- continue;
- }
+ // iterate content of directory
+ struct dirent *itemInDirectory = 0;
+ while ((itemInDirectory = readdir(directory)))
+ {
+ unsigned char entryType = itemInDirectory->d_type;
+ std::string entryName = itemInDirectory->d_name;
+ std::string fullName = *dirIter + "/" + entryName;
+
+ bool regularFile = (entryType == DT_REG || entryType == DT_LNK);
+ bool sharedLibExtension = ("so" == entryName.substr(entryName.find_last_of(".") + 1));
+
+ // Handle cases where readdir() could not determine the file type
+ if (entryType == DT_UNKNOWN) {
+ struct stat buf;
+
+ if (stat(fullName.c_str(), &buf)) {
+ logInfo(__METHOD_NAME__,"Failed to stat file: ", entryName, errno);
+ continue;
+ }
+
+ regularFile = S_ISREG(buf.st_mode);
+ }
+
+ if (regularFile && sharedLibExtension)
+ {
+ logInfo(__METHOD_NAME__,"adding file: ", entryName);
+ std::string name(directoryName);
+ sharedLibraryNameList.push_back(name + "/" + entryName);
+ }
+ else
+ {
+ logInfo(__METHOD_NAME__, "plugin search ignoring file :", entryName);
+ }
+ }
- // iterate content of directory
- struct dirent *itemInDirectory = 0;
- while ((itemInDirectory = readdir(directory)))
- {
- unsigned char entryType = itemInDirectory->d_type;
- std::string entryName = itemInDirectory->d_name;
- std::string fullName = *dirIter + "/" + entryName;
-
- bool regularFile = (entryType == DT_REG || entryType == DT_LNK);
- bool sharedLibExtension = ("so" == entryName.substr(entryName.find_last_of(".") + 1));
-
- // Handle cases where readdir() could not determine the file type
- if (entryType == DT_UNKNOWN) {
- struct stat buf;
-
- if (stat(fullName.c_str(), &buf)) {
- logInfo(__METHOD_NAME__,"Failed to stat file: ", entryName, errno);
- continue;
- }
-
- regularFile = S_ISREG(buf.st_mode);
- }
-
- if (regularFile && sharedLibExtension)
- {
- logInfo(__METHOD_NAME__,"adding file: ", entryName);
- std::string name(directoryName);
- sharedLibraryNameList.push_back(name + "/" + entryName);
- }
- else
- {
- logInfo(__METHOD_NAME__, "plugin search ignoring file :", entryName);
- }
- }
+ closedir(directory);
+ }
- closedir(directory);
- }
+ // iterate all communicator plugins and start them
+ std::vector<std::string>::iterator iter = sharedLibraryNameList.begin();
+ std::vector<std::string>::iterator iterEnd = sharedLibraryNameList.end();
- // iterate all communicator plugins and start them
- std::vector<std::string>::iterator iter = sharedLibraryNameList.begin();
- std::vector<std::string>::iterator iterEnd = sharedLibraryNameList.end();
+ for (; iter != iterEnd; ++iter)
+ {
+ logInfo(__METHOD_NAME__,"try loading: ", *iter);
- for (; iter != iterEnd; ++iter)
- {
- logInfo(__METHOD_NAME__,"try loading: ", *iter);
+ IAmRoutingSend* (*createFunc)();
+ void* tempLibHandle = NULL;
+ createFunc = getCreateFunction<IAmRoutingSend*()>(*iter, tempLibHandle);
- IAmRoutingSend* (*createFunc)();
- void* tempLibHandle = NULL;
- createFunc = getCreateFunction<IAmRoutingSend*()>(*iter, tempLibHandle);
+ if (!createFunc)
+ {
+ logError(__METHOD_NAME__,"Entry point of RoutingPlugin not found");
+ continue;
+ }
- if (!createFunc)
- {
- logError(__METHOD_NAME__,"Entry point of RoutingPlugin not found");
- continue;
- }
+ IAmRoutingSend* router = createFunc();
- IAmRoutingSend* router = createFunc();
+ if (!router)
+ {
+ logError(__METHOD_NAME__,"initialization of plugin ",*iter,"failed. Entry Function not callable");
+ dlclose(tempLibHandle);
+ continue;
+ }
- if (!router)
- {
- logError(__METHOD_NAME__,"initialization of plugin ",*iter,"failed. Entry Function not callable");
- dlclose(tempLibHandle);
- continue;
- }
+ InterfaceNamePairs routerInterface;
+ routerInterface.routingInterface = router;
- InterfaceNamePairs routerInterface;
- routerInterface.routingInterface = router;
-
- //check libversion
- std::string version, cVersion(RoutingVersion);
- router->getInterfaceVersion(version);
- uint16_t minorVersion, majorVersion, cMinorVersion, cMajorVersion;
- std::istringstream(version.substr(0, 1)) >> majorVersion;
- std::istringstream(version.substr(2, 1)) >> minorVersion;
- std::istringstream(cVersion.substr(0, 1)) >> cMajorVersion;
- std::istringstream(cVersion.substr(2, 1)) >> cMinorVersion;
-
-
-
- if (majorVersion < cMajorVersion || ((majorVersion == cMajorVersion) && (minorVersion > cMinorVersion)))
- {
- logError(__METHOD_NAME__,"Routing initialization failed. Version of Interface to old");
- dlclose(tempLibHandle);
- continue;
- }
+ //check libversion
+ std::string version, cVersion(RoutingVersion);
+ router->getInterfaceVersion(version);
+ uint16_t minorVersion, majorVersion, cMinorVersion, cMajorVersion;
+ std::istringstream(version.substr(0, 1)) >> majorVersion;
+ std::istringstream(version.substr(2, 1)) >> minorVersion;
+ std::istringstream(cVersion.substr(0, 1)) >> cMajorVersion;
+ std::istringstream(cVersion.substr(2, 1)) >> cMinorVersion;
- //here, the busname is saved together with the interface. Later The domains will register with the name and sinks, sources etc with the domain....
- router->returnBusName(routerInterface.busName);
- assert(!routerInterface.busName.empty());
- mListInterfaces.push_back(routerInterface);
- mListLibraryHandles.push_back(tempLibHandle);
- }
+ if (majorVersion < cMajorVersion || ((majorVersion == cMajorVersion) && (minorVersion > cMinorVersion)))
+ {
+ logError(__METHOD_NAME__,"Routing initialization failed. Version of Interface to old");
+ dlclose(tempLibHandle);
+ continue;
+ }
+
+ //here, the busname is saved together with the interface. Later The domains will register with the name and sinks, sources etc with the domain....
+ router->returnBusName(routerInterface.busName);
+ assert(!routerInterface.busName.empty());
+ mListInterfaces.push_back(routerInterface);
+ mListLibraryHandles.push_back(tempLibHandle);
+ }
+
+ dboNewSink = [&](const am_Sink_s& sink) {
+ addSinkLookup(sink);
+ };
+ dboNewSource = [&](const am_Source_s& source) {
+ addSourceLookup(source);
+ };
+ dboNewDomain = [&](const am_Domain_s& domain) {
+ addDomainLookup(domain);
+ };
+ //todo: newGateway implement something
+ //todo: newConverter implement something
+ dboNewCrossfader = [&](const am_Crossfader_s& crossfader) {
+ addCrossfaderLookup(crossfader);
+ };
+ dboRemovedSink = [&](const am_sinkID_t sinkID, const bool visible) {
+ removeSinkLookup(sinkID);
+ };
+ dboRemovedSource = [&](const am_sourceID_t sourceID, const bool visible) {
+ removeSourceLookup(sourceID);
+ };
+ dboRemoveDomain = [&](const am_domainID_t domainID) {
+ removeDomainLookup(domainID);
+ };
+ //todo: removeGateway implement something
+ //todo: removeConverter implement something
+ dboRemoveCrossfader = [&](const am_crossfaderID_t crossfaderID) {
+ removeCrossfaderLookup(crossfaderID);
+ };
}
CAmRoutingSender::~CAmRoutingSender()
@@ -786,17 +813,32 @@ am_Error_e CAmRoutingSender::getListHandles(std::vector<am_Handle_s> & listHandl
am_Handle_s CAmRoutingSender::createHandle(std::shared_ptr<handleDataBase> handleData, const am_Handle_e type)
{
am_Handle_s handle;
- if (++mHandleCount>=1024) //defined by 10 bit (out if structure!)
- mHandleCount=1;
- handle.handle = mHandleCount;
handle.handleType = type;
- mlistActiveHandles.insert(std::make_pair(handle, handleData));
- if ((mlistActiveHandles.size()%100) == 0)
- {
- logInfo("CAmRoutingSender::createHandle warning: too many open handles, number of handles: ", mlistActiveHandles.size());
+
+ for (int checkOverflow=0;checkOverflow<1024;checkOverflow++)
+ {
+ if (++mHandleCount>=1024) //defined by 10 bit (out if structure!)
+ {
+ mHandleCount=1;
+ }
+ handle.handle = mHandleCount;
+
+ if ( mlistActiveHandles.find(handle) == mlistActiveHandles.end() )
+ {
+ mlistActiveHandles.insert(std::make_pair(handle, handleData));
+ if (mlistActiveHandles.size()>100)
+ {
+ logWarning(__METHOD_NAME__,"too many open handles, number of handles: ", mlistActiveHandles.size());
+ }
+ logInfo(__METHOD_NAME__,handle.handle, handle.handleType);
+ return (handle);
+ }
}
- logInfo(__METHOD_NAME__,handle.handle, handle.handleType);
- return (handle);
+
+ logError(__METHOD_NAME__,"could not create new handle, all handles in use!");
+ handle.handle=0;
+
+ return(handle);
}
void CAmRoutingSender::setRoutingReady()
diff --git a/AudioManagerCore/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp b/AudioManagerCore/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp
index 9c09deb..27ed2b6 100644
--- a/AudioManagerCore/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp
+++ b/AudioManagerCore/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp
@@ -51,7 +51,7 @@ CAmControlInterfaceTest::CAmControlInterfaceTest() :
plistRoutingPluginDirs(), //
pDatabaseHandler(), //
pRoutingSender(plistRoutingPluginDirs,dynamic_cast<IAmDatabaseHandler*>( &pDatabaseHandler )), //RoutingReceiver
- pCommandSender(plistCommandPluginDirs), //
+ pCommandSender(plistCommandPluginDirs, &pSocketHandler), //
pMockControlInterface(), //
pMockRoutingInterface(), //
pRoutingInterfaceBackdoor(), //
@@ -59,11 +59,11 @@ CAmControlInterfaceTest::CAmControlInterfaceTest() :
pControlInterfaceBackdoor(), //
pControlSender(), //
pRouter(&pDatabaseHandler,&pControlSender), //
- pDatabaseObserver(&pCommandSender, &pRoutingSender, &pSocketHandler), //
pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pSocketHandler, &pRouter), //
pRoutingReceiver(&pDatabaseHandler, &pRoutingSender, &pControlSender, &pSocketHandler)
{
- pDatabaseHandler.registerObserver(&pDatabaseObserver);
+ pDatabaseHandler.registerObserver(&pRoutingSender);
+ pDatabaseHandler.registerObserver(&pCommandSender);
pControlInterfaceBackdoor.replaceController(&pControlSender, &pMockControlInterface);
pRoutingInterfaceBackdoor.injectInterface(&pRoutingSender, &pMockRoutingInterface, "mock");
diff --git a/AudioManagerCore/test/AmControlInterfaceTest/CAmControlInterfaceTest.h b/AudioManagerCore/test/AmControlInterfaceTest/CAmControlInterfaceTest.h
index 3e645fb..9ebcec7 100644
--- a/AudioManagerCore/test/AmControlInterfaceTest/CAmControlInterfaceTest.h
+++ b/AudioManagerCore/test/AmControlInterfaceTest/CAmControlInterfaceTest.h
@@ -26,11 +26,9 @@
#include "gtest/gtest.h"
#include "gmock/gmock.h"
-//#include "CAmDatabaseHandlerSQLite.h"
#include "CAmDatabaseHandlerMap.h"
#include "CAmControlReceiver.h"
#include "CAmRoutingReceiver.h"
-#include "CAmDatabaseObserver.h"
#include "CAmControlSender.h"
#include "CAmRoutingSender.h"
#include "CAmRouter.h"
@@ -65,7 +63,6 @@ public:
IAmControlBackdoor pControlInterfaceBackdoor;
CAmControlSender pControlSender;
CAmRouter pRouter;
- CAmDatabaseObserver pDatabaseObserver;
CAmControlReceiver pControlReceiver;
CAmRoutingReceiver pRoutingReceiver;
CAmCommonFunctions pCF;
diff --git a/AudioManagerCore/test/AmMapHandlerTest/CAmMapHandlerTest.cpp b/AudioManagerCore/test/AmMapHandlerTest/CAmMapHandlerTest.cpp
index 559764d..fe2f68a 100644
--- a/AudioManagerCore/test/AmMapHandlerTest/CAmMapHandlerTest.cpp
+++ b/AudioManagerCore/test/AmMapHandlerTest/CAmMapHandlerTest.cpp
@@ -47,18 +47,18 @@ TCLAP::SwitchArg enableDebug ("V","logDlt","print DLT logs to stdout or dlt-daem
CAmMapBasicTest::CAmMapBasicTest() :
+ pDatabaseHandler(), //
plistRoutingPluginDirs(), //
plistCommandPluginDirs(), //
- pSocketHandler(),//
- pDatabaseHandler(), //
+ pSocketHandler(),//
pRoutingSender(plistRoutingPluginDirs,dynamic_cast<IAmDatabaseHandler*>( &pDatabaseHandler )), //
- pCommandSender(plistCommandPluginDirs), //
+ pCommandSender(plistCommandPluginDirs, &pSocketHandler), //
pRoutingInterfaceBackdoor(), //
pCommandInterfaceBackdoor(), //
pControlSender(), //
pRouter(&pDatabaseHandler, &pControlSender), //
pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pSocketHandler, &pRouter), //
- pCF()
+ pCF()
{
}
@@ -96,7 +96,8 @@ void CAmMapBasicTest::createMainConnectionSetup(am_mainConnectionID_t & mainConn
connection.delay = -1;
connection.connectionFormat = CF_GENIVI_ANALOG;
connection.connectionID = 0;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink(_)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource(_)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,forgetSink));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,forgetSource));
ASSERT_EQ(E_OK, pDatabaseHandler.enterConnectionDB(connection,connectionID));
@@ -114,6 +115,9 @@ void CAmMapBasicTest::createMainConnectionSetup(am_mainConnectionID_t & mainConn
mainConnection.delay = -1;
//enter mainconnection in database
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newMainConnection(_)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), mainConnectionStateChanged(_, _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), timingInformationChanged(_, _)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterMainConnectionDB(mainConnection,mainConnectionID));
ASSERT_NE(0, mainConnectionID);
@@ -135,10 +139,8 @@ void CAmMapBasicTest::createMainConnectionSetup(am_mainConnectionID_t & mainConn
void CAmMapBasicTest::SetUp()
{
- ::testing::FLAGS_gmock_verbose = "error";
-
- am_Domain_s domain;
- pCF.createDomain(domain);
+ am_Domain_s domain;
+ pCF.createDomain(domain);
am_domainID_t forgetDomain;
am_sinkClass_t forgetSinkClassID;
am_SinkClass_s sinkClass;
@@ -149,6 +151,9 @@ void CAmMapBasicTest::SetUp()
sourceClass.name="TestSourceClass";
sourceClass.sourceClassID=1;
domain.domainID=4;
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newDomain(_)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), numberOfSinkClassesChanged()).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), numberOfSourceClassesChanged()).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,forgetDomain));
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkClassDB(sinkClass,forgetSinkClassID));
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceClassDB(forgetSourceClassID,sourceClass));
@@ -156,16 +161,16 @@ void CAmMapBasicTest::SetUp()
void CAmMapBasicTest::TearDown()
{
- ::testing::FLAGS_gmock_verbose = "warning";
+ Mock::VerifyAndClearExpectations(MockDatabaseObserver::getMockObserverObject());
}
CAmMapHandlerTest::CAmMapHandlerTest() :
pMockInterface(), //
- pObserver(&pCommandSender,&pRoutingSender, &pSocketHandler)
+ mMockObserver()
{
- pDatabaseHandler.registerObserver(&pObserver);
+ pDatabaseHandler.registerObserver(&mMockObserver);
pDatabaseHandler.setConnectionIDRange(1, TEST_MAX_CONNECTION_ID);
pDatabaseHandler.setMainConnectionIDRange(1, TEST_MAX_MAINCONNECTION_ID);
pDatabaseHandler.setSinkIDRange(DYNAMIC_ID_BOUNDARY, DYNAMIC_ID_BOUNDARY+TEST_MAX_SINK_ID);
@@ -174,6 +179,7 @@ CAmMapHandlerTest::CAmMapHandlerTest() :
CAmMapHandlerTest::~CAmMapHandlerTest()
{
+ pDatabaseHandler.unregisterObserver(&mMockObserver);
}
TEST_F(CAmMapHandlerTest,getMainConnectionInfo)
@@ -200,7 +206,8 @@ TEST_F(CAmMapHandlerTest,getSinkInfo)
pCF.createSink(staticSink);
staticSink.sinkID = 4;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink(_)).Times(3);
+
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))
<< "ERROR: database error";
ASSERT_EQ(staticSink.sinkID,staticSinkID)
@@ -270,7 +277,8 @@ TEST_F(CAmMapHandlerTest,getSourceInfo)
staticSource.sourceID = 4;
staticSource.name = "Static";
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource(_)).Times(3);
+
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))
<< "ERROR: database error";
ASSERT_EQ(staticSource.sourceID,staticSourceID)
@@ -344,7 +352,7 @@ TEST_F(CAmMapHandlerTest, peekSourceID)
sourceClass.name = sourceName;
sourceClass.sourceClassID = 0;
sourceClass.listClassProperties.push_back(classProperty);
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), numberOfSourceClassesChanged()).Times(1);
//first we peek without an existing class
ASSERT_EQ(E_NON_EXISTENT, pDatabaseHandler.peekSourceClassID(sourceName,sourceClassID));
@@ -368,7 +376,7 @@ TEST_F(CAmMapHandlerTest, peekSinkID)
sinkClass.name = sinkName;
sinkClass.sinkClassID = 0;
sinkClass.listClassProperties.push_back(classProperty);
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), numberOfSinkClassesChanged()).Times(1);
//first we peek without an existing class
ASSERT_EQ(E_NON_EXISTENT, pDatabaseHandler.peekSinkClassID(sinkName,sinkClassID));
@@ -392,7 +400,9 @@ TEST_F(CAmMapHandlerTest,crossfaders)
pCF.createSink(sinkB);
sinkB.name = "sinkB";
pCF.createSource(source);
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource(_)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink(_)).Times(2);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newCrossfader(_)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sinkA,sinkAID));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sinkB,sinkBID));
@@ -419,9 +429,6 @@ TEST_F(CAmMapHandlerTest,crossfaders)
TEST_F(CAmMapHandlerTest,crossfadersGetFromDomain)
{
-
-
-
am_Crossfader_s crossfader;
am_crossfaderID_t crossfaderID;
am_Sink_s sinkA, sinkB;
@@ -435,6 +442,12 @@ TEST_F(CAmMapHandlerTest,crossfadersGetFromDomain)
pCF.createDomain(domain);
sinkB.name = "sinkB";
pCF.createSource(source);
+
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newDomain(_)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource(_)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink(_)).Times(2);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newCrossfader(_)).Times(1);
+
ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
source.domainID = domainID;
sinkA.domainID = domainID;
@@ -469,7 +482,7 @@ TEST_F(CAmMapHandlerTest,sourceState)
source.sourceState = SS_OFF;
//prepare the test
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource(_)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
//change the source state
@@ -489,7 +502,7 @@ TEST_F(CAmMapHandlerTest,sourceInterruptState)
source.interruptState = IS_OFF;
//prepare the test
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource(_)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
//change the source interrupt state
@@ -509,7 +522,7 @@ TEST_F(CAmMapHandlerTest,sinkVolumeChange)
sink.volume = 23;
//prepare the test
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink(_)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
//change the volume and check the read out
@@ -527,7 +540,7 @@ TEST_F(CAmMapHandlerTest,sourceVolumeChange)
source.volume = 23;
//prepare test
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource(_)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
//change the volume and check the read out
@@ -543,9 +556,8 @@ TEST_F(CAmMapHandlerTest, peekSource)
am_sourceID_t sourceID, source2ID, source3ID;
am_Source_s source;
pCF.createSource(source);
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource(_)).Times(1);
//peek a source that does not exits
-
ASSERT_EQ(E_OK, pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
//make sure it is not in the list
@@ -591,7 +603,7 @@ TEST_F(CAmMapHandlerTest, peekSourceDouble)
pCF.createSource(source);
//peek a source that does not exits
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource(_)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.peekSource(std::string("newsource"),sourceID));
//peek a second source that does not exits
@@ -626,7 +638,7 @@ TEST_F(CAmMapHandlerTest, peekSink)
pCF.createSink(sink);
//peek a sink that does not exits
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink(_)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
//make sure it is not in the list
@@ -668,7 +680,7 @@ TEST_F(CAmMapHandlerTest, peekSinkDouble)
pCF.createSink(sink);
//peek a sink that does not exits
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink(_)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.peekSink(std::string("newsink"),sinkID));
//peek again
@@ -712,6 +724,7 @@ TEST_F(CAmMapHandlerTest,changeConnectionTimingInformationCheckMainConnection)
std::vector<am_Connection_s>::iterator iteratorConnectionList = connectionList.begin();
for (; iteratorConnectionList < connectionList.end(); ++iteratorConnectionList)
{
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), timingInformationChanged(_,_)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionTimingInformation(iteratorConnectionList->connectionID,24));
}
@@ -732,7 +745,10 @@ TEST_F(CAmMapHandlerTest,changeConnectionTimingInformation)
pCF.createConnection(connection);
pCF.createSink(sink);
pCF.createSource(source);
-
+
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink(_)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource(_)).Times(1);
+
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkid));
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceid));
@@ -769,7 +785,8 @@ TEST_F(CAmMapHandlerTest,getSinkClassOfSink)
sinkClass.listClassProperties = classPropertyList;
pCF.createSink(sink);
sink.sinkClassID = 4;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), numberOfSinkClassesChanged()).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink(_)).Times(1);
//prepare test
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
@@ -808,7 +825,9 @@ TEST_F(CAmMapHandlerTest,getSourceClassOfSource)
sourceClass.listClassProperties = classPropertyList;
pCF.createSource(source);
source.sourceClassID=8;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), numberOfSourceClassesChanged()).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource(_)).Times(1);
+
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
@@ -838,7 +857,7 @@ TEST_F(CAmMapHandlerTest,removeSourceClass)
sourceClass.name = "test";
sourceClass.sourceClassID = 3;
sourceClass.listClassProperties = classPropertyList;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), numberOfSourceClassesChanged()).Times(3);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
@@ -870,7 +889,7 @@ TEST_F(CAmMapHandlerTest,updateSourceClass)
changedClass = sourceClass;
changedClass.listClassProperties[1].value = 6;
changedPropertyList = changedClass.listClassProperties;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), numberOfSourceClassesChanged()).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
changedClass.sourceClassID = sourceClassID;
ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
@@ -901,7 +920,7 @@ TEST_F(CAmMapHandlerTest,enterSourceClass)
sourceClass.sourceClassID = 0;
sourceClass.listClassProperties = classPropertyList;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), numberOfSourceClassesChanged()).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
@@ -926,7 +945,7 @@ TEST_F(CAmMapHandlerTest,enterSourceClassStatic)
sourceClass.sourceClassID = 3;
sourceClass.listClassProperties = classPropertyList;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), numberOfSourceClassesChanged()).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
ASSERT_EQ(E_OK, pDatabaseHandler.getListSourceClasses(sourceClassList));
ASSERT_EQ(sourceClassList[0].name, sourceClass.name);
@@ -950,7 +969,7 @@ TEST_F(CAmMapHandlerTest,removeSinkClass)
sinkClass.name = "test";
sinkClass.sinkClassID = 0;
sinkClass.listClassProperties = classPropertyList;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), numberOfSinkClassesChanged()).Times(3);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
@@ -982,7 +1001,7 @@ TEST_F(CAmMapHandlerTest,updateSinkClass)
changedClass = sinkClass;
changedClass.listClassProperties[1].value = 6;
changedPropertyList = changedClass.listClassProperties;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), numberOfSinkClassesChanged()).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
changedClass.sinkClassID = sinkClassID;
ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
@@ -1012,7 +1031,7 @@ TEST_F(CAmMapHandlerTest,enterSinkClass)
sinkClass.name = "test";
sinkClass.sinkClassID = 0;
sinkClass.listClassProperties = classPropertyList;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), numberOfSinkClassesChanged()).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
@@ -1038,7 +1057,7 @@ TEST_F(CAmMapHandlerTest,enterSinkClassStatic)
sinkClass.sinkClassID = 4;
sinkClass.listClassProperties = classPropertyList;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), numberOfSinkClassesChanged()).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
ASSERT_EQ(E_OK, pDatabaseHandler.getListSinkClasses(sinkClassList));
ASSERT_EQ(sinkClassList[0].name, sinkClass.name);
@@ -1054,6 +1073,7 @@ TEST_F(CAmMapHandlerTest, changeSystemProperty)
systemProperty.type = SYP_UNKNOWN;
systemProperty.value = 33;
listSystemProperties.push_back(systemProperty);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), systemPropertyChanged(_)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSystemProperties(listSystemProperties));
systemProperty.value = 444;
ASSERT_EQ(E_OK, pDatabaseHandler.changeSystemPropertyDB(systemProperty));
@@ -1088,7 +1108,7 @@ TEST_F(CAmMapHandlerTest,enterSourcesCorrect)
staticSource.sourceID = 4;
staticSource.name = "Static";
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource(_)).Times(3);
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))
<< "ERROR: database error";
ASSERT_EQ(staticSource.sourceID,staticSourceID)
@@ -1142,6 +1162,8 @@ TEST_F(CAmMapHandlerTest, changeSinkMuteState)
am_sinkID_t sinkID;
pCF.createSink(sink);
am_MuteState_e muteState = MS_MUTED;
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink(_)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), sinkMuteStateChanged(_, _)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
@@ -1159,6 +1181,8 @@ TEST_F(CAmMapHandlerTest, changeSourceMainSoundProperty)
am_MainSoundProperty_s property;
property.type = MSP_UNKNOWN;
property.value = 33;
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource(_)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), mainSourceSoundPropertyChanged(_, _)).Times(2);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
@@ -1191,7 +1215,8 @@ TEST_F(CAmMapHandlerTest, changeSinkMainSoundProperty)
property.type = MSP_UNKNOWN;
property.value = 33;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink(_)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), mainSinkSoundPropertyChanged(_, _)).Times(2);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
ASSERT_EQ(E_OK, pDatabaseHandler.changeMainSinkSoundPropertyDB(property,sinkID));
@@ -1222,7 +1247,7 @@ TEST_F(CAmMapHandlerTest, changeSourceSoundProperty)
am_SoundProperty_s property;
property.type = SP_GENIVI_MID;
property.value = 33;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource(_)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceSoundPropertyDB(property,sourceID));
@@ -1254,7 +1279,7 @@ TEST_F(CAmMapHandlerTest, changeSinkSoundProperty)
property.type = SP_GENIVI_MID;
property.value = 33;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink(_)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkSoundPropertyDB(property,sinkID));
@@ -1283,6 +1308,7 @@ TEST_F(CAmMapHandlerTest, peekDomain)
am_domainID_t domainID;
am_domainID_t domain2ID;
pCF.createDomain(domain);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newDomain(_)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.peekDomain(std::string("newdomain"),domainID));
ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains));
ASSERT_FALSE(listDomains.empty());
@@ -1302,6 +1328,7 @@ TEST_F(CAmMapHandlerTest, peekDomainFirstEntered)
am_domainID_t domain2ID;
pCF.createDomain(domain);
domain.name = "newdomain";
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newDomain(_)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
ASSERT_EQ(E_OK, pDatabaseHandler.peekDomain(std::string("newdomain"),domain2ID));
ASSERT_EQ(domainID, domain2ID);
@@ -1316,6 +1343,7 @@ TEST_F(CAmMapHandlerTest, changeDomainState)
am_domainID_t domainID;
pCF.createDomain(domain);
am_DomainState_e newState = DS_INDEPENDENT_STARTUP;
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newDomain(_)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
ASSERT_EQ(E_OK, pDatabaseHandler.changeDomainStateDB(newState,domainID));
ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains));
@@ -1328,7 +1356,7 @@ TEST_F(CAmMapHandlerTest, changeMainConnectionState)
am_MainConnection_s mainConnection;
std::vector<am_MainConnection_s> listMainConnections;
createMainConnectionSetup(mainConnectionID, mainConnection);
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), mainConnectionStateChanged(_, _)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.changeMainConnectionStateDB(1,CS_DISCONNECTING));
ASSERT_EQ(E_OK, pDatabaseHandler.getListMainConnections(listMainConnections));
ASSERT_EQ(CS_DISCONNECTING, listMainConnections[0].connectionState);
@@ -1343,7 +1371,8 @@ TEST_F(CAmMapHandlerTest, changeSinkAvailability)
am_Availability_s availability;
availability.availability = A_UNKNOWN;
availability.availabilityReason = AR_GENIVI_TEMPERATURE;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), sinkAvailabilityChanged(_, _)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkAvailabilityDB(availability,sinkID));
ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
@@ -1361,7 +1390,8 @@ TEST_F(CAmMapHandlerTest, changeSourceAvailability)
availability.availability = A_UNKNOWN;
availability.availabilityReason = AR_GENIVI_TEMPERATURE;
source.visible = true;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), sourceAvailabilityChanged(_, _)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceAvailabilityDB(availability,sourceID));
ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
@@ -1376,7 +1406,7 @@ TEST_F(CAmMapHandlerTest,changeMainConnectionRoute)
std::vector<am_MainConnection_s> originalList;
std::vector<am_MainConnection_s> newList;
createMainConnectionSetup(mainConnectionID, mainConnection);
-
+
//fill the connection database
am_Connection_s connection;
am_Source_s source;
@@ -1405,12 +1435,15 @@ TEST_F(CAmMapHandlerTest,changeMainConnectionRoute)
source.name = "source" + int2string(i + 30);
source.domainID = 4;
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
+
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,forgetSink));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,forgetSource));
ASSERT_EQ(E_OK, pDatabaseHandler.enterConnectionDB(connection,connectionID));
listConnectionID.push_back(connectionID);
}
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), timingInformationChanged(_, _)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.getListMainConnections(originalList));
ASSERT_EQ(E_OK, pDatabaseHandler.changeMainConnectionRouteDB(mainConnectionID,listConnectionID));
ASSERT_EQ(E_OK, pDatabaseHandler.getListMainConnections(newList));
@@ -1424,7 +1457,8 @@ TEST_F(CAmMapHandlerTest,changeMainSinkVolume)
am_mainVolume_t newVol = 20;
std::vector<am_Sink_s> listSinks;
pCF.createSink(sink);
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), volumeChanged(_, _)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkMainVolumeDB(newVol,sinkID));
ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
@@ -1438,7 +1472,7 @@ TEST_F(CAmMapHandlerTest,getMainSourceSoundProperties)
pCF.createSource(source);
std::vector<am_MainSoundProperty_s> mainSoundProperties = source.listMainSoundProperties;
std::vector<am_MainSoundProperty_s> listMainSoundProperties;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
ASSERT_EQ(E_OK, pDatabaseHandler.getListMainSourceSoundProperties(sourceID,listMainSoundProperties));
ASSERT_TRUE(std::equal(mainSoundProperties.begin(),mainSoundProperties.end(),listMainSoundProperties.begin(),equalMainSoundProperty));
@@ -1451,7 +1485,7 @@ TEST_F(CAmMapHandlerTest,getMainSinkSoundProperties)
pCF.createSink(sink);
std::vector<am_MainSoundProperty_s> mainSoundProperties = sink.listMainSoundProperties;
std::vector<am_MainSoundProperty_s> listMainSoundProperties;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
ASSERT_EQ(E_OK, pDatabaseHandler.getListMainSinkSoundProperties(sinkID,listMainSoundProperties));
ASSERT_TRUE(std::equal(mainSoundProperties.begin(),mainSoundProperties.end(),listMainSoundProperties.begin(),equalMainSoundProperty));
@@ -1470,7 +1504,7 @@ TEST_F(CAmMapHandlerTest,getMainSources)
source1.visible = false;
std::vector<am_SourceType_s> listMainSources;
std::vector<am_Source_s> listSources;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(3);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
source.sourceID = sourceID;
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source1,sourceID));
@@ -1499,7 +1533,7 @@ TEST_F(CAmMapHandlerTest,getMainSinks)
sink1.visible = false;
std::vector<am_SinkType_s> listMainSinks;
std::vector<am_Sink_s> listSinks;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(3);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
sink.sinkID = sinkID;
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink1,sinkID));
@@ -1521,7 +1555,7 @@ TEST_F(CAmMapHandlerTest,getVisibleMainConnections)
am_mainConnectionID_t mainConnectionID;
am_MainConnection_s mainConnection;
createMainConnectionSetup(mainConnectionID, mainConnection);
-
+
std::vector<am_MainConnectionType_s> listVisibleMainConnections;
std::vector<am_MainConnection_s> listMainConnections;
ASSERT_EQ(E_OK, pDatabaseHandler.getListVisibleMainConnections(listVisibleMainConnections));
@@ -1552,7 +1586,8 @@ TEST_F(CAmMapHandlerTest,getListSourcesOfDomain)
domain.domainID=0;
domain.name="dynDomain";
sourceCheckList.push_back(1); //sink.sinkID);
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newDomain( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(2);
ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))
<< "ERROR: database error";
@@ -1582,6 +1617,8 @@ TEST_F(CAmMapHandlerTest,getListSinksOfDomain)
domain.domainID=0;
domain.name="dyndomain";
sinkCheckList.push_back(1); //sink.sinkID);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newDomain( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(2);
ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))
@@ -1606,7 +1643,10 @@ TEST_F(CAmMapHandlerTest,getListGatewaysOfDomain)
am_Sink_s sink;
am_Source_s source;
std::vector<am_gatewayID_t> gatewayList, gatewayCheckList;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newDomain( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(2);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(2);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newGateway( _)).Times(2);
pCF.createDomain(domain);
domain.domainID=0;
domain.name="dyndomain";
@@ -1679,6 +1719,12 @@ TEST_F(CAmMapHandlerTest,getListConvertersOfDomain)
pCF.createDomain(domain);
domain.domainID=6;
domain.name="sdfsd";
+
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newDomain( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(2);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(2);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newConverter( _)).Times(2);
+
ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
am_sinkID_t sinkID1;
@@ -1743,6 +1789,10 @@ TEST_F(CAmMapHandlerTest,removeDomain)
am_domainID_t domainID;
std::vector<am_Domain_s> listDomains;
pCF.createDomain(domain);
+
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newDomain( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), removeDomain( _)).Times(1);
+
ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))
<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.removeDomainDB(domainID))
@@ -1766,6 +1816,11 @@ TEST_F(CAmMapHandlerTest,removeGateway)
pCF.createSource(source);
sink.sinkID = 1;
source.sourceID = 2;
+
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newGateway( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), removeGateway( _)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
@@ -1792,6 +1847,12 @@ TEST_F(CAmMapHandlerTest,removeConverter)
pCF.createSource(source);
sink.sinkID = 1;
source.sourceID = 2;
+
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newConverter( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), removeConverter( _)).Times(1);
+
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
ASSERT_EQ(E_OK,pDatabaseHandler.enterConverterDB(converter,converterID))
@@ -1810,6 +1871,9 @@ TEST_F(CAmMapHandlerTest,removeSink)
std::vector<am_Sink_s> listSinks;
pCF.createSink(sink);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), removedSink(_, _)).Times(1);
+
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID))
<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.removeSinkDB(sinkID))
@@ -1826,7 +1890,10 @@ TEST_F(CAmMapHandlerTest,removeSource)
am_sourceID_t sourceID;
std::vector<am_Source_s> listSources;
pCF.createSource(source);
-
+
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), removedSource(_, _)).Times(1);
+
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID))
<< "ERROR: database error";
ASSERT_EQ(E_OK,pDatabaseHandler.removeSourceDB(sourceID))
@@ -1841,7 +1908,8 @@ TEST_F(CAmMapHandlerTest, removeMainConnection)
am_mainConnectionID_t mainConnectionID;
am_MainConnection_s mainConnection;
createMainConnectionSetup(mainConnectionID, mainConnection);
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), removedMainConnection(_)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), mainConnectionStateChanged(_, _)).Times(1);
ASSERT_EQ(E_OK,pDatabaseHandler.removeMainConnectionDB(mainConnectionID))
<< "ERROR: database error";
}
@@ -1895,6 +1963,11 @@ TEST_F(CAmMapHandlerTest,registerGatewayCorrect)
pCF.createSource(source);
sink.sinkID = 1;
source.sourceID = 2;
+
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newGateway( _)).Times(3);
+
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))
@@ -1954,6 +2027,11 @@ TEST_F(CAmMapHandlerTest,registerConverterCorrect)
pCF.createSource(source);
sink.sinkID = 1;
source.sourceID = 2;
+
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newConverter( _)).Times(3);
+
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
ASSERT_EQ(E_OK,pDatabaseHandler.enterConverterDB(gateway,gatewayID))
@@ -2015,6 +2093,11 @@ TEST_F(CAmMapHandlerTest,getGatewayInfo)
pCF.createSource(source);
sink.sinkID = 1;
source.sourceID = 2;
+
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newGateway( _)).Times(3);
+
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
ASSERT_EQ(E_OK,pDatabaseHandler.enterGatewayDB(gateway,gatewayID))
@@ -2079,6 +2162,9 @@ TEST_F(CAmMapHandlerTest,getConverterInfo)
pCF.createSource(source);
sink.sinkID = 1;
source.sourceID = 2;
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newConverter( _)).Times(3);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
ASSERT_EQ(E_OK,pDatabaseHandler.enterConverterDB(gateway,gatewayID))
@@ -2133,8 +2219,8 @@ TEST_F(CAmMapHandlerTest,enterSinkThatAlreadyExistFail)
pCF.createSink(staticSink);
staticSink.sinkID = 43;
staticSink.name = "Static";
-
-
+
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))
<< "ERROR: database error";
ASSERT_EQ(staticSink.sinkID,staticSinkID)
@@ -2156,6 +2242,7 @@ TEST_F(CAmMapHandlerTest,enterSourcesThatAlreadyExistFail)
pCF.createSource(staticSource);
staticSource.sourceID = 4;
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(staticSource,staticSourceID))
<< "ERROR: database error";
@@ -2176,6 +2263,8 @@ TEST_F(CAmMapHandlerTest,registerDomainCorrect)
am_Domain_s domain;
am_domainID_t domainID = 0;
pCF.createDomain(domain);
+
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newDomain( _)).Times(1);
ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))
<< "ERROR: database error";
@@ -2204,6 +2293,7 @@ TEST_F(CAmMapHandlerTest,registerDomainPredefined)
am_domainID_t domainID = 10;
pCF.createDomain(domain);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newDomain( _)).Times(1);
ASSERT_EQ(E_OK,pDatabaseHandler.enterDomainDB(domain,domainID))
<< "ERROR: database error";
ASSERT_NE(10,domainID)
@@ -2240,11 +2330,14 @@ TEST_F(CAmMapHandlerTest,registerConnectionCorrect)
sink.sinkID=connection.sinkID;
pCF.createSource(source);
source.sourceID=connection.sourceID;
+
+
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
+
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(sink,sinkID));
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(source,sourceID));
-
-
ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,connectionID))
<< "ERROR: database error";
ASSERT_NE(0,connectionID)
@@ -2283,6 +2376,7 @@ TEST_F(CAmMapHandlerTest,enterSinksCorrect)
pCF.createSink(staticSink);
staticSink.sinkID = 4;
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(3);
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(staticSink,staticSinkID))
<< "ERROR: database error";
@@ -2341,6 +2435,7 @@ TEST_F(CAmMapHandlerTest,enterNotificationConfigurationCorrect)
notify.status=NS_CHANGE;
notify.parameter=25;
testSinkData.listNotificationConfigurations.push_back(notify);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
//enter the sink in the database
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(testSinkData,sinkID))
@@ -2377,6 +2472,7 @@ TEST_F(CAmMapHandlerTest,enterMainNotificationConfigurationCorrect)
notify.parameter=25;
testSinkData.listMainNotificationConfigurations.push_back(notify);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
//enter the sink in the database
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(testSinkData,sinkID))
@@ -2405,8 +2501,10 @@ TEST_F(CAmMapHandlerTest,removeNotificationsSink)
notify.parameter=25;
testSinkData.listMainNotificationConfigurations.push_back(notify);
-
- //enter the sink in the database
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), removedSink(_, _)).Times(1);
+
+ //enter the sink in the database
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(testSinkData,sinkID))
<< "ERROR: database error";
@@ -2437,6 +2535,9 @@ TEST_F(CAmMapHandlerTest,removeNotificationsSource)
testSourceData.listMainNotificationConfigurations.push_back(notify);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), removedSource(_, _)).Times(1);
+
//enter the sink in the database
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(testSourceData,sourceID))
<< "ERROR: database error";
@@ -2475,7 +2576,7 @@ TEST_F(CAmMapHandlerTest,getMainNotificationsSink)
notify1.parameter=5;
testSinkData.listMainNotificationConfigurations.push_back(notify1);
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
//enter the sink in the database
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(testSinkData,sinkID))
<< "ERROR: database error";
@@ -2510,7 +2611,7 @@ TEST_F(CAmMapHandlerTest,getMainNotificationsSources)
notify1.parameter=5;
testSourceData.listMainNotificationConfigurations.push_back(notify1);
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
//enter the sink in the database
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(testSourceData,sourceID))
<< "ERROR: database error";
@@ -2531,7 +2632,8 @@ TEST_F(CAmMapHandlerTest,changeMainNotificationsSources)
am_sourceID_t sourceID;
std::vector<am_Source_s> listSources;
std::vector<am_NotificationConfiguration_s>returnList,returnList1;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), sourceMainNotificationConfigurationChanged(_, _)).Times(1);
//enter the sink in the database
ASSERT_EQ(E_OK,pDatabaseHandler.enterSourceDB(testSourceData,sourceID))
<< "ERROR: database error";
@@ -2572,7 +2674,8 @@ TEST_F(CAmMapHandlerTest,changeMainNotificationsSink)
am_sinkID_t sinkID;
std::vector<am_Sink_s> listSinks;
std::vector<am_NotificationConfiguration_s>returnList,returnList1;
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), sinkMainNotificationConfigurationChanged(_, _)).Times(1);
//enter the sink in the database
ASSERT_EQ(E_OK,pDatabaseHandler.enterSinkDB(testSinkData,sinkID))
<< "ERROR: database error";
@@ -2617,7 +2720,7 @@ TEST_F(CAmMapHandlerTest, peekDomain_2)
ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains));
ASSERT_TRUE(listDomains.size()==1);
ASSERT_EQ(domainID, DYNAMIC_ID_BOUNDARY);
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newDomain( _)).Times(2);
domain2.name = "anotherdomain";
ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domain2ID));
ASSERT_EQ(E_OK, pDatabaseHandler.getListDomains(listDomains));
@@ -2654,6 +2757,8 @@ TEST_F(CAmMapHandlerTest, connectionIDBoundary)
source.sourceID = 0;
source.name = "source" + int2string(i);
source.domainID = 4;
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, forgetSink));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, forgetSource));
connection.sinkID = forgetSink;
@@ -2683,6 +2788,8 @@ TEST_F(CAmMapHandlerTest, connectionIDBoundary)
sink.name="77";
source.sourceID=77;
source.name="77";
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, forgetSink));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, forgetSource));
ASSERT_EQ(E_OK, pDatabaseHandler.enterConnectionDB(connection,connectionID));
@@ -2713,16 +2820,18 @@ TEST_F(CAmMapHandlerTest, mainConnectionIDBoundary)
source.sourceID = 0;
source.name = "source" + int2string(i);
source.domainID = 4;
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, forgetSink));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, forgetSource));
connection.sinkID = forgetSink;
connection.sourceID = forgetSource;
if( i < TEST_MAX_CONNECTION_ID )
{
- ASSERT_EQ(E_OK, pDatabaseHandler.enterConnectionDB(connection,connectionID));
- ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionFinal(connectionID));
- ASSERT_EQ(i, connectionID);
- connectionIDList.push_back(i);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterConnectionDB(connection,connectionID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeConnectionFinal(connectionID));
+ ASSERT_EQ(i, connectionID);
+ connectionIDList.push_back(i);
}
}
std::vector<am_Connection_s> connectionList;
@@ -2744,9 +2853,16 @@ TEST_F(CAmMapHandlerTest, mainConnectionIDBoundary)
{
mainConnection.sinkID = DYNAMIC_ID_BOUNDARY + i;
mainConnection.sourceID = DYNAMIC_ID_BOUNDARY + i;
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newMainConnection( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), mainConnectionStateChanged(_, _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), timingInformationChanged(_, _)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterMainConnectionDB(mainConnection,mainConnectionID));
ASSERT_EQ(i, mainConnectionID);
}
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newMainConnection( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), timingInformationChanged(_, _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), removedMainConnection(_)).Times(2);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), mainConnectionStateChanged(_, _)).Times(3);
ASSERT_EQ(E_OK, pDatabaseHandler.removeMainConnectionDB(10));
ASSERT_EQ(E_OK, pDatabaseHandler.removeMainConnectionDB(12));
ASSERT_EQ(E_OK, pDatabaseHandler.enterMainConnectionDB(mainConnection,mainConnectionID));
@@ -2757,6 +2873,11 @@ TEST_F(CAmMapHandlerTest, mainConnectionIDBoundary)
sink.name="77";
source.sourceID=77;
source.name="77";
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newMainConnection( _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), timingInformationChanged(_, _)).Times(1);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), mainConnectionStateChanged(_, _)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, forgetSink));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source, forgetSource));
ASSERT_EQ(E_OK, pDatabaseHandler.enterMainConnectionDB(mainConnection,mainConnectionID));
@@ -2775,11 +2896,12 @@ TEST_F(CAmMapHandlerTest, increaseID)
sink.sinkID = 0;
sink.name = "sink" + int2string(i);
sink.domainID = 4;
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink( _)).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink, sinkID));
ASSERT_EQ(DYNAMIC_ID_BOUNDARY+i, sinkID);
}
ASSERT_EQ(E_UNKNOWN, pDatabaseHandler.enterSinkDB(sink, sinkID));
-
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), removedSink(_,_)).Times(2);
ASSERT_EQ(E_OK, pDatabaseHandler.removeSinkDB(DYNAMIC_ID_BOUNDARY+10));
ASSERT_EQ(E_OK, pDatabaseHandler.removeSinkDB(DYNAMIC_ID_BOUNDARY+12));
@@ -2788,17 +2910,6 @@ TEST_F(CAmMapHandlerTest, increaseID)
ASSERT_EQ(E_UNKNOWN, pDatabaseHandler.enterSinkDB(sink, sinkID));
}
-
-CAmMapHandlerObserverCallbacksTest::CAmMapHandlerObserverCallbacksTest() :
- mMockObserver(&pCommandSender, &pRoutingSender, &pSocketHandler)
-{
- pDatabaseHandler.registerObserver(&mMockObserver);
-}
-
-CAmMapHandlerObserverCallbacksTest::~CAmMapHandlerObserverCallbacksTest()
-{
-}
-
MATCHER_P(IsDomainDataEqualTo, value, "") {
auto lh = arg;
return lh.domainID == value.domainID &&
@@ -2809,7 +2920,30 @@ MATCHER_P(IsDomainDataEqualTo, value, "") {
lh.state == value.state;
}
-TEST_F(CAmMapHandlerObserverCallbacksTest, peek_enter_removeDomain)
+TEST_F(CAmMapHandlerTest, dbo_addAndRemoveObservers)
+{
+ CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks observer1;
+ CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks observer2;
+ ASSERT_EQ(pDatabaseHandler.registerObserver(&observer1), true);
+ ASSERT_EQ(pDatabaseHandler.countObservers(), 2);
+ ASSERT_EQ(pDatabaseHandler.registerObserver(&observer2), true);
+ ASSERT_EQ(pDatabaseHandler.countObservers(), 3);
+
+ pDatabaseHandler.unregisterObserver(&observer1);
+ ASSERT_EQ(pDatabaseHandler.countObservers(), 2);
+ pDatabaseHandler.unregisterObserver(&observer2);
+ ASSERT_EQ(pDatabaseHandler.countObservers(), 1);
+ pDatabaseHandler.unregisterObserver(&observer2);
+ ASSERT_EQ(pDatabaseHandler.countObservers(), 1);
+
+ ASSERT_EQ(pDatabaseHandler.registerObserver(&observer2), true);
+ ASSERT_EQ(pDatabaseHandler.registerObserver(&observer2), false);
+ ASSERT_EQ(pDatabaseHandler.countObservers(), 2);
+ pDatabaseHandler.unregisterObserver(&observer2);
+ ASSERT_EQ(pDatabaseHandler.countObservers(), 1);
+}
+
+TEST_F(CAmMapHandlerTest, dbo_peek_enter_removeDomain)
{
std::vector<am_Domain_s> listDomains;
am_Domain_s domain;
@@ -2844,7 +2978,7 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, peek_enter_removeDomain)
EXPECT_TRUE(Mock::VerifyAndClearExpectations(MockDatabaseObserver::getMockObserverObject()));
}
-TEST_F(CAmMapHandlerObserverCallbacksTest, peek_enter_update_removeSource)
+TEST_F(CAmMapHandlerTest, dbo_peek_enter_update_removeSource)
{
std::vector<am_Source_s> listSources;
am_sourceID_t sourceID;
@@ -2909,7 +3043,7 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, peek_enter_update_removeSource)
EXPECT_TRUE(Mock::VerifyAndClearExpectations(MockDatabaseObserver::getMockObserverObject()));
}
-TEST_F(CAmMapHandlerObserverCallbacksTest, peek_enter_update_removeSink)
+TEST_F(CAmMapHandlerTest, dbo_peek_enter_update_removeSink)
{
std::vector<am_Sink_s> listSinks;
am_sinkID_t sinkID;
@@ -2973,7 +3107,7 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, peek_enter_update_removeSink)
EXPECT_TRUE(Mock::VerifyAndClearExpectations(MockDatabaseObserver::getMockObserverObject()));
}
-TEST_F(CAmMapHandlerObserverCallbacksTest, peekSourceClassID)
+TEST_F(CAmMapHandlerTest, dbo_peekSourceClassID)
{
std::string sourceName("myClassID");
am_sourceClass_t sourceClassID, peekID;
@@ -2989,7 +3123,7 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, peekSourceClassID)
ASSERT_EQ(E_NON_EXISTENT, pDatabaseHandler.peekSourceClassID(sourceName,sourceClassID));
//now we enter the class into the database
- EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), numberOfSourceClassesChanged()).Times(13);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), numberOfSourceClassesChanged()).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceClassDB(sourceClassID,sourceClass));
//first we peek without an existing class
@@ -2997,7 +3131,7 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, peekSourceClassID)
ASSERT_EQ(sourceClassID, peekID);
}
-TEST_F(CAmMapHandlerObserverCallbacksTest, peekSinkClassID)
+TEST_F(CAmMapHandlerTest, dbo_peekSinkClassID)
{
std::string sinkName("myClassID");
am_sinkClass_t sinkClassID, peekID;
@@ -3013,7 +3147,7 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, peekSinkClassID)
ASSERT_EQ(E_NON_EXISTENT, pDatabaseHandler.peekSinkClassID(sinkName,sinkClassID));
//now we enter the class into the database
- EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), numberOfSinkClassesChanged()).Times(12);
+ EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), numberOfSinkClassesChanged()).Times(1);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkClassDB(sinkClass,sinkClassID));
//first we peek without an existing class
@@ -3021,7 +3155,7 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, peekSinkClassID)
ASSERT_EQ(sinkClassID, peekID);
}
-TEST_F(CAmMapHandlerObserverCallbacksTest, enter_removeGateway)
+TEST_F(CAmMapHandlerTest, dbo_enter_removeGateway)
{
//initialize gateway
std::vector<am_Gateway_s> returnList;
@@ -3056,7 +3190,7 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, enter_removeGateway)
ASSERT_EQ(E_OK,pDatabaseHandler.removeGatewayDB(gatewayID2))<< "ERROR: database error";
}
-TEST_F(CAmMapHandlerObserverCallbacksTest, enter_removeConverter)
+TEST_F(CAmMapHandlerTest, dbo_enter_removeConverter)
{
//initialize gateway
std::vector<am_Converter_s> returnList;
@@ -3091,7 +3225,7 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, enter_removeConverter)
ASSERT_EQ(E_OK,pDatabaseHandler.removeConverterDB(gatewayID2))<< "ERROR: database error";
}
-TEST_F(CAmMapHandlerObserverCallbacksTest, enter_removeCrossfader)
+TEST_F(CAmMapHandlerTest, dbo_enter_removeCrossfader)
{
am_Crossfader_s crossfader;
am_crossfaderID_t crossfaderID;
@@ -3125,19 +3259,11 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, enter_removeCrossfader)
ASSERT_EQ(E_OK,pDatabaseHandler.removeCrossfaderDB(crossfaderID))<< "ERROR: database error";
}
-TEST_F(CAmMapHandlerObserverCallbacksTest, enter_update_removeMainConnection)
+TEST_F(CAmMapHandlerTest, dbo_enter_update_removeMainConnection)
{
am_mainConnectionID_t mainConnectionID;
am_MainConnection_s mainConnection;
- EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSink(_)).Times(9);
- EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newSource(_)).Times(9);
- EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), newMainConnection(Field(&am_MainConnectionType_s::mainConnectionID, 1))).Times(1);
- EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), mainConnectionStateChanged(1, CS_CONNECTED)).Times(1);
-#ifndef WITH_DATABASE_CHANGE_CHECK
- EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), timingInformationChanged(1, _)).Times(1);
-#else
- EXPECT_CALL(*MockDatabaseObserver::getMockObserverObject(), timingInformationChanged(1, _)).Times(0);
-#endif
+
createMainConnectionSetup(mainConnectionID, mainConnection);
//change delay of first connection
@@ -3161,7 +3287,7 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, enter_update_removeMainConnection)
ASSERT_EQ(E_OK,pDatabaseHandler.removeMainConnectionDB(mainConnectionID)) << "ERROR: database error";
}
-TEST_F(CAmMapHandlerObserverCallbacksTest, changeSinkAvailability)
+TEST_F(CAmMapHandlerTest, dbo_changeSinkAvailability)
{
std::vector<am_Sink_s> listSinks;
am_Sink_s sink;
@@ -3187,7 +3313,7 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, changeSinkAvailability)
#endif
}
-TEST_F(CAmMapHandlerObserverCallbacksTest, changeSourceAvailability)
+TEST_F(CAmMapHandlerTest, dbo_changeSourceAvailability)
{
std::vector<am_Source_s> listSources;
am_Source_s source;
@@ -3214,7 +3340,7 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, changeSourceAvailability)
#endif
}
-TEST_F(CAmMapHandlerObserverCallbacksTest,changeMainSinkVolume)
+TEST_F(CAmMapHandlerTest, dbo_changeMainSinkVolume)
{
am_Sink_s sink;
am_sinkID_t sinkID;
@@ -3236,7 +3362,7 @@ TEST_F(CAmMapHandlerObserverCallbacksTest,changeMainSinkVolume)
#endif
}
-TEST_F(CAmMapHandlerObserverCallbacksTest, changeSinkMuteState)
+TEST_F(CAmMapHandlerTest, dbo_changeSinkMuteState)
{
std::vector<am_Sink_s> listSinks;
am_Sink_s sink;
@@ -3258,7 +3384,7 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, changeSinkMuteState)
#endif
}
-TEST_F(CAmMapHandlerObserverCallbacksTest, changeSystemProperty)
+TEST_F(CAmMapHandlerTest, dbo_changeSystemProperty)
{
std::vector<am_SystemProperty_s> listSystemProperties, listReturn;
am_SystemProperty_s systemProperty;
@@ -3282,7 +3408,7 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, changeSystemProperty)
#endif
}
-TEST_F(CAmMapHandlerObserverCallbacksTest, changeMainNotificationsSink)
+TEST_F(CAmMapHandlerTest, dbo_changeMainNotificationsSink)
{
am_Sink_s testSinkData;
pCF.createSink(testSinkData);
@@ -3329,7 +3455,7 @@ TEST_F(CAmMapHandlerObserverCallbacksTest, changeMainNotificationsSink)
ASSERT_EQ(E_OK,pDatabaseHandler.changeMainSinkNotificationConfigurationDB(sinkID,notify2));
}
-TEST_F(CAmMapHandlerObserverCallbacksTest, changeMainNotificationsSources)
+TEST_F(CAmMapHandlerTest, dbo_changeMainNotificationsSources)
{
am_Source_s testSourceData;
diff --git a/AudioManagerCore/test/AmMapHandlerTest/CAmMapHandlerTest.h b/AudioManagerCore/test/AmMapHandlerTest/CAmMapHandlerTest.h
index e3cc0ef..32add3d 100644
--- a/AudioManagerCore/test/AmMapHandlerTest/CAmMapHandlerTest.h
+++ b/AudioManagerCore/test/AmMapHandlerTest/CAmMapHandlerTest.h
@@ -33,16 +33,17 @@
#include "CAmDatabaseHandlerMap.h"
#include "CAmControlReceiver.h"
#include "CAmControlSender.h"
-#include "CAmDatabaseObserver.h"
+#include "CAmTestDatabaseObserver.h"
#include "CAmRoutingSender.h"
#include "CAmRouter.h"
#include "CAmControlSender.h"
+#include "MockDatabaseObserver.h"
#include "../IAmControlBackdoor.h"
#include "../IAmCommandBackdoor.h"
#include "../CAmCommonFunctions.h"
#include "../MockIAmControlSend.h"
#include "../MockIAmCommandSend.h"
-#include "MockDatabaseObserver.h"
+
namespace am
{
@@ -50,15 +51,15 @@ namespace am
class CAmMapBasicTest : public ::testing::Test
{
public:
- CAmMapBasicTest();
+ CAmMapBasicTest();
~CAmMapBasicTest();
+ CAmSocketHandler pSocketHandler;
std::vector<std::string> plistRoutingPluginDirs;
std::vector<std::string> plistCommandPluginDirs;
CAmRoutingSender pRoutingSender;
CAmCommandSender pCommandSender;
IAmRoutingBackdoor pRoutingInterfaceBackdoor;
IAmCommandBackdoor pCommandInterfaceBackdoor;
- CAmSocketHandler pSocketHandler;
CAmDatabaseHandlerMap pDatabaseHandler;
CAmControlSender pControlSender;
CAmRouter pRouter;
@@ -75,18 +76,9 @@ public:
CAmMapHandlerTest();
~CAmMapHandlerTest();
MockIAmCommandSend pMockInterface;
- CAmDatabaseObserver pObserver;
+ CAmDatabaseObserver mMockObserver;
};
-class CAmMapHandlerObserverCallbacksTest : public CAmMapBasicTest
-{
-public:
- CAmMapHandlerObserverCallbacksTest();
- ~CAmMapHandlerObserverCallbacksTest();
- CAmDatabaseObserver mMockObserver;
-};
-
-
}
#endif /* MAPHANDLERTEST_H_ */
diff --git a/AudioManagerCore/test/AmMapHandlerTest/CAmTestDatabaseObserver.cpp b/AudioManagerCore/test/AmMapHandlerTest/CAmTestDatabaseObserver.cpp
index a035cee..ddf0abb 100644
--- a/AudioManagerCore/test/AmMapHandlerTest/CAmTestDatabaseObserver.cpp
+++ b/AudioManagerCore/test/AmMapHandlerTest/CAmTestDatabaseObserver.cpp
@@ -21,78 +21,75 @@
*
*/
-#include "CAmDatabaseObserver.h"
+#include "CAmTestDatabaseObserver.h"
#include "MockDatabaseObserver.h"
namespace am {
-CAmDatabaseObserver::CAmDatabaseObserver(CAmCommandSender *iCommandSender, CAmRoutingSender *iRoutingSender, CAmSocketHandler *iSocketHandler) :
-mCommandSender(iCommandSender), //
-mRoutingSender(iRoutingSender), //
-mTelnetServer(NULL), //
-mSerializer(iSocketHandler) //
-{}
+CAmDatabaseObserver::CAmDatabaseObserver()
+{
+ dboNumberOfSinkClassesChanged = [&]()
+ { MockDatabaseObserver::getMockObserverObject()->numberOfSinkClassesChanged(); };
+ dboNumberOfSourceClassesChanged = [&]()
+ { MockDatabaseObserver::getMockObserverObject()->numberOfSourceClassesChanged(); };
+ dboNewSink = [&](const am_Sink_s& sink)
+ { MockDatabaseObserver::getMockObserverObject()->newSink(sink); };
+ dboNewSource = [&](const am_Source_s& source)
+ { MockDatabaseObserver::getMockObserverObject()->newSource(source); };
+ dboNewDomain = [&](const am_Domain_s& domain)
+ { MockDatabaseObserver::getMockObserverObject()->newDomain(domain); };
+ dboNewGateway = [&](const am_Gateway_s& gateway)
+ { MockDatabaseObserver::getMockObserverObject()->newGateway(gateway); };
+ dboNewConverter = [&](const am_Converter_s& coverter)
+ { MockDatabaseObserver::getMockObserverObject()->newConverter(coverter); };
+ dboNewCrossfader = [&](const am_Crossfader_s& crossfader)
+ { MockDatabaseObserver::getMockObserverObject()->newCrossfader(crossfader); };
+ dboNewMainConnection = [&](const am_MainConnectionType_s& mainConnection)
+ { MockDatabaseObserver::getMockObserverObject()->newMainConnection(mainConnection); };
+ dboRemovedMainConnection = [&](const am_mainConnectionID_t mainConnection)
+ { MockDatabaseObserver::getMockObserverObject()->removedMainConnection(mainConnection); };
+ dboRemovedSink = [&](const am_sinkID_t sinkID, const bool visible)
+ { MockDatabaseObserver::getMockObserverObject()->removedSink(sinkID, visible); };
+ dboRemovedSource = [&](const am_sourceID_t sourceID, const bool visible)
+ { MockDatabaseObserver::getMockObserverObject()->removedSource(sourceID, visible); };
+ dboRemoveDomain = [&](const am_domainID_t domainID)
+ { MockDatabaseObserver::getMockObserverObject()->removeDomain(domainID); };
+ dboRemoveGateway = [&](const am_gatewayID_t gatewayID)
+ { MockDatabaseObserver::getMockObserverObject()->removeGateway(gatewayID); };
+ dboRemoveConverter = [&](const am_converterID_t converterID)
+ { MockDatabaseObserver::getMockObserverObject()->removeConverter(converterID); };
+ dboRemoveCrossfader = [&](const am_crossfaderID_t crossfaderID)
+ { MockDatabaseObserver::getMockObserverObject()->removeCrossfader(crossfaderID); };
+ dboMainConnectionStateChanged = [&](const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState)
+ { MockDatabaseObserver::getMockObserverObject()->mainConnectionStateChanged(connectionID, connectionState); };
+ dboMainSinkSoundPropertyChanged = [&](const am_sinkID_t sinkID, const am_MainSoundProperty_s& SoundProperty)
+ { MockDatabaseObserver::getMockObserverObject()->mainSinkSoundPropertyChanged(sinkID, SoundProperty); };
+ dboMainSourceSoundPropertyChanged = [&](const am_sourceID_t sourceID, const am_MainSoundProperty_s& SoundProperty)
+ { MockDatabaseObserver::getMockObserverObject()->mainSourceSoundPropertyChanged(sourceID, SoundProperty); };
+ dboSinkAvailabilityChanged = [&](const am_sinkID_t sinkID, const am_Availability_s& availability)
+ { MockDatabaseObserver::getMockObserverObject()->sinkAvailabilityChanged(sinkID, availability); };
+ dboSourceAvailabilityChanged = [&](const am_sourceID_t sourceID, const am_Availability_s& availability)
+ { MockDatabaseObserver::getMockObserverObject()->sourceAvailabilityChanged(sourceID, availability); };
+ dboVolumeChanged = [&](const am_sinkID_t sinkID, const am_mainVolume_t volume)
+ { MockDatabaseObserver::getMockObserverObject()->volumeChanged(sinkID, volume); };
+ dboSinkMuteStateChanged = [&](const am_sinkID_t sinkID, const am_MuteState_e muteState)
+ { MockDatabaseObserver::getMockObserverObject()->sinkMuteStateChanged(sinkID, muteState); };
+ dboSystemPropertyChanged = [&](const am_SystemProperty_s& SystemProperty)
+ { MockDatabaseObserver::getMockObserverObject()->systemPropertyChanged(SystemProperty); };
+ dboTimingInformationChanged = [&](const am_mainConnectionID_t mainConnection, const am_timeSync_t time)
+ { MockDatabaseObserver::getMockObserverObject()->timingInformationChanged(mainConnection,time); };
+ dboSinkUpdated = [&](const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties, const bool visible)
+ { MockDatabaseObserver::getMockObserverObject()->sinkUpdated(sinkID,sinkClassID,listMainSoundProperties, visible); };
+ dboSourceUpdated = [&](const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties, const bool visible)
+ { MockDatabaseObserver::getMockObserverObject()->sourceUpdated(sourceID,sourceClassID,listMainSoundProperties, visible); };
+ dboSinkMainNotificationConfigurationChanged = [&](const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration)
+ { MockDatabaseObserver::getMockObserverObject()->sinkMainNotificationConfigurationChanged(sinkID,mainNotificationConfiguration); };
+ dboSourceMainNotificationConfigurationChanged = [&](const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration)
+ { MockDatabaseObserver::getMockObserverObject()->sourceMainNotificationConfigurationChanged(sourceID,mainNotificationConfiguration); };
-CAmDatabaseObserver::~CAmDatabaseObserver() {}
+}
+CAmDatabaseObserver::~CAmDatabaseObserver() {}
-void CAmDatabaseObserver::numberOfSinkClassesChanged()
-{ MockDatabaseObserver::getMockObserverObject()->numberOfSinkClassesChanged(); }
-void CAmDatabaseObserver::numberOfSourceClassesChanged()
-{ MockDatabaseObserver::getMockObserverObject()->numberOfSourceClassesChanged(); }
-void CAmDatabaseObserver::newSink(const am_Sink_s& sink)
-{ MockDatabaseObserver::getMockObserverObject()->newSink(sink); }
-void CAmDatabaseObserver::newSource(const am_Source_s& source)
-{ MockDatabaseObserver::getMockObserverObject()->newSource(source); }
-void CAmDatabaseObserver::newDomain(const am_Domain_s& domain)
-{ MockDatabaseObserver::getMockObserverObject()->newDomain(domain); }
-void CAmDatabaseObserver::newGateway(const am_Gateway_s& gateway)
-{ MockDatabaseObserver::getMockObserverObject()->newGateway(gateway); }
-void CAmDatabaseObserver::newConverter(const am_Converter_s& coverter)
-{ MockDatabaseObserver::getMockObserverObject()->newConverter(coverter); }
-void CAmDatabaseObserver::newCrossfader(const am_Crossfader_s& crossfader)
-{ MockDatabaseObserver::getMockObserverObject()->newCrossfader(crossfader); }
-void CAmDatabaseObserver::newMainConnection(const am_MainConnectionType_s& mainConnection)
-{ MockDatabaseObserver::getMockObserverObject()->newMainConnection(mainConnection); }
-void CAmDatabaseObserver::removedMainConnection(const am_mainConnectionID_t mainConnection)
-{ MockDatabaseObserver::getMockObserverObject()->removedMainConnection(mainConnection); }
-void CAmDatabaseObserver::removedSink(const am_sinkID_t sinkID, const bool visible)
-{ MockDatabaseObserver::getMockObserverObject()->removedSink(sinkID, visible); }
-void CAmDatabaseObserver::removedSource(const am_sourceID_t sourceID, const bool visible)
-{ MockDatabaseObserver::getMockObserverObject()->removedSource(sourceID, visible); }
-void CAmDatabaseObserver::removeDomain(const am_domainID_t domainID)
-{ MockDatabaseObserver::getMockObserverObject()->removeDomain(domainID); }
-void CAmDatabaseObserver::removeGateway(const am_gatewayID_t gatewayID)
-{ MockDatabaseObserver::getMockObserverObject()->removeGateway(gatewayID); }
-void CAmDatabaseObserver::removeConverter(const am_converterID_t converterID)
-{ MockDatabaseObserver::getMockObserverObject()->removeConverter(converterID); }
-void CAmDatabaseObserver::removeCrossfader(const am_crossfaderID_t crossfaderID)
-{ MockDatabaseObserver::getMockObserverObject()->removeCrossfader(crossfaderID); }
-void CAmDatabaseObserver::mainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState)
-{ MockDatabaseObserver::getMockObserverObject()->mainConnectionStateChanged(connectionID, connectionState); }
-void CAmDatabaseObserver::mainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s& SoundProperty)
-{ MockDatabaseObserver::getMockObserverObject()->mainSinkSoundPropertyChanged(sinkID, SoundProperty); }
-void CAmDatabaseObserver::mainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s& SoundProperty)
-{ MockDatabaseObserver::getMockObserverObject()->mainSourceSoundPropertyChanged(sourceID, SoundProperty); }
-void CAmDatabaseObserver::sinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s& availability)
-{ MockDatabaseObserver::getMockObserverObject()->sinkAvailabilityChanged(sinkID, availability); }
-void CAmDatabaseObserver::sourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s& availability)
-{ MockDatabaseObserver::getMockObserverObject()->sourceAvailabilityChanged(sourceID, availability); }
-void CAmDatabaseObserver::volumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume)
-{ MockDatabaseObserver::getMockObserverObject()->volumeChanged(sinkID, volume); }
-void CAmDatabaseObserver::sinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState)
-{ MockDatabaseObserver::getMockObserverObject()->sinkMuteStateChanged(sinkID, muteState); }
-void CAmDatabaseObserver::systemPropertyChanged(const am_SystemProperty_s& SystemProperty)
-{ MockDatabaseObserver::getMockObserverObject()->systemPropertyChanged(SystemProperty); }
-void CAmDatabaseObserver::timingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time)
-{ MockDatabaseObserver::getMockObserverObject()->timingInformationChanged(mainConnection,time); }
-void CAmDatabaseObserver::sinkUpdated(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties, const bool visible)
-{ MockDatabaseObserver::getMockObserverObject()->sinkUpdated(sinkID,sinkClassID,listMainSoundProperties, visible); }
-void CAmDatabaseObserver::sourceUpdated(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties, const bool visible)
-{ MockDatabaseObserver::getMockObserverObject()->sourceUpdated(sourceID,sourceClassID,listMainSoundProperties, visible); }
-void CAmDatabaseObserver::sinkMainNotificationConfigurationChanged(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration)
-{ MockDatabaseObserver::getMockObserverObject()->sinkMainNotificationConfigurationChanged(sinkID,mainNotificationConfiguration); }
-void CAmDatabaseObserver::sourceMainNotificationConfigurationChanged(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration)
-{ MockDatabaseObserver::getMockObserverObject()->sourceMainNotificationConfigurationChanged(sourceID,mainNotificationConfiguration); }
}
diff --git a/AudioManagerCore/test/AmMapHandlerTest/CAmTestDatabaseObserver.h b/AudioManagerCore/test/AmMapHandlerTest/CAmTestDatabaseObserver.h
new file mode 100644
index 0000000..12ba32e
--- /dev/null
+++ b/AudioManagerCore/test/AmMapHandlerTest/CAmTestDatabaseObserver.h
@@ -0,0 +1,53 @@
+/**
+ * SPDX license identifier: MPL-2.0
+ *
+ * Copyright (C) 2012, BMW AG
+ *
+ * This file is part of GENIVI Project AudioManager.
+ *
+ * Contributions are licensed to the GENIVI Alliance under one or more
+ * Contribution License Agreements.
+ *
+ * \copyright
+ * This Source Code Form is subject to the terms of the
+ * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
+ * this file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ *
+ * \author Christian Linke, christian.linke@bmw.de BMW 2011,2012
+ *
+ * \file CAmDatabaseObserver.h
+ * For further information see http://www.genivi.org/.
+ *
+ */
+
+#ifndef DATABASEOBSERVER_H_
+#define DATABASEOBSERVER_H_
+
+#include "audiomanagertypes.h"
+#include <queue>
+#include <vector>
+#include <functional>
+#include "CAmDatabaseHandlerMap.h"
+
+
+namespace am
+{
+
+
+/**
+ * This class observes the Database and notifies other classes about important events, mainly the CommandSender.
+ */
+
+class CAmDatabaseObserver: public CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks
+{
+public:
+ explicit CAmDatabaseObserver();
+ ~CAmDatabaseObserver();
+
+private:
+};
+
+}
+
+#endif /* DATABASEOBSERVER_H_ */
diff --git a/AudioManagerCore/test/AmMapHandlerTest/MockDatabaseObserver.h b/AudioManagerCore/test/AmMapHandlerTest/MockDatabaseObserver.h
index da1b3b4..82e1ea4 100644
--- a/AudioManagerCore/test/AmMapHandlerTest/MockDatabaseObserver.h
+++ b/AudioManagerCore/test/AmMapHandlerTest/MockDatabaseObserver.h
@@ -27,7 +27,7 @@
#include "gtest/gtest.h"
#include "gmock/gmock.h"
-#include "CAmDatabaseObserver.h"
+#include "CAmTestDatabaseObserver.h"
class CAmCommandSender;
class CAmRoutingSender;
diff --git a/AudioManagerCore/test/AmRouterMapTest/CAmRouterMapTest.cpp b/AudioManagerCore/test/AmRouterMapTest/CAmRouterMapTest.cpp
index 465995f..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), //
- pMockInterface(), //
- pMockControlInterface(), //
- pRoutingInterfaceBackdoor(), //
- pCommandInterfaceBackdoor(), //
- pControlInterfaceBackdoor(), //
- pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender,&pSocketHandler, &pRouter), //
- pObserver(&pCommandSender, &pRoutingSender, &pSocketHandler)
+ 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(&pObserver);
- 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,152 +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));
}
-void CAmRouterMapTest::getRoute(const bool onlyfree, const am_Source_s & aSource, const am_Sink_s & aSink, std::vector<am_Route_s> & listRoutes)
+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)
{
- std::ios_base::fmtflags oldflags = std::cout.flags();
- std::streamsize oldprecision = std::cout.precision();
- auto t_start = std::chrono::high_resolution_clock::now();
- ASSERT_EQ(E_OK, pRouter.getRoute(onlyfree, aSource, aSink, listRoutes));
- auto t_end = std::chrono::high_resolution_clock::now();
- std::cout << std::fixed << std::setprecision(2);
- std::cout << "getRoute did find " << 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 getRoute(onlyfree, shouldReload, aSource.sourceID, aSink.sinkID, listRoutes, countCycles, pathsCount);
}
-void CAmRouterMapTest::getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s>& returnList)
+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)
{
- std::ios_base::fmtflags oldflags = std::cout.flags();
- std::streamsize oldprecision = std::cout.precision();
- auto t_start = std::chrono::high_resolution_clock::now();
- ASSERT_EQ(E_OK, pRouter.getRoute(onlyfree, sourceID, sinkID, returnList));
- auto t_end = std::chrono::high_resolution_clock::now();
- std::cout << std::fixed << std::setprecision(2);
- std::cout << "getRoute by id did find " << 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);
+ 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;
}
-void CAmRouterMapTest::getAllPaths(CAmRoutingNode & aSource,
- CAmRoutingNode & aSink,
- std::vector<am_Route_s> & resultPath,
- std::vector<std::vector<CAmRoutingNode*>> & resultNodesPath,
- const bool includeCycles)
+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)
{
- std::ios_base::fmtflags oldflags = std::cout.flags();
- std::streamsize oldprecision = std::cout.precision();
- auto t_start = std::chrono::high_resolution_clock::now();
- ASSERT_EQ(E_OK, pRouter.getAllPaths(aSource, aSink, resultPath, resultNodesPath, includeCycles));
- auto t_end = std::chrono::high_resolution_clock::now();
- std::cout << std::fixed << std::setprecision(2);
- std::cout << "getAllPaths did find " << 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);
+ 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));
- domains.push_back(22);
- ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 22));
- domains.push_back(22);
- ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 22));
- ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 50));
- domains.push_back(30);
- ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 30));
- ASSERT_FALSE(CAmRouter::shouldGoInDomain(domains, 22));
- domains.push_back(30);
- ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 30));
- ASSERT_FALSE(CAmRouter::shouldGoInDomain(domains, 22));
- ASSERT_TRUE(CAmRouter::shouldGoInDomain(domains, 60));
+ 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
@@ -247,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";
@@ -263,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";
@@ -280,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;
@@ -300,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();
- getRoute(true, sourceDb, sinkDb, listRoutes);
- 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
@@ -322,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";
@@ -338,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";
@@ -355,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;
@@ -375,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();
- getRoute(true, sourceDb, sinkDb, listRoutes);
- 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
@@ -402,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";
@@ -426,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";
@@ -450,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;
@@ -468,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;
@@ -498,12 +490,11 @@ TEST_F(CAmRouterMapTest,simpleRoute2DomainsOnlyFree)
pDatabaseHandler.getSinkInfoDB(sinkID, sinkDb);
pDatabaseHandler.getSourceInfoDB(sourceID, sourceDb);
- getRoute(true,sourceID,sinkID,listRoutes);
+ 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)
{
@@ -522,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";
@@ -546,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";
@@ -571,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;
@@ -589,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;
@@ -614,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();
- getRoute(true, sourceDb, sinkDb, listRoutes);
- ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
-
- listRoutes.clear();
- getRoute(false, sourceDb, sinkDb, listRoutes);
- 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)
@@ -660,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";
@@ -691,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";
@@ -723,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;
@@ -753,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;
@@ -780,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();
- getRoute(true, sourceDb, sinkDb, listRoutes);
- 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.
@@ -811,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";
@@ -848,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;
@@ -863,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";
@@ -882,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;
@@ -920,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;
@@ -954,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);
- getRoute(false, sourceDb, sinkDb, listRoutes);
- 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.
@@ -984,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;
@@ -1000,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";
@@ -1019,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";
@@ -1052,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;
@@ -1087,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;
@@ -1121,15 +1110,14 @@ 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);
- getRoute(false, sourceDb, sinkDb, listRoutes);
- 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.
TEST_F(CAmRouterMapTest,simpleRoute3DomainsListConnectionFormats)
{
@@ -1152,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";
@@ -1185,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";
@@ -1219,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;
@@ -1250,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;
@@ -1284,15 +1272,14 @@ 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);
- getRoute(false, sourceDb, sinkDb, listRoutes);
- 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
TEST_F(CAmRouterMapTest,simpleRoute4Domains2Routes)
{
@@ -1319,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";
@@ -1366,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;
@@ -1411,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;
@@ -1468,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;
@@ -1531,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);
- getRoute(false, sourceDb, sinkDb, listRoutes);
- 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);
}
@@ -1570,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;
@@ -1585,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";
@@ -1602,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;
@@ -1617,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";
@@ -1634,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;
@@ -1664,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;
@@ -1698,13 +1687,14 @@ 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();
- getRoute(false, sourceDb, sinkDb, listRoutes);
- 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
TEST_F(CAmRouterMapTest,simpleRoute2Domains)
{
@@ -1723,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;
@@ -1737,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";
@@ -1747,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";
@@ -1772,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;
@@ -1791,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;
@@ -1817,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);
- getRoute(false, sourceDb, sinkDb, listRoutes);
- 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
@@ -1843,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;
@@ -1857,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";
@@ -1867,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";
@@ -1891,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;
@@ -1909,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);
- getRoute(false, sourceDb, sinkDb, listRoutes);
- 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)
@@ -1943,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";
@@ -1975,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";
@@ -2008,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;
@@ -2038,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;
@@ -2072,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();
- getRoute(false, sourceDb, sinkDb, listRoutes);
- 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.
@@ -2107,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";
@@ -2147,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;
@@ -2184,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;
@@ -2229,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;
@@ -2271,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();
- getRoute(false, sourceDb, sinkDb, listRoutes);
- 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;
@@ -2385,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;
- getRoute(false, source, sink, listRoutes);
- 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;
@@ -2463,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;
-
- getRoute(false, source, sink, listRoutes);
- 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);
@@ -2552,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;
-
- getRoute(false, source, sink, listRoutes);
- 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;
@@ -2665,58 +2648,59 @@ TEST_F(CAmRouterMapTest,route2Domains1Source1Sink)
pDatabaseHandler.getSourceInfoDB(sourceID, source);
std::vector<am_Route_s> listRoutes;
- getRoute(false, source, sink, listRoutes);
- 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);
@@ -2727,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);
@@ -2741,65 +2725,67 @@ TEST_F(CAmRouterMapTest,route3Domains1Source1Sink)
std::vector<am_Route_s> listRoutes;
- getRoute(false, source, sink, listRoutes);
- 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";
-
+ 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);
- 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<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);
@@ -2807,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;
@@ -2822,76 +2808,78 @@ TEST_F(CAmRouterMapTest,routeSource1Sink2PathThroughConv1Gate1)
std::vector<am_Route_s> listRoutes;
- getRoute(false, source, sink1, listRoutes);
- 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();
- getRoute(false, source, sink2, listRoutes);
- 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";
+ 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);
- 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<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;
@@ -2900,90 +2888,91 @@ TEST_F(CAmRouterMapTest, routeSource1Sink1PathThroughDomain2)
pDatabaseHandler.getSinkInfoDB(sink1ID, sink1);
pDatabaseHandler.getSourceInfoDB(sourceID, source);
- getRoute(false, source, sink1, listRoutes);
- 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);
- getRoute(false, source, sink2, listRoutes);
- 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;
@@ -2993,112 +2982,113 @@ TEST_F(CAmRouterMapTest, routeSource1Sink1PathThroughGate1Conv2Gate2)
std::vector<am_Route_s> listRoutes;
- getRoute(false, source, sink, listRoutes);
- 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);
- getRoute(false, source, sink1, listRoutes);
-
- 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;
@@ -3107,121 +3097,382 @@ TEST_F(CAmRouterMapTest, routeSource1Sink1PathThroughConv1Gate1Conv2Gate2)
std::vector<am_Route_s> listRoutes;
- getRoute(false, source, sink, listRoutes);
- 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);
- pRouter.getRoute(false, source, sink2, listRoutes);
- 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;
+
+ 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);
+
+ std::vector<am_Route_s> listRoutes;
+
+ am_Route_s compareRoute1;
+ compareRoute1.sinkID = sink1ID;
+ compareRoute1.sourceID = source1ID;
+
+#define DO_ASSERT() \
+ {\
+ bool didMatch = false; \
+ for(auto it = listRoutes.begin(); it!=listRoutes.end(); it++) \
+ didMatch|=pCF.compareRoute(compareRoute1,*it); \
+ ASSERT_TRUE(didMatch); \
+ }
+
+ 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)));
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;
- std::vector<std::vector<CAmRoutingNode*>> resultNodesPath;
-
- 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() \
{\
@@ -3231,132 +3482,75 @@ TEST_F(CAmRouterMapTest,route3Domains1Source1SinkGwCycles)
ASSERT_TRUE(didMatch); \
}
-#ifdef ROUTING_BUILD_CONNECTIONS
- getAllPaths(*sourceNode, *sinkNode, listRoutes, resultNodesPath, true);
- 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()
-#else
- compareRoute1.route.clear();
- compareRoute1.route.push_back({source1ID, gw5SinkID, domain1ID, CF_GENIVI_STEREO});
- compareRoute1.route.push_back({gw5SourceID, sink1ID, domain3ID, CF_GENIVI_STEREO});
-#endif
-
- listRoutes.clear();
- resultNodesPath.clear();
- getAllPaths(*sourceNode, *sinkNode, listRoutes, resultNodesPath, false);
- ASSERT_EQ(static_cast<uint>(1), listRoutes.size());
- 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);
@@ -3365,35 +3559,35 @@ TEST_F(CAmRouterMapTest,route3Domains1Source3Gateways3Convertres1Sink)
am_sourceID_t gwSourceID22;
enterSourceDB("gwSource22", domainID3, cfAuto, gwSourceID22);
- am_sourceID_t gwSourceID5;
- enterSourceDB("gwSource5", domainID3, cfStereo, gwSourceID5);
- am_sinkID_t gwSinkID5;
- enterSinkDB("gwSink5", domainID3, cfAnalog, gwSinkID5);
- am_sourceID_t gwSourceID3;
- enterSourceDB("gwSource3", domainID3, cfAnalog, gwSourceID3);
- am_sinkID_t gwSinkID3;
- enterSinkDB("gwSink3", domainID3, cfAuto, gwSinkID3);
- am_sourceID_t gwSourceID4;
- enterSourceDB("gwSource4", domainID3, cfStereo, gwSourceID4);
- am_sinkID_t gwSinkID4;
- enterSinkDB("gwSink4", domainID3, cfAnalog, gwSinkID4);
- am_sinkID_t sinkID;
- enterSinkDB("sink1", domainID3, cfStereo, sinkID);
-
- std::vector<bool> matrix;
- matrix.push_back(true);
+ 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);
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, gwSourceID3, gwSinkID3, converterID1);
- am_converterID_t converterID2;
- enterConverterDB("converter2", domainID3, cfStereo, cfAnalog, matrix, gwSourceID4, gwSinkID4, converterID2);
- am_converterID_t converterID3;
- enterConverterDB("converter3", domainID3, cfStereo, cfAnalog, matrix, gwSourceID5, gwSinkID5, 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;
@@ -3403,77 +3597,186 @@ TEST_F(CAmRouterMapTest,route3Domains1Source3Gateways3Convertres1Sink)
std::vector<am_Route_s> listRoutes;
- getRoute(false, source, sink, listRoutes);
- 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, gwSinkID3, domainID3, CF_GENIVI_AUTO});
- compareRoute1.route.push_back({gwSourceID3, gwSinkID4, domainID3, CF_GENIVI_ANALOG});
- compareRoute1.route.push_back({gwSourceID4, 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, gwSinkID3, domainID3, CF_GENIVI_AUTO});
- compareRoute2.route.push_back({gwSourceID3, gwSinkID5, domainID3, CF_GENIVI_ANALOG});
- compareRoute2.route.push_back({gwSourceID5, 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, gwSinkID3, domainID3, CF_GENIVI_AUTO});
- compareRoute3.route.push_back({gwSourceID3, gwSinkID4, domainID3, CF_GENIVI_ANALOG});
- compareRoute3.route.push_back({gwSourceID4, 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, gwSinkID3, domainID3, CF_GENIVI_AUTO});
- compareRoute4.route.push_back({gwSourceID3, gwSinkID5, domainID3, CF_GENIVI_ANALOG});
- compareRoute4.route.push_back({gwSourceID5, 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)));
+
+ am_SourceClass_s sourceclass;
+
+ sourceclass.name = "sClass";
+ sourceclass.sourceClassID = 5;
+
+ 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);
+ 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<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_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::am_Source_s source;
+ am::am_Sink_s sink;
+ pDatabaseHandler.getSinkInfoDB(rseLeftID, sink);
+ pDatabaseHandler.getSourceInfoDB(tunerID, source);
+
+ std::vector<am_Route_s> listRoutes;
+ 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 65ff97b..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/.
*
@@ -34,7 +34,6 @@
#include "CAmDatabaseHandlerMap.h"
#include "CAmControlReceiver.h"
#include "CAmControlSender.h"
-#include "CAmDatabaseObserver.h"
#include "CAmRoutingSender.h"
#include "CAmRouter.h"
#include "CAmSocketHandler.h"
@@ -44,64 +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;
- CAmDatabaseObserver pObserver;
- 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);
- void getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s>& returnList);
- void getRoute(const bool onlyfree, const am_Source_s & aSource, const am_Sink_s & aSink, std::vector<am_Route_s> & listRoutes);
- void getAllPaths(CAmRoutingNode & aSource,
- CAmRoutingNode & aSink,
- std::vector<am_Route_s> & resultPath,
- std::vector<std::vector<CAmRoutingNode*>> & resultNodesPath,
- const bool includeCycles);
-};
+ 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);
+ };
}
diff --git a/AudioManagerCore/test/AmRouterTest/CAmRouterTest.cpp b/AudioManagerCore/test/AmRouterTest/CAmRouterTest.cpp
index e1acd65..ea1f452 100644
--- a/AudioManagerCore/test/AmRouterTest/CAmRouterTest.cpp
+++ b/AudioManagerCore/test/AmRouterTest/CAmRouterTest.cpp
@@ -38,16 +38,16 @@ CAmRouterTest::CAmRouterTest() :
pDatabaseHandler(),
pRouter(&pDatabaseHandler, &pControlSender), //
pRoutingSender(plistRoutingPluginDirs,dynamic_cast<IAmDatabaseHandler*>( &pDatabaseHandler )), //
- pCommandSender(plistCommandPluginDirs), //
+ pCommandSender(plistCommandPluginDirs, &pSocketHandler), //
pMockInterface(), //
pMockControlInterface(), //
pRoutingInterfaceBackdoor(), //
pCommandInterfaceBackdoor(), //
pControlInterfaceBackdoor(), //
- pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender,&pSocketHandler, &pRouter), //
- pObserver(&pCommandSender, &pRoutingSender, &pSocketHandler)
+ pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender,&pSocketHandler, &pRouter)
{
- pDatabaseHandler.registerObserver(&pObserver);
+ pDatabaseHandler.registerObserver(&pRoutingSender);
+ pDatabaseHandler.registerObserver(&pCommandSender);
pCommandInterfaceBackdoor.injectInterface(&pCommandSender, &pMockInterface);
pControlInterfaceBackdoor.replaceController(&pControlSender, &pMockControlInterface);
}
@@ -143,7 +143,7 @@ TEST_F(CAmRouterTest,simpleRoute2withDomainNoMatchFormats)
compareRoute.sinkID = sinkID;
compareRoute.sourceID = sourceID;
- ASSERT_EQ(E_OK, pRouter.getRoute(true,sourceID,sinkID,listRoutes));
+ ASSERT_EQ(E_NOT_POSSIBLE, pRouter.getRoute(true,sourceID,sinkID,listRoutes));
ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
}
@@ -435,7 +435,7 @@ TEST_F(CAmRouterTest,simpleRoute2DomainsOnlyFreeNotFree)
ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection,id1));
ASSERT_EQ(E_OK,pDatabaseHandler.enterConnectionDB(connection1,id2));
- ASSERT_EQ(E_OK, pRouter.getRoute(true,sourceID,sinkID,listRoutes));
+ ASSERT_EQ(E_NOT_POSSIBLE, pRouter.getRoute(true,sourceID,sinkID,listRoutes));
ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
@@ -1416,7 +1416,7 @@ TEST_F(CAmRouterTest,simpleRoute3DomainsNoConnection)
compareRoute.sinkID = sinkID;
compareRoute.sourceID = sourceID;
- ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
+ ASSERT_EQ(E_NOT_POSSIBLE, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
}
//test that checks just 2 domains, one sink one source with only one connection format each
@@ -1629,7 +1629,7 @@ TEST_F(CAmRouterTest,simpleRoute2DomainsNoMatchConnectionFormats)
compareRoute.sinkID = sinkID;
compareRoute.sourceID = sourceID;
- ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
+ ASSERT_EQ(E_NOT_POSSIBLE, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
ASSERT_EQ(static_cast<uint>(0), listRoutes.size());
}
diff --git a/AudioManagerCore/test/AmRouterTest/CAmRouterTest.h b/AudioManagerCore/test/AmRouterTest/CAmRouterTest.h
index 4a4e35b..ad3ed68 100644
--- a/AudioManagerCore/test/AmRouterTest/CAmRouterTest.h
+++ b/AudioManagerCore/test/AmRouterTest/CAmRouterTest.h
@@ -35,7 +35,6 @@
#include "CAmDatabaseHandlerMap.h"
#include "CAmControlReceiver.h"
#include "CAmControlSender.h"
-#include "CAmDatabaseObserver.h"
#include "CAmRoutingSender.h"
#include "CAmRouter.h"
#include "CAmSocketHandler.h"
@@ -68,7 +67,6 @@ public:
IAmCommandBackdoor pCommandInterfaceBackdoor;
IAmControlBackdoor pControlInterfaceBackdoor;
CAmControlReceiver pControlReceiver;
- CAmDatabaseObserver pObserver;
CAmCommonFunctions pCF;
void SetUp();
void TearDown();
diff --git a/AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp b/AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp
index 2a166cf..3a576e6 100644
--- a/AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp
+++ b/AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp
@@ -35,17 +35,17 @@ CAmRoutingInterfaceTest::CAmRoutingInterfaceTest() :
pSocketHandler(), //
pDatabaseHandler(), //
pRoutingSender(plistRoutingPluginDirs,dynamic_cast<IAmDatabaseHandler*>( &pDatabaseHandler )), //
- pCommandSender(plistCommandPluginDirs), //
+ pCommandSender(plistCommandPluginDirs, &pSocketHandler), //
pControlSender(), //
pRouter(&pDatabaseHandler, &pControlSender), //
pMockInterface(), //
pRoutingInterfaceBackdoor(), //
pCommandInterfaceBackdoor(), //
pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pSocketHandler, &pRouter), //
- pObserver(&pCommandSender, &pRoutingSender, &pSocketHandler), //
pRoutingReceiver(&pDatabaseHandler, &pRoutingSender, &pControlSender, &pSocketHandler)
{
- pDatabaseHandler.registerObserver(&pObserver);
+ pDatabaseHandler.registerObserver(&pRoutingSender);
+ pDatabaseHandler.registerObserver(&pCommandSender);
pRoutingInterfaceBackdoor.unloadPlugins(&pRoutingSender);
pRoutingInterfaceBackdoor.injectInterface(&pRoutingSender, &pMockInterface, "mock");
pControlInterfaceBackdoor.replaceController(&pControlSender, &pMockControlInterface);
@@ -546,6 +546,103 @@ TEST_F(CAmRoutingInterfaceTest,nothingTodisconnect)
ASSERT_TRUE(listHandles.empty());
}
+TEST_F(CAmRoutingInterfaceTest,handleOverflow)
+{
+ am_Handle_s handle,handleOverflow1,handleOverflow2,handleOverflowCheck1,handleOverflowCheck2;
+ am_sinkID_t sinkID;
+ am_Sink_s sink;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = DYNAMIC_ID_BOUNDARY;
+ am_SoundProperty_s soundProperty;
+ soundProperty.type = SP_GENIVI_TREBLE;
+ soundProperty.value = 23;
+
+ sink.listSoundProperties.push_back(soundProperty);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+
+
+ EXPECT_CALL(pMockInterface,asyncSetSinkSoundProperty(_,sinkID,_)).WillRepeatedly(Return(E_OK));
+
+ //open handles till 50
+ for(int i=0;i<50;i++)
+ {
+ handle.handle=0;
+ soundProperty.value = i;
+ ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handle,sinkID,soundProperty));
+ }
+ //now we ack 2 handles
+ EXPECT_CALL(pMockControlInterface,cbAckSetSinkSoundProperty(_,E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handleOverflow1,sinkID,soundProperty));
+ pRoutingReceiver.ackSetSinkSoundProperty(handleOverflow1,E_OK);
+
+ EXPECT_CALL(pMockControlInterface,cbAckSetSinkSoundProperty(_,E_OK));
+ ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handleOverflow2,sinkID,soundProperty));
+ pRoutingReceiver.ackSetSinkSoundProperty(handleOverflow2,E_OK);
+
+ for(int i=52;i<1023;i++) //now we get into the overflow areay
+ {
+ handle.handle=0;
+ soundProperty.value = i;
+ ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handle,sinkID,soundProperty));
+ }
+
+ //the next two handles must be the one we already acked
+ ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handleOverflowCheck1,sinkID,soundProperty));
+ ASSERT_EQ(handleOverflow1.handle,handleOverflowCheck1.handle);
+
+ ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handleOverflowCheck2,sinkID,soundProperty));
+ ASSERT_EQ(handleOverflow2.handle,handleOverflowCheck2.handle);
+
+}
+
+TEST_F(CAmRoutingInterfaceTest,handleOverflowAbsolute)
+{
+ am_Handle_s handle,handleOverflow1,handleOverflow2,handleOverflowCheck1,handleOverflowCheck2;
+ am_sinkID_t sinkID;
+ am_Sink_s sink;
+ am_Domain_s domain;
+ am_domainID_t domainID;
+
+ pCF.createSink(sink);
+ pCF.createDomain(domain);
+ domain.name = "mock";
+ domain.busname = "mock";
+ sink.sinkID = 2;
+ sink.domainID = DYNAMIC_ID_BOUNDARY;
+ am_SoundProperty_s soundProperty;
+ soundProperty.type = SP_GENIVI_TREBLE;
+ soundProperty.value = 23;
+
+ sink.listSoundProperties.push_back(soundProperty);
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+
+
+ EXPECT_CALL(pMockInterface,asyncSetSinkSoundProperty(_,sinkID,_)).WillRepeatedly(Return(E_OK));
+
+
+ for(int i=0;i<1023;i++) //we fill up the handles
+ {
+ handle.handle=0;
+ soundProperty.value = i;
+ ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handle,sinkID,soundProperty));
+ }
+
+ //the next handle must return 0!
+ ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handleOverflowCheck1,sinkID,soundProperty));
+ ASSERT_EQ(handleOverflowCheck1.handle,0);
+}
+
int main(int argc, char **argv)
diff --git a/AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.h b/AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.h
index 6233c17..78497ca 100644
--- a/AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.h
+++ b/AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.h
@@ -33,7 +33,6 @@
#include "CAmControlReceiver.h"
#include "CAmRoutingReceiver.h"
#include "CAmControlSender.h"
-#include "CAmDatabaseObserver.h"
#include "CAmRouter.h"
#include "../IAmRoutingBackdoor.h"
#include "../IAmCommandBackdoor.h"
@@ -66,7 +65,6 @@ public:
IAmCommandBackdoor pCommandInterfaceBackdoor;
IAmControlBackdoor pControlInterfaceBackdoor;
CAmControlReceiver pControlReceiver;
- CAmDatabaseObserver pObserver;
CAmCommonFunctions pCF;
void SetUp();
void TearDown();
diff --git a/AudioManagerCore/test/CMakeLists.txt b/AudioManagerCore/test/CMakeLists.txt
index 47658b4..4459e14 100644
--- a/AudioManagerCore/test/CMakeLists.txt
+++ b/AudioManagerCore/test/CMakeLists.txt
@@ -21,7 +21,7 @@ cmake_minimum_required(VERSION 3.0)
set(EXECUTABLE_OUTPUT_PATH ${TEST_EXECUTABLE_OUTPUT_PATH})
#make aunt google stop complaining
-set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUNIT_TEST=1 -DDLT_CONTEXT=AudioManager -Wno-unused-local-typedefs -lz -ldl")
+set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUNIT_TEST=1 -DDLT_CONTEXT=AudioManager -Wno-unused-local-typedefs -lz -ldl -g -O0")
add_subdirectory (AmControlInterfaceTest)
add_subdirectory (AmMapHandlerTest)
diff --git a/AudioManagerDaemon/src/main.cpp b/AudioManagerDaemon/src/main.cpp
index 6f5c273..26d7cea 100755
--- a/AudioManagerDaemon/src/main.cpp
+++ b/AudioManagerDaemon/src/main.cpp
@@ -55,7 +55,6 @@
#include "CAmRoutingReceiver.h"
#include "CAmCommandReceiver.h"
#include "CAmControlReceiver.h"
-#include "CAmDatabaseObserver.h"
#include "CAmDltWrapper.h"
#include "CAmSocketHandler.h"
#include "CAmCommandLineSingleton.h"
@@ -284,10 +283,10 @@ void mainProgram(int argc, char *argv[])
//later when the plugins are started, the commandline is already parsed and the objects defined before can be used to get the neccesary information
CAmDatabaseHandlerMap iDatabaseHandler;
- IAmDatabaseHandler *pDatabaseHandler = dynamic_cast<IAmDatabaseHandler*>( &iDatabaseHandler );
+ IAmDatabaseHandler *pDatabaseHandler = dynamic_cast<IAmDatabaseHandler*>( &iDatabaseHandler );
CAmRoutingSender iRoutingSender(listRoutingPluginDirs,pDatabaseHandler);
- CAmCommandSender iCommandSender(listCommandPluginDirs);
+ CAmCommandSender iCommandSender(listCommandPluginDirs, &iSocketHandler);
CAmControlSender iControlSender(controllerPlugin.getValue(),&iSocketHandler);
try
@@ -332,11 +331,10 @@ CAmRouter iRouter(pDatabaseHandler, &iControlSender);
#endif /*WITH_DBUS_WRAPPER*/
CAmControlReceiver iControlReceiver(pDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter);
-CAmDatabaseObserver iObserver(&iCommandSender,&iRoutingSender, &iSocketHandler);
-
-
-iDatabaseHandler.registerObserver(&iObserver);
+iDatabaseHandler.registerObserver(&iRoutingSender);
+iDatabaseHandler.registerObserver(&iCommandSender);
+iDatabaseHandler.registerObserver(&iRouter);
//startup all the Plugins and Interfaces
//at this point, commandline arguments can be parsed
iControlSender.startupController(&iControlReceiver);
diff --git a/AudioManagerUtilities/src/CAmDltWrapper.cpp b/AudioManagerUtilities/src/CAmDltWrapper.cpp
index 4b82e33..dc594af 100644
--- a/AudioManagerUtilities/src/CAmDltWrapper.cpp
+++ b/AudioManagerUtilities/src/CAmDltWrapper.cpp
@@ -424,7 +424,7 @@ bool CAmDltWrapper::initNoDlt(DltLogLevelType loglevel, DltContext* context)
if (!context)
context = &mDltContext;
- if(dlt_user_log_write_start(context, &mDltContextData, loglevel) < 0)
+ if(dlt_user_log_write_start(context, &mDltContextData, loglevel) <= 0)
{
pthread_mutex_unlock(&mMutex);
return false;
diff --git a/docx/images/dependencies.png b/docx/images/dependencies.png
index 30d272f..6755869 100644..100755
--- a/docx/images/dependencies.png
+++ b/docx/images/dependencies.png
Binary files differ
diff --git a/docx/images/dependencies_test.png b/docx/images/dependencies_test.png
index 870bc26..c6ba903 100644..100755
--- a/docx/images/dependencies_test.png
+++ b/docx/images/dependencies_test.png
Binary files differ
diff --git a/docx/images/dependency_created.png b/docx/images/dependency_created.png
index 7eabbf8..8a17fd2 100644..100755
--- a/docx/images/dependency_created.png
+++ b/docx/images/dependency_created.png
Binary files differ