summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AudioManagerCore/include/CAmCommandReceiver.h66
-rw-r--r--AudioManagerCore/include/CAmCommandSender.h52
-rw-r--r--AudioManagerCore/include/CAmControlReceiver.h168
-rw-r--r--AudioManagerCore/include/CAmControlSender.h157
-rw-r--r--AudioManagerCore/include/CAmDatabaseHandlerMap.h710
-rw-r--r--AudioManagerCore/include/CAmGraph.h1329
-rw-r--r--AudioManagerCore/include/CAmLog.h126
-rw-r--r--AudioManagerCore/include/CAmRouter.h633
-rw-r--r--AudioManagerCore/include/CAmRoutingReceiver.h84
-rw-r--r--AudioManagerCore/include/CAmRoutingSender.h525
-rw-r--r--AudioManagerCore/include/IAmDatabaseHandler.h237
-rw-r--r--AudioManagerCore/src/CAmCommandReceiver.cpp173
-rw-r--r--AudioManagerCore/src/CAmCommandSender.cpp323
-rw-r--r--AudioManagerCore/src/CAmControlReceiver.cpp282
-rw-r--r--AudioManagerCore/src/CAmControlSender.cpp205
-rw-r--r--AudioManagerCore/src/CAmDatabaseHandlerMap.cpp3666
-rw-r--r--AudioManagerCore/src/CAmLog.cpp85
-rw-r--r--AudioManagerCore/src/CAmRouter.cpp1479
-rw-r--r--AudioManagerCore/src/CAmRoutingReceiver.cpp314
-rw-r--r--AudioManagerCore/src/CAmRoutingSender.cpp1250
-rw-r--r--[-rwxr-xr-x]AudioManagerDaemon/src/main.cpp258
-rw-r--r--AudioManagerUtilities/include/CAmCommandLineSingleton.h26
-rw-r--r--AudioManagerUtilities/include/CAmCommonAPIWrapper.h421
-rw-r--r--AudioManagerUtilities/include/CAmDbusWrapper.h58
-rw-r--r--AudioManagerUtilities/include/CAmDltWrapper.h299
-rw-r--r--AudioManagerUtilities/include/CAmSerializer.h2201
-rw-r--r--AudioManagerUtilities/include/CAmSocketHandler.h468
-rw-r--r--[-rwxr-xr-x]AudioManagerUtilities/include/CAmWatchdog.h11
-rw-r--r--AudioManagerUtilities/include/TAmPluginTemplate.h46
-rw-r--r--AudioManagerUtilities/src/CAmCommandLineSingleton.cpp47
-rw-r--r--AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp263
-rw-r--r--AudioManagerUtilities/src/CAmDbusWrapper.cpp317
-rw-r--r--AudioManagerUtilities/src/CAmDltWrapper.cpp1366
-rw-r--r--AudioManagerUtilities/src/CAmSocketHandler.cpp916
-rw-r--r--[-rwxr-xr-x]AudioManagerUtilities/src/CAmWatchdog.cpp39
-rw-r--r--Foo/uncrustify_files.cfg12
36 files changed, 9785 insertions, 8827 deletions
diff --git a/AudioManagerCore/include/CAmCommandReceiver.h b/AudioManagerCore/include/CAmCommandReceiver.h
index 0f30d81..9080b25 100644
--- a/AudioManagerCore/include/CAmCommandReceiver.h
+++ b/AudioManagerCore/include/CAmCommandReceiver.h
@@ -37,39 +37,39 @@ class CAmSocketHandler;
/**
* This class realizes the command Interface
*/
-class CAmCommandReceiver: public IAmCommandReceive
+class CAmCommandReceiver : public IAmCommandReceive
{
public:
- CAmCommandReceiver(IAmDatabaseHandler* iDatabaseHandler, CAmControlSender* iControlSender, CAmSocketHandler* iSocketHandler);
- CAmCommandReceiver(IAmDatabaseHandler* iDatabaseHandler, CAmControlSender* iControlSender, CAmSocketHandler* iSocketHandler, CAmDbusWrapper* iDBusWrapper);
+ CAmCommandReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler);
+ CAmCommandReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler, CAmDbusWrapper *iDBusWrapper);
~CAmCommandReceiver();
- am_Error_e connect(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID);
+ am_Error_e connect(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t &mainConnectionID);
am_Error_e disconnect(const am_mainConnectionID_t mainConnectionID);
am_Error_e setVolume(const am_sinkID_t sinkID, const am_mainVolume_t volume);
am_Error_e volumeStep(const am_sinkID_t sinkID, const int16_t volumeStep);
am_Error_e setSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState);
- am_Error_e setMainSinkSoundProperty(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID);
- am_Error_e setMainSourceSoundProperty(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID);
- am_Error_e setSystemProperty(const am_SystemProperty_s& property);
- am_Error_e getVolume(const am_sinkID_t sinkID, am_mainVolume_t& mainVolume) const;
- am_Error_e getListMainConnections(std::vector<am_MainConnectionType_s>& listConnections) const;
- am_Error_e getListMainSinks(std::vector<am_SinkType_s>& listMainSinks) const;
- am_Error_e getListMainSources(std::vector<am_SourceType_s>& listMainSources) const;
- am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s>& listSoundProperties) const;
- am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s>& listSourceProperties) const;
- am_Error_e getListSourceClasses(std::vector<am_SourceClass_s>& listSourceClasses) const;
- am_Error_e getListSinkClasses(std::vector<am_SinkClass_s>& listSinkClasses) const;
- am_Error_e getListSystemProperties(std::vector<am_SystemProperty_s>& listSystemProperties) const;
- am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay) const;
- am_Error_e getDBusConnectionWrapper(CAmDbusWrapper*& dbusConnectionWrapper) const;
- am_Error_e getSocketHandler(CAmSocketHandler*& socketHandler) const;
+ am_Error_e setMainSinkSoundProperty(const am_MainSoundProperty_s &soundProperty, const am_sinkID_t sinkID);
+ am_Error_e setMainSourceSoundProperty(const am_MainSoundProperty_s &soundProperty, const am_sourceID_t sourceID);
+ am_Error_e setSystemProperty(const am_SystemProperty_s &property);
+ am_Error_e getVolume(const am_sinkID_t sinkID, am_mainVolume_t &mainVolume) const;
+ am_Error_e getListMainConnections(std::vector<am_MainConnectionType_s> &listConnections) const;
+ am_Error_e getListMainSinks(std::vector<am_SinkType_s> &listMainSinks) const;
+ am_Error_e getListMainSources(std::vector<am_SourceType_s> &listMainSources) const;
+ am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s> &listSoundProperties) const;
+ am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s> &listSourceProperties) const;
+ am_Error_e getListSourceClasses(std::vector<am_SourceClass_s> &listSourceClasses) const;
+ am_Error_e getListSinkClasses(std::vector<am_SinkClass_s> &listSinkClasses) const;
+ am_Error_e getListSystemProperties(std::vector<am_SystemProperty_s> &listSystemProperties) const;
+ am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t &delay) const;
+ am_Error_e getDBusConnectionWrapper(CAmDbusWrapper * &dbusConnectionWrapper) const;
+ am_Error_e getSocketHandler(CAmSocketHandler * &socketHandler) const;
void confirmCommandReady(const uint16_t handle, const am_Error_e error);
void confirmCommandRundown(const uint16_t handle, const am_Error_e error);
- void getInterfaceVersion(std::string& version) const;
- am_Error_e getListMainSinkNotificationConfigurations(const am_sinkID_t sinkID, std::vector<am_NotificationConfiguration_s>& listMainNotificationConfigurations) const ;
- am_Error_e getListMainSourceNotificationConfigurations(const am_sourceID_t sourceID, std::vector<am_NotificationConfiguration_s>& listMainNotificationConfigurations) const ;
- am_Error_e setMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s& mainNotificationConfiguration) ;
- am_Error_e setMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s& mainNotificationConfiguration) ;
+ void getInterfaceVersion(std::string &version) const;
+ am_Error_e getListMainSinkNotificationConfigurations(const am_sinkID_t sinkID, std::vector<am_NotificationConfiguration_s> &listMainNotificationConfigurations) const;
+ am_Error_e getListMainSourceNotificationConfigurations(const am_sourceID_t sourceID, std::vector<am_NotificationConfiguration_s> &listMainNotificationConfigurations) const;
+ am_Error_e setMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s &mainNotificationConfiguration);
+ am_Error_e setMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s &mainNotificationConfiguration);
uint16_t getStartupHandle(); //!< returns a startup handle
uint16_t getRundownHandle(); //!< returns a rundown handle
@@ -78,18 +78,18 @@ public:
void waitOnRundown(bool rundown); //!< tells the ComandReceiver to start waiting for all handles to be confirmed
private:
- IAmDatabaseHandler* mDatabaseHandler; //!< pointer to the databasehandler
- CAmControlSender* mControlSender; //!< pointer to the control sender
- CAmDbusWrapper* mDBusWrapper; //!< pointer to the dbuswrapper
- CAmSocketHandler* mSocketHandler; //!< pointer to the SocketHandler
+ IAmDatabaseHandler *mDatabaseHandler; //!< pointer to the databasehandler
+ CAmControlSender *mControlSender; //!< pointer to the control sender
+ CAmDbusWrapper *mDBusWrapper; //!< pointer to the dbuswrapper
+ CAmSocketHandler *mSocketHandler; //!< pointer to the SocketHandler
- uint16_t handleCount; //!< counts all handles
+ uint16_t handleCount; //!< counts all handles
std::vector<uint16_t> mListStartupHandles; //!< list of handles that wait for a confirm
std::vector<uint16_t> mListRundownHandles; //!< list of handles that wait for a confirm
- bool mWaitStartup; //!< if true confirmation will be sent if list of handles = 0
- bool mWaitRundown; //!< if true confirmation will be sent if list of handles = 0
- am_Error_e mLastErrorStartup;
- am_Error_e mLastErrorRundown;
+ bool mWaitStartup; //!< if true confirmation will be sent if list of handles = 0
+ bool mWaitRundown; //!< if true confirmation will be sent if list of handles = 0
+ am_Error_e mLastErrorStartup;
+ am_Error_e mLastErrorRundown;
};
}
diff --git a/AudioManagerCore/include/CAmCommandSender.h b/AudioManagerCore/include/CAmCommandSender.h
index c9f8fb6..5646282 100644
--- a/AudioManagerCore/include/CAmCommandSender.h
+++ b/AudioManagerCore/include/CAmCommandSender.h
@@ -25,7 +25,7 @@
#define COMMANDSENDER_H_
#ifdef UNIT_TEST
-#include "../test/IAmCommandBackdoor.h" //we need this for the unit test
+# include "../test/IAmCommandBackdoor.h" // we need this for the unit test
#endif
#include "IAmCommand.h"
@@ -38,17 +38,16 @@ 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: public CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks
+class CAmCommandSender : public CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks
{
public:
- CAmCommandSender(const std::vector<std::string>& listOfPluginDirectories, CAmSocketHandler *iSocketHandler);
+ CAmCommandSender(const std::vector<std::string> &listOfPluginDirectories, CAmSocketHandler *iSocketHandler);
~CAmCommandSender();
- am_Error_e startupInterfaces(CAmCommandReceiver* iCommandReceiver);
+ am_Error_e startupInterfaces(CAmCommandReceiver *iCommandReceiver);
void setCommandReady();
void setCommandRundown();
void cbNewMainConnection(const am_MainConnectionType_s mainConnection);
@@ -60,38 +59,37 @@ public:
void cbNumberOfSinkClassesChanged();
void cbNumberOfSourceClassesChanged();
void cbMainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState);
- void cbMainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty);
- void cbMainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty);
- void cbSinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s& availability);
- void cbSourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s& availability);
+ void cbMainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s &soundProperty);
+ void cbMainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s &soundProperty);
+ void cbSinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s &availability);
+ void cbSourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s &availability);
void cbVolumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume);
void cbSinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState);
- void cbSystemPropertyChanged(const am_SystemProperty_s& systemProperty);
+ void cbSystemPropertyChanged(const am_SystemProperty_s &systemProperty);
void cbTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time);
- void getInterfaceVersion(std::string& version) const;
- am_Error_e getListPlugins(std::vector<std::string>& interfaces) const;
- void cbSinkUpdated(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties);
- void cbSourceUpdated(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties);
- void cbSinkNotification(const am_sinkID_t sinkID, const am_NotificationPayload_s& notification);
- void cbSourceNotification(const am_sourceID_t sourceID, const am_NotificationPayload_s& notification);
- void cbSinkMainNotificationConfigurationChanged(const am_sinkID_t sinkID, const am_NotificationConfiguration_s& mainNotificationConfiguration);
- void cbSourceMainNotificationConfigurationChanged(const am_sourceID_t sourceID, const am_NotificationConfiguration_s& mainNotificationConfiguration);
+ void getInterfaceVersion(std::string &version) const;
+ am_Error_e getListPlugins(std::vector<std::string> &interfaces) const;
+ void cbSinkUpdated(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties);
+ void cbSourceUpdated(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties);
+ void cbSinkNotification(const am_sinkID_t sinkID, const am_NotificationPayload_s &notification);
+ void cbSourceNotification(const am_sourceID_t sourceID, const am_NotificationPayload_s &notification);
+ void cbSinkMainNotificationConfigurationChanged(const am_sinkID_t sinkID, const am_NotificationConfiguration_s &mainNotificationConfiguration);
+ void cbSourceMainNotificationConfigurationChanged(const am_sourceID_t sourceID, const am_NotificationConfiguration_s &mainNotificationConfiguration);
#ifdef UNIT_TEST
- friend class IAmCommandBackdoor; //this is to get access to the loaded plugins and be able to exchange the interfaces
+ friend class IAmCommandBackdoor; // this is to get access to the loaded plugins and be able to exchange the interfaces
#endif
private:
- void loadPlugins(const std::vector<std::string>& listOfPluginDirectories);
+ void loadPlugins(const std::vector<std::string> &listOfPluginDirectories);
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;
- V2::CAmSerializer mSerializer;
-};
+ 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;
+ V2::CAmSerializer mSerializer;
+};
}
diff --git a/AudioManagerCore/include/CAmControlReceiver.h b/AudioManagerCore/include/CAmControlReceiver.h
index 897ac5e..36c4d14 100644
--- a/AudioManagerCore/include/CAmControlReceiver.h
+++ b/AudioManagerCore/include/CAmControlReceiver.h
@@ -39,46 +39,46 @@ class CAmNodeStateCommunicator;
/**
* This class is used to receive all commands from the control interface
*/
-class CAmControlReceiver: public IAmControlReceive
+class CAmControlReceiver : public IAmControlReceive
{
public:
- CAmControlReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter);
+ CAmControlReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter *iRouter);
~CAmControlReceiver();
- 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 connect(am_Handle_s& handle, am_connectionID_t& connectionID, const am_CustomConnectionFormat_t format, const am_sourceID_t sourceID, const am_sinkID_t sinkID);
- am_Error_e disconnect(am_Handle_s& handle, const am_connectionID_t connectionID);
- am_Error_e crossfade(am_Handle_s& handle, const am_HotSink_e hotSource, const am_crossfaderID_t crossfaderID, const am_CustomRampType_t rampType, const am_time_t rampTime);
+ 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 connect(am_Handle_s &handle, am_connectionID_t &connectionID, const am_CustomConnectionFormat_t format, const am_sourceID_t sourceID, const am_sinkID_t sinkID);
+ am_Error_e disconnect(am_Handle_s &handle, const am_connectionID_t connectionID);
+ am_Error_e crossfade(am_Handle_s &handle, const am_HotSink_e hotSource, const am_crossfaderID_t crossfaderID, const am_CustomRampType_t rampType, const am_time_t rampTime);
am_Error_e abortAction(const am_Handle_s handle);
- am_Error_e setSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state);
- am_Error_e setSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time);
- am_Error_e setSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_CustomRampType_t rampType, const am_time_t time);
- am_Error_e setSinkSoundProperties(am_Handle_s& handle, const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s>& soundProperty);
- am_Error_e setSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty);
- am_Error_e setSourceSoundProperties(am_Handle_s& handle, const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s>& soundProperty);
- am_Error_e setSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty);
+ am_Error_e setSourceState(am_Handle_s &handle, const am_sourceID_t sourceID, const am_SourceState_e state);
+ am_Error_e setSinkVolume(am_Handle_s &handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time);
+ am_Error_e setSourceVolume(am_Handle_s &handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_CustomRampType_t rampType, const am_time_t time);
+ am_Error_e setSinkSoundProperties(am_Handle_s &handle, const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s> &soundProperty);
+ am_Error_e setSinkSoundProperty(am_Handle_s &handle, const am_sinkID_t sinkID, const am_SoundProperty_s &soundProperty);
+ am_Error_e setSourceSoundProperties(am_Handle_s &handle, const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s> &soundProperty);
+ am_Error_e setSourceSoundProperty(am_Handle_s &handle, const am_sourceID_t sourceID, const am_SoundProperty_s &soundProperty);
am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState);
- 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);
- am_Error_e enterCrossfaderDB(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID);
- am_Error_e enterGatewayDB(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID);
- am_Error_e enterConverterDB(const am_Converter_s & converterData, am_converterID_t & converterID);
- am_Error_e enterSourceDB(const am_Source_s& sourceData, am_sourceID_t& sourceID);
- am_Error_e enterSinkClassDB(const am_SinkClass_s& sinkClass, am_sinkClass_t& sinkClassID);
- am_Error_e enterSourceClassDB(am_sourceClass_t& sourceClassID, const am_SourceClass_s& sourceClass);
- am_Error_e changeSinkClassInfoDB(const am_SinkClass_s& sinkClass);
- am_Error_e changeSourceClassInfoDB(const am_SourceClass_s& sourceClass);
- am_Error_e enterSystemPropertiesListDB(const std::vector<am_SystemProperty_s>& listSystemProperties);
- am_Error_e changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector<am_connectionID_t>& listConnectionID);
+ 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);
+ am_Error_e enterCrossfaderDB(const am_Crossfader_s &crossfaderData, am_crossfaderID_t &crossfaderID);
+ am_Error_e enterGatewayDB(const am_Gateway_s &gatewayData, am_gatewayID_t &gatewayID);
+ am_Error_e enterConverterDB(const am_Converter_s &converterData, am_converterID_t &converterID);
+ am_Error_e enterSourceDB(const am_Source_s &sourceData, am_sourceID_t &sourceID);
+ am_Error_e enterSinkClassDB(const am_SinkClass_s &sinkClass, am_sinkClass_t &sinkClassID);
+ am_Error_e enterSourceClassDB(am_sourceClass_t &sourceClassID, const am_SourceClass_s &sourceClass);
+ am_Error_e changeSinkClassInfoDB(const am_SinkClass_s &sinkClass);
+ am_Error_e changeSourceClassInfoDB(const am_SourceClass_s &sourceClass);
+ am_Error_e enterSystemPropertiesListDB(const std::vector<am_SystemProperty_s> &listSystemProperties);
+ am_Error_e changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector<am_connectionID_t> &listConnectionID);
am_Error_e changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState);
am_Error_e changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID);
- am_Error_e changeSinkAvailabilityDB(const am_Availability_s& availability, const am_sinkID_t sinkID);
+ am_Error_e changeSinkAvailabilityDB(const am_Availability_s &availability, const am_sinkID_t sinkID);
am_Error_e changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID);
am_Error_e changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID);
- am_Error_e changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID);
- am_Error_e changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID);
- am_Error_e changeSourceAvailabilityDB(const am_Availability_s& availability, const am_sourceID_t sourceID);
- am_Error_e changeSystemPropertyDB(const am_SystemProperty_s& property);
+ am_Error_e changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s &soundProperty, const am_sinkID_t sinkID);
+ am_Error_e changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s &soundProperty, const am_sourceID_t sourceID);
+ am_Error_e changeSourceAvailabilityDB(const am_Availability_s &availability, const am_sourceID_t sourceID);
+ am_Error_e changeSystemPropertyDB(const am_SystemProperty_s &property);
am_Error_e removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID);
am_Error_e removeSinkDB(const am_sinkID_t sinkID);
am_Error_e removeSourceDB(const am_sourceID_t sourceID);
@@ -88,68 +88,68 @@ public:
am_Error_e removeDomainDB(const am_domainID_t domainID);
am_Error_e removeSinkClassDB(const am_sinkClass_t sinkClassID);
am_Error_e removeSourceClassDB(const am_sourceClass_t sourceClassID);
- am_Error_e getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s& classInfo) const;
- am_Error_e getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s& sinkClass) const;
- am_Error_e getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s& sinkData) const;
- am_Error_e getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s& sourceData) const;
- am_Error_e getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s& gatewayData) const;
- am_Error_e getConverterInfoDB(const am_converterID_t converterID, am_Converter_s& converterData) const;
- am_Error_e getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s& crossfaderData) const;
- am_Error_e getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s& mainConnectionData) const;
- am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t>& listSinkID) const;
- am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t>& listSourceID) const;
- am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t>& listCrossfadersID) const;
- am_Error_e getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t>& listGatewaysID) const;
- am_Error_e getListConvertersOfDomain(const am_domainID_t domainID, std::vector<am_converterID_t>& listConverterID) const;
- am_Error_e getListMainConnections(std::vector<am_MainConnection_s>& listMainConnections) const;
- am_Error_e getListDomains(std::vector<am_Domain_s>& listDomains) const;
- am_Error_e getListConnections(std::vector<am_Connection_s>& listConnections) const;
- am_Error_e getListSinks(std::vector<am_Sink_s>& listSinks) const;
- am_Error_e getListSources(std::vector<am_Source_s>& listSources) const;
- am_Error_e getListSourceClasses(std::vector<am_SourceClass_s>& listSourceClasses) const;
- am_Error_e getListHandles(std::vector<am_Handle_s>& listHandles) const;
- am_Error_e getListCrossfaders(std::vector<am_Crossfader_s>& listCrossfaders) const;
- am_Error_e getListGateways(std::vector<am_Gateway_s>& listGateways) const;
- am_Error_e getListConverters(std::vector<am_Converter_s>& listConverters) const;
- am_Error_e getListSinkClasses(std::vector<am_SinkClass_s>& listSinkClasses) const;
- am_Error_e getListSystemProperties(std::vector<am_SystemProperty_s>& listSystemProperties) const;
+ am_Error_e getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s &classInfo) const;
+ am_Error_e getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s &sinkClass) const;
+ am_Error_e getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s &sinkData) const;
+ am_Error_e getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s &sourceData) const;
+ am_Error_e getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s &gatewayData) const;
+ am_Error_e getConverterInfoDB(const am_converterID_t converterID, am_Converter_s &converterData) const;
+ am_Error_e getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s &crossfaderData) const;
+ am_Error_e getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s &mainConnectionData) const;
+ am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t> &listSinkID) const;
+ am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t> &listSourceID) const;
+ am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t> &listCrossfadersID) const;
+ am_Error_e getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t> &listGatewaysID) const;
+ am_Error_e getListConvertersOfDomain(const am_domainID_t domainID, std::vector<am_converterID_t> &listConverterID) const;
+ am_Error_e getListMainConnections(std::vector<am_MainConnection_s> &listMainConnections) const;
+ am_Error_e getListDomains(std::vector<am_Domain_s> &listDomains) const;
+ am_Error_e getListConnections(std::vector<am_Connection_s> &listConnections) const;
+ am_Error_e getListSinks(std::vector<am_Sink_s> &listSinks) const;
+ am_Error_e getListSources(std::vector<am_Source_s> &listSources) const;
+ am_Error_e getListSourceClasses(std::vector<am_SourceClass_s> &listSourceClasses) const;
+ am_Error_e getListHandles(std::vector<am_Handle_s> &listHandles) const;
+ am_Error_e getListCrossfaders(std::vector<am_Crossfader_s> &listCrossfaders) const;
+ am_Error_e getListGateways(std::vector<am_Gateway_s> &listGateways) const;
+ am_Error_e getListConverters(std::vector<am_Converter_s> &listConverters) const;
+ am_Error_e getListSinkClasses(std::vector<am_SinkClass_s> &listSinkClasses) const;
+ am_Error_e getListSystemProperties(std::vector<am_SystemProperty_s> &listSystemProperties) const;
void setCommandReady();
void setCommandRundown();
void setRoutingReady();
void setRoutingRundown();
void confirmControllerReady(const am_Error_e error);
void confirmControllerRundown(const am_Error_e error);
- am_Error_e getSocketHandler(CAmSocketHandler*& socketHandler);
- void getInterfaceVersion(std::string& version) const;
- am_Error_e changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) ;
- am_Error_e changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) ;
- am_Error_e changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t>& listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t>& listSinkConnectionFormats, const std::vector<bool>& convertionMatrix) ;
- 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);
- am_Error_e setVolumes(am_Handle_s& handle, const std::vector<am_Volumes_s>& listVolumes) ;
- am_Error_e setSinkNotificationConfiguration(am_Handle_s& handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration) ;
- am_Error_e setSourceNotificationConfiguration(am_Handle_s& handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration) ;
- void sendMainSinkNotificationPayload(const am_sinkID_t sinkID, const am_NotificationPayload_s& notificationPayload) ;
- void sendMainSourceNotificationPayload(const am_sourceID_t sourceID, const am_NotificationPayload_s& notificationPayload) ;
- am_Error_e changeMainSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s& mainNotificationConfiguration) ;
- am_Error_e changeMainSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s& mainNotificationConfiguration) ;
- am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s>& listSoundproperties) const;
- am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s>& listSoundproperties) const;
- am_Error_e getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s>& listSoundproperties) const;
- am_Error_e getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s>& listSoundproperties) const;
- am_Error_e getMainSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const;
- am_Error_e getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const;
- am_Error_e getMainSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const;
- am_Error_e getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const;
- am_Error_e resyncConnectionState(const am_domainID_t domainID, std::vector<am_Connection_s>& listOfExistingConnections);
+ am_Error_e getSocketHandler(CAmSocketHandler * &socketHandler);
+ void getInterfaceVersion(std::string &version) const;
+ am_Error_e changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s> &listSoundProperties, const std::vector<am_CustomConnectionFormat_t> &listConnectionFormats, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties);
+ am_Error_e changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s> &listSoundProperties, const std::vector<am_CustomConnectionFormat_t> &listConnectionFormats, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties);
+ am_Error_e changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t> &listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t> &listSinkConnectionFormats, const std::vector<bool> &convertionMatrix);
+ 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);
+ am_Error_e setVolumes(am_Handle_s &handle, const std::vector<am_Volumes_s> &listVolumes);
+ am_Error_e setSinkNotificationConfiguration(am_Handle_s &handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s &notificationConfiguration);
+ am_Error_e setSourceNotificationConfiguration(am_Handle_s &handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s &notificationConfiguration);
+ void sendMainSinkNotificationPayload(const am_sinkID_t sinkID, const am_NotificationPayload_s &notificationPayload);
+ void sendMainSourceNotificationPayload(const am_sourceID_t sourceID, const am_NotificationPayload_s &notificationPayload);
+ am_Error_e changeMainSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s &mainNotificationConfiguration);
+ am_Error_e changeMainSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s &mainNotificationConfiguration);
+ am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s> &listSoundproperties) const;
+ am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s> &listSoundproperties) const;
+ am_Error_e getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s> &listSoundproperties) const;
+ am_Error_e getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s> &listSoundproperties) const;
+ am_Error_e getMainSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t &value) const;
+ am_Error_e getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomSoundPropertyType_t propertyType, int16_t &value) const;
+ am_Error_e getMainSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t &value) const;
+ am_Error_e getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomSoundPropertyType_t propertyType, int16_t &value) const;
+ am_Error_e resyncConnectionState(const am_domainID_t domainID, std::vector<am_Connection_s> &listOfExistingConnections);
am_Error_e removeHandle(const am_Handle_s handle);
private:
- IAmDatabaseHandler* mDatabaseHandler; //!< pointer tto the databasehandler
- CAmRoutingSender* mRoutingSender; //!< pointer to the routing send interface.
- CAmCommandSender* mCommandSender; //!< pointer to the command send interface
- CAmSocketHandler* mSocketHandler; //!< pointer to the socketHandler
- CAmRouter* mRouter; //!< pointer to the Router
- CAmNodeStateCommunicator* mNodeStateCommunicator;
+ IAmDatabaseHandler *mDatabaseHandler; //!< pointer tto the databasehandler
+ CAmRoutingSender *mRoutingSender; //!< pointer to the routing send interface.
+ CAmCommandSender *mCommandSender; //!< pointer to the command send interface
+ CAmSocketHandler *mSocketHandler; //!< pointer to the socketHandler
+ CAmRouter *mRouter; //!< pointer to the Router
+ CAmNodeStateCommunicator *mNodeStateCommunicator;
};
}
diff --git a/AudioManagerCore/include/CAmControlSender.h b/AudioManagerCore/include/CAmControlSender.h
index 2c31cf9..6d6a562 100644
--- a/AudioManagerCore/include/CAmControlSender.h
+++ b/AudioManagerCore/include/CAmControlSender.h
@@ -25,7 +25,7 @@
#define CONTROLSENDER_H_
#ifdef UNIT_TEST
-#include "../test/IAmControlBackdoor.h"
+# include "../test/IAmControlBackdoor.h"
#endif
#include "IAmControl.h"
@@ -41,95 +41,96 @@ namespace am
class CAmControlSender
{
public:
- CAmControlSender(std::string controlPluginFile,CAmSocketHandler* sockethandler);
+ CAmControlSender(std::string controlPluginFile, CAmSocketHandler *sockethandler);
CAmControlSender();
~CAmControlSender();
- am_Error_e startupController(IAmControlReceive* controlreceiveinterface) ;
- void setControllerReady() ;
- void setControllerRundown(const int16_t signal) ;
- am_Error_e hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID) ;
- am_Error_e hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID) ;
- am_Error_e hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty) ;
- am_Error_e hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty) ;
- am_Error_e hookUserSetSystemProperty(const am_SystemProperty_s& property) ;
- am_Error_e hookUserVolumeChange(const am_sinkID_t SinkID, const am_mainVolume_t newVolume) ;
- am_Error_e hookUserVolumeStep(const am_sinkID_t SinkID, const int16_t increment) ;
- am_Error_e hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState) ;
- am_Error_e hookSystemRegisterDomain(const am_Domain_s& domainData, am_domainID_t& domainID) ;
- am_Error_e hookSystemDeregisterDomain(const am_domainID_t domainID) ;
- void hookSystemDomainRegistrationComplete(const am_domainID_t domainID) ;
- am_Error_e hookSystemRegisterSink(const am_Sink_s& sinkData, am_sinkID_t& sinkID) ;
- am_Error_e hookSystemDeregisterSink(const am_sinkID_t sinkID) ;
- am_Error_e hookSystemRegisterSource(const am_Source_s& sourceData, am_sourceID_t& sourceID) ;
- am_Error_e hookSystemDeregisterSource(const am_sourceID_t sourceID) ;
- am_Error_e hookSystemRegisterGateway(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID) ;
- am_Error_e hookSystemRegisterConverter(const am_Converter_s& converterData, am_converterID_t& converterID);
- am_Error_e hookSystemDeregisterGateway(const am_gatewayID_t gatewayID) ;
- am_Error_e hookSystemDeregisterConverter(const am_converterID_t converterID) ;
- am_Error_e hookSystemRegisterCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID) ;
- am_Error_e hookSystemDeregisterCrossfader(const am_crossfaderID_t crossfaderID) ;
- void hookSystemSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume) ;
- void hookSystemSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume) ;
- void hookSystemInterruptStateChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState) ;
- void hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s& availability) ;
- void hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s& availability) ;
- void hookSystemDomainStateChange(const am_domainID_t domainID, const am_DomainState_e state) ;
- void hookSystemReceiveEarlyData(const std::vector<am_EarlyData_s>& data) ;
- void hookSystemSpeedChange(const am_speed_t speed) ;
- void hookSystemTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time) ;
- void cbAckConnect(const am_Handle_s handle, const am_Error_e errorID) ;
- void cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID) ;
- void cbAckCrossFade(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error) ;
- void cbAckSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error) ;
- void cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error) ;
- void cbAckSetSourceState(const am_Handle_s handle, const am_Error_e error) ;
- void cbAckSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error) ;
- void cbAckSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error) ;
- void cbAckSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error) ;
- void cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error) ;
- am_Error_e getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector<am_CustomConnectionFormat_t> listPossibleConnectionFormats, std::vector<am_CustomConnectionFormat_t>& listPrioConnectionFormats) ;
- void confirmCommandReady(const am_Error_e error) ;
- void confirmRoutingReady(const am_Error_e error) ;
- void confirmCommandRundown(const am_Error_e error) ;
- void confirmRoutingRundown(const am_Error_e error) ;
- void getInterfaceVersion(std::string& version) const ;
- am_Error_e hookSystemUpdateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) ;
- am_Error_e hookSystemUpdateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) ;
- am_Error_e hookSystemUpdateGateway(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t>& listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t>& listSinkConnectionFromats, const std::vector<bool>& convertionMatrix) ;
- am_Error_e hookSystemUpdateConverter(const am_converterID_t converterID, const std::vector<am_CustomConnectionFormat_t>& listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t>& listSinkConnectionFromats, const std::vector<bool>& convertionMatrix);
- void cbAckSetVolume(const am_Handle_s handle, const std::vector<am_Volumes_s>& listVolumes, const am_Error_e error) ;
- void cbAckSetSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) ;
- void cbAckSetSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) ;
- void hookSinkNotificationDataChanged(const am_sinkID_t sinkID, const am_NotificationPayload_s& payload) ;
- void hookSourceNotificationDataChanged(const am_sourceID_t sourceID, const am_NotificationPayload_s& payload) ;
- am_Error_e hookUserSetMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration) ;
- am_Error_e hookUserSetMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration) ;
+ am_Error_e startupController(IAmControlReceive *controlreceiveinterface);
+ void setControllerReady();
+ void setControllerRundown(const int16_t signal);
+ am_Error_e hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t &mainConnectionID);
+ am_Error_e hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID);
+ am_Error_e hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s &soundProperty);
+ am_Error_e hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s &soundProperty);
+ am_Error_e hookUserSetSystemProperty(const am_SystemProperty_s &property);
+ am_Error_e hookUserVolumeChange(const am_sinkID_t SinkID, const am_mainVolume_t newVolume);
+ am_Error_e hookUserVolumeStep(const am_sinkID_t SinkID, const int16_t increment);
+ am_Error_e hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState);
+ am_Error_e hookSystemRegisterDomain(const am_Domain_s &domainData, am_domainID_t &domainID);
+ am_Error_e hookSystemDeregisterDomain(const am_domainID_t domainID);
+ void hookSystemDomainRegistrationComplete(const am_domainID_t domainID);
+ am_Error_e hookSystemRegisterSink(const am_Sink_s &sinkData, am_sinkID_t &sinkID);
+ am_Error_e hookSystemDeregisterSink(const am_sinkID_t sinkID);
+ am_Error_e hookSystemRegisterSource(const am_Source_s &sourceData, am_sourceID_t &sourceID);
+ am_Error_e hookSystemDeregisterSource(const am_sourceID_t sourceID);
+ am_Error_e hookSystemRegisterGateway(const am_Gateway_s &gatewayData, am_gatewayID_t &gatewayID);
+ am_Error_e hookSystemRegisterConverter(const am_Converter_s &converterData, am_converterID_t &converterID);
+ am_Error_e hookSystemDeregisterGateway(const am_gatewayID_t gatewayID);
+ am_Error_e hookSystemDeregisterConverter(const am_converterID_t converterID);
+ am_Error_e hookSystemRegisterCrossfader(const am_Crossfader_s &crossfaderData, am_crossfaderID_t &crossfaderID);
+ am_Error_e hookSystemDeregisterCrossfader(const am_crossfaderID_t crossfaderID);
+ void hookSystemSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume);
+ void hookSystemSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume);
+ void hookSystemInterruptStateChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState);
+ void hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s &availability);
+ void hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s &availability);
+ void hookSystemDomainStateChange(const am_domainID_t domainID, const am_DomainState_e state);
+ void hookSystemReceiveEarlyData(const std::vector<am_EarlyData_s> &data);
+ void hookSystemSpeedChange(const am_speed_t speed);
+ void hookSystemTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time);
+ void cbAckConnect(const am_Handle_s handle, const am_Error_e errorID);
+ void cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID);
+ void cbAckCrossFade(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error);
+ void cbAckSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error);
+ void cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error);
+ void cbAckSetSourceState(const am_Handle_s handle, const am_Error_e error);
+ void cbAckSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error);
+ void cbAckSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error);
+ void cbAckSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error);
+ void cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error);
+ am_Error_e getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector<am_CustomConnectionFormat_t> listPossibleConnectionFormats, std::vector<am_CustomConnectionFormat_t> &listPrioConnectionFormats);
+ void confirmCommandReady(const am_Error_e error);
+ void confirmRoutingReady(const am_Error_e error);
+ void confirmCommandRundown(const am_Error_e error);
+ void confirmRoutingRundown(const am_Error_e error);
+ void getInterfaceVersion(std::string &version) const;
+ am_Error_e hookSystemUpdateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s> &listSoundProperties, const std::vector<am_CustomConnectionFormat_t> &listConnectionFormats, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties);
+ am_Error_e hookSystemUpdateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s> &listSoundProperties, const std::vector<am_CustomConnectionFormat_t> &listConnectionFormats, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties);
+ am_Error_e hookSystemUpdateGateway(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t> &listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t> &listSinkConnectionFromats, const std::vector<bool> &convertionMatrix);
+ am_Error_e hookSystemUpdateConverter(const am_converterID_t converterID, const std::vector<am_CustomConnectionFormat_t> &listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t> &listSinkConnectionFromats, const std::vector<bool> &convertionMatrix);
+ void cbAckSetVolume(const am_Handle_s handle, const std::vector<am_Volumes_s> &listVolumes, const am_Error_e error);
+ void cbAckSetSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error);
+ void cbAckSetSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error);
+ void hookSinkNotificationDataChanged(const am_sinkID_t sinkID, const am_NotificationPayload_s &payload);
+ void hookSourceNotificationDataChanged(const am_sourceID_t sourceID, const am_NotificationPayload_s &payload);
+ am_Error_e hookUserSetMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s &notificationConfiguration);
+ am_Error_e hookUserSetMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s &notificationConfiguration);
void hookSystemSingleTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t time);
- void receiverCallback(const pollfd pollfd, const sh_pollHandle_t handle, void* userData);
- bool checkerCallback(const sh_pollHandle_t handle, void* userData);
- bool dispatcherCallback(const sh_pollHandle_t handle, void* userData);
+ void receiverCallback(const pollfd pollfd, const sh_pollHandle_t handle, void *userData);
+ bool checkerCallback(const sh_pollHandle_t handle, void *userData);
+ bool dispatcherCallback(const sh_pollHandle_t handle, void *userData);
void setControllerRundownSafe(int16_t signal)
{
int16_t p(signal);
ssize_t result(-1);
- result = write(mPipe[1], &p, sizeof(p));
- }
+ result = write(mPipe[1], &p, sizeof(p));
+ }
- TAmShPollFired<CAmControlSender> receiverCallbackT;
- TAmShPollCheck<CAmControlSender> checkerCallbackT;
+ TAmShPollFired<CAmControlSender> receiverCallbackT;
+ TAmShPollCheck<CAmControlSender> checkerCallbackT;
TAmShPollDispatch<CAmControlSender> dispatcherCallbackT;
-
- //we need this here to call the rundown from the signal handler. In case everything screwed up
+ // we need this here to call the rundown from the signal handler. In case everything screwed up
static void CallsetControllerRundown(int16_t signal)
{
if (mInstance)
+ {
mInstance->setControllerRundown(signal);
+ }
}
- //this static callback is used from the signal handler. It is used when a normal rundown is assumed and the mainloop is used to call rundown.
+ // this static callback is used from the signal handler. It is used when a normal rundown is assumed and the mainloop is used to call rundown.
static void CallsetControllerRundownSafe(int16_t signal)
{
if (mInstance)
@@ -142,12 +143,12 @@ public:
friend class IAmControlBackdoor;
#endif
private:
- int mPipe[2];
- void* mlibHandle; //!< pointer to the loaded control plugin interface
- IAmControlSend* mController; //!< pointer to the ControlSend interface
- static CAmControlSender* mInstance;
- int16_t mSignal;
- std::string mControlPluginFile;
+ int mPipe[2];
+ void *mlibHandle; //!< pointer to the loaded control plugin interface
+ IAmControlSend *mController; //!< pointer to the ControlSend interface
+ static CAmControlSender *mInstance;
+ int16_t mSignal;
+ std::string mControlPluginFile;
};
}
diff --git a/AudioManagerCore/include/CAmDatabaseHandlerMap.h b/AudioManagerCore/include/CAmDatabaseHandlerMap.h
index 2a3a9ec..93ee1be 100644
--- a/AudioManagerCore/include/CAmDatabaseHandlerMap.h
+++ b/AudioManagerCore/include/CAmDatabaseHandlerMap.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
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
*
* \file CAmDatabaseHandlerMap.h
* For further information see http://www.genivi.org/.
@@ -37,114 +37,114 @@
namespace am
{
#ifndef AM_MAP_CAPACITY
- #define AM_MAP_CAPACITY 0
+# define AM_MAP_CAPACITY 0
#endif
#ifndef AM_MAX_CONNECTIONS
- #define AM_MAX_CONNECTIONS 0x1000
+# define AM_MAX_CONNECTIONS 0x1000
#endif
#ifndef AM_MAX_MAIN_CONNECTIONS
- #define AM_MAX_MAIN_CONNECTIONS SHRT_MAX
+# define AM_MAX_MAIN_CONNECTIONS SHRT_MAX
#endif
-
-
-//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
-//todo: If the sink is part of a gateway, the listconnectionFormats is copied to the gatewayInformation. Check this statement for sinks & sources
-//todo: exchange last_insert_row id to be more safe
-//todo: create test to ensure uniqueness of names throughout the database
-//todo: enforce the uniqueness of names
+// 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
+// todo: If the sink is part of a gateway, the listconnectionFormats is copied to the gatewayInformation. Check this statement for sinks & sources
+// todo: exchange last_insert_row id to be more safe
+// todo: create test to ensure uniqueness of names throughout the database
+// todo: enforce the uniqueness of names
/**
* This class handles and abstracts the database
*/
class CAmDatabaseHandlerMap : public IAmDatabaseHandler
{
- bool mFirstStaticSink; //!< bool for dynamic range handling
- bool mFirstStaticSource; //!< bool for dynamic range handling
- bool mFirstStaticGateway; //!< bool for dynamic range handling
- bool mFirstStaticConverter; //!< bool for dynamic range handling
- bool mFirstStaticSinkClass; //!< bool for dynamic range handling
+ bool mFirstStaticSink; //!< bool for dynamic range handling
+ bool mFirstStaticSource; //!< bool for dynamic range handling
+ bool mFirstStaticGateway; //!< bool for dynamic range handling
+ bool mFirstStaticConverter; //!< bool for dynamic range handling
+ bool mFirstStaticSinkClass; //!< bool for dynamic range handling
bool mFirstStaticSourceClass; //!< bool for dynamic range handling
- bool mFirstStaticCrossfader; //!< bool for dynamic range handling
+ bool mFirstStaticCrossfader; //!< bool for dynamic range handling
public:
- CAmDatabaseHandlerMap();
+ CAmDatabaseHandlerMap();
virtual ~CAmDatabaseHandlerMap();
/**
- * Database observer.
- */
- struct AmDatabaseObserverCallbacks: public IAmDatabaseObserver
+ * 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;
+ 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);}
+ friend class CAmDatabaseHandlerMap;
+ AmDatabaseObserverCallbacks()
+ : IAmDatabaseObserver()
+ , mpDatabaseHandler(nullptr) {}
+ virtual ~AmDatabaseObserverCallbacks(){ if (mpDatabaseHandler) {mpDatabaseHandler->unregisterObserver(this);}}
protected:
- CAmDatabaseHandlerMap *mpDatabaseHandler;
+ 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);
- am_Error_e enterCrossfaderDB(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID);
- am_Error_e enterGatewayDB(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID);
- am_Error_e enterConverterDB(const am_Converter_s & converterData, am_converterID_t & converterID);
- am_Error_e enterSourceDB(const am_Source_s& sourceData, am_sourceID_t& sourceID);
- am_Error_e enterConnectionDB(const am_Connection_s& connection, am_connectionID_t& connectionID);
- am_Error_e enterSinkClassDB(const am_SinkClass_s& sinkClass, am_sinkClass_t& sinkClassID);
- am_Error_e enterSourceClassDB(am_sourceClass_t& sourceClassID, const am_SourceClass_s& sourceClass);
- am_Error_e enterSystemProperties(const std::vector<am_SystemProperty_s>& listSystemProperties);
- am_Error_e changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector<am_connectionID_t>& listConnectionID);
+ 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);
+ am_Error_e enterCrossfaderDB(const am_Crossfader_s &crossfaderData, am_crossfaderID_t &crossfaderID);
+ am_Error_e enterGatewayDB(const am_Gateway_s &gatewayData, am_gatewayID_t &gatewayID);
+ am_Error_e enterConverterDB(const am_Converter_s &converterData, am_converterID_t &converterID);
+ am_Error_e enterSourceDB(const am_Source_s &sourceData, am_sourceID_t &sourceID);
+ am_Error_e enterConnectionDB(const am_Connection_s &connection, am_connectionID_t &connectionID);
+ am_Error_e enterSinkClassDB(const am_SinkClass_s &sinkClass, am_sinkClass_t &sinkClassID);
+ am_Error_e enterSourceClassDB(am_sourceClass_t &sourceClassID, const am_SourceClass_s &sourceClass);
+ am_Error_e enterSystemProperties(const std::vector<am_SystemProperty_s> &listSystemProperties);
+ am_Error_e changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector<am_connectionID_t> &listConnectionID);
am_Error_e changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState);
am_Error_e changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID);
- am_Error_e changeSinkAvailabilityDB(const am_Availability_s& availability, const am_sinkID_t sinkID);
+ am_Error_e changeSinkAvailabilityDB(const am_Availability_s &availability, const am_sinkID_t sinkID);
am_Error_e changeDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID);
am_Error_e changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID);
- am_Error_e changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID);
- am_Error_e changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID);
- am_Error_e changeSourceSoundPropertyDB(const am_SoundProperty_s& soundProperty, const am_sourceID_t sourceID);
- am_Error_e changeSinkSoundPropertyDB(const am_SoundProperty_s& soundProperty, const am_sinkID_t sinkID);
- am_Error_e changeSourceAvailabilityDB(const am_Availability_s& availability, const am_sourceID_t sourceID);
- am_Error_e changeSystemPropertyDB(const am_SystemProperty_s& property);
- am_Error_e changeDelayMainConnection(const am_timeSync_t & delay, const am_mainConnectionID_t & connectionID);
- am_Error_e changeSinkClassInfoDB(const am_SinkClass_s& sinkClass);
- am_Error_e changeSourceClassInfoDB(const am_SourceClass_s& sourceClass);
+ am_Error_e changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s &soundProperty, const am_sinkID_t sinkID);
+ am_Error_e changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s &soundProperty, const am_sourceID_t sourceID);
+ am_Error_e changeSourceSoundPropertyDB(const am_SoundProperty_s &soundProperty, const am_sourceID_t sourceID);
+ am_Error_e changeSinkSoundPropertyDB(const am_SoundProperty_s &soundProperty, const am_sinkID_t sinkID);
+ am_Error_e changeSourceAvailabilityDB(const am_Availability_s &availability, const am_sourceID_t sourceID);
+ am_Error_e changeSystemPropertyDB(const am_SystemProperty_s &property);
+ am_Error_e changeDelayMainConnection(const am_timeSync_t &delay, const am_mainConnectionID_t &connectionID);
+ am_Error_e changeSinkClassInfoDB(const am_SinkClass_s &sinkClass);
+ am_Error_e changeSourceClassInfoDB(const am_SourceClass_s &sourceClass);
am_Error_e changeConnectionTimingInformation(const am_connectionID_t connectionID, const am_timeSync_t delay);
am_Error_e changeConnectionFinal(const am_connectionID_t connectionID);
am_Error_e changeSourceState(const am_sourceID_t sourceID, const am_SourceState_e sourceState);
@@ -162,80 +162,80 @@ public:
am_Error_e removeSinkClassDB(const am_sinkClass_t sinkClassID);
am_Error_e removeSourceClassDB(const am_sourceClass_t sourceClassID);
am_Error_e removeConnection(const am_connectionID_t connectionID);
- am_Error_e getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s& classInfo) const;
- am_Error_e getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s& sinkClass) const;
- am_Error_e getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s& gatewayData) const;
- am_Error_e getConverterInfoDB(const am_converterID_t converterID, am_Converter_s& converterData) const;
- am_Error_e getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s& sinkData) const;
- am_Error_e getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s& sourceData) const;
- am_Error_e getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s& crossfaderData) const;
- am_Error_e getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s& mainConnectionData) const;
- am_Error_e getSinkMainVolume(const am_sinkID_t sinkID, am_mainVolume_t& mainVolume) const;
- am_Error_e getSinkVolume(const am_sinkID_t sinkID, am_volume_t& volume) const;
- am_Error_e getSourceVolume(const am_sourceID_t sourceID, am_volume_t& volume) const;
- am_Error_e getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const;
- am_Error_e getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const;
- am_Error_e getMainSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const;
- am_Error_e getMainSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const;
- am_Error_e getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s>& listSoundproperties) const;
- am_Error_e getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s>& listSoundproperties) const;
- am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t>& listSinkID) const;
- am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t>& listSourceID) const;
- am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t>& listGatewaysID) const;
- am_Error_e getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t>& listGatewaysID) const;
- am_Error_e getListConvertersOfDomain(const am_domainID_t domainID, std::vector<am_converterID_t>& listConvertersID) const;
- am_Error_e getListMainConnections(std::vector<am_MainConnection_s>& listMainConnections) const;
- am_Error_e getListDomains(std::vector<am_Domain_s>& listDomains) const;
- am_Error_e getListConnections(std::vector<am_Connection_s>& listConnections) const;
- am_Error_e getListConnectionsReserved(std::vector<am_Connection_s>& listConnections) const;
- am_Error_e getListSinks(std::vector<am_Sink_s>& listSinks) const;
- am_Error_e getListSources(std::vector<am_Source_s>& lisSources) const;
- am_Error_e getListSourceClasses(std::vector<am_SourceClass_s>& listSourceClasses) const;
- am_Error_e getListCrossfaders(std::vector<am_Crossfader_s>& listCrossfaders) const;
- am_Error_e getListGateways(std::vector<am_Gateway_s>& listGateways) const;
- am_Error_e getListConverters(std::vector<am_Converter_s> & listConverters) const;
- am_Error_e getListSinkClasses(std::vector<am_SinkClass_s>& listSinkClasses) const;
- am_Error_e getListVisibleMainConnections(std::vector<am_MainConnectionType_s>& listConnections) const;
- am_Error_e getListMainSinks(std::vector<am_SinkType_s>& listMainSinks) const;
- am_Error_e getListMainSources(std::vector<am_SourceType_s>& listMainSources) const;
- am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s>& listSoundProperties) const;
- am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s>& listSourceProperties) const;
- am_Error_e getListSystemProperties(std::vector<am_SystemProperty_s>& listSystemProperties) const;
- am_Error_e getListSinkConnectionFormats(const am_sinkID_t sinkID, std::vector<am_CustomAvailabilityReason_t> & listConnectionFormats) const;
- am_Error_e getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector<am_CustomAvailabilityReason_t> & listConnectionFormats) const;
- am_Error_e getListGatewayConnectionFormats(const am_gatewayID_t gatewayID, std::vector<bool> & listConnectionFormat) const;
- am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay) const;
- am_Error_e getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t& domainID) const;
- am_Error_e getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t& domainID) const;
- am_Error_e getDomainOfCrossfader(const am_converterID_t crossfader, am_domainID_t& domainID) const;
- am_Error_e getSoureState(const am_sourceID_t sourceID, am_SourceState_e& sourceState) const;
- am_Error_e getDomainState(const am_domainID_t domainID, am_DomainState_e& state) const;
- am_Error_e peekDomain(const std::string& name, am_domainID_t& domainID);
- am_Error_e peekSink(const std::string& name, am_sinkID_t& sinkID);
- am_Error_e peekSource(const std::string& name, am_sourceID_t& sourceID);
- am_Error_e peekSinkClassID(const std::string& name, am_sinkClass_t& sinkClassID);
- am_Error_e peekSourceClassID(const std::string& name, am_sourceClass_t& sourceClassID);
- am_Error_e changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomAvailabilityReason_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties);
- am_Error_e changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomAvailabilityReason_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties);
- am_Error_e getListMainSinkNotificationConfigurations(const am_sinkID_t sinkID, std::vector<am_NotificationConfiguration_s>& listMainNotificationConfigurations);
- am_Error_e getListMainSourceNotificationConfigurations(const am_sourceID_t sourceID, std::vector<am_NotificationConfiguration_s>& listMainNotificationConfigurations);
+ am_Error_e getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s &classInfo) const;
+ am_Error_e getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s &sinkClass) const;
+ am_Error_e getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s &gatewayData) const;
+ am_Error_e getConverterInfoDB(const am_converterID_t converterID, am_Converter_s &converterData) const;
+ am_Error_e getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s &sinkData) const;
+ am_Error_e getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s &sourceData) const;
+ am_Error_e getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s &crossfaderData) const;
+ am_Error_e getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s &mainConnectionData) const;
+ am_Error_e getSinkMainVolume(const am_sinkID_t sinkID, am_mainVolume_t &mainVolume) const;
+ am_Error_e getSinkVolume(const am_sinkID_t sinkID, am_volume_t &volume) const;
+ am_Error_e getSourceVolume(const am_sourceID_t sourceID, am_volume_t &volume) const;
+ am_Error_e getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomSoundPropertyType_t propertyType, int16_t &value) const;
+ am_Error_e getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomSoundPropertyType_t propertyType, int16_t &value) const;
+ am_Error_e getMainSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t &value) const;
+ am_Error_e getMainSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t &value) const;
+ am_Error_e getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s> &listSoundproperties) const;
+ am_Error_e getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s> &listSoundproperties) const;
+ am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t> &listSinkID) const;
+ am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t> &listSourceID) const;
+ am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t> &listGatewaysID) const;
+ am_Error_e getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t> &listGatewaysID) const;
+ am_Error_e getListConvertersOfDomain(const am_domainID_t domainID, std::vector<am_converterID_t> &listConvertersID) const;
+ am_Error_e getListMainConnections(std::vector<am_MainConnection_s> &listMainConnections) const;
+ am_Error_e getListDomains(std::vector<am_Domain_s> &listDomains) const;
+ am_Error_e getListConnections(std::vector<am_Connection_s> &listConnections) const;
+ am_Error_e getListConnectionsReserved(std::vector<am_Connection_s> &listConnections) const;
+ am_Error_e getListSinks(std::vector<am_Sink_s> &listSinks) const;
+ am_Error_e getListSources(std::vector<am_Source_s> &lisSources) const;
+ am_Error_e getListSourceClasses(std::vector<am_SourceClass_s> &listSourceClasses) const;
+ am_Error_e getListCrossfaders(std::vector<am_Crossfader_s> &listCrossfaders) const;
+ am_Error_e getListGateways(std::vector<am_Gateway_s> &listGateways) const;
+ am_Error_e getListConverters(std::vector<am_Converter_s> &listConverters) const;
+ am_Error_e getListSinkClasses(std::vector<am_SinkClass_s> &listSinkClasses) const;
+ am_Error_e getListVisibleMainConnections(std::vector<am_MainConnectionType_s> &listConnections) const;
+ am_Error_e getListMainSinks(std::vector<am_SinkType_s> &listMainSinks) const;
+ am_Error_e getListMainSources(std::vector<am_SourceType_s> &listMainSources) const;
+ am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s> &listSoundProperties) const;
+ am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s> &listSourceProperties) const;
+ am_Error_e getListSystemProperties(std::vector<am_SystemProperty_s> &listSystemProperties) const;
+ am_Error_e getListSinkConnectionFormats(const am_sinkID_t sinkID, std::vector<am_CustomAvailabilityReason_t> &listConnectionFormats) const;
+ am_Error_e getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector<am_CustomAvailabilityReason_t> &listConnectionFormats) const;
+ am_Error_e getListGatewayConnectionFormats(const am_gatewayID_t gatewayID, std::vector<bool> &listConnectionFormat) const;
+ am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t &delay) const;
+ am_Error_e getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t &domainID) const;
+ am_Error_e getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t &domainID) const;
+ am_Error_e getDomainOfCrossfader(const am_converterID_t crossfader, am_domainID_t &domainID) const;
+ am_Error_e getSoureState(const am_sourceID_t sourceID, am_SourceState_e &sourceState) const;
+ am_Error_e getDomainState(const am_domainID_t domainID, am_DomainState_e &state) const;
+ am_Error_e peekDomain(const std::string &name, am_domainID_t &domainID);
+ am_Error_e peekSink(const std::string &name, am_sinkID_t &sinkID);
+ am_Error_e peekSource(const std::string &name, am_sourceID_t &sourceID);
+ am_Error_e peekSinkClassID(const std::string &name, am_sinkClass_t &sinkClassID);
+ am_Error_e peekSourceClassID(const std::string &name, am_sourceClass_t &sourceClassID);
+ am_Error_e changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s> &listSoundProperties, const std::vector<am_CustomAvailabilityReason_t> &listConnectionFormats, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties);
+ am_Error_e changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s> &listSoundProperties, const std::vector<am_CustomAvailabilityReason_t> &listConnectionFormats, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties);
+ am_Error_e getListMainSinkNotificationConfigurations(const am_sinkID_t sinkID, std::vector<am_NotificationConfiguration_s> &listMainNotificationConfigurations);
+ am_Error_e getListMainSourceNotificationConfigurations(const am_sourceID_t sourceID, std::vector<am_NotificationConfiguration_s> &listMainNotificationConfigurations);
am_Error_e changeMainSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration);
am_Error_e changeMainSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration);
- am_Error_e changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector<am_CustomAvailabilityReason_t>& listSourceConnectionFormats, const std::vector<am_CustomAvailabilityReason_t>& listSinkConnectionFormats, const std::vector<bool>& convertionMatrix);
- 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);
- am_Error_e changeSinkNotificationConfigurationDB(const am_sinkID_t sinkID,const am_NotificationConfiguration_s notificationConfiguration);
- am_Error_e changeSourceNotificationConfigurationDB(const am_sourceID_t sourceID,const am_NotificationConfiguration_s notificationConfiguration);
+ am_Error_e changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector<am_CustomAvailabilityReason_t> &listSourceConnectionFormats, const std::vector<am_CustomAvailabilityReason_t> &listSinkConnectionFormats, const std::vector<bool> &convertionMatrix);
+ 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);
+ am_Error_e changeSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration);
+ am_Error_e changeSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration);
bool existMainConnection(const am_mainConnectionID_t mainConnectionID) const;
bool existCrossFader(const am_crossfaderID_t crossfaderID) const;
- bool existConnection(const am_Connection_s & connection) const;
+ bool existConnection(const am_Connection_s &connection) const;
bool existConnectionID(const am_connectionID_t connectionID) const;
bool existSource(const am_sourceID_t sourceID) const;
- bool existSourceNameOrID(const am_sourceID_t sourceID, const std::string& name) const;
- bool existSourceName(const std::string& name) const;
+ bool existSourceNameOrID(const am_sourceID_t sourceID, const std::string &name) const;
+ bool existSourceName(const std::string &name) const;
bool existSink(const am_sinkID_t sinkID) const;
- bool existSinkNameOrID(const am_sinkID_t sinkID, const std::string& name) const;
- bool existSinkName(const std::string& name) const;
+ bool existSinkNameOrID(const am_sinkID_t sinkID, const std::string &name) const;
+ bool existSinkName(const std::string &name) const;
bool existDomain(const am_domainID_t domainID) const;
bool existGateway(const am_gatewayID_t gatewayID) const;
bool existConverter(const am_converterID_t converterID) const;
@@ -243,70 +243,71 @@ public:
bool existSourceClass(const am_sourceClass_t sourceClassID) const;
bool sourceVisible(const am_sourceID_t sourceID) const;
bool sinkVisible(const am_sinkID_t sinkID) const;
- bool isComponentConnected(const am_Gateway_s & gateway) const;
- bool isComponentConnected(const am_Converter_s & converter) const;
- void dump( std::ostream & output ) const;
- am_Error_e enumerateSources(std::function<void(const am_Source_s & element)> cb) const;
- 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);
+ bool isComponentConnected(const am_Gateway_s &gateway) const;
+ bool isComponentConnected(const am_Converter_s &converter) const;
+ void dump(std::ostream &output) const;
+ am_Error_e enumerateSources(std::function<void(const am_Source_s &element)> cb) const;
+ 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'.
*/
-#define AM_SUBCLASS(TYPE, SUBCLASS, CLASS, MEMBER, ASSIGN) \
- typedef struct SUBCLASS : public CLASS \
- { \
- MEMBER \
- bool reserved; \
- SUBCLASS() : CLASS(), reserved(false) {} \
- SUBCLASS & operator=(const SUBCLASS &anObject) \
- { \
- if (this != &anObject) \
- { \
- CLASS::operator=(anObject); \
- reserved = anObject.reserved; \
- ASSIGN \
- } \
- return *this; \
- } \
- SUBCLASS & operator=(const CLASS & anObject) \
- { \
- if (this != &anObject) { \
- CLASS::operator=(anObject);} \
- return *this; \
- } \
- void getDescription(std::string & outString) const; \
- } TYPE \
+#define AM_SUBCLASS(TYPE, SUBCLASS, CLASS, MEMBER, ASSIGN) \
+ typedef struct SUBCLASS : public CLASS \
+ { \
+ MEMBER \
+ bool reserved; \
+ SUBCLASS() : CLASS(), reserved(false) {} \
+ SUBCLASS &operator=(const SUBCLASS &anObject) \
+ { \
+ if (this != &anObject) \
+ { \
+ CLASS::operator=(anObject); \
+ reserved = anObject.reserved; \
+ ASSIGN \
+ } \
+ return *this; \
+ } \
+ SUBCLASS &operator=(const CLASS &anObject) \
+ { \
+ if (this != &anObject) { \
+ CLASS::operator=(anObject);} \
+ return *this; \
+ } \
+ void getDescription(std::string &outString) const; \
+ } TYPE \
#define AM_SUBLCASS_ADD_MAP_TYPE(TYPE, NAME) std::unordered_map<TYPE, int16_t> NAME;
-#define AM_SUBLCASS_ADD_ASSIGNMENT(NAME) NAME = anObject.NAME;
+#define AM_SUBLCASS_ADD_ASSIGNMENT(NAME) NAME = anObject.NAME;
private:
AM_SUBCLASS(AmDomain, am_Domain_Database_s, am_Domain_s, , );
- AM_SUBCLASS(AmSink, am_Sink_Database_s, am_Sink_s, \
- void getSinkType(am_SinkType_s & sinkType) const; \
- AM_SUBLCASS_ADD_MAP_TYPE(am_CustomSoundPropertyType_t, cacheSoundProperties) \
- AM_SUBLCASS_ADD_MAP_TYPE(am_CustomMainSoundPropertyType_t, cacheMainSoundProperties), \
- AM_SUBLCASS_ADD_ASSIGNMENT(cacheSoundProperties) \
- AM_SUBLCASS_ADD_ASSIGNMENT(cacheMainSoundProperties) );
+ AM_SUBCLASS(AmSink, am_Sink_Database_s, am_Sink_s, \
+ void getSinkType(am_SinkType_s & sinkType) const; \
+ AM_SUBLCASS_ADD_MAP_TYPE(am_CustomSoundPropertyType_t, cacheSoundProperties) \
+ AM_SUBLCASS_ADD_MAP_TYPE(am_CustomMainSoundPropertyType_t, cacheMainSoundProperties), \
+ AM_SUBLCASS_ADD_ASSIGNMENT(cacheSoundProperties) \
+ AM_SUBLCASS_ADD_ASSIGNMENT(cacheMainSoundProperties));
AM_SUBCLASS(AmSource, am_Source_Database_s, am_Source_s,
- void getSourceType(am_SourceType_s & sourceType) const; \
- AM_SUBLCASS_ADD_MAP_TYPE(am_CustomSoundPropertyType_t, cacheSoundProperties) \
- AM_SUBLCASS_ADD_MAP_TYPE(am_CustomMainSoundPropertyType_t, cacheMainSoundProperties), \
- AM_SUBLCASS_ADD_ASSIGNMENT(cacheSoundProperties) \
- AM_SUBLCASS_ADD_ASSIGNMENT(cacheMainSoundProperties) );
+ void getSourceType(am_SourceType_s & sourceType) const; \
+ AM_SUBLCASS_ADD_MAP_TYPE(am_CustomSoundPropertyType_t, cacheSoundProperties) \
+ AM_SUBLCASS_ADD_MAP_TYPE(am_CustomMainSoundPropertyType_t, cacheMainSoundProperties), \
+ AM_SUBLCASS_ADD_ASSIGNMENT(cacheSoundProperties) \
+ AM_SUBLCASS_ADD_ASSIGNMENT(cacheMainSoundProperties));
AM_SUBCLASS(AmConnection, am_Connection_Database_s, am_Connection_s, , );
AM_SUBCLASS(AmMainConnection, am_MainConnection_Database_s, am_MainConnection_s,
- void getMainConnectionType(am_MainConnectionType_s & connectionType) const;, );
+ void getMainConnectionType(am_MainConnectionType_s & connectionType) const;
+ , );
AM_SUBCLASS(AmSourceClass, am_SourceClass_Database_s, am_SourceClass_s, , );
@@ -318,18 +319,17 @@ private:
AM_SUBCLASS(AmCrossfader, am_Crossfader_Database_s, am_Crossfader_s, , );
-
- 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;
+ 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.
@@ -343,159 +343,191 @@ private:
* The structure encapsulates the id boundary and the current id value.
* It defines a range within the id can vary.
*/
- struct AmIdentifier
- {
- int16_t mMin; //!< min possible value
- int16_t mMax; //!< max possible value
- int16_t mCurrentValue; //!< current value
-
- 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);};
- };
-
- 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),
- mCurrentSinkID(DYNAMIC_ID_BOUNDARY, SHRT_MAX),
- mCurrentSourceID(DYNAMIC_ID_BOUNDARY, SHRT_MAX),
- mCurrentGatewayID(DYNAMIC_ID_BOUNDARY, SHRT_MAX),
- mCurrentConverterID(DYNAMIC_ID_BOUNDARY, SHRT_MAX),
- mCurrentCrossfaderID(DYNAMIC_ID_BOUNDARY, SHRT_MAX),
- mCurrentConnectionID(1, AM_MAX_CONNECTIONS),
- mCurrentMainConnectionID(1, AM_MAX_MAIN_CONNECTIONS),
-
- mSystemProperties(),
- mDomainMap(),mSourceClassesMap(), mSinkClassesMap(), mSinkMap(AM_MAP_CAPACITY), mSourceMap(AM_MAP_CAPACITY),
- mGatewayMap(), mConverterMap(), mCrossfaderMap(), mConnectionMap(), mMainConnectionMap()
- {};
- /**
- * \brief Increases a given map ID.
- *
- * A common method implementing the logic for static and dynamic IDs except main connection ID.
- *
- * @param resultID Pointer to an output variable.
- * @param elementID Pointer to ID, which will be manipulated.
- * @param desiredStaticID Not 0 for static IDs and 0 for dynamic IDs.
- * Usually the static IDs are in interval [1 , DYNAMIC_ID_BOUNDARY-1]. Default is 0.
- * @return TRUE on successfully changed ID.
- */
- bool increaseID(int16_t & resultID, AmIdentifier & elementID, int16_t const desiredStaticID);
- /**
- * \brief Increases the main connection ID.
- *
- * @param resultID Pointer to an output variable.
- * @return TRUE on successfully changed ID.
- */
- bool increaseMainConnectionID(int16_t & resultID);
-
- /**
- * \brief Increases the connection ID.
- *
- * @param resultID Pointer to an output variable.
- * @return TRUE on successfully changed ID.
- */
- bool increaseConnectionID(int16_t & resultID);
-
- template <class TPrintObject> static void print (const TPrintObject & t, std::ostream & output)
+ struct AmIdentifier
+ {
+ int16_t mMin; //!< min possible value
+ int16_t mMax; //!< max possible value
+ int16_t mCurrentValue; //!< current value
+
+ 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);}
+ };
+
+ 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)
+ , mCurrentSinkID(DYNAMIC_ID_BOUNDARY, SHRT_MAX)
+ , mCurrentSourceID(DYNAMIC_ID_BOUNDARY, SHRT_MAX)
+ , mCurrentGatewayID(DYNAMIC_ID_BOUNDARY, SHRT_MAX)
+ , mCurrentConverterID(DYNAMIC_ID_BOUNDARY, SHRT_MAX)
+ , mCurrentCrossfaderID(DYNAMIC_ID_BOUNDARY, SHRT_MAX)
+ , mCurrentConnectionID(1, AM_MAX_CONNECTIONS)
+ , mCurrentMainConnectionID(1, AM_MAX_MAIN_CONNECTIONS)
+ , mSystemProperties()
+ , mDomainMap()
+ , mSourceClassesMap()
+ , mSinkClassesMap()
+ , mSinkMap(AM_MAP_CAPACITY)
+ , mSourceMap(AM_MAP_CAPACITY)
+ , mGatewayMap()
+ , mConverterMap()
+ , mCrossfaderMap()
+ , mConnectionMap()
+ , mMainConnectionMap()
+ {}
+ /**
+ * \brief Increases a given map ID.
+ *
+ * A common method implementing the logic for static and dynamic IDs except main connection ID.
+ *
+ * @param resultID Pointer to an output variable.
+ * @param elementID Pointer to ID, which will be manipulated.
+ * @param desiredStaticID Not 0 for static IDs and 0 for dynamic IDs.
+ * Usually the static IDs are in interval [1 , DYNAMIC_ID_BOUNDARY-1]. Default is 0.
+ * @return TRUE on successfully changed ID.
+ */
+ bool increaseID(int16_t &resultID, AmIdentifier &elementID, int16_t const desiredStaticID);
+
+ /**
+ * \brief Increases the main connection ID.
+ *
+ * @param resultID Pointer to an output variable.
+ * @return TRUE on successfully changed ID.
+ */
+ bool increaseMainConnectionID(int16_t &resultID);
+
+ /**
+ * \brief Increases the connection ID.
+ *
+ * @param resultID Pointer to an output variable.
+ * @return TRUE on successfully changed ID.
+ */
+ bool increaseConnectionID(int16_t &resultID);
+
+ template <class TPrintObject>
+ static void print(const TPrintObject &t, std::ostream &output)
{
- std::string description;
- t.getDescription( description );
- output << description;
+ std::string description;
+ t.getDescription(description);
+ output << description;
}
- template <typename TPrintMapKey,class TPrintMapObject> static void printMap (const std::unordered_map<TPrintMapKey, TPrintMapObject> & t, std::ostream & output)
+
+ template <typename TPrintMapKey, class TPrintMapObject>
+ static void printMap(const std::unordered_map<TPrintMapKey, TPrintMapObject> &t, std::ostream &output)
{
- typename std::unordered_map<TPrintMapKey, TPrintMapObject>::const_iterator iter = t.begin();
- for(; iter!=t.end(); iter++)
- AmMappedData::print(iter->second, output);
+ typename std::unordered_map<TPrintMapKey, TPrintMapObject>::const_iterator iter = t.begin();
+ for (; iter != t.end(); iter++)
+ {
+ AmMappedData::print(iter->second, output);
+ }
}
+
private:
- template <typename TMapKey,class TMapObject> bool getNextConnectionID(int16_t & resultID, AmIdentifier & connID,
- const std::unordered_map<TMapKey, TMapObject> & map);
+ template <typename TMapKey, class TMapObject>
+ bool getNextConnectionID(int16_t &resultID, AmIdentifier &connID,
+ const std::unordered_map<TMapKey, TMapObject> &map);
+
};
/*
* Helper methods.
*/
am_timeSync_t calculateMainConnectionDelay(const am_mainConnectionID_t mainConnectionID) const; //!< calculates a new main connection delay
- int16_t calculateDelayForRoute(const std::vector<am_connectionID_t>& listConnectionID);
- bool insertSinkDB(const am_Sink_s & sinkData, am_sinkID_t & sinkID);
- bool insertCrossfaderDB(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID);
- bool insertGatewayDB(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID);
- bool insertConverterDB(const am_Converter_s & converteData, am_converterID_t & converterID);
- bool insertSourceDB(const am_Source_s & sourceData, am_sourceID_t & sourceID);
- bool insertSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID);
- bool insertSourceClassDB(am_sourceClass_t & sourceClassID, const am_SourceClass_s & sourceClass);
- const am_Sink_Database_s * sinkWithNameOrID(const am_sinkID_t sinkID, const std::string & name) const;
- const am_Source_Database_s * sourceWithNameOrID(const am_sourceID_t sourceID, const std::string & name) const;
- template <class Component> bool isConnected(const Component & comp) const
+ int16_t calculateDelayForRoute(const std::vector<am_connectionID_t> &listConnectionID);
+ bool insertSinkDB(const am_Sink_s &sinkData, am_sinkID_t &sinkID);
+ bool insertCrossfaderDB(const am_Crossfader_s &crossfaderData, am_crossfaderID_t &crossfaderID);
+ bool insertGatewayDB(const am_Gateway_s &gatewayData, am_gatewayID_t &gatewayID);
+ bool insertConverterDB(const am_Converter_s &converteData, am_converterID_t &converterID);
+ bool insertSourceDB(const am_Source_s &sourceData, am_sourceID_t &sourceID);
+ bool insertSinkClassDB(const am_SinkClass_s &sinkClass, am_sinkClass_t &sinkClassID);
+ bool insertSourceClassDB(am_sourceClass_t &sourceClassID, const am_SourceClass_s &sourceClass);
+ const am_Sink_Database_s *sinkWithNameOrID(const am_sinkID_t sinkID, const std::string &name) const;
+ const am_Source_Database_s *sourceWithNameOrID(const am_sourceID_t sourceID, const std::string &name) const;
+
+ template <class Component>
+ bool isConnected(const Component &comp) const
+ {
+ return std::find_if(mMappedData.mConnectionMap.begin(), mMappedData.mConnectionMap.end(), [&](const std::pair<am_connectionID_t, am_Connection_Database_s> &rConnection){
+ return (rConnection.second.sinkID == comp.sinkID || rConnection.second.sourceID == comp.sourceID);
+ }) != mMappedData.mConnectionMap.end();
+ }
+
+ void filterDuplicateNotificationConfigurationTypes(std::vector<am_NotificationConfiguration_s> &list)
{
- return std::find_if(mMappedData.mConnectionMap.begin(), mMappedData.mConnectionMap.end(),[&](const std::pair<am_connectionID_t, am_Connection_Database_s>& rConnection){
- return (rConnection.second.sinkID == comp.sinkID ||rConnection.second.sourceID ==comp.sourceID);})!=mMappedData.mConnectionMap.end();
+ std::vector<am_NotificationConfiguration_s> oldList(list);
+ list.clear();
+ std::for_each(oldList.begin(), oldList.end(), [&](am_NotificationConfiguration_s &provided) {
+ std::vector<am_NotificationConfiguration_s>::iterator found =
+ std::find_if(list.begin(), list.end(), [&](am_NotificationConfiguration_s &stored) {
+ if (provided.type == stored.type)
+ {
+ stored = provided;
+ return true;
+ }
+
+ return false;
+ });
+ if (found == list.end())
+ {
+ list.push_back(provided);
+ }
+ });
}
- void filterDuplicateNotificationConfigurationTypes(std::vector<am_NotificationConfiguration_s> & list)
- {
- std::vector<am_NotificationConfiguration_s> oldList(list);
- list.clear();
- std::for_each(oldList.begin(), oldList.end(), [&](am_NotificationConfiguration_s & provided) {
- std::vector<am_NotificationConfiguration_s>::iterator found =
- std::find_if(list.begin(), list.end(), [&](am_NotificationConfiguration_s & stored) {
- if (provided.type == stored.type) {
- stored = provided;
- return true;
- }
- return false;
- } );
- if (found == list.end())
- list.push_back(provided);
- } );
- }
ListConnectionFormat mListConnectionFormat; //!< list of connection formats
- AmMappedData mMappedData; //!< Internal structure encapsulating all the maps used in this class
- std::vector<AmDatabaseObserverCallbacks*> mDatabaseObservers;
+ AmMappedData mMappedData; //!< Internal structure encapsulating all the maps used in this class
+ std::vector<AmDatabaseObserverCallbacks *> mDatabaseObservers;
#ifdef UNIT_TEST
- public:
- void setConnectionIDRange(const int16_t & min, const int16_t & max)
- {
- mMappedData.mCurrentConnectionID.mMin = min;
- mMappedData.mCurrentConnectionID.mMax = max;
- }
- void setMainConnectionIDRange(const int16_t & min, const int16_t & max)
- {
- mMappedData.mCurrentMainConnectionID.mMin = min;
- mMappedData.mCurrentMainConnectionID.mMax = max;
- }
- void setSinkIDRange(const int16_t & min, const int16_t & max)
- {
- mMappedData.mCurrentSinkID.mMin = min;
- mMappedData.mCurrentSinkID.mMax = max;
- }
-#endif
+public:
+ void setConnectionIDRange(const int16_t &min, const int16_t &max)
+ {
+ mMappedData.mCurrentConnectionID.mMin = min;
+ mMappedData.mCurrentConnectionID.mMax = max;
+ }
+
+ void setMainConnectionIDRange(const int16_t &min, const int16_t &max)
+ {
+ mMappedData.mCurrentMainConnectionID.mMin = min;
+ mMappedData.mCurrentMainConnectionID.mMax = max;
+ }
+
+ void setSinkIDRange(const int16_t &min, const int16_t &max)
+ {
+ mMappedData.mCurrentSinkID.mMin = min;
+ mMappedData.mCurrentSinkID.mMax = max;
+ }
+#endif // ifdef UNIT_TEST
};
}
diff --git a/AudioManagerCore/include/CAmGraph.h b/AudioManagerCore/include/CAmGraph.h
index 45043f7..9d9f082 100644
--- a/AudioManagerCore/include/CAmGraph.h
+++ b/AudioManagerCore/include/CAmGraph.h
@@ -37,643 +37,704 @@
#include <cstring>
#include <set>
-
namespace am
{
- /**
- * Graph element status.
- */
- typedef enum:uint8_t
- {
- GES_NOT_VISITED,
- GES_IN_PROGRESS,
- GES_VISITED
- }am_GraphElementStatus_e;
-
- /**
- * Callback parameter telling on which position in the path we are.
- */
- typedef enum:uint8_t
- {
- GRAPH_PATH_START, //at the beginning of the path
- GRAPH_PATH_MIDDLE, //in middle of the path
- GRAPH_PATH_END //at the end of the path
- }am_GraphPathPosition_e;
-
-
- /**
- * This class is base class for nodes and vertices.
- */
- class CAmGraphElement
- {
- am_GraphElementStatus_e mStatus; //!< item status
- public:
- CAmGraphElement(): mStatus(GES_NOT_VISITED) { };
- ~CAmGraphElement() { };
- /**
- * Setter and getter.
- */
- void setStatus(const am_GraphElementStatus_e s) { mStatus = s; };
- am_GraphElementStatus_e getStatus() const { return mStatus; };
- };
-
- template <class NodeData> class CAmNode : public CAmGraphElement
- {
- uint16_t mIndex; //!< uint16_t index used for direct access
- NodeData mData; //!< NodeData user data
- public:
- CAmNode(const NodeData & in):CAmGraphElement(), mIndex(0), mData(in) { };
- CAmNode(const NodeData & in, const uint16_t index):CAmGraphElement(), mIndex(index), mData(in) { };
- ~CAmNode() { };
- /**
- * 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; }
- };
-
- template <class NodeData, class VertexData> class CAmVertex : public CAmGraphElement
- {
- CAmNode<NodeData>* mpNode; //!< CAmNode<NodeData>* pointer to a node
- VertexData mVertexData; //!< VertexData vertex user data
- uint16_t mWeight; //!< uint16_t a positive value used in the shortest path algorithms
- public:
- CAmVertex(CAmNode<NodeData> *aNode, const VertexData & vertexData, const uint16_t weight):CAmGraphElement(),
- mpNode(aNode), mVertexData(vertexData), mWeight(weight) { };
- ~CAmVertex() { };
- /**
- * Setters and getters.
- */
- CAmNode<NodeData>* getNode() const { return mpNode; }
- VertexData & getData() { return mVertexData; }
- uint16_t getWeight() const { return mWeight; }
- void setWeight(const uint16_t weight) { mWeight=weight; }
- };
-
- /**
- * Class representing a directed or undirected graph. It contains nodes and connections.
- * T, V are types for custom user data.
- */
- template <class T, class V> class CAmGraph
- {
- 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::vector<CAmNode<T>*> CAmNodeReferenceList;
- typedef typename std::vector<CAmListVertices*> CAmVertexReferenceList;
-
- CAmListNodes mStoreNodes; //!< CAmListNodes list with all nodes
- CAmNodesAdjList mStoreAdjList; //!< CAmNodesAdjList adjacency list
- CAmNodeReferenceList mPointersNodes; //!< CAmNodeReferenceList vector with pointers to nodes for direct access
- 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.
- *
- * @param fromIndex updates all nodes from given index.
- */
- void updateIndexes(const int16_t fromIndex)
- {
- if( fromIndex<mPointersNodes.size() )
- {
- for(auto iter = mPointersNodes.begin()+fromIndex; iter!=mPointersNodes.end(); iter++)
- (*iter)->setIndex(iter-mPointersNodes.begin());
- }
- }
-
-
- /**
- * Finds the shortest path and the minimal weights from given node.
- *
- * @param node start node.
- * @param minDistance vector with all result distances.
- * @param previous vector with previous nodes.
- */
-
- typedef uint16_t vertex_t;
- typedef uint16_t weight_t;
-
- void findShortestPathsFromNode(const CAmNode<T> & node, std::vector<weight_t> &minDistance, std::vector<CAmNode<T> *> &previous)
- {
- typename CAmListVertices::const_iterator nIter;
- CAmListVertices * neighbors;
- weight_t dist, weight, v, distanceThroughU;
- CAmNode<T>* pU;
- CAmVertex<T,V> * pVertex;
- CAmNode<T> *pDstNode;
-
- size_t n = mPointersAdjList.size();
- std::set<std::pair<weight_t, CAmNode<T>*> > vertexQueue;
-
- minDistance.clear();
- minDistance.resize(n, std::numeric_limits<weight_t>::max());
- minDistance[node.getIndex()] = 0;
- previous.clear();
- previous.resize(n, NULL);
-
- vertexQueue.insert(std::make_pair(minDistance[node.getIndex()], (CAmNode<T>*)&node));
-
- while (!vertexQueue.empty())
- {
- dist = vertexQueue.begin()->first;
- pU = vertexQueue.begin()->second;
- vertexQueue.erase(vertexQueue.begin());
- //todo: terminate the search at this position if you want the path to a target node ( if(pU==target)break; )
-
- // Visit each edge exiting u
- neighbors = mPointersAdjList[pU->getIndex()];
- nIter = neighbors->begin();
- for (; nIter != neighbors->end(); nIter++)
- {
- pVertex = (CAmVertex<T,V> *)&(*nIter);
- pDstNode = pVertex->getNode();
-
- v = pDstNode->getIndex();
- weight = pVertex->getWeight();
- distanceThroughU = dist + weight;
- if (distanceThroughU < minDistance[pDstNode->getIndex()])
- {
- vertexQueue.erase(std::make_pair(minDistance[v], pDstNode));
- minDistance[v] = distanceThroughU;
- previous[v] = pU;
- vertexQueue.insert(std::make_pair(minDistance[v], pDstNode));
- }
- }
- }
- }
-
- /**
- * Constructs a path to given node after findShortestsPathsFromNode has been called.
- *
- * @param node end node.
- * @param previous vector with previous nodes.
- * @param result result path.
- */
- void constructShortestPathTo(const CAmNode<T> & node, const std::vector<CAmNode<T> *> &previous, CAmListNodePtrs & result)
- {
- CAmNode<T> * vertex = (CAmNode<T> *)&node;
-
- int i=0;
- while ( (vertex = previous[vertex->getIndex()])!=NULL )
- {
- result.insert(result.begin(), vertex);
- i++;
- }
- if(i)
- result.push_back((CAmNode<T> *)&node);
- }
-
- /**
- * Calls a function with every node from this path after findShortestsPathsFromNode has been called.
- * The construction of the path is delegated to the caller.
- *
- * @param node end node.
- * @param previous vector with previous nodes.
- * @param cb callback which is mostly used for constructing.
- */
- void constructShortestPathTo(const CAmNode<T> & node, const std::vector<CAmNode<T> *> &previous, std::function<void(const am_GraphPathPosition_e pos, CAmNode<T> &)> cb)
- {
- CAmNode<T> * vertex = (CAmNode<T> *)&node;
- CAmNode<T> * prev = vertex;
- int i=0;
- while ( (vertex = previous[vertex->getIndex()])!=NULL )
- {
- cb(i==0?GRAPH_PATH_START:GRAPH_PATH_MIDDLE, *prev);
- prev = vertex;
- i++;
- }
- if(i)
- cb(GRAPH_PATH_END, *prev);
- }
-
- /**
- * Iterate through the nodes and generate all paths to given node.
- *
- * @param dst end node.
- * @param visited vector with current path.
- * @param delegate enumeration delegate.
- */
- void findAllPaths(IterateThroughAllNodesDelegate & delegate)
- {
- CAmListVertices * nodes = mPointersAdjList[delegate.visited.back()->getIndex()];
- CAmListVerticesItrConst vItr(nodes->begin());
-
- CAmVertex<T,V> * pNextVertex;
- CAmNode<T> * pNextNode;
- for (; vItr != nodes->end(); ++vItr)
- {
- pNextVertex = (CAmVertex<T,V> *)&(*vItr);
- pNextNode = pNextVertex->getNode();
- if(
- pNextNode->getStatus()!=GES_NOT_VISITED ||
- !delegate.shouldVisitNode(pNextNode)
- )
- continue;
- if (pNextNode==delegate.destination)
- {
- delegate.willVisitNode(pNextNode);
- pNextNode->setStatus(GES_IN_PROGRESS);
- delegate.visited.push_back(pNextNode);
- //notify observer
- delegate.didFindPath(delegate.visited);
- //remove last node from the list
- auto last = delegate.visited.end()-1;
- delegate.visited.erase(last);
- pNextNode->setStatus(GES_NOT_VISITED);
- delegate.didVisitNode(pNextNode);
- break;
- }
- }
- vItr = nodes->begin();
- //bfs like loop
- for (; vItr != nodes->end(); ++vItr)
- {
- pNextVertex = (CAmVertex<T,V> *)&(*vItr);
- pNextNode = pNextVertex->getNode();
-
- if(pNextNode->getStatus()!=GES_NOT_VISITED ||
- pNextNode==delegate.destination ||
- !delegate.shouldVisitNode(pNextNode)
- )
- continue;
- delegate.willVisitNode(pNextNode);
- pNextNode->setStatus(GES_IN_PROGRESS);
- delegate.visited.push_back(pNextNode);
- findAllPaths(delegate);
- //remove last node from the list
- 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;
- inItr itr(v.begin());
-
- for (; itr != v.end(); ++itr)
- {
- addNode(*itr);
- }
-
- mIsCyclic = false;
- };
- CAmGraph():mStoreNodes(), mStoreAdjList(), mPointersNodes(), mPointersAdjList(), mIsCyclic(false){};
- ~CAmGraph(){}
-
- const CAmListNodes & getNodes() const
- {
- return mStoreNodes;
- }
-
- const CAmVertexReferenceList & getVertexList() const
- {
- return mPointersAdjList;
- }
-
- /**
- * Returns pointer to a node which data is equal to the given.
- * @return pointer to a node or NULL.
- */
- const CAmNode<T>* findNode(const T & in)
- {
- typename CAmNodeReferenceList::const_iterator itr (mPointersNodes.begin());
-
- for (; itr != mPointersNodes.end(); ++itr)
- {
- if ((*itr)->getData() == in) {
- return (*itr);
- }
- }
- return NULL;
- }
-
- /**
- * Returns pointer to a vertex which two ends are equal to the given nodes.
- * @return pointer to a vertex or NULL.
- */
- const CAmVertex<T,V>* findVertex(const CAmNode<T> & edge1, const CAmNode<T> & edge2) const
- {
- const CAmNode<T> * pEdge2 = (CAmNode<T> *)&edge2;
- const CAmListVertices * list = mPointersAdjList[edge1.getIndex()];
- CAmListVerticesItrConst result = std::find_if(list->begin(), list->end(), [&](const CAmVertex<T,V> & refObject){
- return refObject.getNode()==pEdge2;
- });
- if(result!=list->end())
- return (CAmVertex<T,V>*)&(*result);
-
- return NULL;
- }
-
- bool hasCycles() const
- {
- return mIsCyclic;
- }
-
-
- /**
- * Adds a new node to the graph with given user data.
- * @return reference to the newly inserted node.
- */
- 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();
- }
-
- /**
- * Removes a vertex with two ends equal to the given nodes .
- */
- void removeVertex(const CAmNode<T> & edge1, const CAmNode<T> & edge2)
- {
- const CAmListVertices * list = mPointersAdjList[edge1.getIndex()];
- CAmListVerticesItr iter = std::find_if(list->begin(), list->end(), [&edge2](const CAmVertex<T,V> & refVertex){
- return (refVertex.getNode()==&edge2);
- });
- if(iter!=list->end())
- list->erase(iter);
- }
-
- /**
- * Removes all vertices to given node .
- */
- void removeAllVerticesToNode(const CAmNode<T> & node)
- {
- auto comparator = [&node](const CAmVertex<T,V> & refVertex){
- return (refVertex.getNode()==&node);
- };
- auto itr = mPointersAdjList.begin();
- for(;itr!=mPointersAdjList.end();itr++)
- {
- CAmListVertices * vertices = *itr;
- auto iterVert = std::find_if(vertices->begin(), vertices->end(), comparator);
- if(iterVert!=vertices->end())
- vertices->erase(iterVert);
- }
- }
-
- /**
- * Removes a node with given user data .
- */
- void removeNode(const T & in)
- {
- CAmNode<T> * node = findNode(in);
- if(node!=NULL)
- removeNode(*node);
- }
-
- /**
- * Removes the given node from the graph .
- */
- 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;
+/**
+ * Graph element status.
+ */
+typedef enum : uint8_t
+{
+ GES_NOT_VISITED,
+ GES_IN_PROGRESS,
+ GES_VISITED
+} am_GraphElementStatus_e;
+
+/**
+ * Callback parameter telling on which position in the path we are.
+ */
+typedef enum : uint8_t
+{
+ GRAPH_PATH_START, // at the beginning of the path
+ GRAPH_PATH_MIDDLE, // in middle of the path
+ GRAPH_PATH_END // at the end of the path
+} am_GraphPathPosition_e;
+
+/**
+ * This class is base class for nodes and vertices.
+ */
+class CAmGraphElement
+{
+ am_GraphElementStatus_e mStatus; //!< item status
+public:
+ CAmGraphElement()
+ : mStatus(GES_NOT_VISITED) { }
+ ~CAmGraphElement() { }
+ /**
+ * Setter and getter.
+ */
+ void setStatus(const am_GraphElementStatus_e s) { mStatus = s; }
+ am_GraphElementStatus_e getStatus() const { return mStatus; }
+};
+
+template <class NodeData>
+class CAmNode : public CAmGraphElement
+{
+ uint16_t mIndex; //!< uint16_t index used for direct access
+ NodeData mData; //!< NodeData user data
+public:
+ CAmNode(const NodeData &in)
+ : CAmGraphElement()
+ , mIndex(0)
+ , mData(in) { }
+ CAmNode(const NodeData &in, const uint16_t index)
+ : CAmGraphElement()
+ , mIndex(index)
+ , mData(in) { }
+ ~CAmNode() { }
+ /**
+ * 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; }
+};
+
+template <class NodeData, class VertexData>
+class CAmVertex : public CAmGraphElement
+{
+ CAmNode<NodeData> *mpNode; //!< CAmNode<NodeData>* pointer to a node
+ VertexData mVertexData; //!< VertexData vertex user data
+ uint16_t mWeight; //!< uint16_t a positive value used in the shortest path algorithms
+public:
+ CAmVertex(CAmNode<NodeData> *aNode, const VertexData &vertexData, const uint16_t weight)
+ : CAmGraphElement()
+ , mpNode(aNode)
+ , mVertexData(vertexData)
+ , mWeight(weight) { }
+ ~CAmVertex() { }
+ /**
+ * Setters and getters.
+ */
+ CAmNode<NodeData> *getNode() const { return mpNode; }
+ VertexData &getData() { return mVertexData; }
+ uint16_t getWeight() const { return mWeight; }
+ void setWeight(const uint16_t weight) { mWeight = weight; }
+};
+
+/**
+ * Class representing a directed or undirected graph. It contains nodes and connections.
+ * T, V are types for custom user data.
+ */
+template <class T, class V>
+class CAmGraph
+{
+ 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::vector<CAmNode<T> *> CAmNodeReferenceList;
+ typedef typename std::vector<CAmListVertices *> CAmVertexReferenceList;
+
+ CAmListNodes mStoreNodes; //!< CAmListNodes list with all nodes
+ CAmNodesAdjList mStoreAdjList; //!< CAmNodesAdjList adjacency list
+ CAmNodeReferenceList mPointersNodes; //!< CAmNodeReferenceList vector with pointers to nodes for direct access
+ 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.
+ *
+ * @param fromIndex updates all nodes from given index.
+ */
+ void updateIndexes(const int16_t fromIndex)
+ {
+ if ( fromIndex < mPointersNodes.size())
+ {
+ for (auto iter = mPointersNodes.begin() + fromIndex; iter != mPointersNodes.end(); iter++)
+ {
+ (*iter)->setIndex(iter - mPointersNodes.begin());
+ }
+ }
+ }
+
+ /**
+ * Finds the shortest path and the minimal weights from given node.
+ *
+ * @param node start node.
+ * @param minDistance vector with all result distances.
+ * @param previous vector with previous nodes.
+ */
+
+ typedef uint16_t vertex_t;
+ typedef uint16_t weight_t;
+
+ void findShortestPathsFromNode(const CAmNode<T> &node, std::vector<weight_t> &minDistance, std::vector<CAmNode<T> *> &previous)
+ {
+ typename CAmListVertices::const_iterator nIter;
+ CAmListVertices *neighbors;
+ weight_t dist, weight, v, distanceThroughU;
+ CAmNode<T> *pU;
+ CAmVertex<T, V> *pVertex;
+ CAmNode<T> *pDstNode;
+
+ size_t n = mPointersAdjList.size();
+ std::set<std::pair<weight_t, CAmNode<T> *> > vertexQueue;
+
+ minDistance.clear();
+ minDistance.resize(n, std::numeric_limits<weight_t>::max());
+ minDistance[node.getIndex()] = 0;
+ previous.clear();
+ previous.resize(n, NULL);
+
+ vertexQueue.insert(std::make_pair(minDistance[node.getIndex()], (CAmNode<T> *) & node));
+
+ while (!vertexQueue.empty())
+ {
+ dist = vertexQueue.begin()->first;
+ pU = vertexQueue.begin()->second;
+ vertexQueue.erase(vertexQueue.begin());
+ // todo: terminate the search at this position if you want the path to a target node ( if(pU==target)break; )
+
+ // Visit each edge exiting u
+ neighbors = mPointersAdjList[pU->getIndex()];
+ nIter = neighbors->begin();
+ for (; nIter != neighbors->end(); nIter++)
+ {
+ pVertex = (CAmVertex<T, V> *) & (*nIter);
+ pDstNode = pVertex->getNode();
+
+ v = pDstNode->getIndex();
+ weight = pVertex->getWeight();
+ distanceThroughU = dist + weight;
+ if (distanceThroughU < minDistance[pDstNode->getIndex()])
+ {
+ vertexQueue.erase(std::make_pair(minDistance[v], pDstNode));
+ minDistance[v] = distanceThroughU;
+ previous[v] = pU;
+ vertexQueue.insert(std::make_pair(minDistance[v], pDstNode));
+ }
+ }
+ }
+ }
+
+ /**
+ * Constructs a path to given node after findShortestsPathsFromNode has been called.
+ *
+ * @param node end node.
+ * @param previous vector with previous nodes.
+ * @param result result path.
+ */
+ void constructShortestPathTo(const CAmNode<T> &node, const std::vector<CAmNode<T> *> &previous, CAmListNodePtrs &result)
+ {
+ CAmNode<T> *vertex = (CAmNode<T> *) & node;
+
+ int i = 0;
+ while ((vertex = previous[vertex->getIndex()]) != NULL )
+ {
+ result.insert(result.begin(), vertex);
+ i++;
+ }
+
+ if (i)
+ {
+ result.push_back((CAmNode<T> *) & node);
+ }
+ }
+
+ /**
+ * Calls a function with every node from this path after findShortestsPathsFromNode has been called.
+ * The construction of the path is delegated to the caller.
+ *
+ * @param node end node.
+ * @param previous vector with previous nodes.
+ * @param cb callback which is mostly used for constructing.
+ */
+ void constructShortestPathTo(const CAmNode<T> &node, const std::vector<CAmNode<T> *> &previous, std::function<void(const am_GraphPathPosition_e pos, CAmNode<T> &)> cb)
+ {
+ CAmNode<T> *vertex = (CAmNode<T> *) & node;
+ CAmNode<T> *prev = vertex;
+ int i = 0;
+ while ((vertex = previous[vertex->getIndex()]) != NULL )
+ {
+ cb(i == 0 ? GRAPH_PATH_START : GRAPH_PATH_MIDDLE, *prev);
+ prev = vertex;
+ i++;
+ }
+
+ if (i)
+ {
+ cb(GRAPH_PATH_END, *prev);
+ }
+ }
+
+ /**
+ * Iterate through the nodes and generate all paths to given node.
+ *
+ * @param dst end node.
+ * @param visited vector with current path.
+ * @param delegate enumeration delegate.
+ */
+ void findAllPaths(IterateThroughAllNodesDelegate &delegate)
+ {
+ CAmListVertices *nodes = mPointersAdjList[delegate.visited.back()->getIndex()];
+ CAmListVerticesItrConst vItr(nodes->begin());
+
+ CAmVertex<T, V> *pNextVertex;
+ CAmNode<T> *pNextNode;
+ for (; vItr != nodes->end(); ++vItr)
+ {
+ pNextVertex = (CAmVertex<T, V> *) & (*vItr);
+ pNextNode = pNextVertex->getNode();
+ if (
+ pNextNode->getStatus() != GES_NOT_VISITED ||
+ !delegate.shouldVisitNode(pNextNode)
+ )
+ {
+ continue;
+ }
+
+ if (pNextNode == delegate.destination)
+ {
+ delegate.willVisitNode(pNextNode);
+ pNextNode->setStatus(GES_IN_PROGRESS);
+ delegate.visited.push_back(pNextNode);
+ // notify observer
+ delegate.didFindPath(delegate.visited);
+ // remove last node from the list
+ auto last = delegate.visited.end() - 1;
+ delegate.visited.erase(last);
+ pNextNode->setStatus(GES_NOT_VISITED);
+ delegate.didVisitNode(pNextNode);
+ break;
+ }
+ }
+
+ vItr = nodes->begin();
+ // bfs like loop
+ for (; vItr != nodes->end(); ++vItr)
+ {
+ pNextVertex = (CAmVertex<T, V> *) & (*vItr);
+ pNextNode = pNextVertex->getNode();
+
+ if (pNextNode->getStatus() != GES_NOT_VISITED ||
+ pNextNode == delegate.destination ||
+ !delegate.shouldVisitNode(pNextNode)
+ )
+ {
+ continue;
+ }
+
+ delegate.willVisitNode(pNextNode);
+ pNextNode->setStatus(GES_IN_PROGRESS);
+ delegate.visited.push_back(pNextNode);
+ findAllPaths(delegate);
+ // remove last node from the list
+ 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;
+ inItr itr(v.begin());
+
+ for (; itr != v.end(); ++itr)
+ {
+ addNode(*itr);
+ }
+
+ mIsCyclic = false;
+ }
+
+ CAmGraph()
+ : mStoreNodes()
+ , mStoreAdjList()
+ , mPointersNodes()
+ , mPointersAdjList()
+ , mIsCyclic(false){}
+ ~CAmGraph(){}
+
+ const CAmListNodes &getNodes() const
+ {
+ return mStoreNodes;
+ }
+
+ const CAmVertexReferenceList &getVertexList() const
+ {
+ return mPointersAdjList;
+ }
+
+ /**
+ * Returns pointer to a node which data is equal to the given.
+ * @return pointer to a node or NULL.
+ */
+ const CAmNode<T> *findNode(const T &in)
+ {
+ typename CAmNodeReferenceList::const_iterator itr(mPointersNodes.begin());
+
+ for (; itr != mPointersNodes.end(); ++itr)
+ {
+ if ((*itr)->getData() == in)
+ {
+ return (*itr);
+ }
+ }
+
+ return NULL;
+ }
+
+ /**
+ * Returns pointer to a vertex which two ends are equal to the given nodes.
+ * @return pointer to a vertex or NULL.
+ */
+ const CAmVertex<T, V> *findVertex(const CAmNode<T> &edge1, const CAmNode<T> &edge2) const
+ {
+ const CAmNode<T> *pEdge2 = (CAmNode<T> *) & edge2;
+ const CAmListVertices *list = mPointersAdjList[edge1.getIndex()];
+ CAmListVerticesItrConst result = std::find_if(list->begin(), list->end(), [&](const CAmVertex<T, V> &refObject){
+ return refObject.getNode() == pEdge2;
+ });
+ if (result != list->end())
+ {
+ return (CAmVertex<T, V> *) & (*result);
+ }
+
+ return NULL;
+ }
+
+ bool hasCycles() const
+ {
+ return mIsCyclic;
+ }
+
+ /**
+ * Adds a new node to the graph with given user data.
+ * @return reference to the newly inserted node.
+ */
+ 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();
+ }
+
+ /**
+ * Removes a vertex with two ends equal to the given nodes .
+ */
+ void removeVertex(const CAmNode<T> &edge1, const CAmNode<T> &edge2)
+ {
+ const CAmListVertices *list = mPointersAdjList[edge1.getIndex()];
+ CAmListVerticesItr iter = std::find_if(list->begin(), list->end(), [&edge2](const CAmVertex<T, V> &refVertex){
+ return (refVertex.getNode() == &edge2);
+ });
+ if (iter != list->end())
+ {
+ list->erase(iter);
+ }
+ }
+
+ /**
+ * Removes all vertices to given node .
+ */
+ void removeAllVerticesToNode(const CAmNode<T> &node)
+ {
+ auto comparator = [&node](const CAmVertex<T, V> &refVertex){
+ return (refVertex.getNode() == &node);
+ };
+ auto itr = mPointersAdjList.begin();
+ for (; itr != mPointersAdjList.end(); itr++)
+ {
+ CAmListVertices *vertices = *itr;
+ auto iterVert = std::find_if(vertices->begin(), vertices->end(), comparator);
+ if (iterVert != vertices->end())
+ {
+ vertices->erase(iterVert);
+ }
+ }
+ }
+
+ /**
+ * Removes a node with given user data .
+ */
+ void removeNode(const T &in)
+ {
+ CAmNode<T> *node = findNode(in);
+ if (node != NULL)
+ {
+ removeNode(*node);
+ }
+ }
+
+ /**
+ * Removes the given node from the graph .
+ */
+ 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);
+ }
+
+ /**
+ * Connect first with last node and set user data and weight to the vertex.
+ */
+ void connectNodes(const CAmNode<T> &first, const CAmNode<T> &last, const V &vertexData, const int16_t weight = 1)
+ {
+ CAmListVertices *list = mPointersAdjList[first.getIndex()];
+ CAmNode<T> *node = mPointersNodes[last.getIndex()];
+ list->emplace_back(node, vertexData, weight);
+ }
+
+ /**
+ * Exists any vertex with two given ends.
+ * @return TRUE on successfully changed ID.
+ */
+ bool isAnyVertex(const CAmNode<T> &edge1, const CAmNode<T> &edge2) const
+ {
+ return findVertex(edge1, edge2) != NULL;
+ }
+
+ /**
+ * Sets the status of all nodes and vertices to GES_NOT_VISITED.
+ */
+ void reset()
+ {
+ // set all nodes to GES_NOT_VISITED
+ std::for_each(mPointersNodes.begin(), mPointersNodes.end(), [](CAmNode<T> *refNode){
+ if (refNode->getStatus() != GES_NOT_VISITED)
+ {
+ refNode->setStatus(GES_NOT_VISITED);
+ }
+ });
+ // set all vertices to GES_NOT_VISITED
+ auto action = [](CAmVertex<T, V> &refVertex){
+ if (refVertex.getStatus() != GES_NOT_VISITED)
+ {
+ refVertex.setStatus(GES_NOT_VISITED);
+ }
+ };
+ auto itr1(mPointersAdjList.begin());
+ for (; itr1 != mPointersAdjList.end(); ++itr1)
+ {
+ CAmListVertices *vertices = *itr1;
+ std::for_each(vertices->begin(), vertices->end(), action);
+ }
+ }
+
+ /**
+ * Clears all nodes and vertices.
+ */
+ void clear()
+ {
+ mStoreNodes.clear();
+ mStoreAdjList.clear();
+ mPointersAdjList.clear();
+ mPointersNodes.clear();
+ mPointersAdjList.clear();
+ }
+
+ /**
+ * Goes through all nodes and vertices and calls the callback.
+ */
+ void trace(std::function<void(const CAmNode<T> &, const std::vector<CAmVertex<T, V> *> &)> cb)
+ {
+ std::for_each(mPointersNodes.begin(), mPointersNodes.end(), [&](CAmNode<T> *refNode){
+ CAmListVertices *vertices = this->mPointersAdjList[refNode->getIndex()];
+ std::vector<CAmVertex<T, V> *> list;
+ std::for_each(vertices->begin(), vertices->end(), [&list](CAmVertex<T, V> &refVertex){
+ list.push_back(&refVertex);
});
- if(iter!=mStoreNodes.end())
- mStoreNodes.erase(iter);
- updateIndexes(index);
- }
-
- /**
- * Connect first with last node and set user data and weight to the vertex.
- */
- void connectNodes(const CAmNode<T> & first, const CAmNode<T> & last, const V & vertexData, const int16_t weight = 1)
- {
- CAmListVertices * list = mPointersAdjList[first.getIndex()];
- CAmNode<T> * node = mPointersNodes[last.getIndex()];
- list->emplace_back(node, vertexData, weight);
- }
-
- /**
- * Exists any vertex with two given ends.
- * @return TRUE on successfully changed ID.
- */
- bool isAnyVertex(const CAmNode<T> & edge1, const CAmNode<T> & edge2) const
- {
- return findVertex(edge1, edge2)!=NULL;
- }
-
- /**
- * Sets the status of all nodes and vertices to GES_NOT_VISITED.
- */
- void reset()
- {
- // set all nodes to GES_NOT_VISITED
- std::for_each(mPointersNodes.begin(), mPointersNodes.end(), [](CAmNode<T> * refNode){
- if(refNode->getStatus()!= GES_NOT_VISITED)
- refNode->setStatus(GES_NOT_VISITED);
- });
- // set all vertices to GES_NOT_VISITED
- auto action = [](CAmVertex<T,V> & refVertex){
- if(refVertex.getStatus()!= GES_NOT_VISITED)
- refVertex.setStatus(GES_NOT_VISITED);
- };
- auto itr1(mPointersAdjList.begin());
- for (; itr1 != mPointersAdjList.end(); ++itr1)
- {
- CAmListVertices * vertices = *itr1;
- std::for_each(vertices->begin(), vertices->end(), action);
- }
- }
-
- /**
- * Clears all nodes and vertices.
- */
- void clear()
- {
- mStoreNodes.clear();
- mStoreAdjList.clear();
- mPointersAdjList.clear();
- mPointersNodes.clear();
- mPointersAdjList.clear();
- }
-
- /**
- * Goes through all nodes and vertices and calls the callback.
- */
- void trace(std::function<void(const CAmNode<T> &, const std::vector<CAmVertex<T,V>*> &)> cb)
- {
- std::for_each(mPointersNodes.begin(), mPointersNodes.end(), [&](CAmNode<T> * refNode){
- CAmListVertices * vertices = this->mPointersAdjList[refNode->getIndex()];
- std::vector<CAmVertex<T,V>*> list;
- std::for_each(vertices->begin(), vertices->end(), [&list](CAmVertex<T,V> & refVertex){
- list.push_back(&refVertex);
- });
- cb(*refNode, list);
- });
- }
-
- /**
- * Finds the shortest path from given node to all nodes in listTargets.
- *
- * @param source start node.
- * @param listTargets destination nodes.
- * @param resultPath list with all shortest paths.
- */
- void getShortestPath(const CAmNode<T> & source, const CAmListNodePtrs & listTargets, std::vector<CAmListNodePtrs> & resultPath )
- {
- const size_t numberOfNodes = mPointersNodes.size();
- if(numberOfNodes==0)
- return;
-
- std::vector<weight_t> min_distance;
- std::vector<CAmNode<T>*> previous;
- findShortestPathsFromNode(source, min_distance, previous);
-
- for(auto it=listTargets.begin(); it!=listTargets.end(); it++)
- {
- CAmNode<T> *node = *it;
- resultPath.emplace_back();
- CAmListNodePtrs & path = resultPath.back();
- constructShortestPathTo(*node, previous, path);
- if(path.empty())
- {
- typename std::vector<CAmListNodePtrs>::iterator iter = resultPath.end();
- resultPath.erase(--iter);
- }
- }
- }
-
- /**
- * Finds the shortest path between two nodes.
- *
- * @param source start node.
- * @param destination destination node.
- * @param resultPath list with the found shortest paths.
- */
- void getShortestPath(const CAmNode<T> & source, const CAmNode<T> & destination, CAmListNodePtrs & resultPath )
- {
- const size_t numberOfNodes = mPointersNodes.size();
- if(numberOfNodes==0)
- return;
- std::vector<weight_t> min_distance;
- std::vector<CAmNode<T>*> previous;
- findShortestPathsFromNode(source, min_distance, previous);
- constructShortestPathTo(destination, previous, resultPath);
- }
-
- /**
- * Finds the shortest path from given node to all nodes in listTargets.
- * Delegates the construction of the path to the caller.
- *
- * @param source start node.
- * @param listTargets destination nodes.
- * @param cb callabck.
- */
- void getShortestPath(const CAmNode<T> & source,
- const CAmListNodePtrs & listTargets,
- std::function<void(const am_GraphPathPosition_e, CAmNode<T> &)> cb )
- {
- const size_t numberOfNodes = mPointersNodes.size();
- if(numberOfNodes==0)
- return;
-
- std::vector<weight_t> min_distance;
- std::vector<CAmNode<T>*> previous;
- findShortestPathsFromNode(source, min_distance, previous);
-
- for(auto it=listTargets.begin(); it!=listTargets.end(); it++)
- {
- CAmNode<T>* node = *it;
- constructShortestPathTo(*node, previous, cb);
- }
- }
-
- /**
- * Finds the shortest path between two given nodes.
- * Delegates the construction of the path to the caller.
- *
- * @param source start node.
- * @param destination destination node.
- * @param cb callabck.
- */
- void getShortestPath(const CAmNode<T> & source,
- const CAmNode<T> & destination,
- std::function<void(const am_GraphPathPosition_e, CAmNode<T> &)> cb )
- {
- const size_t numberOfNodes = mPointersNodes.size();
- if(numberOfNodes==0)
- return;
-
- std::vector<weight_t> min_distance;
- std::vector<CAmNode<T>*> previous;
- findShortestPathsFromNode(source, min_distance, previous);
- constructShortestPathTo(destination, previous, cb);
- }
-
- /**
- * Finds all possible paths between two given nodes.
- * Delegates the construction of the path to the caller.
- *
- * @param src start node.
- * @param dst destination node.
- * @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(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)
- {
- 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);
- findAllPaths(delegate);
- ((CAmNode<T>*)&src)->setStatus(GES_NOT_VISITED);
- }
- };
+ cb(*refNode, list);
+ });
+ }
+
+ /**
+ * Finds the shortest path from given node to all nodes in listTargets.
+ *
+ * @param source start node.
+ * @param listTargets destination nodes.
+ * @param resultPath list with all shortest paths.
+ */
+ void getShortestPath(const CAmNode<T> &source, const CAmListNodePtrs &listTargets, std::vector<CAmListNodePtrs> &resultPath)
+ {
+ const size_t numberOfNodes = mPointersNodes.size();
+ if (numberOfNodes == 0)
+ {
+ return;
+ }
+
+ std::vector<weight_t> min_distance;
+ std::vector<CAmNode<T> *> previous;
+ findShortestPathsFromNode(source, min_distance, previous);
+
+ for (auto it = listTargets.begin(); it != listTargets.end(); it++)
+ {
+ CAmNode<T> *node = *it;
+ resultPath.emplace_back();
+ CAmListNodePtrs &path = resultPath.back();
+ constructShortestPathTo(*node, previous, path);
+ if (path.empty())
+ {
+ typename std::vector<CAmListNodePtrs>::iterator iter = resultPath.end();
+ resultPath.erase(--iter);
+ }
+ }
+ }
+
+ /**
+ * Finds the shortest path between two nodes.
+ *
+ * @param source start node.
+ * @param destination destination node.
+ * @param resultPath list with the found shortest paths.
+ */
+ void getShortestPath(const CAmNode<T> &source, const CAmNode<T> &destination, CAmListNodePtrs &resultPath)
+ {
+ const size_t numberOfNodes = mPointersNodes.size();
+ if (numberOfNodes == 0)
+ {
+ return;
+ }
+
+ std::vector<weight_t> min_distance;
+ std::vector<CAmNode<T> *> previous;
+ findShortestPathsFromNode(source, min_distance, previous);
+ constructShortestPathTo(destination, previous, resultPath);
+ }
+
+ /**
+ * Finds the shortest path from given node to all nodes in listTargets.
+ * Delegates the construction of the path to the caller.
+ *
+ * @param source start node.
+ * @param listTargets destination nodes.
+ * @param cb callabck.
+ */
+ void getShortestPath(const CAmNode<T> &source,
+ const CAmListNodePtrs &listTargets,
+ std::function<void(const am_GraphPathPosition_e, CAmNode<T> &)> cb)
+ {
+ const size_t numberOfNodes = mPointersNodes.size();
+ if (numberOfNodes == 0)
+ {
+ return;
+ }
+
+ std::vector<weight_t> min_distance;
+ std::vector<CAmNode<T> *> previous;
+ findShortestPathsFromNode(source, min_distance, previous);
+
+ for (auto it = listTargets.begin(); it != listTargets.end(); it++)
+ {
+ CAmNode<T> *node = *it;
+ constructShortestPathTo(*node, previous, cb);
+ }
+ }
+
+ /**
+ * Finds the shortest path between two given nodes.
+ * Delegates the construction of the path to the caller.
+ *
+ * @param source start node.
+ * @param destination destination node.
+ * @param cb callabck.
+ */
+ void getShortestPath(const CAmNode<T> &source,
+ const CAmNode<T> &destination,
+ std::function<void(const am_GraphPathPosition_e, CAmNode<T> &)> cb)
+ {
+ const size_t numberOfNodes = mPointersNodes.size();
+ if (numberOfNodes == 0)
+ {
+ return;
+ }
+
+ std::vector<weight_t> min_distance;
+ std::vector<CAmNode<T> *> previous;
+ findShortestPathsFromNode(source, min_distance, previous);
+ constructShortestPathTo(destination, previous, cb);
+ }
+
+ /**
+ * Finds all possible paths between two given nodes.
+ * Delegates the construction of the path to the caller.
+ *
+ * @param src start node.
+ * @param dst destination node.
+ * @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(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)
+ {
+ 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);
+ findAllPaths(delegate);
+ ((CAmNode<T> *) & src)->setStatus(GES_NOT_VISITED);
+ }
+
+};
}
-#endif
+#endif // ifndef GRAPH_H
diff --git a/AudioManagerCore/include/CAmLog.h b/AudioManagerCore/include/CAmLog.h
index cf7a3a6..5659961 100644
--- a/AudioManagerCore/include/CAmLog.h
+++ b/AudioManagerCore/include/CAmLog.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
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
*
* \file CAmLog.h
* For further information see http://www.genivi.org/.
@@ -40,11 +40,11 @@
* Example: CAmLogger << "Text"; //to print out through the singleton object directly to the console
*/
-#define DEFAULT_LOG_FOLDER "/tmp/"
+#define DEFAULT_LOG_FOLDER "/tmp/"
#define DEFAULT_LOGFILE_PREFIX "am_dump_"
-#define DEFAULT_LOGFILE_EXT ".log"
+#define DEFAULT_LOGFILE_EXT ".log"
-#define DEL( aPointer ) delete aPointer, aPointer = NULL
+#define DEL(aPointer) delete aPointer, aPointer = NULL
/* */
typedef enum { eCAmLogNone = 0, eCAmLogStdout = 1, eCAmLogFile = 2 } eCAmLogType;
@@ -52,78 +52,86 @@ typedef enum { eCAmLogNone = 0, eCAmLogStdout = 1, eCAmLogFile = 2 } eCAmLogType
class CAmLog
{
private:
- /**
- * Private classes which usually own (wrap) a stream object. They are responsible for creating and deleting it.
- */
- class CAmLogger
- {
- protected:
- std::ostream* mOutputStream;
- public:
- CAmLogger ():mOutputStream(NULL) {};
- virtual ~CAmLogger () { };
- virtual void log(const std::string& _s)
- {
- (*mOutputStream) << _s;
- mOutputStream->flush();
- }
- template <class T>
- CAmLogger & operator << (const T & t)
- {
- (*mOutputStream) << t;
- return (*this);
- }
- };
-
- class CAmFileLogger : public CAmLogger
- {
- std::string mFilename;
- public:
- static void generateLogFilename(std::string &result);
- explicit CAmFileLogger(const std::string& _s) : CAmLogger()
- {
- mFilename = _s;
- mOutputStream = new std::ofstream(mFilename.c_str());
- }
- ~CAmFileLogger();
- };
-
- class CAmStdOutLogger : public CAmLogger
- {
- public:
- CAmStdOutLogger()
- {
- mOutputStream = &std::cout;
- }
- };
+ /**
+ * Private classes which usually own (wrap) a stream object. They are responsible for creating and deleting it.
+ */
+ class CAmLogger
+ {
+ protected:
+ std::ostream *mOutputStream;
+ public:
+ CAmLogger ()
+ : mOutputStream(NULL) {}
+ virtual ~CAmLogger () { }
+ virtual void log(const std::string &_s)
+ {
+ (*mOutputStream) << _s;
+ mOutputStream->flush();
+ }
+
+ template <class T>
+ CAmLogger &operator <<(const T &t)
+ {
+ (*mOutputStream) << t;
+ return (*this);
+ }
+
+ };
+
+ class CAmFileLogger : public CAmLogger
+ {
+ std::string mFilename;
+ public:
+ static void generateLogFilename(std::string &result);
+
+ explicit CAmFileLogger(const std::string &_s)
+ : CAmLogger()
+ {
+ mFilename = _s;
+ mOutputStream = new std::ofstream(mFilename.c_str());
+ }
+
+ ~CAmFileLogger();
+ };
+
+ class CAmStdOutLogger : public CAmLogger
+ {
+ public:
+ CAmStdOutLogger()
+ {
+ mOutputStream = &std::cout;
+ }
+
+ };
private:
- eCAmLogType mLogType;
- CAmLogger* mLogger;
+ eCAmLogType mLogType;
+ CAmLogger *mLogger;
protected:
void releaseLogger();
- void instantiateLogger( const eCAmLogType type);
+ void instantiateLogger(const eCAmLogType type);
+
public:
- CAmLog(const eCAmLogType type );
+ CAmLog(const eCAmLogType type);
CAmLog();
~CAmLog();
static CAmLog *getDefaultLog();
- void setLogType( const eCAmLogType type);
+ void setLogType(const eCAmLogType type);
eCAmLogType getLogType() const;
template <class T>
- CAmLog & operator << (const T & t)
+ CAmLog &operator <<(const T &t)
{
- assert(mLogger!=NULL);
- (*mLogger) << t;
- return (*this);
+ assert(mLogger != NULL);
+ (*mLogger) << t;
+ return (*this);
}
- };
-#define CAmLogger (*CAmLog::getDefaultLog())
+};
+#define CAmLogger (*CAmLog::getDefaultLog())
#endif /* CAMLOG_H_ */
diff --git a/AudioManagerCore/include/CAmRouter.h b/AudioManagerCore/include/CAmRouter.h
index f62141a..bb889c3 100644
--- a/AudioManagerCore/include/CAmRouter.h
+++ b/AudioManagerCore/include/CAmRouter.h
@@ -36,343 +36,372 @@
namespace am
{
- /**
- * Optimal path search is implemented with graph which contains nodes - sinks, sources, gateways, converters.
- * The nodes are identified by sinkID, sourceID, gatewayID, converterID.
- * A possible connection between two nodes represents the facts that the nodes can be connected with one or more connectionFormats (Node[id=1] ---> Node[id=2]).
- * It is assumption that the two nodes can be connected. The controller itself decides later whether the connection is possible or not.
- *
- */
+/**
+ * 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.
- */
+/**
+ * Trace on/off.
+ */
#undef TRACE_GRAPH
- /**
- * Max paths count returned to the controller
- */
+/**
+ * Max paths count returned to the controller
+ */
#ifndef MAX_ROUTING_PATHS
-#define MAX_ROUTING_PATHS 5
+# define MAX_ROUTING_PATHS 5
#endif
- /**
- * How many times the routing algorithm should look back into domains.
- *
- * 0 - no cycles are allowed
- * 1 - default is one cycle
- * ...
- * UINT_MAX - set this define to UINT_MAX in order to allow cycles.
- *
- */
+/**
+ * How many times the routing algorithm should look back into domains.
+ *
+ * 0 - no cycles are allowed
+ * 1 - default is one cycle
+ * ...
+ * UINT_MAX - set this define to UINT_MAX in order to allow cycles.
+ *
+ */
#ifndef MAX_ALLOWED_DOMAIN_CYCLES
-#define MAX_ALLOWED_DOMAIN_CYCLES 1
+# define MAX_ALLOWED_DOMAIN_CYCLES 1
#endif
- class CAmRouter;
+class CAmRouter;
- /**
- * A structure used as user data in the graph nodes.
- */
- struct am_RoutingNodeData_s
+/**
+ * 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
{
- 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)
- {
- }
+ 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 operator==(const am_RoutingNodeData_s &anotherObject) const
+ {
+ bool result = false;
+ if (type == anotherObject.type)
{
- bool result = false;
- if (type == anotherObject.type)
+ result = true;
+ if (type == SINK)
{
- 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);
+ result &= (data.sink->sinkID == anotherObject.data.sink->sinkID);
}
- return result;
- }
- ;
-
-#ifdef TRACE_GRAPH
-#define COUT_NODE(HEAD, NAME, ID) \
- std::cout << HEAD << "(" << std::setfill('0') << std::setw(4) << ID << " " << NAME << ")"
-
- void trace() const
- {
- if(type==SINK)
- COUT_NODE("SI", data.sink->name, data.sink->sinkID );
- else if(type==SOURCE)
- COUT_NODE("SO", data.source->name, data.source->sourceID );
- else if(type==GATEWAY)
- COUT_NODE("GA", data.gateway->name, data.gateway->gatewayID );
- else if(type==CONVERTER)
- COUT_NODE("CO", data.converter->name, data.converter->converterID );
- };
-#endif
-
- am_domainID_t domainID() const
- {
- if (type == SINK)
- return data.sink->domainID;
else if (type == SOURCE)
- return data.source->domainID;
+ {
+ result &= (data.source->sourceID == anotherObject.data.source->sourceID);
+ }
else if (type == GATEWAY)
- return data.gateway->controlDomainID;
+ {
+ result &= (data.gateway->gatewayID == anotherObject.data.gateway->gatewayID);
+ }
else if (type == CONVERTER)
- return data.converter->domainID;
- return 0;
+ {
+ result &= (data.converter->converterID == anotherObject.data.converter->converterID);
+ }
}
- ;
- };
- 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;
+ return result;
+ }
- class CAmControlSender;
+#ifdef TRACE_GRAPH
+# define COUT_NODE(HEAD, NAME, ID) \
+ std::cout << HEAD << "(" << std::setfill('0') << std::setw(4) << ID << " " << NAME << ")"
- /**
- * Implements autorouting algorithm for connecting sinks and sources via different audio domains.
- */
- class CAmRouter: public CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks
+ void trace() const
{
- 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)
+ if (type == SINK)
{
- return mpDatabaseHandler->isComponentConnected(comp);
+ COUT_NODE("SI", data.sink->name, data.sink->sinkID);
}
-
- /**
- * 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()
+ else if (type == SOURCE)
+ {
+ COUT_NODE("SO", data.source->name, data.source->sourceID);
+ }
+ else if (type == GATEWAY)
{
- return mMaxAllowedCycles;
+ COUT_NODE("GA", data.gateway->name, data.gateway->gatewayID);
}
- void setMaxAllowedCycles(unsigned count)
+ else if (type == CONVERTER)
{
- mMaxAllowedCycles = count;
+ COUT_NODE("CO", data.converter->name, data.converter->converterID);
}
+ }
+#endif // ifdef TRACE_GRAPH
- unsigned getMaxPathCount()
+ am_domainID_t domainID() const
+ {
+ if (type == SINK)
{
- return mMaxPathCount;
+ return data.sink->domainID;
}
- void setMaxPathCount(unsigned count)
+ else if (type == SOURCE)
{
- mMaxPathCount = count;
+ return data.source->domainID;
}
-
- bool getUpdateGraphNodesAction()
+ else if (type == GATEWAY)
+ {
+ return data.gateway->controlDomainID;
+ }
+ else if (type == CONVERTER)
{
- return mUpdateGraphNodesAction;
+ return data.converter->domainID;
}
- /**
- * 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!")));
- };
+ 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/CAmRoutingReceiver.h b/AudioManagerCore/include/CAmRoutingReceiver.h
index e8f464f..42f3e89 100644
--- a/AudioManagerCore/include/CAmRoutingReceiver.h
+++ b/AudioManagerCore/include/CAmRoutingReceiver.h
@@ -38,7 +38,7 @@ class CAmControlSender;
/**
* Implements the Receiving side of the RoutingPlugins.
*/
-class CAmRoutingReceiver: public IAmRoutingReceive
+class CAmRoutingReceiver : public IAmRoutingReceive
{
public:
CAmRoutingReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler);
@@ -56,47 +56,47 @@ public:
void ackCrossFading(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error);
void ackSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume);
void ackSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume);
- am_Error_e peekDomain(const std::string& name, am_domainID_t& domainID);
- am_Error_e registerDomain(const am_Domain_s& domainData, am_domainID_t& domainID);
+ am_Error_e peekDomain(const std::string &name, am_domainID_t &domainID);
+ am_Error_e registerDomain(const am_Domain_s &domainData, am_domainID_t &domainID);
am_Error_e deregisterDomain(const am_domainID_t domainID);
- am_Error_e registerGateway(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID);
- am_Error_e registerConverter(const am_Converter_s& converterData, am_converterID_t& converterID);
+ am_Error_e registerGateway(const am_Gateway_s &gatewayData, am_gatewayID_t &gatewayID);
+ am_Error_e registerConverter(const am_Converter_s &converterData, am_converterID_t &converterID);
am_Error_e deregisterGateway(const am_gatewayID_t gatewayID);
am_Error_e deregisterConverter(const am_converterID_t converterID);
- am_Error_e peekSink(const std::string& name, am_sinkID_t& sinkID);
- am_Error_e registerSink(const am_Sink_s& sinkData, am_sinkID_t& sinkID);
+ am_Error_e peekSink(const std::string &name, am_sinkID_t &sinkID);
+ am_Error_e registerSink(const am_Sink_s &sinkData, am_sinkID_t &sinkID);
am_Error_e deregisterSink(const am_sinkID_t sinkID);
- am_Error_e peekSource(const std::string& name, am_sourceID_t& sourceID);
- am_Error_e registerSource(const am_Source_s& sourceData, am_sourceID_t& sourceID);
+ am_Error_e peekSource(const std::string &name, am_sourceID_t &sourceID);
+ am_Error_e registerSource(const am_Source_s &sourceData, am_sourceID_t &sourceID);
am_Error_e deregisterSource(const am_sourceID_t sourceID);
- am_Error_e registerCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID);
+ am_Error_e registerCrossfader(const am_Crossfader_s &crossfaderData, am_crossfaderID_t &crossfaderID);
am_Error_e deregisterCrossfader(const am_crossfaderID_t crossfaderID);
- am_Error_e peekSourceClassID(const std::string& name, am_sourceClass_t& sourceClassID);
- am_Error_e peekSinkClassID(const std::string& name, am_sinkClass_t& sinkClassID);
+ am_Error_e peekSourceClassID(const std::string &name, am_sourceClass_t &sourceClassID);
+ am_Error_e peekSinkClassID(const std::string &name, am_sinkClass_t &sinkClassID);
void hookInterruptStatusChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState);
void hookDomainRegistrationComplete(const am_domainID_t domainID);
- void hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s& availability);
- void hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s& availability);
+ void hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s &availability);
+ void hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s &availability);
void hookDomainStateChange(const am_domainID_t domainID, const am_DomainState_e domainState);
void hookTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t delay);
- void sendChangedData(const std::vector<am_EarlyData_s>& earlyData);
- am_Error_e getDBusConnectionWrapper(CAmDbusWrapper*& dbusConnectionWrapper) const;
- am_Error_e getSocketHandler(CAmSocketHandler*& socketHandler) const;
- void getInterfaceVersion(std::string& version) const;
+ void sendChangedData(const std::vector<am_EarlyData_s> &earlyData);
+ am_Error_e getDBusConnectionWrapper(CAmDbusWrapper * &dbusConnectionWrapper) const;
+ am_Error_e getSocketHandler(CAmSocketHandler * &socketHandler) const;
+ void getInterfaceVersion(std::string &version) const;
void confirmRoutingReady(const uint16_t handle, const am_Error_e error);
void confirmRoutingRundown(const uint16_t handle, const am_Error_e error);
- am_Error_e updateGateway(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t>& listSourceFormats, const std::vector<am_CustomConnectionFormat_t>& listSinkFormats, const std::vector<bool>& convertionMatrix) ;
- am_Error_e updateConverter(const am_converterID_t converterID, const std::vector<am_CustomConnectionFormat_t>& listSourceFormats, const std::vector<am_CustomConnectionFormat_t>& listSinkFormats, const std::vector<bool>& convertionMatrix);
- am_Error_e updateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) ;
- am_Error_e updateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) ;
- void ackSetVolumes(const am_Handle_s handle, const std::vector<am_Volumes_s>& listvolumes, const am_Error_e error) ;
- void ackSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) ;
- void ackSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) ;
- void hookSinkNotificationDataChange(const am_sinkID_t sinkID, const am_NotificationPayload_s& payload) ;
- void hookSourceNotificationDataChange(const am_sourceID_t sourceID, const am_NotificationPayload_s& payload) ;
- am_Error_e getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t& domainID) const;
- am_Error_e getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t& domainID) const;
- am_Error_e getDomainOfCrossfader(const am_crossfaderID_t crossfader, am_domainID_t& domainID) const;
+ am_Error_e updateGateway(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t> &listSourceFormats, const std::vector<am_CustomConnectionFormat_t> &listSinkFormats, const std::vector<bool> &convertionMatrix);
+ am_Error_e updateConverter(const am_converterID_t converterID, const std::vector<am_CustomConnectionFormat_t> &listSourceFormats, const std::vector<am_CustomConnectionFormat_t> &listSinkFormats, const std::vector<bool> &convertionMatrix);
+ am_Error_e updateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s> &listSoundProperties, const std::vector<am_CustomConnectionFormat_t> &listConnectionFormats, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties);
+ am_Error_e updateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s> &listSoundProperties, const std::vector<am_CustomConnectionFormat_t> &listConnectionFormats, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties);
+ void ackSetVolumes(const am_Handle_s handle, const std::vector<am_Volumes_s> &listvolumes, const am_Error_e error);
+ void ackSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error);
+ void ackSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error);
+ void hookSinkNotificationDataChange(const am_sinkID_t sinkID, const am_NotificationPayload_s &payload);
+ void hookSourceNotificationDataChange(const am_sourceID_t sourceID, const am_NotificationPayload_s &payload);
+ am_Error_e getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t &domainID) const;
+ am_Error_e getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t &domainID) const;
+ am_Error_e getDomainOfCrossfader(const am_crossfaderID_t crossfader, am_domainID_t &domainID) const;
uint16_t getStartupHandle(); //!< returns a startup handle
uint16_t getRundownHandle(); //!< returns a rundown handle
@@ -105,23 +105,23 @@ public:
void waitOnRundown(bool rundown); //!< tells the RoutingReceiver to start waiting for all handles to be confirmed
private:
-
- void handleCallback(const am_Handle_s handle, const am_Error_e error);
- IAmDatabaseHandler *mpDatabaseHandler; //!< pointer to the databaseHandler
- CAmRoutingSender *mpRoutingSender; //!< pointer to the routingSender
- CAmControlSender *mpControlSender; //!< pointer to the controlSender
- CAmSocketHandler *mpSocketHandler; //!< pointer to sockethandler
- CAmDbusWrapper *mpDBusWrapper; //!< pointer to dbuswrapper
+ void handleCallback(const am_Handle_s handle, const am_Error_e error);
+
+ IAmDatabaseHandler *mpDatabaseHandler; //!< pointer to the databaseHandler
+ CAmRoutingSender *mpRoutingSender; //!< pointer to the routingSender
+ CAmControlSender *mpControlSender; //!< pointer to the controlSender
+ CAmSocketHandler *mpSocketHandler; //!< pointer to sockethandler
+ CAmDbusWrapper *mpDBusWrapper; //!< pointer to dbuswrapper
std::vector<uint16_t> mListStartupHandles; //!< list of handles that wait for a confirm
std::vector<uint16_t> mListRundownHandles; //!< list of handles that wait for a confirm
- uint16_t handleCount; //!< counts all handles
- bool mWaitStartup; //!< if true confirmation will be sent if list of handles = 0
- bool mWaitRundown; //!< if true confirmation will be sent if list of handles = 0
+ uint16_t handleCount; //!< counts all handles
+ bool mWaitStartup; //!< if true confirmation will be sent if list of handles = 0
+ bool mWaitRundown; //!< if true confirmation will be sent if list of handles = 0
- am_Error_e mLastStartupError;
- am_Error_e mLastRundownError;
+ am_Error_e mLastStartupError;
+ am_Error_e mLastRundownError;
};
diff --git a/AudioManagerCore/include/CAmRoutingSender.h b/AudioManagerCore/include/CAmRoutingSender.h
index e14dd6d..39b5c23 100644
--- a/AudioManagerCore/include/CAmRoutingSender.h
+++ b/AudioManagerCore/include/CAmRoutingSender.h
@@ -28,8 +28,8 @@
#include <map>
#include <memory>
-#ifdef UNIT_TEST //this is needed to test RoutingSender
-#include "../test/IAmRoutingBackdoor.h"
+#ifdef UNIT_TEST // this is needed to test RoutingSender
+# include "../test/IAmRoutingBackdoor.h"
#endif
#include "CAmDatabaseHandlerMap.h"
@@ -42,292 +42,309 @@ class CAmRoutingReceiver;
/**
* Implements the RoutingSendInterface. Loads all plugins and dispatches calls to the plugins
*/
-class CAmRoutingSender: public CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks
+class CAmRoutingSender : public CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks
{
public:
- CAmRoutingSender(const std::vector<std::string>& listOfPluginDirectories, IAmDatabaseHandler* databaseHandler);
+ CAmRoutingSender(const std::vector<std::string> &listOfPluginDirectories, IAmDatabaseHandler *databaseHandler);
~CAmRoutingSender();
- am_Error_e removeHandle(const am_Handle_s& handle);
- am_Error_e addDomainLookup(const am_Domain_s& domainData);
- am_Error_e addSourceLookup(const am_Source_s& sourceData);
- am_Error_e addSinkLookup(const am_Sink_s& sinkData);
- am_Error_e addCrossfaderLookup(const am_Crossfader_s& crossfaderData);
+ am_Error_e removeHandle(const am_Handle_s &handle);
+ am_Error_e addDomainLookup(const am_Domain_s &domainData);
+ am_Error_e addSourceLookup(const am_Source_s &sourceData);
+ am_Error_e addSinkLookup(const am_Sink_s &sinkData);
+ am_Error_e addCrossfaderLookup(const am_Crossfader_s &crossfaderData);
am_Error_e removeDomainLookup(const am_domainID_t domainID);
am_Error_e removeSourceLookup(const am_sourceID_t sourceID);
am_Error_e removeSinkLookup(const am_sinkID_t sinkID);
am_Error_e removeCrossfaderLookup(const am_crossfaderID_t crossfaderID);
am_Error_e removeConnectionLookup(const am_connectionID_t connectionID);
- am_Error_e startupInterfaces(CAmRoutingReceiver* iRoutingReceiver);
+ am_Error_e startupInterfaces(CAmRoutingReceiver *iRoutingReceiver);
void setRoutingReady();
void setRoutingRundown();
- am_Error_e asyncAbort(const am_Handle_s& handle);
- am_Error_e asyncConnect(am_Handle_s& handle, am_connectionID_t& connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_CustomConnectionFormat_t connectionFormat);
- am_Error_e asyncDisconnect(am_Handle_s& handle, const am_connectionID_t connectionID);
- am_Error_e asyncSetSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time);
- am_Error_e asyncSetSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time);
- am_Error_e asyncSetSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state);
- am_Error_e asyncSetSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty);
- am_Error_e asyncSetSourceSoundProperties(am_Handle_s& handle, const std::vector<am_SoundProperty_s>& listSoundProperties, const am_sourceID_t sourceID);
- am_Error_e asyncSetSinkSoundProperties(am_Handle_s& handle, const std::vector<am_SoundProperty_s>& listSoundProperties, const am_sinkID_t sinkID);
- am_Error_e asyncSetSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty);
- am_Error_e asyncCrossFade(am_Handle_s& handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_CustomRampType_t rampType, const am_time_t time);
+ am_Error_e asyncAbort(const am_Handle_s &handle);
+ am_Error_e asyncConnect(am_Handle_s &handle, am_connectionID_t &connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_CustomConnectionFormat_t connectionFormat);
+ am_Error_e asyncDisconnect(am_Handle_s &handle, const am_connectionID_t connectionID);
+ am_Error_e asyncSetSinkVolume(am_Handle_s &handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time);
+ am_Error_e asyncSetSourceVolume(am_Handle_s &handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time);
+ am_Error_e asyncSetSourceState(am_Handle_s &handle, const am_sourceID_t sourceID, const am_SourceState_e state);
+ am_Error_e asyncSetSinkSoundProperty(am_Handle_s &handle, const am_sinkID_t sinkID, const am_SoundProperty_s &soundProperty);
+ am_Error_e asyncSetSourceSoundProperties(am_Handle_s &handle, const std::vector<am_SoundProperty_s> &listSoundProperties, const am_sourceID_t sourceID);
+ am_Error_e asyncSetSinkSoundProperties(am_Handle_s &handle, const std::vector<am_SoundProperty_s> &listSoundProperties, const am_sinkID_t sinkID);
+ am_Error_e asyncSetSourceSoundProperty(am_Handle_s &handle, const am_sourceID_t sourceID, const am_SoundProperty_s &soundProperty);
+ am_Error_e asyncCrossFade(am_Handle_s &handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_CustomRampType_t rampType, const am_time_t time);
am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState);
- am_Error_e getListHandles(std::vector<am_Handle_s> & listHandles) const;
- am_Error_e getListPlugins(std::vector<std::string>& interfaces) const;
- void getInterfaceVersion(std::string& version) const;
- am_Error_e asyncSetVolumes(am_Handle_s& handle, const std::vector<am_Volumes_s>& listVolumes);
- am_Error_e asyncSetSinkNotificationConfiguration(am_Handle_s& handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration);
- am_Error_e asyncSetSourceNotificationConfiguration(am_Handle_s& handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration);
- am_Error_e resyncConnectionState(const am_domainID_t domainID, std::vector<am_Connection_s>& listOfExistingConnections);
+ am_Error_e getListHandles(std::vector<am_Handle_s> &listHandles) const;
+ am_Error_e getListPlugins(std::vector<std::string> &interfaces) const;
+ void getInterfaceVersion(std::string &version) const;
+ am_Error_e asyncSetVolumes(am_Handle_s &handle, const std::vector<am_Volumes_s> &listVolumes);
+ am_Error_e asyncSetSinkNotificationConfiguration(am_Handle_s &handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s &notificationConfiguration);
+ am_Error_e asyncSetSourceNotificationConfiguration(am_Handle_s &handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s &notificationConfiguration);
+ am_Error_e resyncConnectionState(const am_domainID_t domainID, std::vector<am_Connection_s> &listOfExistingConnections);
struct InterfaceNamePairs //!< is used to pair interfaces with busnames
{
- IAmRoutingSend* routingInterface; //!< pointer to the routingInterface
- std::string busName; //!< the busname
+ IAmRoutingSend *routingInterface; //!< pointer to the routingInterface
+ std::string busName; //!< the busname
};
-
+
class handleDataBase
{
- public:
- handleDataBase(IAmRoutingSend* interface, IAmDatabaseHandler* databaseHandler) : mInterface(interface), mpDatabaseHandler(databaseHandler) {}
- virtual ~handleDataBase() {}
- virtual am_Error_e writeDataToDatabase()=0; //!< function to write the handle data to the database
- IAmRoutingSend* returnInterface() {return mInterface;}
- private:
- IAmRoutingSend* mInterface;
- protected:
- IAmDatabaseHandler* mpDatabaseHandler;
- };
-
- class handleVolumeBase : public handleDataBase
- {
- public:
- handleVolumeBase(IAmRoutingSend* interface, IAmDatabaseHandler* databaseHandler,am_volume_t volume) :
- handleDataBase(interface,databaseHandler)
- ,mVolume(volume) {}
- virtual ~handleVolumeBase(){}
- am_volume_t returnVolume() { return mVolume; }
- private:
- am_volume_t mVolume;
- };
-
- class handleSinkSoundProperty : public handleDataBase
- {
- public:
- handleSinkSoundProperty(IAmRoutingSend* interface,const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty, IAmDatabaseHandler* databaseHandler) :
- handleDataBase(interface,databaseHandler)
- ,mSinkID(sinkID)
- ,mSoundProperty(soundProperty) {}
- ~handleSinkSoundProperty() {}
- am_Error_e writeDataToDatabase();
- private:
- am_sinkID_t mSinkID;
- am_SoundProperty_s mSoundProperty;
- };
-
- class handleSinkSoundProperties : public handleDataBase
- {
- public:
- handleSinkSoundProperties(IAmRoutingSend* interface,const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s>& listSoundProperties, IAmDatabaseHandler* databaseHandler) :
- handleDataBase(interface,databaseHandler)
- ,mSinkID(sinkID)
- ,mlistSoundProperties(listSoundProperties) {}
- ~handleSinkSoundProperties() {}
- am_Error_e writeDataToDatabase();
- private:
- am_sinkID_t mSinkID;
- std::vector<am_SoundProperty_s> mlistSoundProperties;
- };
-
- class handleSourceSoundProperty : public handleDataBase
- {
- public:
- handleSourceSoundProperty(IAmRoutingSend* interface,const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty, IAmDatabaseHandler* databaseHandler) :
- handleDataBase(interface,databaseHandler)
- ,mSourceID(sourceID)
- ,mSoundProperty(soundProperty) {}
- ~handleSourceSoundProperty() {}
- am_Error_e writeDataToDatabase();
- private:
- am_sourceID_t mSourceID;
- am_SoundProperty_s mSoundProperty;
- };
-
- class handleSourceSoundProperties : public handleDataBase
- {
- public:
- handleSourceSoundProperties(IAmRoutingSend* interface,const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s>& listSoundProperties, IAmDatabaseHandler* databaseHandler) :
- handleDataBase(interface,databaseHandler)
- ,mSourceID(sourceID)
- ,mlistSoundProperties(listSoundProperties) {}
- ~handleSourceSoundProperties(){}
- am_Error_e writeDataToDatabase();
- private:
- am_sourceID_t mSourceID;
- std::vector<am_SoundProperty_s> mlistSoundProperties;
- };
-
- class handleSourceState : public handleDataBase
- {
- public:
- handleSourceState(IAmRoutingSend* interface,const am_sourceID_t sourceID, const am_SourceState_e& state, IAmDatabaseHandler* databaseHandler) :
- handleDataBase(interface,databaseHandler)
- ,mSourceID(sourceID)
- ,mSourceState(state) {}
- ~handleSourceState() {}
- am_Error_e writeDataToDatabase();
- private:
- am_sourceID_t mSourceID;
- am_SourceState_e mSourceState;
- };
-
- class handleSourceVolume : public handleVolumeBase
- {
- public:
- handleSourceVolume(IAmRoutingSend* interface, const am_sourceID_t sourceID, IAmDatabaseHandler* databaseHandler,const am_volume_t& volume) :
- handleVolumeBase(interface,databaseHandler,volume)
- ,mSourceID(sourceID) {}
- ~handleSourceVolume() {}
- am_Error_e writeDataToDatabase();
- private:
- am_sourceID_t mSourceID;
- };
-
- class handleSinkVolume : public handleVolumeBase
- {
- public:
- handleSinkVolume(IAmRoutingSend* interface, const am_sinkID_t sinkID, IAmDatabaseHandler* databaseHandler,const am_volume_t& volume) :
- handleVolumeBase(interface,databaseHandler,volume)
- ,mSinkID(sinkID) {}
- ~handleSinkVolume() {}
- am_Error_e writeDataToDatabase();
- private:
- am_sinkID_t mSinkID;
- };
-
- class handleCrossFader : public handleDataBase
- {
- public:
- handleCrossFader(IAmRoutingSend* interface, const am_crossfaderID_t crossfaderID, const am_HotSink_e& hotSink, IAmDatabaseHandler* databaseHandler) :
- handleDataBase(interface,databaseHandler)
- ,mCrossfaderID(crossfaderID)
- ,mHotSink(hotSink) {}
- ~handleCrossFader() {}
- am_Error_e writeDataToDatabase();
- private:
- am_crossfaderID_t mCrossfaderID;
- am_HotSink_e mHotSink;
- };
-
- class handleConnect : public handleDataBase
- {
- public:
- handleConnect(IAmRoutingSend* interface, const am_connectionID_t connectionID, IAmDatabaseHandler* databaseHandler) :
- handleDataBase(interface,databaseHandler)
- ,mConnectionID(connectionID)
- ,mConnectionPending(true) {}
- ~handleConnect();
- am_Error_e writeDataToDatabase();
- private:
- am_connectionID_t mConnectionID;
- bool mConnectionPending;
- };
-
- class handleDisconnect : public handleDataBase
- {
- public:
- handleDisconnect(IAmRoutingSend* interface, const am_connectionID_t connectionID, IAmDatabaseHandler* databaseHandler,CAmRoutingSender* routingSender) :
- handleDataBase(interface,databaseHandler)
- ,mConnectionID(connectionID)
- ,mRoutingSender(routingSender){}
- ~handleDisconnect();
- am_Error_e writeDataToDatabase();
- private:
- am_connectionID_t mConnectionID;
- CAmRoutingSender* mRoutingSender;
- };
-
- class handleSetVolumes : public handleDataBase
- {
- public:
- handleSetVolumes(IAmRoutingSend* interface, const std::vector<am_Volumes_s> listVolumes, IAmDatabaseHandler* databaseHandler) :
- handleDataBase(interface,databaseHandler)
- ,mlistVolumes(listVolumes) {}
- ~handleSetVolumes() {}
- am_Error_e writeDataToDatabase();
- private:
- std::vector<am_Volumes_s> mlistVolumes;
- };
-
- class handleSetSinkNotificationConfiguration : public handleDataBase
- {
- public:
- handleSetSinkNotificationConfiguration(IAmRoutingSend* interface, const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration, IAmDatabaseHandler* databaseHandler) :
- handleDataBase(interface,databaseHandler)
- ,mSinkID(sinkID)
- ,mNotificationConfiguration(notificationConfiguration){}
- ~handleSetSinkNotificationConfiguration() {}
- am_Error_e writeDataToDatabase();
- private:
- am_sinkID_t mSinkID;
- am_NotificationConfiguration_s mNotificationConfiguration;
- };
-
- class handleSetSourceNotificationConfiguration : public handleDataBase
- {
- public:
- handleSetSourceNotificationConfiguration(IAmRoutingSend* interface, const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration, IAmDatabaseHandler* databaseHandler) :
- handleDataBase(interface,databaseHandler)
- ,mSourceID(sourceID)
- ,mNotificationConfiguration(notificationConfiguration) {}
- ~handleSetSourceNotificationConfiguration() {}
- am_Error_e writeDataToDatabase();
- private:
- am_sourceID_t mSourceID;
- am_NotificationConfiguration_s mNotificationConfiguration;
- };
-
+ public:
+ handleDataBase(IAmRoutingSend *interface, IAmDatabaseHandler *databaseHandler)
+ : mInterface(interface)
+ , mpDatabaseHandler(databaseHandler) {}
+ virtual ~handleDataBase() {}
+ virtual am_Error_e writeDataToDatabase() = 0; //!< function to write the handle data to the database
+
+ IAmRoutingSend *returnInterface() {return mInterface;}
+ private:
+ IAmRoutingSend *mInterface;
+ protected:
+ IAmDatabaseHandler *mpDatabaseHandler;
+ };
+
+ class handleVolumeBase : public handleDataBase
+ {
+ public:
+ handleVolumeBase(IAmRoutingSend *interface, IAmDatabaseHandler *databaseHandler, am_volume_t volume)
+ : handleDataBase(interface, databaseHandler)
+ , mVolume(volume) {}
+ virtual ~handleVolumeBase(){}
+ am_volume_t returnVolume() { return mVolume; }
+ private:
+ am_volume_t mVolume;
+ };
+
+ class handleSinkSoundProperty : public handleDataBase
+ {
+ public:
+ handleSinkSoundProperty(IAmRoutingSend *interface, const am_sinkID_t sinkID, const am_SoundProperty_s &soundProperty, IAmDatabaseHandler *databaseHandler)
+ : handleDataBase(interface, databaseHandler)
+ , mSinkID(sinkID)
+ , mSoundProperty(soundProperty) {}
+ ~handleSinkSoundProperty() {}
+ am_Error_e writeDataToDatabase();
+
+ private:
+ am_sinkID_t mSinkID;
+ am_SoundProperty_s mSoundProperty;
+ };
+
+ class handleSinkSoundProperties : public handleDataBase
+ {
+ public:
+ handleSinkSoundProperties(IAmRoutingSend *interface, const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s> &listSoundProperties, IAmDatabaseHandler *databaseHandler)
+ : handleDataBase(interface, databaseHandler)
+ , mSinkID(sinkID)
+ , mlistSoundProperties(listSoundProperties) {}
+ ~handleSinkSoundProperties() {}
+ am_Error_e writeDataToDatabase();
+
+ private:
+ am_sinkID_t mSinkID;
+ std::vector<am_SoundProperty_s> mlistSoundProperties;
+ };
+
+ class handleSourceSoundProperty : public handleDataBase
+ {
+ public:
+ handleSourceSoundProperty(IAmRoutingSend *interface, const am_sourceID_t sourceID, const am_SoundProperty_s &soundProperty, IAmDatabaseHandler *databaseHandler)
+ : handleDataBase(interface, databaseHandler)
+ , mSourceID(sourceID)
+ , mSoundProperty(soundProperty) {}
+ ~handleSourceSoundProperty() {}
+ am_Error_e writeDataToDatabase();
+
+ private:
+ am_sourceID_t mSourceID;
+ am_SoundProperty_s mSoundProperty;
+ };
+
+ class handleSourceSoundProperties : public handleDataBase
+ {
+ public:
+ handleSourceSoundProperties(IAmRoutingSend *interface, const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s> &listSoundProperties, IAmDatabaseHandler *databaseHandler)
+ : handleDataBase(interface, databaseHandler)
+ , mSourceID(sourceID)
+ , mlistSoundProperties(listSoundProperties) {}
+ ~handleSourceSoundProperties(){}
+ am_Error_e writeDataToDatabase();
+
+ private:
+ am_sourceID_t mSourceID;
+ std::vector<am_SoundProperty_s> mlistSoundProperties;
+ };
+
+ class handleSourceState : public handleDataBase
+ {
+ public:
+ handleSourceState(IAmRoutingSend *interface, const am_sourceID_t sourceID, const am_SourceState_e &state, IAmDatabaseHandler *databaseHandler)
+ : handleDataBase(interface, databaseHandler)
+ , mSourceID(sourceID)
+ , mSourceState(state) {}
+ ~handleSourceState() {}
+ am_Error_e writeDataToDatabase();
+
+ private:
+ am_sourceID_t mSourceID;
+ am_SourceState_e mSourceState;
+ };
+
+ class handleSourceVolume : public handleVolumeBase
+ {
+ public:
+ handleSourceVolume(IAmRoutingSend *interface, const am_sourceID_t sourceID, IAmDatabaseHandler *databaseHandler, const am_volume_t &volume)
+ : handleVolumeBase(interface, databaseHandler, volume)
+ , mSourceID(sourceID) {}
+ ~handleSourceVolume() {}
+ am_Error_e writeDataToDatabase();
+
+ private:
+ am_sourceID_t mSourceID;
+ };
+
+ class handleSinkVolume : public handleVolumeBase
+ {
+ public:
+ handleSinkVolume(IAmRoutingSend *interface, const am_sinkID_t sinkID, IAmDatabaseHandler *databaseHandler, const am_volume_t &volume)
+ : handleVolumeBase(interface, databaseHandler, volume)
+ , mSinkID(sinkID) {}
+ ~handleSinkVolume() {}
+ am_Error_e writeDataToDatabase();
+
+ private:
+ am_sinkID_t mSinkID;
+ };
+
+ class handleCrossFader : public handleDataBase
+ {
+ public:
+ handleCrossFader(IAmRoutingSend *interface, const am_crossfaderID_t crossfaderID, const am_HotSink_e &hotSink, IAmDatabaseHandler *databaseHandler)
+ : handleDataBase(interface, databaseHandler)
+ , mCrossfaderID(crossfaderID)
+ , mHotSink(hotSink) {}
+ ~handleCrossFader() {}
+ am_Error_e writeDataToDatabase();
+
+ private:
+ am_crossfaderID_t mCrossfaderID;
+ am_HotSink_e mHotSink;
+ };
+
+ class handleConnect : public handleDataBase
+ {
+ public:
+ handleConnect(IAmRoutingSend *interface, const am_connectionID_t connectionID, IAmDatabaseHandler *databaseHandler)
+ : handleDataBase(interface, databaseHandler)
+ , mConnectionID(connectionID)
+ , mConnectionPending(true) {}
+ ~handleConnect();
+ am_Error_e writeDataToDatabase();
+
+ private:
+ am_connectionID_t mConnectionID;
+ bool mConnectionPending;
+ };
+
+ class handleDisconnect : public handleDataBase
+ {
+ public:
+ handleDisconnect(IAmRoutingSend *interface, const am_connectionID_t connectionID, IAmDatabaseHandler *databaseHandler, CAmRoutingSender *routingSender)
+ : handleDataBase(interface, databaseHandler)
+ , mConnectionID(connectionID)
+ , mRoutingSender(routingSender){}
+ ~handleDisconnect();
+ am_Error_e writeDataToDatabase();
+
+ private:
+ am_connectionID_t mConnectionID;
+ CAmRoutingSender *mRoutingSender;
+ };
+
+ class handleSetVolumes : public handleDataBase
+ {
+ public:
+ handleSetVolumes(IAmRoutingSend *interface, const std::vector<am_Volumes_s> listVolumes, IAmDatabaseHandler *databaseHandler)
+ : handleDataBase(interface, databaseHandler)
+ , mlistVolumes(listVolumes) {}
+ ~handleSetVolumes() {}
+ am_Error_e writeDataToDatabase();
+
+ private:
+ std::vector<am_Volumes_s> mlistVolumes;
+ };
+
+ class handleSetSinkNotificationConfiguration : public handleDataBase
+ {
+ public:
+ handleSetSinkNotificationConfiguration(IAmRoutingSend *interface, const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration, IAmDatabaseHandler *databaseHandler)
+ : handleDataBase(interface, databaseHandler)
+ , mSinkID(sinkID)
+ , mNotificationConfiguration(notificationConfiguration){}
+ ~handleSetSinkNotificationConfiguration() {}
+ am_Error_e writeDataToDatabase();
+
+ private:
+ am_sinkID_t mSinkID;
+ am_NotificationConfiguration_s mNotificationConfiguration;
+ };
+
+ class handleSetSourceNotificationConfiguration : public handleDataBase
+ {
+ public:
+ handleSetSourceNotificationConfiguration(IAmRoutingSend *interface, const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration, IAmDatabaseHandler *databaseHandler)
+ : handleDataBase(interface, databaseHandler)
+ , mSourceID(sourceID)
+ , mNotificationConfiguration(notificationConfiguration) {}
+ ~handleSetSourceNotificationConfiguration() {}
+ am_Error_e writeDataToDatabase();
+
+ private:
+ am_sourceID_t mSourceID;
+ am_NotificationConfiguration_s mNotificationConfiguration;
+ };
+
am_Error_e writeToDatabaseAndRemove(const am_Handle_s handle); //!< write data to Database and remove handle
void checkVolume(const am_Handle_s handle, const am_volume_t volume);
bool handleExists(const am_Handle_s handle); //!< returns true if the handle exists
-#ifdef UNIT_TEST //this is needed to test RoutingSender
+#ifdef UNIT_TEST // this is needed to test RoutingSender
friend class IAmRoutingBackdoor;
#endif
private:
struct comparator //!< is needed to sort the handles in the map
{
- bool operator()(const am_Handle_s& a, const am_Handle_s& b) const
+ bool operator()(const am_Handle_s &a, const am_Handle_s &b) const
{
- return (a.handle<b.handle || (a.handle==b.handle && a.handleType<b.handleType));
+ return (a.handle < b.handle || (a.handle == b.handle && a.handleType < b.handleType));
}
+
};
- void loadPlugins(const std::vector<std::string>& listOfPluginDirectories);
+ void loadPlugins(const std::vector<std::string> &listOfPluginDirectories);
am_Handle_s createHandle(std::shared_ptr<handleDataBase> handleData, const am_Handle_e type); //!< creates a handle
- void unloadLibraries(void); //!< unloads all loaded plugins
-
- typedef std::map<am_domainID_t, IAmRoutingSend*> DomainInterfaceMap; //!< maps domains to interfaces
- typedef std::map<am_sinkID_t, IAmRoutingSend*> SinkInterfaceMap; //!< maps sinks to interfaces
- typedef std::map<am_sourceID_t, IAmRoutingSend*> SourceInterfaceMap; //!< maps sources to interfaces
- typedef std::map<am_crossfaderID_t, IAmRoutingSend*> CrossfaderInterfaceMap; //!< maps crossfaders to interfaces
- typedef std::map<am_connectionID_t, IAmRoutingSend*> ConnectionInterfaceMap; //!< maps connections to interfaces
- typedef std::map<am_Handle_s, std::shared_ptr<handleDataBase>, comparator> HandlesMap; //!< maps handleData to handles
-
- int16_t mHandleCount; //!< is used to create handles
- HandlesMap mlistActiveHandles; //!< list of all currently "running" handles.
- std::vector<void*> mListLibraryHandles; //!< list of all loaded pluginInterfaces
- std::vector<InterfaceNamePairs> mListInterfaces; //!< list of busname/interface relation
- CrossfaderInterfaceMap mMapCrossfaderInterface; //!< map of crossfaders to interface
- ConnectionInterfaceMap mMapConnectionInterface; //!< map of connection to interfaces
- DomainInterfaceMap mMapDomainInterface; //!< map of domains to interfaces
- SinkInterfaceMap mMapSinkInterface; //!< map of sinks to interfaces
- SourceInterfaceMap mMapSourceInterface; //!< map of sources to interfaces
- CAmRoutingReceiver *mpRoutingReceiver; //!< pointer to routing receiver
- IAmDatabaseHandler* mpDatabaseHandler; //!< pointer to the databaseHandler
+ void unloadLibraries(void); //!< unloads all loaded plugins
+
+ typedef std::map<am_domainID_t, IAmRoutingSend *> DomainInterfaceMap; //!< maps domains to interfaces
+ typedef std::map<am_sinkID_t, IAmRoutingSend *> SinkInterfaceMap; //!< maps sinks to interfaces
+ typedef std::map<am_sourceID_t, IAmRoutingSend *> SourceInterfaceMap; //!< maps sources to interfaces
+ typedef std::map<am_crossfaderID_t, IAmRoutingSend *> CrossfaderInterfaceMap; //!< maps crossfaders to interfaces
+ typedef std::map<am_connectionID_t, IAmRoutingSend *> ConnectionInterfaceMap; //!< maps connections to interfaces
+ typedef std::map<am_Handle_s, std::shared_ptr<handleDataBase>, comparator> HandlesMap; //!< maps handleData to handles
+
+ int16_t mHandleCount; //!< is used to create handles
+ HandlesMap mlistActiveHandles; //!< list of all currently "running" handles.
+ std::vector<void *> mListLibraryHandles; //!< list of all loaded pluginInterfaces
+ std::vector<InterfaceNamePairs> mListInterfaces; //!< list of busname/interface relation
+ CrossfaderInterfaceMap mMapCrossfaderInterface; //!< map of crossfaders to interface
+ ConnectionInterfaceMap mMapConnectionInterface; //!< map of connection to interfaces
+ DomainInterfaceMap mMapDomainInterface; //!< map of domains to interfaces
+ SinkInterfaceMap mMapSinkInterface; //!< map of sinks to interfaces
+ SourceInterfaceMap mMapSourceInterface; //!< map of sources to interfaces
+ CAmRoutingReceiver *mpRoutingReceiver; //!< pointer to routing receiver
+ IAmDatabaseHandler *mpDatabaseHandler; //!< pointer to the databaseHandler
};
}
diff --git a/AudioManagerCore/include/IAmDatabaseHandler.h b/AudioManagerCore/include/IAmDatabaseHandler.h
index f4fe8a1..5272d4f 100644
--- a/AudioManagerCore/include/IAmDatabaseHandler.h
+++ b/AudioManagerCore/include/IAmDatabaseHandler.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
+ * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013
*
* \file IAmDatabaseHandler.h
* For further information see http://www.genivi.org/.
@@ -38,13 +38,13 @@
namespace am
{
-//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
-//todo: If the sink is part of a gateway, the listconnectionFormats is copied to the gatewayInformation. Check this statement for sinks & sources
-//todo: exchange last_insert_row id to be more safe
-//todo: create test to ensure uniqueness of names throughout the database
-//todo: enforce the uniqueness of names
+// 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
+// todo: If the sink is part of a gateway, the listconnectionFormats is copied to the gatewayInformation. Check this statement for sinks & sources
+// todo: exchange last_insert_row id to be more safe
+// todo: create test to ensure uniqueness of names throughout the database
+// todo: enforce the uniqueness of names
typedef std::map<am_gatewayID_t, std::vector<bool> > ListConnectionFormat; //!< type for list of connection formats
@@ -59,34 +59,34 @@ public:
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;
- virtual am_Error_e enterCrossfaderDB(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID) = 0;
- virtual am_Error_e enterGatewayDB(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID) = 0;
- virtual am_Error_e enterConverterDB(const am_Converter_s & converteData, am_converterID_t & converterID) = 0;
- virtual am_Error_e enterSourceDB(const am_Source_s& sourceData, am_sourceID_t& sourceID) = 0;
- virtual am_Error_e enterConnectionDB(const am_Connection_s& connection, am_connectionID_t& connectionID) = 0;
- virtual am_Error_e enterSinkClassDB(const am_SinkClass_s& sinkClass, am_sinkClass_t& sinkClassID) = 0;
- virtual am_Error_e enterSourceClassDB(am_sourceClass_t& sourceClassID, const am_SourceClass_s& sourceClass) = 0;
- virtual am_Error_e enterSystemProperties(const std::vector<am_SystemProperty_s>& listSystemProperties) = 0;
- virtual am_Error_e changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector<am_connectionID_t>& listConnectionID) = 0;
+ * 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;
+ virtual am_Error_e enterCrossfaderDB(const am_Crossfader_s &crossfaderData, am_crossfaderID_t &crossfaderID) = 0;
+ virtual am_Error_e enterGatewayDB(const am_Gateway_s &gatewayData, am_gatewayID_t &gatewayID) = 0;
+ virtual am_Error_e enterConverterDB(const am_Converter_s &converteData, am_converterID_t &converterID) = 0;
+ virtual am_Error_e enterSourceDB(const am_Source_s &sourceData, am_sourceID_t &sourceID) = 0;
+ virtual am_Error_e enterConnectionDB(const am_Connection_s &connection, am_connectionID_t &connectionID) = 0;
+ virtual am_Error_e enterSinkClassDB(const am_SinkClass_s &sinkClass, am_sinkClass_t &sinkClassID) = 0;
+ virtual am_Error_e enterSourceClassDB(am_sourceClass_t &sourceClassID, const am_SourceClass_s &sourceClass) = 0;
+ virtual am_Error_e enterSystemProperties(const std::vector<am_SystemProperty_s> &listSystemProperties) = 0;
+ virtual am_Error_e changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector<am_connectionID_t> &listConnectionID) = 0;
virtual am_Error_e changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState) = 0;
virtual am_Error_e changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID) = 0;
- virtual am_Error_e changeSinkAvailabilityDB(const am_Availability_s& availability, const am_sinkID_t sinkID) = 0;
+ virtual am_Error_e changeSinkAvailabilityDB(const am_Availability_s &availability, const am_sinkID_t sinkID) = 0;
virtual am_Error_e changeDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID) = 0;
virtual am_Error_e changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID) = 0;
- virtual am_Error_e changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sinkID_t sinkID) = 0;
- virtual am_Error_e changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s& soundProperty, const am_sourceID_t sourceID) = 0;
- virtual am_Error_e changeSourceSoundPropertyDB(const am_SoundProperty_s& soundProperty, const am_sourceID_t sourceID) = 0;
- virtual am_Error_e changeSinkSoundPropertyDB(const am_SoundProperty_s& soundProperty, const am_sinkID_t sinkID) = 0;
- virtual am_Error_e changeSourceAvailabilityDB(const am_Availability_s& availability, const am_sourceID_t sourceID) = 0;
- virtual am_Error_e changeSystemPropertyDB(const am_SystemProperty_s& property) = 0;
- virtual am_Error_e changeDelayMainConnection(const am_timeSync_t & delay, const am_mainConnectionID_t & connectionID) = 0;
- virtual am_Error_e changeSinkClassInfoDB(const am_SinkClass_s& sinkClass) = 0;
- virtual am_Error_e changeSourceClassInfoDB(const am_SourceClass_s& sourceClass) = 0;
+ virtual am_Error_e changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s &soundProperty, const am_sinkID_t sinkID) = 0;
+ virtual am_Error_e changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s &soundProperty, const am_sourceID_t sourceID) = 0;
+ virtual am_Error_e changeSourceSoundPropertyDB(const am_SoundProperty_s &soundProperty, const am_sourceID_t sourceID) = 0;
+ virtual am_Error_e changeSinkSoundPropertyDB(const am_SoundProperty_s &soundProperty, const am_sinkID_t sinkID) = 0;
+ virtual am_Error_e changeSourceAvailabilityDB(const am_Availability_s &availability, const am_sourceID_t sourceID) = 0;
+ virtual am_Error_e changeSystemPropertyDB(const am_SystemProperty_s &property) = 0;
+ virtual am_Error_e changeDelayMainConnection(const am_timeSync_t &delay, const am_mainConnectionID_t &connectionID) = 0;
+ virtual am_Error_e changeSinkClassInfoDB(const am_SinkClass_s &sinkClass) = 0;
+ virtual am_Error_e changeSourceClassInfoDB(const am_SourceClass_s &sourceClass) = 0;
virtual am_Error_e changeConnectionTimingInformation(const am_connectionID_t connectionID, const am_timeSync_t delay) = 0;
virtual am_Error_e changeConnectionFinal(const am_connectionID_t connectionID) = 0;
virtual am_Error_e changeSourceState(const am_sourceID_t sourceID, const am_SourceState_e sourceState) = 0;
@@ -104,107 +104,108 @@ public:
virtual am_Error_e removeSinkClassDB(const am_sinkClass_t sinkClassID) = 0;
virtual am_Error_e removeSourceClassDB(const am_sourceClass_t sourceClassID) = 0;
virtual am_Error_e removeConnection(const am_connectionID_t connectionID) = 0;
- virtual am_Error_e getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s& classInfo) const = 0;
- virtual am_Error_e getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s& sinkClass) const = 0;
- virtual am_Error_e getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s& gatewayData) const = 0;
- virtual am_Error_e getConverterInfoDB(const am_converterID_t converterID, am_Converter_s& converterData) const = 0;
- virtual am_Error_e getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s& sinkData) const = 0;
- virtual am_Error_e getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s& sourceData) const = 0;
- virtual am_Error_e getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s& crossfaderData) const = 0;
- virtual am_Error_e getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s& mainConnectionData) const = 0;
- virtual am_Error_e getSinkMainVolume(const am_sinkID_t sinkID, am_mainVolume_t& mainVolume) const = 0;
- virtual am_Error_e getSinkVolume(const am_sinkID_t sinkID, am_volume_t& volume) const = 0;
- 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 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;
- virtual am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t>& listSinkID) const = 0;
- virtual am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t>& listSourceID) const = 0;
- virtual am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t>& listGatewaysID) const = 0;
- virtual am_Error_e getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t>& listGatewaysID) const = 0;
- virtual am_Error_e getListConvertersOfDomain(const am_domainID_t domainID, std::vector<am_converterID_t>& listConvertersID) const = 0;
- virtual am_Error_e getListMainConnections(std::vector<am_MainConnection_s>& listMainConnections) const = 0;
- virtual am_Error_e getListDomains(std::vector<am_Domain_s>& listDomains) const = 0;
- virtual am_Error_e getListConnections(std::vector<am_Connection_s>& listConnections) const = 0;
- virtual am_Error_e getListSinks(std::vector<am_Sink_s>& listSinks) const = 0;
- virtual am_Error_e getListSources(std::vector<am_Source_s>& lisSources) const = 0;
- virtual am_Error_e getListSourceClasses(std::vector<am_SourceClass_s>& listSourceClasses) const = 0;
- virtual am_Error_e getListCrossfaders(std::vector<am_Crossfader_s>& listCrossfaders) const = 0;
- virtual am_Error_e getListGateways(std::vector<am_Gateway_s>& listGateways) const = 0;
- virtual am_Error_e getListConverters(std::vector<am_Converter_s> & listConverters) const = 0;
- virtual am_Error_e getListSinkClasses(std::vector<am_SinkClass_s>& listSinkClasses) const = 0;
- virtual am_Error_e getListVisibleMainConnections(std::vector<am_MainConnectionType_s>& listConnections) const = 0;
- virtual am_Error_e getListMainSinks(std::vector<am_SinkType_s>& listMainSinks) const = 0;
- virtual am_Error_e getListMainSources(std::vector<am_SourceType_s>& listMainSources) const = 0;
- virtual am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s>& listSoundProperties) const = 0;
- virtual am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s>& listSourceProperties) const = 0;
- virtual am_Error_e getListSystemProperties(std::vector<am_SystemProperty_s>& listSystemProperties) const = 0;
- virtual am_Error_e getListSinkConnectionFormats(const am_sinkID_t sinkID, std::vector<am_CustomConnectionFormat_t> & listConnectionFormats) const = 0;
- virtual am_Error_e getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector<am_CustomConnectionFormat_t> & listConnectionFormats) const = 0;
- virtual am_Error_e getListGatewayConnectionFormats(const am_gatewayID_t gatewayID, std::vector<bool> & listConnectionFormat) const = 0;
- virtual am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay) const = 0;
- virtual am_Error_e getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t& domainID) const = 0;
- virtual am_Error_e getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t& domainID) const = 0;
- virtual am_Error_e getDomainOfCrossfader(const am_crossfaderID_t crossfader, am_domainID_t& domainID) const = 0;
- virtual am_Error_e getSoureState(const am_sourceID_t sourceID, am_SourceState_e& sourceState) const = 0;
- virtual am_Error_e getDomainState(const am_domainID_t domainID, am_DomainState_e& state) const = 0;
- virtual am_Error_e peekDomain(const std::string& name, am_domainID_t& domainID) = 0;
- virtual am_Error_e peekSink(const std::string& name, am_sinkID_t& sinkID) = 0;
- virtual am_Error_e peekSource(const std::string& name, am_sourceID_t& sourceID) = 0;
- virtual am_Error_e peekSinkClassID(const std::string& name, am_sinkClass_t& sinkClassID) = 0;
- virtual am_Error_e peekSourceClassID(const std::string& name, am_sourceClass_t& sourceClassID) = 0;
- virtual am_Error_e changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) = 0;
- virtual am_Error_e changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) = 0;
- virtual am_Error_e getListMainSinkNotificationConfigurations(const am_sinkID_t sinkID, std::vector<am_NotificationConfiguration_s>& listMainNotificationConfigurations) = 0;
- virtual am_Error_e getListMainSourceNotificationConfigurations(const am_sourceID_t sourceID, std::vector<am_NotificationConfiguration_s>& listMainNotificationConfigurations) = 0;
+ virtual am_Error_e getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s &classInfo) const = 0;
+ virtual am_Error_e getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s &sinkClass) const = 0;
+ virtual am_Error_e getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s &gatewayData) const = 0;
+ virtual am_Error_e getConverterInfoDB(const am_converterID_t converterID, am_Converter_s &converterData) const = 0;
+ virtual am_Error_e getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s &sinkData) const = 0;
+ virtual am_Error_e getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s &sourceData) const = 0;
+ virtual am_Error_e getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s &crossfaderData) const = 0;
+ virtual am_Error_e getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s &mainConnectionData) const = 0;
+ virtual am_Error_e getSinkMainVolume(const am_sinkID_t sinkID, am_mainVolume_t &mainVolume) const = 0;
+ virtual am_Error_e getSinkVolume(const am_sinkID_t sinkID, am_volume_t &volume) const = 0;
+ 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 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;
+ virtual am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t> &listSinkID) const = 0;
+ virtual am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t> &listSourceID) const = 0;
+ virtual am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t> &listGatewaysID) const = 0;
+ virtual am_Error_e getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t> &listGatewaysID) const = 0;
+ virtual am_Error_e getListConvertersOfDomain(const am_domainID_t domainID, std::vector<am_converterID_t> &listConvertersID) const = 0;
+ virtual am_Error_e getListMainConnections(std::vector<am_MainConnection_s> &listMainConnections) const = 0;
+ virtual am_Error_e getListDomains(std::vector<am_Domain_s> &listDomains) const = 0;
+ virtual am_Error_e getListConnections(std::vector<am_Connection_s> &listConnections) const = 0;
+ virtual am_Error_e getListSinks(std::vector<am_Sink_s> &listSinks) const = 0;
+ virtual am_Error_e getListSources(std::vector<am_Source_s> &lisSources) const = 0;
+ virtual am_Error_e getListSourceClasses(std::vector<am_SourceClass_s> &listSourceClasses) const = 0;
+ virtual am_Error_e getListCrossfaders(std::vector<am_Crossfader_s> &listCrossfaders) const = 0;
+ virtual am_Error_e getListGateways(std::vector<am_Gateway_s> &listGateways) const = 0;
+ virtual am_Error_e getListConverters(std::vector<am_Converter_s> &listConverters) const = 0;
+ virtual am_Error_e getListSinkClasses(std::vector<am_SinkClass_s> &listSinkClasses) const = 0;
+ virtual am_Error_e getListVisibleMainConnections(std::vector<am_MainConnectionType_s> &listConnections) const = 0;
+ virtual am_Error_e getListMainSinks(std::vector<am_SinkType_s> &listMainSinks) const = 0;
+ virtual am_Error_e getListMainSources(std::vector<am_SourceType_s> &listMainSources) const = 0;
+ virtual am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s> &listSoundProperties) const = 0;
+ virtual am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s> &listSourceProperties) const = 0;
+ virtual am_Error_e getListSystemProperties(std::vector<am_SystemProperty_s> &listSystemProperties) const = 0;
+ virtual am_Error_e getListSinkConnectionFormats(const am_sinkID_t sinkID, std::vector<am_CustomConnectionFormat_t> &listConnectionFormats) const = 0;
+ virtual am_Error_e getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector<am_CustomConnectionFormat_t> &listConnectionFormats) const = 0;
+ virtual am_Error_e getListGatewayConnectionFormats(const am_gatewayID_t gatewayID, std::vector<bool> &listConnectionFormat) const = 0;
+ virtual am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t &delay) const = 0;
+ virtual am_Error_e getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t &domainID) const = 0;
+ virtual am_Error_e getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t &domainID) const = 0;
+ virtual am_Error_e getDomainOfCrossfader(const am_crossfaderID_t crossfader, am_domainID_t &domainID) const = 0;
+ virtual am_Error_e getSoureState(const am_sourceID_t sourceID, am_SourceState_e &sourceState) const = 0;
+ virtual am_Error_e getDomainState(const am_domainID_t domainID, am_DomainState_e &state) const = 0;
+ virtual am_Error_e peekDomain(const std::string &name, am_domainID_t &domainID) = 0;
+ virtual am_Error_e peekSink(const std::string &name, am_sinkID_t &sinkID) = 0;
+ virtual am_Error_e peekSource(const std::string &name, am_sourceID_t &sourceID) = 0;
+ virtual am_Error_e peekSinkClassID(const std::string &name, am_sinkClass_t &sinkClassID) = 0;
+ virtual am_Error_e peekSourceClassID(const std::string &name, am_sourceClass_t &sourceClassID) = 0;
+ virtual am_Error_e changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s> &listSoundProperties, const std::vector<am_CustomConnectionFormat_t> &listConnectionFormats, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties) = 0;
+ virtual am_Error_e changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s> &listSoundProperties, const std::vector<am_CustomConnectionFormat_t> &listConnectionFormats, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties) = 0;
+ virtual am_Error_e getListMainSinkNotificationConfigurations(const am_sinkID_t sinkID, std::vector<am_NotificationConfiguration_s> &listMainNotificationConfigurations) = 0;
+ virtual am_Error_e getListMainSourceNotificationConfigurations(const am_sourceID_t sourceID, std::vector<am_NotificationConfiguration_s> &listMainNotificationConfigurations) = 0;
virtual am_Error_e changeMainSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration) = 0;
virtual am_Error_e changeMainSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration) = 0;
- virtual am_Error_e changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t>& listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t>& listSinkConnectionFormats, const std::vector<bool>& convertionMatrix) = 0;
- 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 am_Error_e changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t> &listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t> &listSinkConnectionFormats, const std::vector<bool> &convertionMatrix) = 0;
+ 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;
+ virtual bool existConnection(const am_Connection_s &connection) const = 0;
virtual bool existConnectionID(const am_connectionID_t connectionID) const = 0;
virtual bool existSource(const am_sourceID_t sourceID) const = 0;
- virtual bool existSourceNameOrID(const am_sourceID_t sourceID, const std::string& name) const = 0;
- virtual bool existSourceName(const std::string& name) const = 0;
+ virtual bool existSourceNameOrID(const am_sourceID_t sourceID, const std::string &name) const = 0;
+ virtual bool existSourceName(const std::string &name) const = 0;
virtual bool existSink(const am_sinkID_t sinkID) const = 0;
- virtual bool existSinkNameOrID(const am_sinkID_t sinkID, const std::string& name) const = 0;
- virtual bool existSinkName(const std::string& name) const = 0;
- virtual bool existDomain(const am_domainID_t domainID) const = 0;
- 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 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;
- virtual bool isComponentConnected(const am_Converter_s & converter) const = 0;
+ virtual bool existSinkNameOrID(const am_sinkID_t sinkID, const std::string &name) const = 0;
+ virtual bool existSinkName(const std::string &name) const = 0;
+ virtual bool existDomain(const am_domainID_t domainID) const = 0;
+ 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 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;
+ virtual bool isComponentConnected(const am_Converter_s &converter) const = 0;
virtual am_timeSync_t calculateMainConnectionDelay(const am_mainConnectionID_t mainConnectionID) const = 0; //!< calculates a new main connection delay
- virtual void dump( std::ostream & output) const = 0 ;
- virtual am_Error_e enumerateSources(std::function<void(const am_Source_s & element)> cb) const = 0 ;
- 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 ;
+ virtual void dump(std::ostream &output) const = 0;
+ virtual am_Error_e enumerateSources(std::function<void(const am_Source_s &element)> cb) const = 0;
+ 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
- */
+ * Database observer protocol
+ */
class IAmDatabaseObserver
{
public:
- IAmDatabaseObserver() {}
- virtual ~IAmDatabaseObserver(){}
+ IAmDatabaseObserver() {}
+ virtual ~IAmDatabaseObserver(){}
};
- virtual bool registerObserver(IAmDatabaseObserver * iObserver) = 0;
- virtual bool unregisterObserver(IAmDatabaseObserver * iObserver) = 0;
- virtual unsigned countObservers() = 0;
-};
+ virtual bool registerObserver(IAmDatabaseObserver *iObserver) = 0;
+ virtual bool unregisterObserver(IAmDatabaseObserver *iObserver) = 0;
+ virtual unsigned countObservers() = 0;
+};
}
diff --git a/AudioManagerCore/src/CAmCommandReceiver.cpp b/AudioManagerCore/src/CAmCommandReceiver.cpp
index 8b60c66..78d8cbe 100644
--- a/AudioManagerCore/src/CAmCommandReceiver.cpp
+++ b/AudioManagerCore/src/CAmCommandReceiver.cpp
@@ -29,152 +29,151 @@
#include "CAmDltWrapper.h"
#include "CAmSocketHandler.h"
-#define __METHOD_NAME__ std::string (std::string("CAmCommandReceiver::") + __func__)
+#define __METHOD_NAME__ std::string(std::string("CAmCommandReceiver::") + __func__)
namespace am
{
-CAmCommandReceiver::CAmCommandReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler) :
- mDatabaseHandler(iDatabaseHandler),
- mControlSender(iControlSender),
- mDBusWrapper(NULL),
- mSocketHandler(iSocketHandler),
- handleCount(0),
- mListStartupHandles(),
- mListRundownHandles(),
- mWaitStartup(false),
- mWaitRundown(false),
- mLastErrorStartup(E_OK),
- mLastErrorRundown(E_OK)
-
-{
- assert(mDatabaseHandler!=NULL);
- assert(mSocketHandler!=NULL);
- assert(mControlSender!=NULL);
-}
-
-CAmCommandReceiver::CAmCommandReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler, CAmDbusWrapper *iDBusWrapper) :
- mDatabaseHandler(iDatabaseHandler),
- mControlSender(iControlSender),
- mDBusWrapper(iDBusWrapper),
- mSocketHandler(iSocketHandler),
- handleCount(0),
- mListStartupHandles(),
- mListRundownHandles(),
- mWaitStartup(false),
- mWaitRundown(false),
- mLastErrorStartup(E_UNKNOWN),
- mLastErrorRundown(E_UNKNOWN)
-{
- assert(mDatabaseHandler!=NULL);
- assert(mSocketHandler!=NULL);
- assert(mControlSender!=NULL);
- assert(mDBusWrapper!=NULL);
+CAmCommandReceiver::CAmCommandReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler)
+ : mDatabaseHandler(iDatabaseHandler)
+ , mControlSender(iControlSender)
+ , mDBusWrapper(NULL)
+ , mSocketHandler(iSocketHandler)
+ , handleCount(0)
+ , mListStartupHandles()
+ , mListRundownHandles()
+ , mWaitStartup(false)
+ , mWaitRundown(false)
+ , mLastErrorStartup(E_OK)
+ , mLastErrorRundown(E_OK)
+{
+ assert(mDatabaseHandler != NULL);
+ assert(mSocketHandler != NULL);
+ assert(mControlSender != NULL);
+}
+
+CAmCommandReceiver::CAmCommandReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler, CAmDbusWrapper *iDBusWrapper)
+ : mDatabaseHandler(iDatabaseHandler)
+ , mControlSender(iControlSender)
+ , mDBusWrapper(iDBusWrapper)
+ , mSocketHandler(iSocketHandler)
+ , handleCount(0)
+ , mListStartupHandles()
+ , mListRundownHandles()
+ , mWaitStartup(false)
+ , mWaitRundown(false)
+ , mLastErrorStartup(E_UNKNOWN)
+ , mLastErrorRundown(E_UNKNOWN)
+{
+ assert(mDatabaseHandler != NULL);
+ assert(mSocketHandler != NULL);
+ assert(mControlSender != NULL);
+ assert(mDBusWrapper != NULL);
}
CAmCommandReceiver::~CAmCommandReceiver()
{
}
-am_Error_e CAmCommandReceiver::connect(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t & mainConnectionID)
+am_Error_e CAmCommandReceiver::connect(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t &mainConnectionID)
{
- logInfo(__METHOD_NAME__,"sourceID=", sourceID, "sinkID=", sinkID);
+ logInfo(__METHOD_NAME__, "sourceID=", sourceID, "sinkID=", sinkID);
return (mControlSender->hookUserConnectionRequest(sourceID, sinkID, mainConnectionID));
}
am_Error_e CAmCommandReceiver::disconnect(const am_mainConnectionID_t mainConnectionID)
{
- logInfo(__METHOD_NAME__,"mainConnectionID=", mainConnectionID);
+ logInfo(__METHOD_NAME__, "mainConnectionID=", mainConnectionID);
return (mControlSender->hookUserDisconnectionRequest(mainConnectionID));
}
am_Error_e CAmCommandReceiver::setVolume(const am_sinkID_t sinkID, const am_mainVolume_t volume)
{
- logInfo(__METHOD_NAME__,"sinkID=", sinkID, "volume=", volume);
+ logInfo(__METHOD_NAME__, "sinkID=", sinkID, "volume=", volume);
return (mControlSender->hookUserVolumeChange(sinkID, volume));
}
am_Error_e CAmCommandReceiver::volumeStep(const am_sinkID_t sinkID, const int16_t volumeStep)
{
- logInfo(__METHOD_NAME__,"sinkID=", sinkID, "volumeStep=", volumeStep);
+ logInfo(__METHOD_NAME__, "sinkID=", sinkID, "volumeStep=", volumeStep);
return (mControlSender->hookUserVolumeStep(sinkID, volumeStep));
}
am_Error_e CAmCommandReceiver::setSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState)
{
- logInfo(__METHOD_NAME__,"sinkID=", sinkID, "muteState=", muteState);
+ logInfo(__METHOD_NAME__, "sinkID=", sinkID, "muteState=", muteState);
return (mControlSender->hookUserSetSinkMuteState(sinkID, muteState));
}
-am_Error_e CAmCommandReceiver::setMainSinkSoundProperty(const am_MainSoundProperty_s & soundProperty, const am_sinkID_t sinkID)
+am_Error_e CAmCommandReceiver::setMainSinkSoundProperty(const am_MainSoundProperty_s &soundProperty, const am_sinkID_t sinkID)
{
- logInfo(__METHOD_NAME__,"sinkID=", sinkID, "soundPropertyType=", soundProperty.type, "soundPropertyValue=", soundProperty.value);
+ logInfo(__METHOD_NAME__, "sinkID=", sinkID, "soundPropertyType=", soundProperty.type, "soundPropertyValue=", soundProperty.value);
return (mControlSender->hookUserSetMainSinkSoundProperty(sinkID, soundProperty));
}
-am_Error_e CAmCommandReceiver::setMainSourceSoundProperty(const am_MainSoundProperty_s & soundProperty, const am_sourceID_t sourceID)
+am_Error_e CAmCommandReceiver::setMainSourceSoundProperty(const am_MainSoundProperty_s &soundProperty, const am_sourceID_t sourceID)
{
- logInfo(__METHOD_NAME__,"sourceID=", sourceID, "soundPropertyType=", soundProperty.type, "soundPropertyValue=", soundProperty.value);
+ logInfo(__METHOD_NAME__, "sourceID=", sourceID, "soundPropertyType=", soundProperty.type, "soundPropertyValue=", soundProperty.value);
return (mControlSender->hookUserSetMainSourceSoundProperty(sourceID, soundProperty));
}
-am_Error_e CAmCommandReceiver::setSystemProperty(const am_SystemProperty_s & property)
+am_Error_e CAmCommandReceiver::setSystemProperty(const am_SystemProperty_s &property)
{
- logInfo(__METHOD_NAME__,"type=", property.type, "systemPropertyValue=", property.value);
+ logInfo(__METHOD_NAME__, "type=", property.type, "systemPropertyValue=", property.value);
return (mControlSender->hookUserSetSystemProperty(property));
}
-am_Error_e CAmCommandReceiver::getVolume(const am_sinkID_t sinkID, am_mainVolume_t& mainVolume) const
+am_Error_e CAmCommandReceiver::getVolume(const am_sinkID_t sinkID, am_mainVolume_t &mainVolume) const
{
return (mDatabaseHandler->getSinkMainVolume(sinkID, mainVolume));
}
-am_Error_e CAmCommandReceiver::getListMainConnections(std::vector<am_MainConnectionType_s> & listConnections) const
+am_Error_e CAmCommandReceiver::getListMainConnections(std::vector<am_MainConnectionType_s> &listConnections) const
{
return (mDatabaseHandler->getListVisibleMainConnections(listConnections));
}
-am_Error_e CAmCommandReceiver::getListMainSinks(std::vector<am_SinkType_s>& listMainSinks) const
+am_Error_e CAmCommandReceiver::getListMainSinks(std::vector<am_SinkType_s> &listMainSinks) const
{
return (mDatabaseHandler->getListMainSinks(listMainSinks));
}
-am_Error_e CAmCommandReceiver::getListMainSources(std::vector<am_SourceType_s>& listMainSources) const
+am_Error_e CAmCommandReceiver::getListMainSources(std::vector<am_SourceType_s> &listMainSources) const
{
return (mDatabaseHandler->getListMainSources(listMainSources));
}
-am_Error_e CAmCommandReceiver::getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s> & listSoundProperties) const
+am_Error_e CAmCommandReceiver::getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s> &listSoundProperties) const
{
return (mDatabaseHandler->getListMainSinkSoundProperties(sinkID, listSoundProperties));
}
-am_Error_e CAmCommandReceiver::getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s> & listSourceProperties) const
+am_Error_e CAmCommandReceiver::getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s> &listSourceProperties) const
{
return (mDatabaseHandler->getListMainSourceSoundProperties(sourceID, listSourceProperties));
}
-am_Error_e CAmCommandReceiver::getListSourceClasses(std::vector<am_SourceClass_s> & listSourceClasses) const
+am_Error_e CAmCommandReceiver::getListSourceClasses(std::vector<am_SourceClass_s> &listSourceClasses) const
{
return (mDatabaseHandler->getListSourceClasses(listSourceClasses));
}
-am_Error_e CAmCommandReceiver::getListSinkClasses(std::vector<am_SinkClass_s> & listSinkClasses) const
+am_Error_e CAmCommandReceiver::getListSinkClasses(std::vector<am_SinkClass_s> &listSinkClasses) const
{
return (mDatabaseHandler->getListSinkClasses(listSinkClasses));
}
-am_Error_e CAmCommandReceiver::getListSystemProperties(std::vector<am_SystemProperty_s> & listSystemProperties) const
+am_Error_e CAmCommandReceiver::getListSystemProperties(std::vector<am_SystemProperty_s> &listSystemProperties) const
{
return (mDatabaseHandler->getListSystemProperties(listSystemProperties));
}
-am_Error_e CAmCommandReceiver::getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t & delay) const
+am_Error_e CAmCommandReceiver::getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t &delay) const
{
return (mDatabaseHandler->getTimingInformation(mainConnectionID, delay));
}
-am_Error_e CAmCommandReceiver::getDBusConnectionWrapper(CAmDbusWrapper*& dbusConnectionWrapper) const
+am_Error_e CAmCommandReceiver::getDBusConnectionWrapper(CAmDbusWrapper * &dbusConnectionWrapper) const
{
#ifdef WITH_DBUS_WRAPPER
dbusConnectionWrapper = mDBusWrapper;
@@ -185,81 +184,91 @@ am_Error_e CAmCommandReceiver::getDBusConnectionWrapper(CAmDbusWrapper*& dbusCon
#endif /*WITH_DBUS_WRAPPER*/
}
-am_Error_e CAmCommandReceiver::getSocketHandler(CAmSocketHandler *& socketHandler) const
+am_Error_e CAmCommandReceiver::getSocketHandler(CAmSocketHandler * &socketHandler) const
{
socketHandler = mSocketHandler;
return (E_OK);
}
-void CAmCommandReceiver::getInterfaceVersion(std::string & version) const
+void CAmCommandReceiver::getInterfaceVersion(std::string &version) const
{
version = CommandVersion;
}
void CAmCommandReceiver::confirmCommandReady(const uint16_t handle, const am_Error_e error)
{
- if (error !=E_OK)
- mLastErrorStartup=error;
+ if (error != E_OK)
+ {
+ mLastErrorStartup = error;
+ }
+
mListStartupHandles.erase(std::remove(mListStartupHandles.begin(), mListStartupHandles.end(), handle), mListStartupHandles.end());
if (mWaitStartup && mListStartupHandles.empty())
+ {
mControlSender->confirmCommandReady(mLastErrorStartup);
+ }
}
void CAmCommandReceiver::confirmCommandRundown(const uint16_t handle, const am_Error_e error)
{
- if (error !=E_OK)
- mLastErrorRundown=error;
+ if (error != E_OK)
+ {
+ mLastErrorRundown = error;
+ }
+
mListRundownHandles.erase(std::remove(mListRundownHandles.begin(), mListRundownHandles.end(), handle), mListRundownHandles.end());
if (mWaitRundown && mListRundownHandles.empty())
+ {
mControlSender->confirmCommandRundown(mLastErrorRundown);
+ }
}
uint16_t CAmCommandReceiver::getStartupHandle()
{
- uint16_t handle = ++handleCount; //todo: handle overflow
+ uint16_t handle = ++handleCount; // todo: handle overflow
mListStartupHandles.push_back(handle);
return (handle);
}
uint16_t CAmCommandReceiver::getRundownHandle()
{
- uint16_t handle = ++handleCount; //todo: handle overflow
+ uint16_t handle = ++handleCount; // todo: handle overflow
mListRundownHandles.push_back(handle);
return (handle);
}
void CAmCommandReceiver::waitOnStartup(bool startup)
{
- mWaitStartup = startup;
- mLastErrorStartup=E_OK;
+ mWaitStartup = startup;
+ mLastErrorStartup = E_OK;
}
-am_Error_e CAmCommandReceiver::getListMainSinkNotificationConfigurations(const am_sinkID_t sinkID, std::vector<am_NotificationConfiguration_s>& listMainNotificationConfigurations) const
+am_Error_e CAmCommandReceiver::getListMainSinkNotificationConfigurations(const am_sinkID_t sinkID, std::vector<am_NotificationConfiguration_s> &listMainNotificationConfigurations) const
{
- return (mDatabaseHandler->getListMainSinkNotificationConfigurations(sinkID,listMainNotificationConfigurations));
+ return (mDatabaseHandler->getListMainSinkNotificationConfigurations(sinkID, listMainNotificationConfigurations));
}
-am_Error_e CAmCommandReceiver::getListMainSourceNotificationConfigurations(const am_sourceID_t sourceID, std::vector<am_NotificationConfiguration_s>& listMainNotificationConfigurations) const
+am_Error_e CAmCommandReceiver::getListMainSourceNotificationConfigurations(const am_sourceID_t sourceID, std::vector<am_NotificationConfiguration_s> &listMainNotificationConfigurations) const
{
- return (mDatabaseHandler->getListMainSourceNotificationConfigurations(sourceID,listMainNotificationConfigurations));
+ return (mDatabaseHandler->getListMainSourceNotificationConfigurations(sourceID, listMainNotificationConfigurations));
}
-am_Error_e CAmCommandReceiver::setMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s& mainNotificationConfiguration)
+am_Error_e CAmCommandReceiver::setMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s &mainNotificationConfiguration)
{
- logInfo(__METHOD_NAME__,"sinkID=", sinkID, " type=",mainNotificationConfiguration.type, " parameter=", mainNotificationConfiguration.parameter, "status=",mainNotificationConfiguration.status);
- return (mControlSender->hookUserSetMainSinkNotificationConfiguration(sinkID,mainNotificationConfiguration));
+ logInfo(__METHOD_NAME__, "sinkID=", sinkID, " type=", mainNotificationConfiguration.type, " parameter=", mainNotificationConfiguration.parameter, "status=", mainNotificationConfiguration.status);
+ return (mControlSender->hookUserSetMainSinkNotificationConfiguration(sinkID, mainNotificationConfiguration));
}
-am_Error_e CAmCommandReceiver::setMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s& mainNotificationConfiguration)
+am_Error_e CAmCommandReceiver::setMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s &mainNotificationConfiguration)
{
- logInfo(__METHOD_NAME__,"sourceID=", sourceID, " type=",mainNotificationConfiguration.type, " parameter=", mainNotificationConfiguration.parameter, "status=",mainNotificationConfiguration.status);
- return (mControlSender->hookUserSetMainSourceNotificationConfiguration(sourceID,mainNotificationConfiguration));
+ logInfo(__METHOD_NAME__, "sourceID=", sourceID, " type=", mainNotificationConfiguration.type, " parameter=", mainNotificationConfiguration.parameter, "status=", mainNotificationConfiguration.status);
+ return (mControlSender->hookUserSetMainSourceNotificationConfiguration(sourceID, mainNotificationConfiguration));
}
void CAmCommandReceiver::waitOnRundown(bool rundown)
{
- mWaitRundown = rundown;
- mLastErrorStartup=E_OK;
+ mWaitRundown = rundown;
+ mLastErrorStartup = E_OK;
}
}
diff --git a/AudioManagerCore/src/CAmCommandSender.cpp b/AudioManagerCore/src/CAmCommandSender.cpp
index 1a61883..d1a4a22 100644
--- a/AudioManagerCore/src/CAmCommandSender.cpp
+++ b/AudioManagerCore/src/CAmCommandSender.cpp
@@ -35,7 +35,7 @@
#include "CAmDltWrapper.h"
#include "audiomanagerconfig.h"
-#define __METHOD_NAME__ std::string (std::string("CAmCommandSender::") + __func__)
+#define __METHOD_NAME__ std::string(std::string("CAmCommandSender::") + __func__)
namespace am
{
@@ -43,135 +43,143 @@ namespace am
/**
* macro to call all interfaces
*/
-#define CALL_ALL_INTERFACES(...) \
- std::vector<IAmCommandSend*>::iterator iter = mListInterfaces.begin(); \
- std::vector<IAmCommandSend*>::iterator iterEnd = mListInterfaces.end(); \
- for (; iter<iterEnd;++iter) \
- { \
- (*iter)->__VA_ARGS__; \
- }
-
-CAmCommandSender::CAmCommandSender(const std::vector<std::string>& listOfPluginDirectories, CAmSocketHandler *iSocketHandler) :
- CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks(),
- mListInterfaces(),
- mListLibraryHandles(),
- mListLibraryNames(),
- mCommandReceiver(),
- mSerializer(iSocketHandler)
+#define CALL_ALL_INTERFACES(...) \
+ std::vector<IAmCommandSend *>::iterator iter = mListInterfaces.begin(); \
+ std::vector<IAmCommandSend *>::iterator iterEnd = mListInterfaces.end(); \
+ for (; iter < iterEnd; ++iter) \
+ { \
+ (*iter)->__VA_ARGS__; \
+ }
+
+CAmCommandSender::CAmCommandSender(const std::vector<std::string> &listOfPluginDirectories, CAmSocketHandler *iSocketHandler)
+ : CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks()
+ , mListInterfaces()
+ , mListLibraryHandles()
+ , mListLibraryNames()
+ , mCommandReceiver()
+ , mSerializer(iSocketHandler)
{
loadPlugins(listOfPluginDirectories);
- dboNewMainConnection = [&](const am_MainConnectionType_s& mainConnection) {
- mSerializer.asyncCall(this, &CAmCommandSender::cbNewMainConnection, mainConnection);
- };
+ dboNewMainConnection = [&](const am_MainConnectionType_s &mainConnection) {
+ mSerializer.asyncCall(this, &CAmCommandSender::cbNewMainConnection, mainConnection);
+ };
dboRemovedMainConnection = [&](const am_mainConnectionID_t mainConnection) {
- mSerializer.asyncCall(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;
- typedef void(CAmCommandSender::*TMeth)(am::am_SinkType_s);
- mSerializer.asyncCall<CAmCommandSender, TMeth, am::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;
- typedef void(CAmCommandSender::*TMeth)(am::am_SourceType_s);
- mSerializer.asyncCall<CAmCommandSender, TMeth, am::am_SourceType_s>(this, &CAmCommandSender::cbNewSource, s);
- }
- };
+ mSerializer.asyncCall(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;
+ typedef void (CAmCommandSender::*TMeth)(am::am_SinkType_s);
+ mSerializer.asyncCall<CAmCommandSender, TMeth, am::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;
+ typedef void (CAmCommandSender::*TMeth)(am::am_SourceType_s);
+ mSerializer.asyncCall<CAmCommandSender, TMeth, am::am_SourceType_s>(this, &CAmCommandSender::cbNewSource, s);
+ }
+ };
dboRemovedSink = [&](const am_sinkID_t sinkID, const bool visible) {
- if (visible)
- mSerializer.asyncCall(this, &CAmCommandSender::cbRemovedSink, sinkID);
- };
+ if (visible)
+ {
+ mSerializer.asyncCall(this, &CAmCommandSender::cbRemovedSink, sinkID);
+ }
+ };
dboRemovedSource = [&](const am_sourceID_t sourceID, const bool visible) {
- if (visible)
- mSerializer.asyncCall(this, &CAmCommandSender::cbRemovedSource, sourceID);
- };
+ if (visible)
+ {
+ mSerializer.asyncCall(this, &CAmCommandSender::cbRemovedSource, sourceID);
+ }
+ };
dboNumberOfSinkClassesChanged = [&]() {
- mSerializer.asyncCall(this, &CAmCommandSender::cbNumberOfSinkClassesChanged);
- };
+ mSerializer.asyncCall(this, &CAmCommandSender::cbNumberOfSinkClassesChanged);
+ };
dboNumberOfSourceClassesChanged = [&]() {
- mSerializer.asyncCall(this, &CAmCommandSender::cbNumberOfSourceClassesChanged);
- };
+ mSerializer.asyncCall(this, &CAmCommandSender::cbNumberOfSourceClassesChanged);
+ };
dboMainConnectionStateChanged = [&](const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState) {
- mSerializer.asyncCall(this, &CAmCommandSender::cbMainConnectionStateChanged, connectionID, connectionState);
- };
- dboMainSinkSoundPropertyChanged = [&](const am_sinkID_t sinkID, const am_MainSoundProperty_s& SoundProperty) {
- mSerializer.asyncCall(this, &CAmCommandSender::cbMainSinkSoundPropertyChanged, sinkID, SoundProperty);
- };
- dboMainSourceSoundPropertyChanged = [&](const am_sourceID_t sourceID, const am_MainSoundProperty_s& SoundProperty) {
- mSerializer.asyncCall(this, &CAmCommandSender::cbMainSourceSoundPropertyChanged, sourceID, SoundProperty);
- };
- dboSinkAvailabilityChanged = [&](const am_sinkID_t sinkID, const am_Availability_s & availability) {
- mSerializer.asyncCall(this, &CAmCommandSender::cbSinkAvailabilityChanged, sinkID, availability);
- };
- dboSourceAvailabilityChanged = [&](const am_sourceID_t sourceID, const am_Availability_s & availability) {
- mSerializer.asyncCall(this, &CAmCommandSender::cbSourceAvailabilityChanged, sourceID, availability);
- };
+ mSerializer.asyncCall(this, &CAmCommandSender::cbMainConnectionStateChanged, connectionID, connectionState);
+ };
+ dboMainSinkSoundPropertyChanged = [&](const am_sinkID_t sinkID, const am_MainSoundProperty_s &SoundProperty) {
+ mSerializer.asyncCall(this, &CAmCommandSender::cbMainSinkSoundPropertyChanged, sinkID, SoundProperty);
+ };
+ dboMainSourceSoundPropertyChanged = [&](const am_sourceID_t sourceID, const am_MainSoundProperty_s &SoundProperty) {
+ mSerializer.asyncCall(this, &CAmCommandSender::cbMainSourceSoundPropertyChanged, sourceID, SoundProperty);
+ };
+ dboSinkAvailabilityChanged = [&](const am_sinkID_t sinkID, const am_Availability_s &availability) {
+ mSerializer.asyncCall(this, &CAmCommandSender::cbSinkAvailabilityChanged, sinkID, availability);
+ };
+ dboSourceAvailabilityChanged = [&](const am_sourceID_t sourceID, const am_Availability_s &availability) {
+ mSerializer.asyncCall(this, &CAmCommandSender::cbSourceAvailabilityChanged, sourceID, availability);
+ };
dboVolumeChanged = [&](const am_sinkID_t sinkID, const am_mainVolume_t volume) {
- mSerializer.asyncCall(this, &CAmCommandSender::cbVolumeChanged, sinkID, volume);
- };
+ mSerializer.asyncCall(this, &CAmCommandSender::cbVolumeChanged, sinkID, volume);
+ };
dboSinkMuteStateChanged = [&](const am_sinkID_t sinkID, const am_MuteState_e muteState) {
- mSerializer.asyncCall(this, &CAmCommandSender::cbSinkMuteStateChanged, sinkID, muteState);
- };
- dboSystemPropertyChanged = [&](const am_SystemProperty_s& SystemProperty) {
- mSerializer.asyncCall(this, &CAmCommandSender::cbSystemPropertyChanged, SystemProperty);
- };
+ mSerializer.asyncCall(this, &CAmCommandSender::cbSinkMuteStateChanged, sinkID, muteState);
+ };
+ dboSystemPropertyChanged = [&](const am_SystemProperty_s &SystemProperty) {
+ mSerializer.asyncCall(this, &CAmCommandSender::cbSystemPropertyChanged, SystemProperty);
+ };
dboTimingInformationChanged = [&](const am_mainConnectionID_t mainConnection, const am_timeSync_t time) {
- mSerializer.asyncCall(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(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(this, &CAmCommandSender::cbSinkUpdated, sourceID, sourceClassID, listMainSoundProperties);
- };
+ mSerializer.asyncCall(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(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(this, &CAmCommandSender::cbSinkUpdated, sourceID, sourceClassID, listMainSoundProperties);
+ }
+ };
dboSinkMainNotificationConfigurationChanged = [&](const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration) {
- mSerializer.asyncCall(this, &CAmCommandSender::cbSinkMainNotificationConfigurationChanged, sinkID, mainNotificationConfiguration);
- };
+ mSerializer.asyncCall(this, &CAmCommandSender::cbSinkMainNotificationConfigurationChanged, sinkID, mainNotificationConfiguration);
+ };
dboSourceMainNotificationConfigurationChanged = [&](const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration) {
- mSerializer.asyncCall(this, &CAmCommandSender::cbSourceMainNotificationConfigurationChanged, sourceID, mainNotificationConfiguration);
- };
+ mSerializer.asyncCall(this, &CAmCommandSender::cbSourceMainNotificationConfigurationChanged, sourceID, mainNotificationConfiguration);
+ };
}
-void CAmCommandSender::loadPlugins(const std::vector<std::string>& listOfPluginDirectories)
+void CAmCommandSender::loadPlugins(const std::vector<std::string> &listOfPluginDirectories)
{
if (listOfPluginDirectories.empty())
{
- logError(__METHOD_NAME__,"List of commandplugins is empty");
+ logError(__METHOD_NAME__, "List of commandplugins is empty");
}
- std::vector<std::string> sharedLibraryNameList;
- std::vector<std::string>::const_iterator dirIter = listOfPluginDirectories.begin();
+ 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 CommandPlugins in", *dirIter);
+ const char *directoryName = dirIter->c_str();
+ logInfo(__METHOD_NAME__, "Searching for CommandPlugins in", *dirIter);
DIR *directory = opendir(directoryName);
if (!directory)
{
- logError(__METHOD_NAME__,"Error opening directory ", *dirIter);
+ logError(__METHOD_NAME__, "Error opening directory ", *dirIter);
continue;
}
@@ -180,10 +188,10 @@ void CAmCommandSender::loadPlugins(const std::vector<std::string>& listOfPluginD
while ((itemInDirectory = readdir(directory)))
{
unsigned char entryType = itemInDirectory->d_type;
- std::string entryName = itemInDirectory->d_name;
- std::string fullName = *dirIter + "/" + entryName;
+ std::string entryName = itemInDirectory->d_name;
+ std::string fullName = *dirIter + "/" + entryName;
- bool regularFile = (entryType == DT_REG || entryType == DT_LNK);
+ 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
@@ -193,7 +201,7 @@ void CAmCommandSender::loadPlugins(const std::vector<std::string>& listOfPluginD
if (stat(fullName.c_str(), &buf))
{
- logInfo(__METHOD_NAME__,"Failed to stat file: ", entryName, errno);
+ logInfo(__METHOD_NAME__, "Failed to stat file: ", entryName, errno);
continue;
}
@@ -206,36 +214,37 @@ void CAmCommandSender::loadPlugins(const std::vector<std::string>& listOfPluginD
sharedLibraryNameList.push_back(name + "/" + entryName);
}
}
+
closedir(directory);
}
// iterate all communicator plugins and start them
- std::vector<std::string>::iterator iter = sharedLibraryNameList.begin();
+ std::vector<std::string>::iterator iter = sharedLibraryNameList.begin();
std::vector<std::string>::iterator iterEnd = sharedLibraryNameList.end();
for (; iter < iterEnd; ++iter)
{
- logInfo(__METHOD_NAME__,"Loading CommandSender plugin", *iter);
- IAmCommandSend* (*createFunc)();
- void* tempLibHandle = NULL;
- createFunc = getCreateFunction<IAmCommandSend*()>(*iter, tempLibHandle);
+ logInfo(__METHOD_NAME__, "Loading CommandSender plugin", *iter);
+ IAmCommandSend *(*createFunc)();
+ void *tempLibHandle = NULL;
+ createFunc = getCreateFunction<IAmCommandSend *()>(*iter, tempLibHandle);
if (!createFunc)
{
- logInfo(__METHOD_NAME__,"Entry point of CommandPlugin not found", *iter);
+ logInfo(__METHOD_NAME__, "Entry point of CommandPlugin not found", *iter);
continue;
}
- IAmCommandSend* commander = createFunc();
+ IAmCommandSend *commander = createFunc();
if (!commander)
{
- logInfo(__METHOD_NAME__,"CommandPlugin initialization failed. Entry Function not callable");
+ logInfo(__METHOD_NAME__, "CommandPlugin initialization failed. Entry Function not callable");
dlclose(tempLibHandle);
continue;
}
- //check libversion
+ // check libversion
std::string version, cVersion(CommandVersion);
commander->getInterfaceVersion(version);
uint16_t minorVersion, majorVersion, cMinorVersion, cMajorVersion;
@@ -246,7 +255,7 @@ void CAmCommandSender::loadPlugins(const std::vector<std::string>& listOfPluginD
if (majorVersion < cMajorVersion || ((majorVersion == cMajorVersion) && (minorVersion > cMinorVersion)))
{
- logError(__METHOD_NAME__,"CommandInterface initialization failed. Version of Interface to old");
+ logError(__METHOD_NAME__, "CommandInterface initialization failed. Version of Interface to old");
dlclose(tempLibHandle);
continue;
}
@@ -259,7 +268,7 @@ void CAmCommandSender::loadPlugins(const std::vector<std::string>& listOfPluginD
CAmCommandSender::~CAmCommandSender()
{
- //unloadLibraries();
+ // unloadLibraries();
}
am_Error_e CAmCommandSender::startupInterfaces(CAmCommandReceiver *iCommandReceiver)
@@ -267,8 +276,8 @@ am_Error_e CAmCommandSender::startupInterfaces(CAmCommandReceiver *iCommandRecei
mCommandReceiver = iCommandReceiver;
am_Error_e returnError = E_OK;
- std::vector<IAmCommandSend*>::iterator iter = mListInterfaces.begin();
- std::vector<IAmCommandSend*>::iterator iterEnd = mListInterfaces.end();
+ std::vector<IAmCommandSend *>::iterator iter = mListInterfaces.begin();
+ std::vector<IAmCommandSend *>::iterator iterEnd = mListInterfaces.end();
for (; iter < iterEnd; ++iter)
{
am_Error_e error = (*iter)->startupInterface(iCommandReceiver);
@@ -277,6 +286,7 @@ am_Error_e CAmCommandSender::startupInterfaces(CAmCommandReceiver *iCommandRecei
returnError = error;
}
}
+
return (returnError);
}
@@ -292,47 +302,47 @@ void CAmCommandSender::cbNumberOfSourceClassesChanged()
void CAmCommandSender::cbMainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState)
{
- CALL_ALL_INTERFACES(cbMainConnectionStateChanged(connectionID,connectionState))
+ CALL_ALL_INTERFACES(cbMainConnectionStateChanged(connectionID, connectionState))
}
-void CAmCommandSender::cbMainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s& SoundProperty)
+void CAmCommandSender::cbMainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s &SoundProperty)
{
- CALL_ALL_INTERFACES(cbMainSinkSoundPropertyChanged(sinkID,SoundProperty))
+ CALL_ALL_INTERFACES(cbMainSinkSoundPropertyChanged(sinkID, SoundProperty))
}
-void CAmCommandSender::cbMainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s& SoundProperty)
+void CAmCommandSender::cbMainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s &SoundProperty)
{
- CALL_ALL_INTERFACES(cbMainSourceSoundPropertyChanged(sourceID,SoundProperty))
+ CALL_ALL_INTERFACES(cbMainSourceSoundPropertyChanged(sourceID, SoundProperty))
}
-void CAmCommandSender::cbSinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s & availability)
+void CAmCommandSender::cbSinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s &availability)
{
- CALL_ALL_INTERFACES(cbSinkAvailabilityChanged(sinkID,availability))
+ CALL_ALL_INTERFACES(cbSinkAvailabilityChanged(sinkID, availability))
}
-void CAmCommandSender::cbSourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s & availability)
+void CAmCommandSender::cbSourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s &availability)
{
- CALL_ALL_INTERFACES(cbSourceAvailabilityChanged(sourceID,availability))
+ CALL_ALL_INTERFACES(cbSourceAvailabilityChanged(sourceID, availability))
}
void CAmCommandSender::cbVolumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume)
{
- CALL_ALL_INTERFACES(cbVolumeChanged(sinkID,volume))
+ CALL_ALL_INTERFACES(cbVolumeChanged(sinkID, volume))
}
void CAmCommandSender::cbSinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState)
{
- CALL_ALL_INTERFACES(cbSinkMuteStateChanged(sinkID,muteState))
+ CALL_ALL_INTERFACES(cbSinkMuteStateChanged(sinkID, muteState))
}
-void CAmCommandSender::cbSystemPropertyChanged(const am_SystemProperty_s & SystemProperty)
+void CAmCommandSender::cbSystemPropertyChanged(const am_SystemProperty_s &SystemProperty)
{
CALL_ALL_INTERFACES(cbSystemPropertyChanged(SystemProperty))
}
void CAmCommandSender::cbTimingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time)
{
- CALL_ALL_INTERFACES(cbTimingInformationChanged(mainConnection,time))
+ CALL_ALL_INTERFACES(cbTimingInformationChanged(mainConnection, time))
}
void CAmCommandSender::cbNewMainConnection(const am_MainConnectionType_s mainConnection)
@@ -369,20 +379,20 @@ void CAmCommandSender::setCommandReady()
{
mCommandReceiver->waitOnStartup(false);
- //create a list of handles
+ // create a list of handles
std::vector<uint16_t> listStartupHandles;
for (size_t i = 0; i < mListInterfaces.size(); i++)
{
listStartupHandles.push_back(mCommandReceiver->getStartupHandle());
}
- //set the receiver ready to wait for replies
+ // set the receiver ready to wait for replies
mCommandReceiver->waitOnStartup(true);
- //now do the calls
- std::vector<IAmCommandSend*>::iterator iter = mListInterfaces.begin();
- std::vector<IAmCommandSend*>::iterator iterEnd = mListInterfaces.end();
- std::vector<uint16_t>::const_iterator handleIter(listStartupHandles.begin());
+ // now do the calls
+ std::vector<IAmCommandSend *>::iterator iter = mListInterfaces.begin();
+ std::vector<IAmCommandSend *>::iterator iterEnd = mListInterfaces.end();
+ std::vector<uint16_t>::const_iterator handleIter(listStartupHandles.begin());
for (; iter < iterEnd; ++iter)
{
(*iter)->setCommandReady(*(handleIter++));
@@ -392,74 +402,75 @@ void CAmCommandSender::setCommandReady()
void CAmCommandSender::setCommandRundown()
{
mCommandReceiver->waitOnRundown(false);
- //create a list of handles
+ // create a list of handles
std::vector<uint16_t> listStartupHandles;
for (size_t i = 0; i < mListInterfaces.size(); i++)
{
listStartupHandles.push_back(mCommandReceiver->getRundownHandle());
}
- //set the receiver ready to wait for replies
+ // set the receiver ready to wait for replies
mCommandReceiver->waitOnRundown(true);
- //now do the calls
- std::vector<IAmCommandSend*>::iterator iter = mListInterfaces.begin();
- std::vector<IAmCommandSend*>::iterator iterEnd = mListInterfaces.end();
- std::vector<uint16_t>::const_iterator handleIter(listStartupHandles.begin());
+ // now do the calls
+ std::vector<IAmCommandSend *>::iterator iter = mListInterfaces.begin();
+ std::vector<IAmCommandSend *>::iterator iterEnd = mListInterfaces.end();
+ std::vector<uint16_t>::const_iterator handleIter(listStartupHandles.begin());
for (; iter < iterEnd; ++iter)
{
(*iter)->setCommandRundown(*(handleIter++));
}
}
-void CAmCommandSender::getInterfaceVersion(std::string & version) const
+void CAmCommandSender::getInterfaceVersion(std::string &version) const
{
version = CommandVersion;
}
-am_Error_e am::CAmCommandSender::getListPlugins(std::vector<std::string> & interfaces) const
+am_Error_e am::CAmCommandSender::getListPlugins(std::vector<std::string> &interfaces) const
{
interfaces = mListLibraryNames;
return (E_OK);
}
-void CAmCommandSender::cbSinkUpdated(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
+void CAmCommandSender::cbSinkUpdated(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties)
{
- CALL_ALL_INTERFACES(cbSinkUpdated(sinkID,sinkClassID,listMainSoundProperties));
+ CALL_ALL_INTERFACES(cbSinkUpdated(sinkID, sinkClassID, listMainSoundProperties));
}
-void CAmCommandSender::cbSourceUpdated(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
+void CAmCommandSender::cbSourceUpdated(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties)
{
- CALL_ALL_INTERFACES(cbSourceUpdated(sourceID,sourceClassID,listMainSoundProperties));
+ CALL_ALL_INTERFACES(cbSourceUpdated(sourceID, sourceClassID, listMainSoundProperties));
}
-void CAmCommandSender::cbSinkNotification(const am_sinkID_t sinkID, const am_NotificationPayload_s& notification)
+void CAmCommandSender::cbSinkNotification(const am_sinkID_t sinkID, const am_NotificationPayload_s &notification)
{
- CALL_ALL_INTERFACES(cbSinkNotification(sinkID,notification));
+ CALL_ALL_INTERFACES(cbSinkNotification(sinkID, notification));
}
-void CAmCommandSender::cbSourceNotification(const am_sourceID_t sourceID, const am_NotificationPayload_s& notification)
+void CAmCommandSender::cbSourceNotification(const am_sourceID_t sourceID, const am_NotificationPayload_s &notification)
{
- CALL_ALL_INTERFACES(cbSourceNotification(sourceID,notification));
+ CALL_ALL_INTERFACES(cbSourceNotification(sourceID, notification));
}
-void CAmCommandSender::cbSinkMainNotificationConfigurationChanged(const am_sinkID_t sinkID, const am_NotificationConfiguration_s& mainNotificationConfiguration)
+void CAmCommandSender::cbSinkMainNotificationConfigurationChanged(const am_sinkID_t sinkID, const am_NotificationConfiguration_s &mainNotificationConfiguration)
{
- CALL_ALL_INTERFACES(cbMainSinkNotificationConfigurationChanged(sinkID,mainNotificationConfiguration));
+ CALL_ALL_INTERFACES(cbMainSinkNotificationConfigurationChanged(sinkID, mainNotificationConfiguration));
}
-void CAmCommandSender::cbSourceMainNotificationConfigurationChanged(const am_sourceID_t sourceID, const am_NotificationConfiguration_s& mainNotificationConfiguration)
+void CAmCommandSender::cbSourceMainNotificationConfigurationChanged(const am_sourceID_t sourceID, const am_NotificationConfiguration_s &mainNotificationConfiguration)
{
- CALL_ALL_INTERFACES(cbMainSourceNotificationConfigurationChanged(sourceID,mainNotificationConfiguration));
+ CALL_ALL_INTERFACES(cbMainSourceNotificationConfigurationChanged(sourceID, mainNotificationConfiguration));
}
void CAmCommandSender::unloadLibraries(void)
{
- std::vector<void*>::iterator iterator = mListLibraryHandles.begin();
+ std::vector<void *>::iterator iterator = mListLibraryHandles.begin();
for (; iterator < mListLibraryHandles.end(); ++iterator)
{
dlclose(*iterator);
}
+
mListLibraryHandles.clear();
}
diff --git a/AudioManagerCore/src/CAmControlReceiver.cpp b/AudioManagerCore/src/CAmControlReceiver.cpp
index 3280c04..6fec509 100644
--- a/AudioManagerCore/src/CAmControlReceiver.cpp
+++ b/AudioManagerCore/src/CAmControlReceiver.cpp
@@ -35,78 +35,78 @@
namespace am {
-#define __METHOD_NAME__ std::string (std::string("CAmControlReceiver::") + __func__)
+#define __METHOD_NAME__ std::string(std::string("CAmControlReceiver::") + __func__)
-CAmControlReceiver::CAmControlReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter) :
- mDatabaseHandler(iDatabaseHandler),
- mRoutingSender(iRoutingSender),
- mCommandSender(iCommandSender),
- mSocketHandler(iSocketHandler),
- mRouter(iRouter),
- mNodeStateCommunicator(NULL)
+CAmControlReceiver::CAmControlReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter *iRouter)
+ : mDatabaseHandler(iDatabaseHandler)
+ , mRoutingSender(iRoutingSender)
+ , mCommandSender(iCommandSender)
+ , mSocketHandler(iSocketHandler)
+ , mRouter(iRouter)
+ , mNodeStateCommunicator(NULL)
{
- assert(mDatabaseHandler!=NULL);
- assert(mRoutingSender!=NULL);
- assert(mCommandSender!=NULL);
- assert(mSocketHandler!=NULL);
- assert(mRouter!=NULL);
+ assert(mDatabaseHandler != NULL);
+ assert(mRoutingSender != NULL);
+ assert(mCommandSender != NULL);
+ assert(mSocketHandler != NULL);
+ assert(mRouter != NULL);
}
CAmControlReceiver::~CAmControlReceiver()
{
}
-am_Error_e CAmControlReceiver::getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s> & returnList)
+am_Error_e CAmControlReceiver::getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s> &returnList)
{
return (mRouter->getRoute(onlyfree, sourceID, sinkID, returnList));
}
-am_Error_e CAmControlReceiver::connect(am_Handle_s & handle, am_connectionID_t & connectionID, const am_CustomConnectionFormat_t format, const am_sourceID_t sourceID, const am_sinkID_t sinkID)
+am_Error_e CAmControlReceiver::connect(am_Handle_s &handle, am_connectionID_t &connectionID, const am_CustomConnectionFormat_t format, const am_sourceID_t sourceID, const am_sinkID_t sinkID)
{
- return (mRoutingSender->asyncConnect(handle, connectionID, sourceID, sinkID, format));
+ return (mRoutingSender->asyncConnect(handle, connectionID, sourceID, sinkID, format));
}
-am_Error_e CAmControlReceiver::disconnect(am_Handle_s & handle, const am_connectionID_t connectionID)
+am_Error_e CAmControlReceiver::disconnect(am_Handle_s &handle, const am_connectionID_t connectionID)
{
return (mRoutingSender->asyncDisconnect(handle, connectionID));
}
-am_Error_e CAmControlReceiver::crossfade(am_Handle_s & handle, const am_HotSink_e hotSource, const am_crossfaderID_t crossfaderID, const am_CustomRampType_t rampType, const am_time_t rampTime)
+am_Error_e CAmControlReceiver::crossfade(am_Handle_s &handle, const am_HotSink_e hotSource, const am_crossfaderID_t crossfaderID, const am_CustomRampType_t rampType, const am_time_t rampTime)
{
return (mRoutingSender->asyncCrossFade(handle, crossfaderID, hotSource, rampType, rampTime));
}
-am_Error_e CAmControlReceiver::setSourceState(am_Handle_s & handle, const am_sourceID_t sourceID, const am_SourceState_e state)
+am_Error_e CAmControlReceiver::setSourceState(am_Handle_s &handle, const am_sourceID_t sourceID, const am_SourceState_e state)
{
return (mRoutingSender->asyncSetSourceState(handle, sourceID, state));
}
-am_Error_e CAmControlReceiver::setSinkVolume(am_Handle_s & handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time)
+am_Error_e CAmControlReceiver::setSinkVolume(am_Handle_s &handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time)
{
return (mRoutingSender->asyncSetSinkVolume(handle, sinkID, volume, ramp, time));
}
-am_Error_e CAmControlReceiver::setSourceVolume(am_Handle_s & handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_CustomRampType_t rampType, const am_time_t time)
+am_Error_e CAmControlReceiver::setSourceVolume(am_Handle_s &handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_CustomRampType_t rampType, const am_time_t time)
{
return (mRoutingSender->asyncSetSourceVolume(handle, sourceID, volume, rampType, time));
}
-am_Error_e CAmControlReceiver::setSinkSoundProperty(am_Handle_s & handle, const am_sinkID_t sinkID, const am_SoundProperty_s & soundProperty)
+am_Error_e CAmControlReceiver::setSinkSoundProperty(am_Handle_s &handle, const am_sinkID_t sinkID, const am_SoundProperty_s &soundProperty)
{
return (mRoutingSender->asyncSetSinkSoundProperty(handle, sinkID, soundProperty));
}
-am_Error_e CAmControlReceiver::setSinkSoundProperties(am_Handle_s & handle, const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s> & listSoundProperties)
+am_Error_e CAmControlReceiver::setSinkSoundProperties(am_Handle_s &handle, const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s> &listSoundProperties)
{
return (mRoutingSender->asyncSetSinkSoundProperties(handle, listSoundProperties, sinkID));
}
-am_Error_e CAmControlReceiver::setSourceSoundProperty(am_Handle_s & handle, const am_sourceID_t sourceID, const am_SoundProperty_s & soundProperty)
+am_Error_e CAmControlReceiver::setSourceSoundProperty(am_Handle_s &handle, const am_sourceID_t sourceID, const am_SoundProperty_s &soundProperty)
{
return (mRoutingSender->asyncSetSourceSoundProperty(handle, sourceID, soundProperty));
}
-am_Error_e CAmControlReceiver::setSourceSoundProperties(am_Handle_s & handle, const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s> & listSoundProperties)
+am_Error_e CAmControlReceiver::setSourceSoundProperties(am_Handle_s &handle, const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s> &listSoundProperties)
{
return (mRoutingSender->asyncSetSourceSoundProperties(handle, listSoundProperties, sourceID));
}
@@ -121,57 +121,57 @@ am_Error_e CAmControlReceiver::abortAction(const am_Handle_s handle)
return (mRoutingSender->asyncAbort(handle));
}
-am_Error_e CAmControlReceiver::enterDomainDB(const am_Domain_s & domainData, am_domainID_t & domainID)
+am_Error_e CAmControlReceiver::enterDomainDB(const am_Domain_s &domainData, am_domainID_t &domainID)
{
return (mDatabaseHandler->enterDomainDB(domainData, domainID));
}
-am_Error_e CAmControlReceiver::enterMainConnectionDB(const am_MainConnection_s & mainConnectionData, am_mainConnectionID_t & connectionID)
+am_Error_e CAmControlReceiver::enterMainConnectionDB(const am_MainConnection_s &mainConnectionData, am_mainConnectionID_t &connectionID)
{
return (mDatabaseHandler->enterMainConnectionDB(mainConnectionData, connectionID));
}
-am_Error_e CAmControlReceiver::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
+am_Error_e CAmControlReceiver::enterSinkDB(const am_Sink_s &sinkData, am_sinkID_t &sinkID)
{
return (mDatabaseHandler->enterSinkDB(sinkData, sinkID));
}
-am_Error_e CAmControlReceiver::enterCrossfaderDB(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
+am_Error_e CAmControlReceiver::enterCrossfaderDB(const am_Crossfader_s &crossfaderData, am_crossfaderID_t &crossfaderID)
{
return (mDatabaseHandler->enterCrossfaderDB(crossfaderData, crossfaderID));
}
-am_Error_e CAmControlReceiver::enterGatewayDB(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
+am_Error_e CAmControlReceiver::enterGatewayDB(const am_Gateway_s &gatewayData, am_gatewayID_t &gatewayID)
{
return (mDatabaseHandler->enterGatewayDB(gatewayData, gatewayID));
}
-am_Error_e CAmControlReceiver::enterConverterDB(const am_Converter_s & converterData, am_converterID_t & converterID)
+am_Error_e CAmControlReceiver::enterConverterDB(const am_Converter_s &converterData, am_converterID_t &converterID)
{
return (mDatabaseHandler->enterConverterDB(converterData, converterID));
}
-am_Error_e CAmControlReceiver::enterSourceDB(const am_Source_s & sourceData, am_sourceID_t & sourceID)
+am_Error_e CAmControlReceiver::enterSourceDB(const am_Source_s &sourceData, am_sourceID_t &sourceID)
{
return (mDatabaseHandler->enterSourceDB(sourceData, sourceID));
}
-am_Error_e CAmControlReceiver::enterSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID)
+am_Error_e CAmControlReceiver::enterSinkClassDB(const am_SinkClass_s &sinkClass, am_sinkClass_t &sinkClassID)
{
return (mDatabaseHandler->enterSinkClassDB(sinkClass, sinkClassID));
}
-am_Error_e CAmControlReceiver::enterSourceClassDB(am_sourceClass_t & sourceClassID, const am_SourceClass_s & sourceClass)
+am_Error_e CAmControlReceiver::enterSourceClassDB(am_sourceClass_t &sourceClassID, const am_SourceClass_s &sourceClass)
{
return (mDatabaseHandler->enterSourceClassDB(sourceClassID, sourceClass));
}
-am_Error_e CAmControlReceiver::enterSystemPropertiesListDB(const std::vector<am_SystemProperty_s> & listSystemProperties)
+am_Error_e CAmControlReceiver::enterSystemPropertiesListDB(const std::vector<am_SystemProperty_s> &listSystemProperties)
{
return (mDatabaseHandler->enterSystemProperties(listSystemProperties));
}
-am_Error_e CAmControlReceiver::changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector<am_connectionID_t>& listConnectionID)
+am_Error_e CAmControlReceiver::changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector<am_connectionID_t> &listConnectionID)
{
return (mDatabaseHandler->changeMainConnectionRouteDB(mainconnectionID, listConnectionID));
}
@@ -186,7 +186,7 @@ am_Error_e CAmControlReceiver::changeSinkMainVolumeDB(const am_mainVolume_t main
return (mDatabaseHandler->changeSinkMainVolumeDB(mainVolume, sinkID));
}
-am_Error_e CAmControlReceiver::changeSinkAvailabilityDB(const am_Availability_s & availability, const am_sinkID_t sinkID)
+am_Error_e CAmControlReceiver::changeSinkAvailabilityDB(const am_Availability_s &availability, const am_sinkID_t sinkID)
{
return (mDatabaseHandler->changeSinkAvailabilityDB(availability, sinkID));
}
@@ -201,22 +201,22 @@ am_Error_e CAmControlReceiver::changeSinkMuteStateDB(const am_MuteState_e muteSt
return (mDatabaseHandler->changeSinkMuteStateDB(muteState, sinkID));
}
-am_Error_e CAmControlReceiver::changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sinkID_t sinkID)
+am_Error_e CAmControlReceiver::changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s &soundProperty, const am_sinkID_t sinkID)
{
return (mDatabaseHandler->changeMainSinkSoundPropertyDB(soundProperty, sinkID));
}
-am_Error_e CAmControlReceiver::changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sourceID_t sourceID)
+am_Error_e CAmControlReceiver::changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s &soundProperty, const am_sourceID_t sourceID)
{
return (mDatabaseHandler->changeMainSourceSoundPropertyDB(soundProperty, sourceID));
}
-am_Error_e CAmControlReceiver::changeSourceAvailabilityDB(const am_Availability_s & availability, const am_sourceID_t sourceID)
+am_Error_e CAmControlReceiver::changeSourceAvailabilityDB(const am_Availability_s &availability, const am_sourceID_t sourceID)
{
return (mDatabaseHandler->changeSourceAvailabilityDB(availability, sourceID));
}
-am_Error_e CAmControlReceiver::changeSystemPropertyDB(const am_SystemProperty_s & property)
+am_Error_e CAmControlReceiver::changeSystemPropertyDB(const am_SystemProperty_s &property)
{
return (mDatabaseHandler->changeSystemPropertyDB(property));
}
@@ -256,138 +256,137 @@ am_Error_e CAmControlReceiver::removeDomainDB(const am_domainID_t domainID)
return (mDatabaseHandler->removeDomainDB(domainID));
}
-am_Error_e CAmControlReceiver::getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s & classInfo) const
+am_Error_e CAmControlReceiver::getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s &classInfo) const
{
return (mDatabaseHandler->getSourceClassInfoDB(sourceID, classInfo));
}
-am_Error_e CAmControlReceiver::getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s & sinkClass) const
+am_Error_e CAmControlReceiver::getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s &sinkClass) const
{
return (mDatabaseHandler->getSinkClassInfoDB(sinkID, sinkClass));
}
-am_Error_e CAmControlReceiver::getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s & sinkData) const
+am_Error_e CAmControlReceiver::getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s &sinkData) const
{
return (mDatabaseHandler->getSinkInfoDB(sinkID, sinkData));
}
-am_Error_e CAmControlReceiver::getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s & sourceData) const
+am_Error_e CAmControlReceiver::getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s &sourceData) const
{
return (mDatabaseHandler->getSourceInfoDB(sourceID, sourceData));
}
-am_Error_e CAmControlReceiver::getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s & mainConnectionData) const
+am_Error_e CAmControlReceiver::getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s &mainConnectionData) const
{
return (mDatabaseHandler->getMainConnectionInfoDB(mainConnectionID, mainConnectionData));
}
-am_Error_e CAmControlReceiver::getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s & gatewayData) const
+am_Error_e CAmControlReceiver::getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s &gatewayData) const
{
return (mDatabaseHandler->getGatewayInfoDB(gatewayID, gatewayData));
}
-am_Error_e CAmControlReceiver::getConverterInfoDB(const am_converterID_t converterID, am_Converter_s & converterData) const
+am_Error_e CAmControlReceiver::getConverterInfoDB(const am_converterID_t converterID, am_Converter_s &converterData) const
{
return (mDatabaseHandler->getConverterInfoDB(converterID, converterData));
}
-
-am_Error_e CAmControlReceiver::getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s & crossfaderData) const
+am_Error_e CAmControlReceiver::getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s &crossfaderData) const
{
return (mDatabaseHandler->getCrossfaderInfoDB(crossfaderID, crossfaderData));
}
-am_Error_e CAmControlReceiver::getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t> & listSinkID) const
+am_Error_e CAmControlReceiver::getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t> &listSinkID) const
{
return (mDatabaseHandler->getListSinksOfDomain(domainID, listSinkID));
}
-am_Error_e CAmControlReceiver::getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t> & listSourceID) const
+am_Error_e CAmControlReceiver::getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t> &listSourceID) const
{
return (mDatabaseHandler->getListSourcesOfDomain(domainID, listSourceID));
}
-am_Error_e CAmControlReceiver::getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t> & listGatewaysID) const
+am_Error_e CAmControlReceiver::getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t> &listGatewaysID) const
{
return (mDatabaseHandler->getListCrossfadersOfDomain(domainID, listGatewaysID));
}
-am_Error_e CAmControlReceiver::getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t> & listGatewaysID) const
+am_Error_e CAmControlReceiver::getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t> &listGatewaysID) const
{
return (mDatabaseHandler->getListGatewaysOfDomain(domainID, listGatewaysID));
}
-am_Error_e CAmControlReceiver::getListConvertersOfDomain(const am_domainID_t domainID,std::vector<am_converterID_t>& listConverterID) const
+am_Error_e CAmControlReceiver::getListConvertersOfDomain(const am_domainID_t domainID, std::vector<am_converterID_t> &listConverterID) const
{
- return (mDatabaseHandler->getListConvertersOfDomain(domainID,listConverterID));
+ return (mDatabaseHandler->getListConvertersOfDomain(domainID, listConverterID));
}
-am_Error_e CAmControlReceiver::getListMainConnections(std::vector<am_MainConnection_s> & listMainConnections) const
+am_Error_e CAmControlReceiver::getListMainConnections(std::vector<am_MainConnection_s> &listMainConnections) const
{
return (mDatabaseHandler->getListMainConnections(listMainConnections));
}
-am_Error_e CAmControlReceiver::getListDomains(std::vector<am_Domain_s> & listDomains) const
+am_Error_e CAmControlReceiver::getListDomains(std::vector<am_Domain_s> &listDomains) const
{
return (mDatabaseHandler->getListDomains(listDomains));
}
-am_Error_e CAmControlReceiver::getListConnections(std::vector<am_Connection_s> & listConnections) const
+am_Error_e CAmControlReceiver::getListConnections(std::vector<am_Connection_s> &listConnections) const
{
return (mDatabaseHandler->getListConnections(listConnections));
}
-am_Error_e CAmControlReceiver::getListSinks(std::vector<am_Sink_s> & listSinks) const
+am_Error_e CAmControlReceiver::getListSinks(std::vector<am_Sink_s> &listSinks) const
{
return (mDatabaseHandler->getListSinks(listSinks));
}
-am_Error_e CAmControlReceiver::getListSources(std::vector<am_Source_s> & listSources) const
+am_Error_e CAmControlReceiver::getListSources(std::vector<am_Source_s> &listSources) const
{
return (mDatabaseHandler->getListSources(listSources));
}
-am_Error_e CAmControlReceiver::getListSourceClasses(std::vector<am_SourceClass_s> & listSourceClasses) const
+am_Error_e CAmControlReceiver::getListSourceClasses(std::vector<am_SourceClass_s> &listSourceClasses) const
{
return (mDatabaseHandler->getListSourceClasses(listSourceClasses));
}
-am_Error_e CAmControlReceiver::getListHandles(std::vector<am_Handle_s> & listHandles) const
+am_Error_e CAmControlReceiver::getListHandles(std::vector<am_Handle_s> &listHandles) const
{
return (mRoutingSender->getListHandles(listHandles));
}
-am_Error_e CAmControlReceiver::getListCrossfaders(std::vector<am_Crossfader_s> & listCrossfaders) const
+am_Error_e CAmControlReceiver::getListCrossfaders(std::vector<am_Crossfader_s> &listCrossfaders) const
{
return (mDatabaseHandler->getListCrossfaders(listCrossfaders));
}
-am_Error_e CAmControlReceiver::getListGateways(std::vector<am_Gateway_s> & listGateways) const
+am_Error_e CAmControlReceiver::getListGateways(std::vector<am_Gateway_s> &listGateways) const
{
return (mDatabaseHandler->getListGateways(listGateways));
}
-am_Error_e CAmControlReceiver::getListConverters(std::vector<am_Converter_s>& listConverters) const
+am_Error_e CAmControlReceiver::getListConverters(std::vector<am_Converter_s> &listConverters) const
{
return (mDatabaseHandler->getListConverters(listConverters));
}
-am_Error_e CAmControlReceiver::getListSinkClasses(std::vector<am_SinkClass_s> & listSinkClasses) const
+am_Error_e CAmControlReceiver::getListSinkClasses(std::vector<am_SinkClass_s> &listSinkClasses) const
{
return (mDatabaseHandler->getListSinkClasses(listSinkClasses));
}
-am_Error_e CAmControlReceiver::getListSystemProperties(std::vector<am_SystemProperty_s> & listSystemProperties) const
+am_Error_e CAmControlReceiver::getListSystemProperties(std::vector<am_SystemProperty_s> &listSystemProperties) const
{
return (mDatabaseHandler->getListSystemProperties(listSystemProperties));
}
-am_Error_e CAmControlReceiver::changeSinkClassInfoDB(const am_SinkClass_s & classInfo)
+am_Error_e CAmControlReceiver::changeSinkClassInfoDB(const am_SinkClass_s &classInfo)
{
return (mDatabaseHandler->changeSinkClassInfoDB(classInfo));
}
-am_Error_e CAmControlReceiver::changeSourceClassInfoDB(const am_SourceClass_s & classInfo)
+am_Error_e CAmControlReceiver::changeSourceClassInfoDB(const am_SourceClass_s &classInfo)
{
return(mDatabaseHandler->changeSourceClassInfoDB(classInfo));
}
@@ -410,32 +409,34 @@ void CAmControlReceiver::setCommandReady()
void CAmControlReceiver::setRoutingReady()
{
- logVerbose(__METHOD_NAME__);
+ logVerbose(__METHOD_NAME__);
mRoutingSender->setRoutingReady();
}
void CAmControlReceiver::confirmControllerReady(const am_Error_e error)
{
- if (error!=E_OK)
- logError(__METHOD_NAME__,"controller reported error", error);
+ if (error != E_OK)
+ {
+ logError(__METHOD_NAME__, "controller reported error", error);
+ }
}
void CAmControlReceiver::confirmControllerRundown(const am_Error_e error)
{
- if (error!=E_OK)
- {
- logError(__METHOD_NAME__,"exited with error ",error);
- //we might be blocked here -> so lets better exit right away
- throw std::runtime_error("controller Confirmed with error");
- }
+ if (error != E_OK)
+ {
+ logError(__METHOD_NAME__, "exited with error ", error);
+ // we might be blocked here -> so lets better exit right away
+ throw std::runtime_error("controller Confirmed with error");
+ }
- logVerbose (__METHOD_NAME__,"will exit now");
+ logVerbose(__METHOD_NAME__, "will exit now");
- //end the mainloop here...
- mSocketHandler->exit_mainloop();
+ // end the mainloop here...
+ mSocketHandler->exit_mainloop();
}
-am_Error_e CAmControlReceiver::getSocketHandler(CAmSocketHandler *& socketHandler)
+am_Error_e CAmControlReceiver::getSocketHandler(CAmSocketHandler * &socketHandler)
{
socketHandler = mSocketHandler;
return (E_OK);
@@ -443,7 +444,7 @@ am_Error_e CAmControlReceiver::getSocketHandler(CAmSocketHandler *& socketHandle
void CAmControlReceiver::setCommandRundown()
{
- logInfo(__METHOD_NAME__);
+ logInfo(__METHOD_NAME__);
mCommandSender->setCommandRundown();
}
@@ -453,129 +454,128 @@ void CAmControlReceiver::setRoutingRundown()
mRoutingSender->setRoutingRundown();
}
-void CAmControlReceiver::getInterfaceVersion(std::string & version) const
+void CAmControlReceiver::getInterfaceVersion(std::string &version) const
{
version = ControlVersion;
}
-am_Error_e CAmControlReceiver::changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
+am_Error_e CAmControlReceiver::changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s> &listSoundProperties, const std::vector<am_CustomConnectionFormat_t> &listConnectionFormats, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties)
{
- return (mDatabaseHandler->changeSourceDB(sourceID,sourceClassID,listSoundProperties,listConnectionFormats,listMainSoundProperties));
+ return (mDatabaseHandler->changeSourceDB(sourceID, sourceClassID, listSoundProperties, listConnectionFormats, listMainSoundProperties));
}
-am_Error_e CAmControlReceiver::changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
+am_Error_e CAmControlReceiver::changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s> &listSoundProperties, const std::vector<am_CustomConnectionFormat_t> &listConnectionFormats, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties)
{
- return (mDatabaseHandler->changeSinkDB(sinkID,sinkClassID,listSoundProperties,listConnectionFormats,listMainSoundProperties));
+ return (mDatabaseHandler->changeSinkDB(sinkID, sinkClassID, listSoundProperties, listConnectionFormats, listMainSoundProperties));
}
-am_Error_e CAmControlReceiver::changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t>& listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t>& listSinkConnectionFormats, const std::vector<bool>& convertionMatrix)
+am_Error_e CAmControlReceiver::changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t> &listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t> &listSinkConnectionFormats, const std::vector<bool> &convertionMatrix)
{
- return (mDatabaseHandler->changeGatewayDB(gatewayID,listSourceConnectionFormats,listSinkConnectionFormats,convertionMatrix));
+ return (mDatabaseHandler->changeGatewayDB(gatewayID, listSourceConnectionFormats, listSinkConnectionFormats, convertionMatrix));
}
-am_Error_e CAmControlReceiver::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)
+am_Error_e CAmControlReceiver::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)
{
- return (mDatabaseHandler->changeConverterDB(converterID,listSourceConnectionFormats,listSinkConnectionFormats,convertionMatrix));
+ return (mDatabaseHandler->changeConverterDB(converterID, listSourceConnectionFormats, listSinkConnectionFormats, convertionMatrix));
}
-am_Error_e CAmControlReceiver::setVolumes(am_Handle_s& handle, const std::vector<am_Volumes_s>& listVolumes)
+am_Error_e CAmControlReceiver::setVolumes(am_Handle_s &handle, const std::vector<am_Volumes_s> &listVolumes)
{
- return (mRoutingSender->asyncSetVolumes(handle,listVolumes));
+ return (mRoutingSender->asyncSetVolumes(handle, listVolumes));
}
-am_Error_e CAmControlReceiver::setSinkNotificationConfiguration(am_Handle_s& handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration)
+am_Error_e CAmControlReceiver::setSinkNotificationConfiguration(am_Handle_s &handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s &notificationConfiguration)
{
- return (mRoutingSender->asyncSetSinkNotificationConfiguration(handle,sinkID,notificationConfiguration));
+ return (mRoutingSender->asyncSetSinkNotificationConfiguration(handle, sinkID, notificationConfiguration));
}
-am_Error_e CAmControlReceiver::setSourceNotificationConfiguration(am_Handle_s& handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration)
+am_Error_e CAmControlReceiver::setSourceNotificationConfiguration(am_Handle_s &handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s &notificationConfiguration)
{
- return (mRoutingSender->asyncSetSourceNotificationConfiguration(handle,sourceID,notificationConfiguration));
+ return (mRoutingSender->asyncSetSourceNotificationConfiguration(handle, sourceID, notificationConfiguration));
}
-void CAmControlReceiver::sendMainSinkNotificationPayload(const am_sinkID_t sinkID, const am_NotificationPayload_s& notificationPayload)
+void CAmControlReceiver::sendMainSinkNotificationPayload(const am_sinkID_t sinkID, const am_NotificationPayload_s &notificationPayload)
{
- logVerbose(__METHOD_NAME__,"sinkID=",sinkID,"type=",notificationPayload.type,"value=",notificationPayload.value);
- mCommandSender->cbSinkNotification(sinkID,notificationPayload);
+ logVerbose(__METHOD_NAME__, "sinkID=", sinkID, "type=", notificationPayload.type, "value=", notificationPayload.value);
+ mCommandSender->cbSinkNotification(sinkID, notificationPayload);
}
-void CAmControlReceiver::sendMainSourceNotificationPayload(const am_sourceID_t sourceID, const am_NotificationPayload_s& notificationPayload)
+void CAmControlReceiver::sendMainSourceNotificationPayload(const am_sourceID_t sourceID, const am_NotificationPayload_s &notificationPayload)
{
- logVerbose(__METHOD_NAME__,"sourceID=",sourceID,"type=",notificationPayload.type,"value=",notificationPayload.value);
- mCommandSender->cbSourceNotification(sourceID,notificationPayload);
+ logVerbose(__METHOD_NAME__, "sourceID=", sourceID, "type=", notificationPayload.type, "value=", notificationPayload.value);
+ mCommandSender->cbSourceNotification(sourceID, notificationPayload);
}
-am_Error_e CAmControlReceiver::changeMainSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s& mainNotificationConfiguration)
+am_Error_e CAmControlReceiver::changeMainSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s &mainNotificationConfiguration)
{
- logVerbose(__METHOD_NAME__,"sinkID", sinkID);
- return (mDatabaseHandler->changeMainSinkNotificationConfigurationDB(sinkID,mainNotificationConfiguration));
+ logVerbose(__METHOD_NAME__, "sinkID", sinkID);
+ return (mDatabaseHandler->changeMainSinkNotificationConfigurationDB(sinkID, mainNotificationConfiguration));
}
-am_Error_e CAmControlReceiver::changeMainSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s& mainNotificationConfiguration)
+am_Error_e CAmControlReceiver::changeMainSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s &mainNotificationConfiguration)
{
- logVerbose(__METHOD_NAME__,"sourceID", sourceID);
- return (mDatabaseHandler->changeMainSourceNotificationConfigurationDB(sourceID,mainNotificationConfiguration));
+ logVerbose(__METHOD_NAME__, "sourceID", sourceID);
+ return (mDatabaseHandler->changeMainSourceNotificationConfigurationDB(sourceID, mainNotificationConfiguration));
}
-am_Error_e CAmControlReceiver::getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s>& listSoundproperties) const
+am_Error_e CAmControlReceiver::getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s> &listSoundproperties) const
{
- logVerbose(__METHOD_NAME__,"sinkID", sinkID);
- return (mDatabaseHandler->getListMainSinkSoundProperties(sinkID,listSoundproperties));
+ logVerbose(__METHOD_NAME__, "sinkID", sinkID);
+ return (mDatabaseHandler->getListMainSinkSoundProperties(sinkID, listSoundproperties));
}
-am_Error_e CAmControlReceiver::getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s>& listSoundproperties) const
+am_Error_e CAmControlReceiver::getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s> &listSoundproperties) const
{
- logVerbose(__METHOD_NAME__,"sourceID", sourceID);
- return (mDatabaseHandler->getListMainSourceSoundProperties(sourceID, listSoundproperties));
+ logVerbose(__METHOD_NAME__, "sourceID", sourceID);
+ return (mDatabaseHandler->getListMainSourceSoundProperties(sourceID, listSoundproperties));
}
-am_Error_e CAmControlReceiver::getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s>& listSoundproperties) const
+am_Error_e CAmControlReceiver::getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s> &listSoundproperties) const
{
- logVerbose(__METHOD_NAME__,"sinkID", sinkID);
- return (mDatabaseHandler->getListSinkSoundProperties(sinkID,listSoundproperties));
+ logVerbose(__METHOD_NAME__, "sinkID", sinkID);
+ return (mDatabaseHandler->getListSinkSoundProperties(sinkID, listSoundproperties));
}
-am_Error_e CAmControlReceiver::getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s>& listSoundproperties) const
+am_Error_e CAmControlReceiver::getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s> &listSoundproperties) const
{
- logVerbose(__METHOD_NAME__,"sourceID", sourceID);
- return (mDatabaseHandler->getListSourceSoundProperties(sourceID, listSoundproperties));
+ logVerbose(__METHOD_NAME__, "sourceID", sourceID);
+ return (mDatabaseHandler->getListSourceSoundProperties(sourceID, listSoundproperties));
}
-am_Error_e CAmControlReceiver::getMainSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const
+am_Error_e CAmControlReceiver::getMainSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t &value) const
{
- logVerbose(__METHOD_NAME__,"sinkID", sinkID);
- return (mDatabaseHandler->getMainSinkSoundPropertyValue(sinkID,propertyType,value));
+ logVerbose(__METHOD_NAME__, "sinkID", sinkID);
+ return (mDatabaseHandler->getMainSinkSoundPropertyValue(sinkID, propertyType, value));
}
-am_Error_e CAmControlReceiver::getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const
+am_Error_e CAmControlReceiver::getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomSoundPropertyType_t propertyType, int16_t &value) const
{
- logVerbose(__METHOD_NAME__,"sinkID", sinkID);
- return (mDatabaseHandler->getSinkSoundPropertyValue(sinkID,propertyType,value));
+ logVerbose(__METHOD_NAME__, "sinkID", sinkID);
+ return (mDatabaseHandler->getSinkSoundPropertyValue(sinkID, propertyType, value));
}
-am_Error_e CAmControlReceiver::getMainSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const
+am_Error_e CAmControlReceiver::getMainSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t &value) const
{
- logVerbose(__METHOD_NAME__,"sourceID", sourceID);
- return (mDatabaseHandler->getMainSourceSoundPropertyValue(sourceID,propertyType,value));
+ logVerbose(__METHOD_NAME__, "sourceID", sourceID);
+ return (mDatabaseHandler->getMainSourceSoundPropertyValue(sourceID, propertyType, value));
}
-am_Error_e CAmControlReceiver::getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const
+am_Error_e CAmControlReceiver::getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomSoundPropertyType_t propertyType, int16_t &value) const
{
- logVerbose(__METHOD_NAME__,"sourceID", sourceID);
- return (mDatabaseHandler->getSourceSoundPropertyValue(sourceID,propertyType,value));
+ logVerbose(__METHOD_NAME__, "sourceID", sourceID);
+ return (mDatabaseHandler->getSourceSoundPropertyValue(sourceID, propertyType, value));
}
-am_Error_e CAmControlReceiver::resyncConnectionState(const am_domainID_t domainID,std::vector<am_Connection_s>& listOfExistingConnections)
+am_Error_e CAmControlReceiver::resyncConnectionState(const am_domainID_t domainID, std::vector<am_Connection_s> &listOfExistingConnections)
{
- logInfo(__METHOD_NAME__,"domainID", domainID);
- return (mRoutingSender->resyncConnectionState(domainID,listOfExistingConnections));
+ logInfo(__METHOD_NAME__, "domainID", domainID);
+ return (mRoutingSender->resyncConnectionState(domainID, listOfExistingConnections));
}
am_Error_e CAmControlReceiver::removeHandle(const am_Handle_s handle)
{
- logInfo(__METHOD_NAME__,"handle", handle.handle);
- return (mRoutingSender->removeHandle(handle));
+ logInfo(__METHOD_NAME__, "handle", handle.handle);
+ return (mRoutingSender->removeHandle(handle));
}
}
-
diff --git a/AudioManagerCore/src/CAmControlSender.cpp b/AudioManagerCore/src/CAmControlSender.cpp
index d80460d..1baeb30 100644
--- a/AudioManagerCore/src/CAmControlSender.cpp
+++ b/AudioManagerCore/src/CAmControlSender.cpp
@@ -37,25 +37,25 @@
namespace am
{
-#define REQUIRED_INTERFACE_VERSION_MAJOR 1 //!< major interface version. All versions smaller than this will be rejected
+#define REQUIRED_INTERFACE_VERSION_MAJOR 1 //!< major interface version. All versions smaller than this will be rejected
#define REQUIRED_INTERFACE_VERSION_MINOR 0 //!< minor interface version. All versions smaller than this will be rejected
-CAmControlSender* CAmControlSender::mInstance=NULL;
+CAmControlSender *CAmControlSender::mInstance = NULL;
-CAmControlSender::CAmControlSender(std::string controlPluginFile,CAmSocketHandler* sockethandler) :
- receiverCallbackT(this, &CAmControlSender::receiverCallback),
- checkerCallbackT(this, &CAmControlSender::checkerCallback),
- dispatcherCallbackT(this, &CAmControlSender::dispatcherCallback),
- mPipe(),
- mlibHandle(NULL),
- mController(NULL),
- mSignal(0)
+CAmControlSender::CAmControlSender(std::string controlPluginFile, CAmSocketHandler *sockethandler)
+ : receiverCallbackT(this, &CAmControlSender::receiverCallback)
+ , checkerCallbackT(this, &CAmControlSender::checkerCallback)
+ , dispatcherCallbackT(this, &CAmControlSender::dispatcherCallback)
+ , mPipe()
+ , mlibHandle(NULL)
+ , mController(NULL)
+ , mSignal(0)
{
assert(sockethandler);
- //Check if a folder is given, then select the first plugin
+ // Check if a folder is given, then select the first plugin
struct stat buf;
- const char* conFile(controlPluginFile.c_str());
+ const char *conFile(controlPluginFile.c_str());
stat(conFile, &buf);
if (S_ISDIR(buf.st_mode))
{
@@ -74,35 +74,38 @@ CAmControlSender::CAmControlSender(std::string controlPluginFile,CAmSocketHandle
while ((itemInDirectory = readdir(directory)))
{
unsigned char entryType = itemInDirectory->d_type;
- std::string entryName = itemInDirectory->d_name;
- std::string fullName = directoryName + "/" + entryName;
+ std::string entryName = itemInDirectory->d_name;
+ std::string fullName = directoryName + "/" + entryName;
- bool regularFile = (entryType == DT_REG || entryType == DT_LNK);
+ 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 (entryType == DT_UNKNOWN)
+ {
+ struct stat buf;
- if (stat(fullName.c_str(), &buf)) {
- logInfo(__PRETTY_FUNCTION__,"Failed to stat file: ", entryName, errno);
- continue;
- }
+ if (stat(fullName.c_str(), &buf))
+ {
+ logInfo(__PRETTY_FUNCTION__, "Failed to stat file: ", entryName, errno);
+ continue;
+ }
- regularFile = S_ISREG(buf.st_mode);
- }
+ regularFile = S_ISREG(buf.st_mode);
+ }
if (regularFile && sharedLibExtension)
{
- controlPluginFile=directoryName + "/" + entryName;
- logInfo("Found ControlPlugin:", controlPluginFile);
- break;
+ controlPluginFile = directoryName + "/" + entryName;
+ logInfo("Found ControlPlugin:", controlPluginFile);
+ break;
}
}
+
closedir(directory);
-
+
}
-
+
std::ifstream isfile(controlPluginFile.c_str());
if (!isfile)
{
@@ -111,13 +114,13 @@ CAmControlSender::CAmControlSender(std::string controlPluginFile,CAmSocketHandle
}
else if (!controlPluginFile.empty())
{
- mInstance=this;
- IAmControlSend* (*createFunc)();
- createFunc = getCreateFunction<IAmControlSend*()>(controlPluginFile, mlibHandle);
- assert(createFunc!=NULL);
- mController = createFunc();
+ mInstance = this;
+ IAmControlSend *(*createFunc)();
+ createFunc = getCreateFunction<IAmControlSend *()>(controlPluginFile, mlibHandle);
+ assert(createFunc != NULL);
+ mController = createFunc();
mControlPluginFile = controlPluginFile;
- //check libversion
+ // check libversion
std::string version, cVersion(ControlVersion);
mController->getInterfaceVersion(version);
uint16_t minorVersion, majorVersion, cMinorVersion, cMajorVersion;
@@ -125,12 +128,10 @@ CAmControlSender::CAmControlSender(std::string controlPluginFile,CAmSocketHandle
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("ControlSender::ControlSender: Interface Version of Controller too old, required version:",ControlVersion," Controller Version:",version,"exiting now");
+ logError("ControlSender::ControlSender: Interface Version of Controller too old, required version:", ControlVersion, " Controller Version:", version, "exiting now");
throw std::runtime_error("Interface Version of Controller too old");
}
}
@@ -139,14 +140,14 @@ CAmControlSender::CAmControlSender(std::string controlPluginFile,CAmSocketHandle
logError("ControlSender::ControlSender: No controller loaded !");
}
- //here we need a pipe to be able to call the rundown function out of the mainloop
+ // here we need a pipe to be able to call the rundown function out of the mainloop
if (pipe(mPipe) == -1)
{
logError("CAmControlSender could not create pipe!");
}
- //add the pipe to the poll - nothing needs to be proccessed here we just need the pipe to trigger the ppoll
- short event = 0;
+ // add the pipe to the poll - nothing needs to be proccessed here we just need the pipe to trigger the ppoll
+ short event = 0;
sh_pollHandle_t handle;
event |= POLLIN;
sockethandler->addFDPoll(mPipe[0], event, NULL, &receiverCallbackT, &checkerCallbackT, &dispatcherCallbackT, NULL, handle);
@@ -159,8 +160,8 @@ CAmControlSender::~CAmControlSender()
if (mlibHandle)
{
- void (*destroyFunc)(IAmControlSend*);
- destroyFunc = getDestroyFunction<void(IAmControlSend*)>(mControlPluginFile, mlibHandle);
+ void (*destroyFunc)(IAmControlSend *);
+ destroyFunc = getDestroyFunction<void(IAmControlSend *)>(mControlPluginFile, mlibHandle);
if (destroyFunc)
{
destroyFunc(mController);
@@ -169,11 +170,12 @@ CAmControlSender::~CAmControlSender()
{
logError("CAmControlSender Dtor: destroyFunc is invalid or not found");
}
+
dlclose(mlibHandle);
}
}
-am_Error_e CAmControlSender::hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t & mainConnectionID)
+am_Error_e CAmControlSender::hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t &mainConnectionID)
{
assert(mController);
return (mController->hookUserConnectionRequest(sourceID, sinkID, mainConnectionID));
@@ -185,19 +187,19 @@ am_Error_e CAmControlSender::hookUserDisconnectionRequest(const am_mainConnectio
return (mController->hookUserDisconnectionRequest(connectionID));
}
-am_Error_e CAmControlSender::hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s & soundProperty)
+am_Error_e CAmControlSender::hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s &soundProperty)
{
assert(mController);
return (mController->hookUserSetMainSinkSoundProperty(sinkID, soundProperty));
}
-am_Error_e CAmControlSender::hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s & soundProperty)
+am_Error_e CAmControlSender::hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s &soundProperty)
{
assert(mController);
return (mController->hookUserSetMainSourceSoundProperty(sourceID, soundProperty));
}
-am_Error_e CAmControlSender::hookUserSetSystemProperty(const am_SystemProperty_s & property)
+am_Error_e CAmControlSender::hookUserSetSystemProperty(const am_SystemProperty_s &property)
{
assert(mController);
return (mController->hookUserSetSystemProperty(property));
@@ -221,7 +223,7 @@ am_Error_e CAmControlSender::hookUserSetSinkMuteState(const am_sinkID_t sinkID,
return (mController->hookUserSetSinkMuteState(sinkID, muteState));
}
-am_Error_e CAmControlSender::hookSystemRegisterDomain(const am_Domain_s & domainData, am_domainID_t & domainID)
+am_Error_e CAmControlSender::hookSystemRegisterDomain(const am_Domain_s &domainData, am_domainID_t &domainID)
{
assert(mController);
return (mController->hookSystemRegisterDomain(domainData, domainID));
@@ -239,7 +241,7 @@ void CAmControlSender::hookSystemDomainRegistrationComplete(const am_domainID_t
return (mController->hookSystemDomainRegistrationComplete(domainID));
}
-am_Error_e CAmControlSender::hookSystemRegisterSink(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
+am_Error_e CAmControlSender::hookSystemRegisterSink(const am_Sink_s &sinkData, am_sinkID_t &sinkID)
{
assert(mController);
return (mController->hookSystemRegisterSink(sinkData, sinkID));
@@ -251,7 +253,7 @@ am_Error_e CAmControlSender::hookSystemDeregisterSink(const am_sinkID_t sinkID)
return (mController->hookSystemDeregisterSink(sinkID));
}
-am_Error_e CAmControlSender::hookSystemRegisterSource(const am_Source_s & sourceData, am_sourceID_t & sourceID)
+am_Error_e CAmControlSender::hookSystemRegisterSource(const am_Source_s &sourceData, am_sourceID_t &sourceID)
{
assert(mController);
return (mController->hookSystemRegisterSource(sourceData, sourceID));
@@ -263,13 +265,13 @@ am_Error_e CAmControlSender::hookSystemDeregisterSource(const am_sourceID_t sour
return (mController->hookSystemDeregisterSource(sourceID));
}
-am_Error_e CAmControlSender::hookSystemRegisterGateway(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
+am_Error_e CAmControlSender::hookSystemRegisterGateway(const am_Gateway_s &gatewayData, am_gatewayID_t &gatewayID)
{
assert(mController);
return (mController->hookSystemRegisterGateway(gatewayData, gatewayID));
}
-am_Error_e CAmControlSender::hookSystemRegisterConverter(const am_Converter_s& converterData, am_converterID_t& converterID)
+am_Error_e CAmControlSender::hookSystemRegisterConverter(const am_Converter_s &converterData, am_converterID_t &converterID)
{
assert(mController);
return (mController->hookSystemRegisterConverter(converterData, converterID));
@@ -287,7 +289,7 @@ am_Error_e CAmControlSender::hookSystemDeregisterConverter(const am_converterID_
return (mController->hookSystemDeregisterConverter(converterID));
}
-am_Error_e CAmControlSender::hookSystemRegisterCrossfader(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
+am_Error_e CAmControlSender::hookSystemRegisterCrossfader(const am_Crossfader_s &crossfaderData, am_crossfaderID_t &crossfaderID)
{
assert(mController);
return (mController->hookSystemRegisterCrossfader(crossfaderData, crossfaderID));
@@ -317,13 +319,13 @@ void CAmControlSender::hookSystemInterruptStateChange(const am_sourceID_t source
mController->hookSystemInterruptStateChange(sourceID, interruptState);
}
-void CAmControlSender::hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s & availability)
+void CAmControlSender::hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s &availability)
{
assert(mController);
mController->hookSystemSinkAvailablityStateChange(sinkID, availability);
}
-void CAmControlSender::hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s & availability)
+void CAmControlSender::hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s &availability)
{
assert(mController);
mController->hookSystemSourceAvailablityStateChange(sourceID, availability);
@@ -335,7 +337,7 @@ void CAmControlSender::hookSystemDomainStateChange(const am_domainID_t domainID,
mController->hookSystemDomainStateChange(domainID, state);
}
-void CAmControlSender::hookSystemReceiveEarlyData(const std::vector<am_EarlyData_s> & data)
+void CAmControlSender::hookSystemReceiveEarlyData(const std::vector<am_EarlyData_s> &data)
{
assert(mController);
mController->hookSystemReceiveEarlyData(data);
@@ -403,6 +405,7 @@ am_Error_e CAmControlSender::startupController(IAmControlReceive *controlreceive
throw std::runtime_error("ControlSender::startupController: no Controller to startup! Exiting now ...");
return (E_NON_EXISTENT);
}
+
return (mController->startupController(controlreceiveinterface));
}
@@ -433,17 +436,17 @@ void CAmControlSender::setControllerReady()
void CAmControlSender::setControllerRundown(const int16_t signal)
{
assert(mController);
- logInfo("CAmControlSender::setControllerRundown received, signal=",signal);
+ logInfo("CAmControlSender::setControllerRundown received, signal=", signal);
mController->setControllerRundown(signal);
}
-am_Error_e am::CAmControlSender::getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector<am_CustomConnectionFormat_t> listPossibleConnectionFormats, std::vector<am_CustomConnectionFormat_t> & listPrioConnectionFormats)
+am_Error_e am::CAmControlSender::getConnectionFormatChoice(const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_Route_s listRoute, const std::vector<am_CustomConnectionFormat_t> listPossibleConnectionFormats, std::vector<am_CustomConnectionFormat_t> &listPrioConnectionFormats)
{
assert(mController);
return (mController->getConnectionFormatChoice(sourceID, sinkID, listRoute, listPossibleConnectionFormats, listPrioConnectionFormats));
}
-void CAmControlSender::getInterfaceVersion(std::string & version) const
+void CAmControlSender::getInterfaceVersion(std::string &version) const
{
version = ControlVersion;
}
@@ -472,116 +475,114 @@ void CAmControlSender::confirmRoutingRundown(const am_Error_e error)
mController->confirmRoutingRundown(error);
}
-am_Error_e CAmControlSender::hookSystemUpdateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
+am_Error_e CAmControlSender::hookSystemUpdateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s> &listSoundProperties, const std::vector<am_CustomConnectionFormat_t> &listConnectionFormats, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties)
{
assert(mController);
- return (mController->hookSystemUpdateSink(sinkID,sinkClassID,listSoundProperties,listConnectionFormats,listMainSoundProperties));
+ return (mController->hookSystemUpdateSink(sinkID, sinkClassID, listSoundProperties, listConnectionFormats, listMainSoundProperties));
}
-am_Error_e CAmControlSender::hookSystemUpdateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
+am_Error_e CAmControlSender::hookSystemUpdateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s> &listSoundProperties, const std::vector<am_CustomConnectionFormat_t> &listConnectionFormats, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties)
{
assert(mController);
- return (mController->hookSystemUpdateSource(sourceID,sourceClassID,listSoundProperties,listConnectionFormats,listMainSoundProperties));
+ return (mController->hookSystemUpdateSource(sourceID, sourceClassID, listSoundProperties, listConnectionFormats, listMainSoundProperties));
}
-am_Error_e CAmControlSender::hookSystemUpdateGateway(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t>& listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t>& listSinkConnectionFromats, const std::vector<bool>& convertionMatrix)
+am_Error_e CAmControlSender::hookSystemUpdateGateway(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t> &listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t> &listSinkConnectionFromats, const std::vector<bool> &convertionMatrix)
{
assert(mController);
- return (mController->hookSystemUpdateGateway(gatewayID,listSourceConnectionFormats,listSinkConnectionFromats,convertionMatrix));
+ return (mController->hookSystemUpdateGateway(gatewayID, listSourceConnectionFormats, listSinkConnectionFromats, convertionMatrix));
}
-am_Error_e CAmControlSender::hookSystemUpdateConverter(const am_converterID_t converterID, const std::vector<am_CustomConnectionFormat_t>& listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t>& listSinkConnectionFromats, const std::vector<bool>& convertionMatrix)
+am_Error_e CAmControlSender::hookSystemUpdateConverter(const am_converterID_t converterID, const std::vector<am_CustomConnectionFormat_t> &listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t> &listSinkConnectionFromats, const std::vector<bool> &convertionMatrix)
{
assert(mController);
- return (mController->hookSystemUpdateConverter(converterID,listSourceConnectionFormats,listSinkConnectionFromats,convertionMatrix));
+ return (mController->hookSystemUpdateConverter(converterID, listSourceConnectionFormats, listSinkConnectionFromats, convertionMatrix));
}
-void CAmControlSender::cbAckSetVolume(const am_Handle_s handle, const std::vector<am_Volumes_s>& listVolumes, const am_Error_e error)
+void CAmControlSender::cbAckSetVolume(const am_Handle_s handle, const std::vector<am_Volumes_s> &listVolumes, const am_Error_e error)
{
assert(mController);
- mController->cbAckSetVolumes(handle,listVolumes,error);
+ mController->cbAckSetVolumes(handle, listVolumes, error);
}
void CAmControlSender::cbAckSetSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error)
{
assert(mController);
- mController->cbAckSetSinkNotificationConfiguration(handle,error);
+ mController->cbAckSetSinkNotificationConfiguration(handle, error);
}
void CAmControlSender::cbAckSetSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error)
{
assert(mController);
- mController->cbAckSetSourceNotificationConfiguration(handle,error);
+ mController->cbAckSetSourceNotificationConfiguration(handle, error);
}
-void CAmControlSender::hookSinkNotificationDataChanged(const am_sinkID_t sinkID, const am_NotificationPayload_s& payload)
+void CAmControlSender::hookSinkNotificationDataChanged(const am_sinkID_t sinkID, const am_NotificationPayload_s &payload)
{
assert(mController);
- mController->hookSinkNotificationDataChanged(sinkID,payload);
+ mController->hookSinkNotificationDataChanged(sinkID, payload);
}
-void CAmControlSender::hookSourceNotificationDataChanged(const am_sourceID_t sourceID, const am_NotificationPayload_s& payload)
+void CAmControlSender::hookSourceNotificationDataChanged(const am_sourceID_t sourceID, const am_NotificationPayload_s &payload)
{
assert(mController);
- mController->hookSourceNotificationDataChanged(sourceID,payload);
+ mController->hookSourceNotificationDataChanged(sourceID, payload);
}
-am_Error_e CAmControlSender::hookUserSetMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration)
+am_Error_e CAmControlSender::hookUserSetMainSinkNotificationConfiguration(const am_sinkID_t sinkID, const am_NotificationConfiguration_s &notificationConfiguration)
{
assert(mController);
- return (mController->hookUserSetMainSinkNotificationConfiguration(sinkID,notificationConfiguration));
+ return (mController->hookUserSetMainSinkNotificationConfiguration(sinkID, notificationConfiguration));
}
-am_Error_e CAmControlSender::hookUserSetMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration)
+am_Error_e CAmControlSender::hookUserSetMainSourceNotificationConfiguration(const am_sourceID_t sourceID, const am_NotificationConfiguration_s &notificationConfiguration)
{
assert(mController);
- return (mController->hookUserSetMainSourceNotificationConfiguration(sourceID,notificationConfiguration));
+ return (mController->hookUserSetMainSourceNotificationConfiguration(sourceID, notificationConfiguration));
}
-void CAmControlSender::receiverCallback(const pollfd pollfd, const sh_pollHandle_t handle, void* userData)
+void CAmControlSender::receiverCallback(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
{
- (void) handle;
- (void) userData;
- //get the signal number from the socket
- ssize_t result = read(pollfd.fd, &mSignal, sizeof(mSignal));
+ (void)handle;
+ (void)userData;
+ // get the signal number from the socket
+ ssize_t result = read(pollfd.fd, &mSignal, sizeof(mSignal));
}
-bool CAmControlSender::checkerCallback(const sh_pollHandle_t handle, void* userData)
+bool CAmControlSender::checkerCallback(const sh_pollHandle_t handle, void *userData)
{
- (void) handle;
- (void) userData;
- return (true);
+ (void)handle;
+ (void)userData;
+ return (true);
}
void CAmControlSender::hookSystemSingleTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t time)
{
assert(mController);
- mController->hookSystemSingleTimingInformationChanged(connectionID,time);
+ mController->hookSystemSingleTimingInformationChanged(connectionID, time);
}
/**for testing only contructor - do not use !
*
*/
-CAmControlSender::CAmControlSender() :
- receiverCallbackT(this, &CAmControlSender::receiverCallback),
- checkerCallbackT(this, &CAmControlSender::checkerCallback),
- dispatcherCallbackT(this, &CAmControlSender::dispatcherCallback),
- mlibHandle(NULL),
- mController(NULL),
- mSignal(0)
+CAmControlSender::CAmControlSender()
+ : receiverCallbackT(this, &CAmControlSender::receiverCallback)
+ , checkerCallbackT(this, &CAmControlSender::checkerCallback)
+ , dispatcherCallbackT(this, &CAmControlSender::dispatcherCallback)
+ , mlibHandle(NULL)
+ , mController(NULL)
+ , mSignal(0)
{
logInfo("CAmControlSender was loaded in test mode!");
std::memset(mPipe, -1, sizeof(mPipe));
}
-bool CAmControlSender::dispatcherCallback(const sh_pollHandle_t handle, void* userData)
+bool CAmControlSender::dispatcherCallback(const sh_pollHandle_t handle, void *userData)
{
- (void)handle;
- (void)userData;
- setControllerRundown(mSignal);
- return (false);
+ (void)handle;
+ (void)userData;
+ setControllerRundown(mSignal);
+ return (false);
}
}
-
-
diff --git a/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp b/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp
index 895b234..8e5c192 100644
--- a/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp
+++ b/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp
@@ -33,53 +33,56 @@
#include "CAmRouter.h"
#include "CAmDltWrapper.h"
-#define __METHOD_NAME__ std::string (std::string("CAmDatabaseHandlerMap::") + __func__)
-
+#define __METHOD_NAME__ std::string(std::string("CAmDatabaseHandlerMap::") + __func__)
#ifdef WITH_DATABASE_CHANGE_CHECK
-# define DB_COND_UPDATE_RIE(x,y) \
- if (isDataEqual(x,y)) return (E_NO_CHANGE); else x = y
-# define DB_COND_UPDATE_INIT \
- bool modified = false
-# define DB_COND_UPDATE(x,y) \
- if (!isDataEqual(x,y)) { x = y; modified = true; }
-# define DB_COND_ISMODIFIED \
- (modified == true)
-#else
-# define DB_COND_UPDATE_RIE(x,y) \
- x = y
-# define DB_COND_UPDATE_INIT
-# define DB_COND_UPDATE(x,y) \
- x = y
-# define DB_COND_ISMODIFIED \
- (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);
+# define DB_COND_UPDATE_RIE(x, y) \
+ if (isDataEqual(x, y)) { return (E_NO_CHANGE);} else x = y
+# define DB_COND_UPDATE_INIT \
+ bool modified = false
+# define DB_COND_UPDATE(x, y) \
+ if (!isDataEqual(x, y)) { x = y; modified = true; }
+# define DB_COND_ISMODIFIED \
+ (modified == true)
+#else // ifdef WITH_DATABASE_CHANGE_CHECK
+# define DB_COND_UPDATE_RIE(x, y) \
+ x = y
+# define DB_COND_UPDATE_INIT
+# define DB_COND_UPDATE(x, y) \
+ x = y
+# define DB_COND_ISMODIFIED \
+ (true)
+#endif // ifdef WITH_DATABASE_CHANGE_CHECK
+
+#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
{
@@ -87,34 +90,40 @@ namespace am
/*
* Checks if content of data is equal
*/
-template <typename T> bool isDataEqual(const T & left, const T & right)
+template <typename T>
+bool isDataEqual(const T &left, const T &right)
{
- return static_cast<bool>(!std::memcmp(&left, &right, sizeof(T)));
+ return static_cast<bool>(!std::memcmp(&left, &right, sizeof(T)));
}
-template <typename T, typename L = std::vector<T> > bool isDataEqual(const L & left, const L & right)
+template <typename T, typename L = std::vector<T> >
+bool isDataEqual(const L &left, const L &right)
{
- return std::equal(left.begin(), left.end(), right.begin(), isDataEqual);
+ return std::equal(left.begin(), left.end(), right.begin(), isDataEqual);
}
-
/*
* Returns an object for given key
*/
-template <typename TMapKeyType, class TMapObjectType> TMapObjectType const * objectForKeyIfExistsInMap(const TMapKeyType & key, const std::unordered_map<TMapKeyType,TMapObjectType> & map)
+template <typename TMapKeyType, class TMapObjectType>
+TMapObjectType const *objectForKeyIfExistsInMap(const TMapKeyType &key, const std::unordered_map<TMapKeyType, TMapObjectType> &map)
{
- typename std::unordered_map<TMapKeyType,TMapObjectType>::const_iterator iter = map.find(key);
- if( iter!=map.end() )
- return &iter->second;
- return NULL;
+ typename std::unordered_map<TMapKeyType, TMapObjectType>::const_iterator iter = map.find(key);
+ if ( iter != map.end())
+ {
+ return &iter->second;
+ }
+
+ return NULL;
}
/*
* Checks whether any object with key exists in a given map
*/
-template <typename TMapKeyType, class TMapObjectType> bool existsObjectWithKeyInMap(const TMapKeyType & key, const std::unordered_map<TMapKeyType,TMapObjectType> & map)
+template <typename TMapKeyType, class TMapObjectType>
+bool existsObjectWithKeyInMap(const TMapKeyType &key, const std::unordered_map<TMapKeyType, TMapObjectType> &map)
{
- return objectForKeyIfExistsInMap(key, map)!=NULL;
+ return objectForKeyIfExistsInMap(key, map) != NULL;
}
/**
@@ -126,489 +135,515 @@ template <typename TMapKeyType, class TMapObjectType> bool existsObjectWithKeyIn
* @param comparator Search predicate.
* @return NULL or pointer to the found object.
*/
-template <class TReturn, typename TIdentifier> const TReturn * objectMatchingPredicate(const std::unordered_map<TIdentifier, TReturn> & map,
- std::function<bool(const TReturn & refObject)> comparator)
-{
- typename std::unordered_map<TIdentifier, TReturn>::const_iterator elementIterator = map.begin();
- for (;elementIterator != map.end(); ++elementIterator)
- {
- if( comparator(elementIterator->second) )
- return &elementIterator->second;
- }
+template <class TReturn, typename TIdentifier>
+const TReturn *objectMatchingPredicate(const std::unordered_map<TIdentifier, TReturn> &map,
+ std::function<bool(const TReturn &refObject)> comparator)
+{
+ typename std::unordered_map<TIdentifier, TReturn>::const_iterator elementIterator = map.begin();
+ for (; elementIterator != map.end(); ++elementIterator)
+ {
+ if ( comparator(elementIterator->second))
+ {
+ return &elementIterator->second;
+ }
+ }
+
return NULL;
}
-
/* Domain */
-void CAmDatabaseHandlerMap::AmDomain::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 <<
- "bus name(" << busname.c_str() <<
- ") node name(" << nodename.c_str() <<
- ") early(" << early <<
- ") domainID(" << domainID <<
- ") complete(" << complete <<
- ") state(" << state <<
- ") reserved(" << reserved << ")" << std::endl;
- outString = fmt.str();
+ std::ostringstream fmt;
+ fmt << "Domain(" << name.c_str() << ") id(" << domainID << ")" << std::endl <<
+ "bus name(" << busname.c_str() <<
+ ") node name(" << nodename.c_str() <<
+ ") early(" << early <<
+ ") domainID(" << domainID <<
+ ") complete(" << complete <<
+ ") state(" << state <<
+ ") reserved(" << reserved << ")" << std::endl;
+ outString = fmt.str();
}
/* Source */
-void CAmDatabaseHandlerMap::AmSource::getSourceType(am_SourceType_s & sourceType) const
-{
- sourceType.name = name;
- sourceType.sourceClassID = sourceClassID;
- sourceType.availability = available;
- sourceType.sourceID = sourceID;
-}
-
-void CAmDatabaseHandlerMap::AmSource::getDescription (std::string & outString) const
-{
- std::ostringstream fmt;
- fmt << "Source(" << name.c_str() << ") id(" << sourceID << ")" << std::endl <<
- "sourceClassID(" << sourceClassID <<
- ") domainID(" << domainID <<
- ") visible(" << visible <<
- ") volume(" << volume <<
- ") interruptState(" << interruptState <<
- ") sourceState(" << sourceState <<
- ") reserved(" << reserved << ")" <<
- ") available([availability:" << available.availability << " availabilityReason:" << available.availabilityReason << "]"
- ") listSoundProperties (";
- std::for_each(listSoundProperties.begin(), listSoundProperties.end(), [&](const am_SoundProperty_s & ref) {
- fmt << "[type:" << ref.type << " value:" << ref.value <<"]";
- });
- fmt << ") listConnectionFormats (";
- std::for_each(listConnectionFormats.begin(), listConnectionFormats.end(), [&](const am_CustomConnectionFormat_t & ref) {
- fmt << "[" << ref << "]";
- });
- fmt << ") listMainSoundProperties (";
- std::for_each(listMainSoundProperties.begin(), listMainSoundProperties.end(), [&](const am_MainSoundProperty_s & ref) {
- fmt << "[type:" << ref.type << " value:" << ref.value <<"]";
- });
- fmt << ") listMainNotificationConfigurations (";
- std::for_each(listMainNotificationConfigurations.begin(), listMainNotificationConfigurations.end(), [&](const am_NotificationConfiguration_s & ref) {
- fmt << "[type:" << ref.type << " status:" << ref.status << " parameter:" << ref.parameter <<"]";
- });
- fmt << ") listNotificationConfigurations (";
- std::for_each(listNotificationConfigurations.begin(), listNotificationConfigurations.end(), [&](const am_NotificationConfiguration_s & ref) {
- fmt << "[type:" << ref.type << " status:" << ref.status << " parameter:" << ref.parameter <<"]";
- });
- fmt << ")" << std::endl;
- outString = fmt.str();
+void CAmDatabaseHandlerMap::AmSource::getSourceType(am_SourceType_s &sourceType) const
+{
+ sourceType.name = name;
+ sourceType.sourceClassID = sourceClassID;
+ sourceType.availability = available;
+ sourceType.sourceID = sourceID;
+}
+
+void CAmDatabaseHandlerMap::AmSource::getDescription(std::string &outString) const
+{
+ std::ostringstream fmt;
+ fmt << "Source(" << name.c_str() << ") id(" << sourceID << ")" << std::endl <<
+ "sourceClassID(" << sourceClassID <<
+ ") domainID(" << domainID <<
+ ") visible(" << visible <<
+ ") volume(" << volume <<
+ ") interruptState(" << interruptState <<
+ ") sourceState(" << sourceState <<
+ ") reserved(" << reserved << ")" <<
+ ") available([availability:" << available.availability << " availabilityReason:" << available.availabilityReason << "]"
+ ") listSoundProperties (";
+ std::for_each(listSoundProperties.begin(), listSoundProperties.end(), [&](const am_SoundProperty_s &ref) {
+ fmt << "[type:" << ref.type << " value:" << ref.value << "]";
+ });
+ fmt << ") listConnectionFormats (";
+ std::for_each(listConnectionFormats.begin(), listConnectionFormats.end(), [&](const am_CustomConnectionFormat_t &ref) {
+ fmt << "[" << ref << "]";
+ });
+ fmt << ") listMainSoundProperties (";
+ std::for_each(listMainSoundProperties.begin(), listMainSoundProperties.end(), [&](const am_MainSoundProperty_s &ref) {
+ fmt << "[type:" << ref.type << " value:" << ref.value << "]";
+ });
+ fmt << ") listMainNotificationConfigurations (";
+ std::for_each(listMainNotificationConfigurations.begin(), listMainNotificationConfigurations.end(), [&](const am_NotificationConfiguration_s &ref) {
+ fmt << "[type:" << ref.type << " status:" << ref.status << " parameter:" << ref.parameter << "]";
+ });
+ fmt << ") listNotificationConfigurations (";
+ std::for_each(listNotificationConfigurations.begin(), listNotificationConfigurations.end(), [&](const am_NotificationConfiguration_s &ref) {
+ fmt << "[type:" << ref.type << " status:" << ref.status << " parameter:" << ref.parameter << "]";
+ });
+ fmt << ")" << std::endl;
+ outString = fmt.str();
}
/* Sink */
-void CAmDatabaseHandlerMap::AmSink::getDescription (std::string & outString) const
-{
- std::ostringstream fmt;
- fmt << "Sink(" << name.c_str() << ") id(" << sinkID << ")" << std::endl <<
- "sinkClassID(" << sinkClassID <<
- ") domainID(" << domainID <<
- ") visible(" << visible <<
- ") volume(" << volume <<
- ") muteState(" << muteState <<
- ") mainVolume(" << mainVolume <<
- ") reserved(" << reserved << ")" <<
- ") available([availability:" << available.availability << " availabilityReason:" << available.availabilityReason << "]"
- ") listSoundProperties (";
- std::for_each(listSoundProperties.begin(), listSoundProperties.end(), [&](const am_SoundProperty_s & ref) {
- fmt << "[type:" << ref.type << " value:" << ref.value <<"]";
- });
- fmt << ") listConnectionFormats (";
- std::for_each(listConnectionFormats.begin(), listConnectionFormats.end(), [&](const am_CustomConnectionFormat_t & ref) {
- fmt << "[" << ref << "]";
- });
- fmt << ") listMainSoundProperties (";
- std::for_each(listMainSoundProperties.begin(), listMainSoundProperties.end(), [&](const am_MainSoundProperty_s & ref) {
- fmt << "[type:" << ref.type << " value:" << ref.value <<"]";
- });
- fmt << ") listMainNotificationConfigurations (";
- std::for_each(listMainNotificationConfigurations.begin(), listMainNotificationConfigurations.end(), [&](const am_NotificationConfiguration_s & ref) {
- fmt << "[type:" << ref.type << " status:" << ref.status << " parameter:" << ref.parameter <<"]";
- });
- fmt << ") listNotificationConfigurations (";
- std::for_each(listNotificationConfigurations.begin(), listNotificationConfigurations.end(), [&](const am_NotificationConfiguration_s & ref) {
- fmt << "[type:" << ref.type << " status:" << ref.status << " parameter:" << ref.parameter <<"]";
- });
- fmt << ")" << std::endl;
- outString = fmt.str();
-}
-
-void CAmDatabaseHandlerMap::AmSink::getSinkType(am_SinkType_s & sinkType) const
-{
- sinkType.name = name;
- sinkType.sinkID = sinkID;
- sinkType.availability = available;
- sinkType.muteState = muteState;
- sinkType.volume = mainVolume;
- sinkType.sinkClassID = sinkClassID;
+void CAmDatabaseHandlerMap::AmSink::getDescription(std::string &outString) const
+{
+ std::ostringstream fmt;
+ fmt << "Sink(" << name.c_str() << ") id(" << sinkID << ")" << std::endl <<
+ "sinkClassID(" << sinkClassID <<
+ ") domainID(" << domainID <<
+ ") visible(" << visible <<
+ ") volume(" << volume <<
+ ") muteState(" << muteState <<
+ ") mainVolume(" << mainVolume <<
+ ") reserved(" << reserved << ")" <<
+ ") available([availability:" << available.availability << " availabilityReason:" << available.availabilityReason << "]"
+ ") listSoundProperties (";
+ std::for_each(listSoundProperties.begin(), listSoundProperties.end(), [&](const am_SoundProperty_s &ref) {
+ fmt << "[type:" << ref.type << " value:" << ref.value << "]";
+ });
+ fmt << ") listConnectionFormats (";
+ std::for_each(listConnectionFormats.begin(), listConnectionFormats.end(), [&](const am_CustomConnectionFormat_t &ref) {
+ fmt << "[" << ref << "]";
+ });
+ fmt << ") listMainSoundProperties (";
+ std::for_each(listMainSoundProperties.begin(), listMainSoundProperties.end(), [&](const am_MainSoundProperty_s &ref) {
+ fmt << "[type:" << ref.type << " value:" << ref.value << "]";
+ });
+ fmt << ") listMainNotificationConfigurations (";
+ std::for_each(listMainNotificationConfigurations.begin(), listMainNotificationConfigurations.end(), [&](const am_NotificationConfiguration_s &ref) {
+ fmt << "[type:" << ref.type << " status:" << ref.status << " parameter:" << ref.parameter << "]";
+ });
+ fmt << ") listNotificationConfigurations (";
+ std::for_each(listNotificationConfigurations.begin(), listNotificationConfigurations.end(), [&](const am_NotificationConfiguration_s &ref) {
+ fmt << "[type:" << ref.type << " status:" << ref.status << " parameter:" << ref.parameter << "]";
+ });
+ fmt << ")" << std::endl;
+ outString = fmt.str();
+}
+
+void CAmDatabaseHandlerMap::AmSink::getSinkType(am_SinkType_s &sinkType) const
+{
+ sinkType.name = name;
+ sinkType.sinkID = sinkID;
+ sinkType.availability = available;
+ sinkType.muteState = muteState;
+ sinkType.volume = mainVolume;
+ sinkType.sinkClassID = sinkClassID;
}
/* Connection */
-void CAmDatabaseHandlerMap::AmConnection::getDescription (std::string & outString) const
+void CAmDatabaseHandlerMap::AmConnection::getDescription(std::string &outString) const
{
- std::ostringstream fmt;
- fmt << "Connection id(" << connectionID << ") " << std::endl <<
- "sourceID(" << sourceID <<
- ") sinkID(" << sinkID <<
- ") delay(" << delay <<
- ") connectionFormat(" << connectionFormat <<
- ") reserved(" << reserved << ")" << std::endl;
- outString = fmt.str();
+ std::ostringstream fmt;
+ fmt << "Connection id(" << connectionID << ") " << std::endl <<
+ "sourceID(" << sourceID <<
+ ") sinkID(" << sinkID <<
+ ") delay(" << delay <<
+ ") connectionFormat(" << connectionFormat <<
+ ") reserved(" << reserved << ")" << std::endl;
+ outString = fmt.str();
}
/* Main Connection */
-void CAmDatabaseHandlerMap::AmMainConnection::getDescription (std::string & outString) const
+void CAmDatabaseHandlerMap::AmMainConnection::getDescription(std::string &outString) const
{
- std::ostringstream fmt;
- fmt << "MainConnection id(" << mainConnectionID << ") " << std::endl <<
- "connectionState(" << connectionState <<
- ") sinkID(" << sinkID <<
- ") sourceID(" << sourceID <<
- ") delay(" << delay <<
- ") listConnectionID (";
- std::for_each(listConnectionID.begin(), listConnectionID.end(), [&](const am_connectionID_t & connID) {
- fmt << "["<< connID << "]";
- });
- fmt << ")" << std::endl;
- outString = fmt.str();
+ std::ostringstream fmt;
+ fmt << "MainConnection id(" << mainConnectionID << ") " << std::endl <<
+ "connectionState(" << connectionState <<
+ ") sinkID(" << sinkID <<
+ ") sourceID(" << sourceID <<
+ ") delay(" << delay <<
+ ") listConnectionID (";
+ std::for_each(listConnectionID.begin(), listConnectionID.end(), [&](const am_connectionID_t &connID) {
+ fmt << "[" << connID << "]";
+ });
+ fmt << ")" << std::endl;
+ outString = fmt.str();
}
-void CAmDatabaseHandlerMap::am_MainConnection_Database_s::getMainConnectionType(am_MainConnectionType_s & connectionType) const
+void CAmDatabaseHandlerMap::am_MainConnection_Database_s::getMainConnectionType(am_MainConnectionType_s &connectionType) const
{
- connectionType.mainConnectionID = mainConnectionID;
- connectionType.sourceID = sourceID;
- connectionType.sinkID = sinkID;
- connectionType.connectionState = connectionState;
- connectionType.delay = delay;
+ connectionType.mainConnectionID = mainConnectionID;
+ connectionType.sourceID = sourceID;
+ connectionType.sinkID = sinkID;
+ connectionType.connectionState = connectionState;
+ connectionType.delay = delay;
}
/* Source Class */
-void CAmDatabaseHandlerMap::AmSourceClass::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" <<
- ") listClassProperties (";
- std::for_each(listClassProperties.begin(), listClassProperties.end(), [&](const am_ClassProperty_s & ref) {
- fmt << "[classProperty:" << ref.classProperty << " value:" << ref.value << "]";
- });
- fmt << ")" << std::endl;
- outString = fmt.str();
+ std::ostringstream fmt;
+ fmt << "Source class(" << name.c_str() << ") id(" << sourceClassID << ")\n" <<
+ ") listClassProperties (";
+ std::for_each(listClassProperties.begin(), listClassProperties.end(), [&](const am_ClassProperty_s &ref) {
+ fmt << "[classProperty:" << ref.classProperty << " value:" << ref.value << "]";
+ });
+ fmt << ")" << std::endl;
+ outString = fmt.str();
}
/* Sink Class */
-void CAmDatabaseHandlerMap::AmSinkClass::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" <<
- ") listClassProperties (";
- std::for_each(listClassProperties.begin(), listClassProperties.end(), [&](const am_ClassProperty_s & ref) {
- fmt << "[classProperty:" << ref.classProperty << " value:" << ref.value << "]";
- });
- fmt << ")" << std::endl;
- outString = fmt.str();
+ std::ostringstream fmt;
+ fmt << "Sink class(" << name.c_str() << ") id(" << sinkClassID << ")\n" <<
+ ") listClassProperties (";
+ std::for_each(listClassProperties.begin(), listClassProperties.end(), [&](const am_ClassProperty_s &ref) {
+ fmt << "[classProperty:" << ref.classProperty << " value:" << ref.value << "]";
+ });
+ fmt << ")" << std::endl;
+ outString = fmt.str();
}
-
/* Gateway */
-void CAmDatabaseHandlerMap::AmGateway::getDescription (std::string & outString) const
-{
- std::ostringstream fmt;
- fmt << "Gateway(" << name.c_str() << ") id(" << gatewayID << ")\n" <<
- "sinkID(" << sinkID <<
- ") sourceID(" << sourceID <<
- ") domainSinkID(" << domainSinkID <<
- ") domainSourceID(" << domainSourceID <<
- ") controlDomainID(" << controlDomainID <<
- ") 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();
+void CAmDatabaseHandlerMap::AmGateway::getDescription(std::string &outString) const
+{
+ std::ostringstream fmt;
+ fmt << "Gateway(" << name.c_str() << ") id(" << gatewayID << ")\n" <<
+ "sinkID(" << sinkID <<
+ ") sourceID(" << sourceID <<
+ ") domainSinkID(" << domainSinkID <<
+ ") domainSourceID(" << domainSourceID <<
+ ") controlDomainID(" << controlDomainID <<
+ ") 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();
}
/* 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();
+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::AmCrossfader::getDescription (std::string & outString) const
-{
- std::ostringstream fmt;
- fmt << "Crossfader(" << name.c_str() << ") id(" << crossfaderID << ")\n" <<
- "sinkID_A(" << sinkID_A <<
- ") sinkID_B(" << sinkID_B <<
- ") sourceID(" << sourceID <<
- ") hotSink(" << hotSink <<
- ")" << std::endl;
- outString = fmt.str();
-}
-
-bool CAmDatabaseHandlerMap::AmMappedData::increaseID(int16_t & resultID, AmIdentifier & elementID,
- int16_t const desiredStaticID = 0)
-{
- if( desiredStaticID > 0 && desiredStaticID < elementID.mMin )
- {
- resultID = desiredStaticID;
- return true;
- }
- else if( elementID.mCurrentValue < elementID.mMax ) //The last used value is 'limit' - 1. e.g. SHRT_MAX - 1, SHRT_MAX is reserved.
- {
- resultID = elementID.mCurrentValue++;
- return true;
- }
- else
- {
- resultID = -1;
- return false;
- }
-}
-
-template <typename TMapKey,class TMapObject> bool CAmDatabaseHandlerMap::AmMappedData::getNextConnectionID(int16_t & resultID, AmIdentifier & connID,
- const std::unordered_map<TMapKey, TMapObject> & map)
-{
- TMapKey nextID;
- int16_t const lastID = connID.mCurrentValue;
- if( connID.mCurrentValue < connID.mMax )
- nextID = connID.mCurrentValue++;
- else
- nextID = connID.mCurrentValue = connID.mMin;
-
- bool notFreeIDs = false;
- while( existsObjectWithKeyInMap(nextID, map) )
- {
-
- if( connID.mCurrentValue < connID.mMax )
- nextID = connID.mCurrentValue++;
- else
- {
- connID.mCurrentValue = connID.mMin;
- nextID = connID.mCurrentValue;
- }
-
- if( connID.mCurrentValue == lastID )
- {
- notFreeIDs = true;
- break;
- }
- }
- if(notFreeIDs)
- {
- resultID = -1;
- return false;
- }
- resultID = nextID;
- return true;
-}
-
-bool CAmDatabaseHandlerMap::AmMappedData::increaseMainConnectionID(int16_t & resultID)
-{
- return getNextConnectionID(resultID, mCurrentMainConnectionID, mMainConnectionMap);
-}
-
-bool CAmDatabaseHandlerMap::AmMappedData::increaseConnectionID(int16_t & resultID)
-{
- return getNextConnectionID(resultID, mCurrentConnectionID, mConnectionMap);
-}
-
-
-CAmDatabaseHandlerMap::CAmDatabaseHandlerMap(): IAmDatabaseHandler(),
- mFirstStaticSink(true),
- mFirstStaticSource(true),
- mFirstStaticGateway(true),
- mFirstStaticConverter(true),
- mFirstStaticSinkClass(true),
- mFirstStaticSourceClass(true),
- mFirstStaticCrossfader(true),
- mListConnectionFormat(),
- mMappedData(),
- mDatabaseObservers()
-{
- logVerbose(__METHOD_NAME__,"Init ");
+void CAmDatabaseHandlerMap::AmCrossfader::getDescription(std::string &outString) const
+{
+ std::ostringstream fmt;
+ fmt << "Crossfader(" << name.c_str() << ") id(" << crossfaderID << ")\n" <<
+ "sinkID_A(" << sinkID_A <<
+ ") sinkID_B(" << sinkID_B <<
+ ") sourceID(" << sourceID <<
+ ") hotSink(" << hotSink <<
+ ")" << std::endl;
+ outString = fmt.str();
+}
+
+bool CAmDatabaseHandlerMap::AmMappedData::increaseID(int16_t &resultID, AmIdentifier &elementID,
+ int16_t const desiredStaticID = 0)
+{
+ if ( desiredStaticID > 0 && desiredStaticID < elementID.mMin )
+ {
+ resultID = desiredStaticID;
+ return true;
+ }
+ else if ( elementID.mCurrentValue < elementID.mMax ) // The last used value is 'limit' - 1. e.g. SHRT_MAX - 1, SHRT_MAX is reserved.
+ {
+ resultID = elementID.mCurrentValue++;
+ return true;
+ }
+ else
+ {
+ resultID = -1;
+ return false;
+ }
+}
+
+template <typename TMapKey, class TMapObject>
+bool CAmDatabaseHandlerMap::AmMappedData::getNextConnectionID(int16_t &resultID, AmIdentifier &connID,
+ const std::unordered_map<TMapKey, TMapObject> &map)
+{
+ TMapKey nextID;
+ int16_t const lastID = connID.mCurrentValue;
+ if ( connID.mCurrentValue < connID.mMax )
+ {
+ nextID = connID.mCurrentValue++;
+ }
+ else
+ {
+ nextID = connID.mCurrentValue = connID.mMin;
+ }
+
+ bool notFreeIDs = false;
+ while ( existsObjectWithKeyInMap(nextID, map))
+ {
+
+ if ( connID.mCurrentValue < connID.mMax )
+ {
+ nextID = connID.mCurrentValue++;
+ }
+ else
+ {
+ connID.mCurrentValue = connID.mMin;
+ nextID = connID.mCurrentValue;
+ }
+
+ if ( connID.mCurrentValue == lastID )
+ {
+ notFreeIDs = true;
+ break;
+ }
+ }
+
+ if (notFreeIDs)
+ {
+ resultID = -1;
+ return false;
+ }
+
+ resultID = nextID;
+ return true;
+}
+
+bool CAmDatabaseHandlerMap::AmMappedData::increaseMainConnectionID(int16_t &resultID)
+{
+ return getNextConnectionID(resultID, mCurrentMainConnectionID, mMainConnectionMap);
+}
+
+bool CAmDatabaseHandlerMap::AmMappedData::increaseConnectionID(int16_t &resultID)
+{
+ return getNextConnectionID(resultID, mCurrentConnectionID, mConnectionMap);
+}
+
+CAmDatabaseHandlerMap::CAmDatabaseHandlerMap()
+ : IAmDatabaseHandler()
+ , mFirstStaticSink(true)
+ , mFirstStaticSource(true)
+ , mFirstStaticGateway(true)
+ , mFirstStaticConverter(true)
+ , mFirstStaticSinkClass(true)
+ , mFirstStaticSourceClass(true)
+ , mFirstStaticCrossfader(true)
+ , mListConnectionFormat()
+ , mMappedData()
+ , mDatabaseObservers()
+{
+ logVerbose(__METHOD_NAME__, "Init ");
}
CAmDatabaseHandlerMap::~CAmDatabaseHandlerMap()
{
- logVerbose(__METHOD_NAME__,"Destroy");
- for(AmDatabaseObserverCallbacks * ptr: mDatabaseObservers)
- ptr->mpDatabaseHandler=nullptr;
+ logVerbose(__METHOD_NAME__, "Destroy");
+ for (AmDatabaseObserverCallbacks *ptr: mDatabaseObservers)
+ {
+ ptr->mpDatabaseHandler = nullptr;
+ }
}
-am_Error_e CAmDatabaseHandlerMap::enterDomainDB(const am_Domain_s & domainData, am_domainID_t & domainID)
+am_Error_e CAmDatabaseHandlerMap::enterDomainDB(const am_Domain_s &domainData, am_domainID_t &domainID)
{
- if(domainData.name.empty())
+ if (domainData.name.empty())
{
- logError(__METHOD_NAME__,"DomainName must not be emtpy!");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "DomainName must not be emtpy!");
+ return (E_NOT_POSSIBLE);
}
- if(domainData.busname.empty())
+
+ if (domainData.busname.empty())
{
- logError(__METHOD_NAME__,"Busname must not be emtpy!");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "Busname must not be emtpy!");
+ return (E_NOT_POSSIBLE);
}
- if(!(domainData.state>=DS_UNKNOWN && domainData.state<=DS_MAX))
+
+ if (!(domainData.state >= DS_UNKNOWN && domainData.state <= DS_MAX))
{
- logError(__METHOD_NAME__,"State must not be valid!");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "State must not be valid!");
+ return (E_NOT_POSSIBLE);
}
- //first check for a reserved domain
- am_Domain_s const *reservedDomain = objectMatchingPredicate<AmDomain, am_domainID_t>(mMappedData.mDomainMap, [&](const AmDomain & obj){
- return domainData.name.compare(obj.name)==0;
- });
+
+ // first check for a reserved domain
+ am_Domain_s const *reservedDomain = objectMatchingPredicate<AmDomain, am_domainID_t>(mMappedData.mDomainMap, [&](const AmDomain &obj){
+ return domainData.name.compare(obj.name) == 0;
+ });
int16_t nextID = 0;
- if( NULL != reservedDomain )
+ if ( NULL != reservedDomain )
{
- nextID = reservedDomain->domainID;
- domainID = nextID;
- mMappedData.mDomainMap[nextID] = 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);
+ nextID = reservedDomain->domainID;
+ domainID = nextID;
+ mMappedData.mDomainMap[nextID] = 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);
- NOTIFY_OBSERVERS1(dboNewDomain, mMappedData.mDomainMap[nextID])
+ NOTIFY_OBSERVERS1(dboNewDomain, mMappedData.mDomainMap[nextID])
- return (E_OK);
+ return (E_OK);
}
else
{
- if(mMappedData.increaseID(nextID, mMappedData.mCurrentDomainID, domainData.domainID))
- {
- domainID = nextID;
- 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 (mMappedData.increaseID(nextID, mMappedData.mCurrentDomainID, domainData.domainID))
+ {
+ domainID = nextID;
+ 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);
- NOTIFY_OBSERVERS1(dboNewDomain, mMappedData.mDomainMap[nextID])
+ NOTIFY_OBSERVERS1(dboNewDomain, mMappedData.mDomainMap[nextID])
- return (E_OK);
- }
- else
- {
- domainID = 0;
- logVerbose(__METHOD_NAME__,"Max limit reached.");
- return (E_UNKNOWN);
- }
+ return (E_OK);
+ }
+ else
+ {
+ domainID = 0;
+ logVerbose(__METHOD_NAME__, "Max limit reached.");
+ return (E_UNKNOWN);
+ }
}
}
-int16_t CAmDatabaseHandlerMap::calculateDelayForRoute(const std::vector<am_connectionID_t>& listConnectionID)
+int16_t CAmDatabaseHandlerMap::calculateDelayForRoute(const std::vector<am_connectionID_t> &listConnectionID)
{
- int16_t delay = 0;
- std::vector<am_connectionID_t>::const_iterator elementIterator = listConnectionID.begin();
- for (; elementIterator < listConnectionID.end(); ++elementIterator)
- {
- am_connectionID_t key = *elementIterator;
- std::unordered_map<am_connectionID_t, am_Connection_Database_s>::const_iterator it = mMappedData.mConnectionMap.find(key);
- if (it!=mMappedData.mConnectionMap.end())
- {
- int16_t temp_delay = it->second.delay;
- if (temp_delay != -1 && delay != -1)
- delay += temp_delay;
- else
- delay = -1;
- }
- }
- return delay;
+ int16_t delay = 0;
+ std::vector<am_connectionID_t>::const_iterator elementIterator = listConnectionID.begin();
+ for (; elementIterator < listConnectionID.end(); ++elementIterator)
+ {
+ am_connectionID_t key = *elementIterator;
+ std::unordered_map<am_connectionID_t, am_Connection_Database_s>::const_iterator it = mMappedData.mConnectionMap.find(key);
+ if (it != mMappedData.mConnectionMap.end())
+ {
+ int16_t temp_delay = it->second.delay;
+ if (temp_delay != -1 && delay != -1)
+ {
+ delay += temp_delay;
+ }
+ else
+ {
+ delay = -1;
+ }
+ }
+ }
+
+ return delay;
}
-am_Error_e CAmDatabaseHandlerMap::enterMainConnectionDB(const am_MainConnection_s & mainConnectionData, am_mainConnectionID_t & connectionID)
+am_Error_e CAmDatabaseHandlerMap::enterMainConnectionDB(const am_MainConnection_s &mainConnectionData, am_mainConnectionID_t &connectionID)
{
- if(mainConnectionData.mainConnectionID!=0)
+ if (mainConnectionData.mainConnectionID != 0)
{
- logError(__METHOD_NAME__,"mainConnectionID must be 0!");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "mainConnectionID must be 0!");
+ return (E_NOT_POSSIBLE);
}
- if(!(mainConnectionData.connectionState>=CS_UNKNOWN && mainConnectionData.connectionState<=CS_MAX))
+
+ if (!(mainConnectionData.connectionState >= CS_UNKNOWN && mainConnectionData.connectionState <= CS_MAX))
{
- logError(__METHOD_NAME__,"connectionState must be valid!");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "connectionState must be valid!");
+ return (E_NOT_POSSIBLE);
}
- if(!existSink(mainConnectionData.sinkID))
+
+ if (!existSink(mainConnectionData.sinkID))
{
- logError(__METHOD_NAME__,"sinkID must be valid!");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "sinkID must be valid!");
+ return (E_NOT_POSSIBLE);
}
- if(!existSource(mainConnectionData.sourceID))
+
+ if (!existSource(mainConnectionData.sourceID))
{
- logError(__METHOD_NAME__,"sourceID must be valid!");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "sourceID must be valid!");
+ return (E_NOT_POSSIBLE);
}
- int16_t delay = 0;
+ int16_t delay = 0;
int16_t nextID = 0;
- if(mMappedData.increaseMainConnectionID(nextID))
- {
- connectionID = nextID;
- mMappedData.mMainConnectionMap[nextID] = mainConnectionData;
- mMappedData.mMainConnectionMap[nextID].mainConnectionID = nextID;
- }
- else
- {
- connectionID = 0;
- logVerbose(__METHOD_NAME__,"Max limit reached.");
- return (E_UNKNOWN);
- }
-
- //now check the connectionTable for all connections in the route. IF connectionID exist
+ if (mMappedData.increaseMainConnectionID(nextID))
+ {
+ connectionID = nextID;
+ mMappedData.mMainConnectionMap[nextID] = mainConnectionData;
+ mMappedData.mMainConnectionMap[nextID].mainConnectionID = nextID;
+ }
+ else
+ {
+ connectionID = 0;
+ logVerbose(__METHOD_NAME__, "Max limit reached.");
+ return (E_UNKNOWN);
+ }
+
+ // now check the connectionTable for all connections in the route. IF connectionID exist
delay = calculateDelayForRoute(mainConnectionData.listConnectionID);
logVerbose("DatabaseHandler::enterMainConnectionDB entered new mainConnection with sourceID", mainConnectionData.sourceID, "sinkID:", mainConnectionData.sinkID, "delay:", delay, "assigned ID:", connectionID);
-
if (mDatabaseObservers.size())
{
- am_MainConnectionType_s mainConnection;
- mMappedData.mMainConnectionMap[nextID].getMainConnectionType(mainConnection);
+ 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
+ // finally, we update the delay value for the maintable
if (delay == 0)
+ {
delay = -1;
+ }
+
(void)changeDelayMainConnection(delay, connectionID);
return (E_OK);
@@ -618,258 +653,278 @@ am_Error_e CAmDatabaseHandlerMap::enterMainConnectionDB(const am_MainConnection_
* Helper method, that inserts a new struct in the map and copies the given into it.
* This method uses the increaseID function to secure the global id is properly increased.
**/
-bool CAmDatabaseHandlerMap::insertSinkDB(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
+bool CAmDatabaseHandlerMap::insertSinkDB(const am_Sink_s &sinkData, am_sinkID_t &sinkID)
{
int16_t nextID = 0;
- if( mMappedData.increaseID(nextID, mMappedData.mCurrentSinkID, sinkData.sinkID) )
- {
- sinkID = nextID;
- mMappedData.mSinkMap[nextID] = sinkData;
- mMappedData.mSinkMap[nextID].sinkID = nextID;
- filterDuplicateNotificationConfigurationTypes(mMappedData.mSinkMap[nextID].listNotificationConfigurations);
- filterDuplicateNotificationConfigurationTypes(mMappedData.mSinkMap[nextID].listMainNotificationConfigurations);
- return (true);
- }
- else
- {
- sinkID = 0;
- logVerbose(__METHOD_NAME__,"Max limit reached!");
- return (false);
- }
+ if ( mMappedData.increaseID(nextID, mMappedData.mCurrentSinkID, sinkData.sinkID))
+ {
+ sinkID = nextID;
+ mMappedData.mSinkMap[nextID] = sinkData;
+ mMappedData.mSinkMap[nextID].sinkID = nextID;
+ filterDuplicateNotificationConfigurationTypes(mMappedData.mSinkMap[nextID].listNotificationConfigurations);
+ filterDuplicateNotificationConfigurationTypes(mMappedData.mSinkMap[nextID].listMainNotificationConfigurations);
+ return (true);
+ }
+ else
+ {
+ sinkID = 0;
+ logVerbose(__METHOD_NAME__, "Max limit reached!");
+ return (false);
+ }
}
-am_Error_e CAmDatabaseHandlerMap::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
+am_Error_e CAmDatabaseHandlerMap::enterSinkDB(const am_Sink_s &sinkData, am_sinkID_t &sinkID)
{
- if(sinkData.sinkID>=DYNAMIC_ID_BOUNDARY)
+ if (sinkData.sinkID >= DYNAMIC_ID_BOUNDARY)
{
- logError(__METHOD_NAME__,"sinkID must be below:",DYNAMIC_ID_BOUNDARY);
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "sinkID must be below:", DYNAMIC_ID_BOUNDARY);
+ return (E_NOT_POSSIBLE);
}
- if(!existDomain(sinkData.domainID))
+
+ if (!existDomain(sinkData.domainID))
{
- logError(__METHOD_NAME__,"domainID must be valid");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "domainID must be valid");
+ return (E_NOT_POSSIBLE);
}
- if(sinkData.name.empty())
+
+ if (sinkData.name.empty())
{
- logError(__METHOD_NAME__,"sinkName must not be zero");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "sinkName must not be zero");
+ return (E_NOT_POSSIBLE);
}
- if(!existSinkClass(sinkData.sinkClassID))
+
+ if (!existSinkClass(sinkData.sinkClassID))
{
- logError(__METHOD_NAME__,"sinkClass must be valid");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "sinkClass must be valid");
+ return (E_NOT_POSSIBLE);
}
- if(!(sinkData.muteState>=MS_UNKNOWN && sinkData.muteState<=MS_MAX))
+ if (!(sinkData.muteState >= MS_UNKNOWN && sinkData.muteState <= MS_MAX))
{
- logError(__METHOD_NAME__,"muteState must be valid");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "muteState must be valid");
+ return (E_NOT_POSSIBLE);
}
- am_sinkID_t temp_SinkID = 0;
+ 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<AmSink, am_sinkID_t>(mMappedData.mSinkMap, [&](const AmSink & obj){
- return true==obj.reserved && obj.name.compare(sinkData.name)==0;
- });
- if( NULL!=reservedDomain )
- {
- am_sinkID_t oldSinkID = reservedDomain->sinkID;
- mMappedData.mSinkMap[oldSinkID] = sinkData;
- mMappedData.mSinkMap[oldSinkID].reserved = 0;
- temp_SinkID = oldSinkID;
- temp_SinkIndex = oldSinkID;
+ // if sinkID is zero and the first Static Sink was already entered, the ID is created
+ 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 )
+ {
+ am_sinkID_t oldSinkID = reservedDomain->sinkID;
+ mMappedData.mSinkMap[oldSinkID] = sinkData;
+ mMappedData.mSinkMap[oldSinkID].reserved = 0;
+ temp_SinkID = oldSinkID;
+ temp_SinkIndex = oldSinkID;
}
else
{
- bool result;
- if ( sinkData.sinkID != 0 || mFirstStaticSink )
- {
- //check if the ID already exists
- if (existSinkNameOrID(sinkData.sinkID, sinkData.name))
- {
- sinkID = sinkData.sinkID;
- return (E_ALREADY_EXISTS);
- }
- }
- result = insertSinkDB(sinkData, temp_SinkID);
- if( false == result )
- return (E_UNKNOWN);
- temp_SinkIndex = temp_SinkID;
- }
- //if the first static sink is entered, we need to set it onto the boundary
+ bool result;
+ if ( sinkData.sinkID != 0 || mFirstStaticSink )
+ {
+ // check if the ID already exists
+ if (existSinkNameOrID(sinkData.sinkID, sinkData.name))
+ {
+ sinkID = sinkData.sinkID;
+ return (E_ALREADY_EXISTS);
+ }
+ }
+
+ result = insertSinkDB(sinkData, temp_SinkID);
+ if ( false == result )
+ {
+ return (E_UNKNOWN);
+ }
+
+ temp_SinkIndex = temp_SinkID;
+ }
+
+ // if the first static sink is entered, we need to set it onto the boundary
if (sinkData.sinkID == 0 && mFirstStaticSink)
{
mFirstStaticSink = false;
}
+
mMappedData.mSinkMap[temp_SinkIndex].sinkID = temp_SinkID;
- sinkID = temp_SinkID;
+ sinkID = temp_SinkID;
- am_Sink_s & sink = mMappedData.mSinkMap[temp_SinkID];
+ 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);
- sink.sinkID=sinkID;
- NOTIFY_OBSERVERS1(dboNewSink, sink)
+ sink.sinkID = sinkID;
+ NOTIFY_OBSERVERS1(dboNewSink, sink)
return (E_OK);
}
-bool CAmDatabaseHandlerMap::insertCrossfaderDB(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
+bool CAmDatabaseHandlerMap::insertCrossfaderDB(const am_Crossfader_s &crossfaderData, am_crossfaderID_t &crossfaderID)
{
int16_t nextID = 0;
- if(mMappedData.increaseID(nextID, mMappedData.mCurrentCrossfaderID, crossfaderData.crossfaderID))
- {
- crossfaderID = nextID;
- mMappedData.mCrossfaderMap[nextID] = crossfaderData;
- mMappedData.mCrossfaderMap[nextID].crossfaderID = nextID;
- return (true);
- }
- else
- {
- crossfaderID = 0;
- logVerbose(__METHOD_NAME__,"Max limit reached.");
- return (false);
- }
+ if (mMappedData.increaseID(nextID, mMappedData.mCurrentCrossfaderID, crossfaderData.crossfaderID))
+ {
+ crossfaderID = nextID;
+ mMappedData.mCrossfaderMap[nextID] = crossfaderData;
+ mMappedData.mCrossfaderMap[nextID].crossfaderID = nextID;
+ return (true);
+ }
+ else
+ {
+ crossfaderID = 0;
+ logVerbose(__METHOD_NAME__, "Max limit reached.");
+ return (false);
+ }
}
-am_Error_e CAmDatabaseHandlerMap::enterCrossfaderDB(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
+am_Error_e CAmDatabaseHandlerMap::enterCrossfaderDB(const am_Crossfader_s &crossfaderData, am_crossfaderID_t &crossfaderID)
{
- if(crossfaderData.crossfaderID>=DYNAMIC_ID_BOUNDARY)
+ if (crossfaderData.crossfaderID >= DYNAMIC_ID_BOUNDARY)
{
- logError(__METHOD_NAME__,"crossfaderID must be below:",DYNAMIC_ID_BOUNDARY);
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "crossfaderID must be below:", DYNAMIC_ID_BOUNDARY);
+ return (E_NOT_POSSIBLE);
}
- if(!(crossfaderData.hotSink>=HS_UNKNOWN && crossfaderData.hotSink<=HS_MAX))
+ if (!(crossfaderData.hotSink >= HS_UNKNOWN && crossfaderData.hotSink <= HS_MAX))
{
- logError(__METHOD_NAME__,"hotSink must be valid");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "hotSink must be valid");
+ return (E_NOT_POSSIBLE);
}
- if(crossfaderData.name.empty())
+
+ if (crossfaderData.name.empty())
{
- logError(__METHOD_NAME__,"crossfaderName must not be zero");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "crossfaderName must not be zero");
+ return (E_NOT_POSSIBLE);
}
- if(!existSink(crossfaderData.sinkID_A))
+ if (!existSink(crossfaderData.sinkID_A))
{
- logError(__METHOD_NAME__,"sinkID_A must exist");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "sinkID_A must exist");
+ return (E_NOT_POSSIBLE);
}
- if(!existSink(crossfaderData.sinkID_B))
+
+ if (!existSink(crossfaderData.sinkID_B))
{
- logError(__METHOD_NAME__,"sinkID_B must exist");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "sinkID_B must exist");
+ return (E_NOT_POSSIBLE);
}
- if(!existSource(crossfaderData.sourceID))
+
+ if (!existSource(crossfaderData.sourceID))
{
- logError(__METHOD_NAME__,"sourceID must exist");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "sourceID must exist");
+ return (E_NOT_POSSIBLE);
}
- am_crossfaderID_t temp_CrossfaderID = 0;
+ am_crossfaderID_t temp_CrossfaderID = 0;
am_crossfaderID_t temp_CrossfaderIndex = 0;
bool result;
- //if gatewayData is zero and the first Static Sink was already entered, the ID is created
+ // if gatewayData is zero and the first Static Sink was already entered, the ID is created
if (crossfaderData.crossfaderID != 0 || mFirstStaticCrossfader)
{
- //check if the ID already exists
+ // check if the ID already exists
if (existCrossFader(crossfaderData.crossfaderID))
{
- crossfaderID = crossfaderData.crossfaderID;
+ crossfaderID = crossfaderData.crossfaderID;
return (E_ALREADY_EXISTS);
}
}
+
result = insertCrossfaderDB(crossfaderData, temp_CrossfaderID);
- if( false == result )
- return (E_UNKNOWN);
- temp_CrossfaderIndex = temp_CrossfaderID;
+ if ( false == result )
+ {
+ return (E_UNKNOWN);
+ }
+
+ temp_CrossfaderIndex = temp_CrossfaderID;
- //if the first static sink is entered, we need to set it onto the boundary
- if ( 0==crossfaderData.crossfaderID && mFirstStaticCrossfader)
+ // if the first static sink is entered, we need to set it onto the boundary
+ if ( 0 == crossfaderData.crossfaderID && mFirstStaticCrossfader)
{
mFirstStaticCrossfader = false;
}
- mMappedData.mCrossfaderMap[temp_CrossfaderIndex].crossfaderID = temp_CrossfaderID;
- 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);
+ mMappedData.mCrossfaderMap[temp_CrossfaderIndex].crossfaderID = temp_CrossfaderID;
+ 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);
- NOTIFY_OBSERVERS1(dboNewCrossfader, mMappedData.mCrossfaderMap[temp_CrossfaderIndex])
+ NOTIFY_OBSERVERS1(dboNewCrossfader, mMappedData.mCrossfaderMap[temp_CrossfaderIndex])
return (E_OK);
}
-bool CAmDatabaseHandlerMap::insertGatewayDB(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
+bool CAmDatabaseHandlerMap::insertGatewayDB(const am_Gateway_s &gatewayData, am_gatewayID_t &gatewayID)
{
int16_t nextID = 0;
- if(mMappedData.increaseID(nextID, mMappedData.mCurrentGatewayID, gatewayData.gatewayID))
- {
- gatewayID = nextID;
- mMappedData.mGatewayMap[nextID] = gatewayData;
- mMappedData.mGatewayMap[nextID].gatewayID = nextID;
- return (true);
- }
- else
- {
- gatewayID = 0;
- logVerbose(__METHOD_NAME__,"Max limit reached.");
- return (false);
- }
+ if (mMappedData.increaseID(nextID, mMappedData.mCurrentGatewayID, gatewayData.gatewayID))
+ {
+ gatewayID = nextID;
+ mMappedData.mGatewayMap[nextID] = gatewayData;
+ mMappedData.mGatewayMap[nextID].gatewayID = nextID;
+ return (true);
+ }
+ else
+ {
+ gatewayID = 0;
+ logVerbose(__METHOD_NAME__, "Max limit reached.");
+ return (false);
+ }
}
-am_Error_e CAmDatabaseHandlerMap::enterGatewayDB(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
+am_Error_e CAmDatabaseHandlerMap::enterGatewayDB(const am_Gateway_s &gatewayData, am_gatewayID_t &gatewayID)
{
- if(gatewayData.gatewayID>=DYNAMIC_ID_BOUNDARY)
+ if (gatewayData.gatewayID >= DYNAMIC_ID_BOUNDARY)
{
- logError(__METHOD_NAME__,"gatewayID must be below:",DYNAMIC_ID_BOUNDARY);
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "gatewayID must be below:", DYNAMIC_ID_BOUNDARY);
+ return (E_NOT_POSSIBLE);
}
- if(!existDomain(gatewayData.controlDomainID))
+ if (!existDomain(gatewayData.controlDomainID))
{
- logError(__METHOD_NAME__,"controlDomainID must be exist");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "controlDomainID must be exist");
+ return (E_NOT_POSSIBLE);
}
- if(gatewayData.name.empty())
+ if (gatewayData.name.empty())
{
- logError(__METHOD_NAME__,"gatewayName must not be empty");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "gatewayName must not be empty");
+ return (E_NOT_POSSIBLE);
}
- //might be that the sinks and sources are not there during registration time
- //assert(existSink(gatewayData.sinkID));
- //assert(existSource(gatewayData.sourceID));
+ // might be that the sinks and sources are not there during registration time
+ // assert(existSink(gatewayData.sinkID));
+ // assert(existSource(gatewayData.sourceID));
- am_gatewayID_t temp_GatewayID = 0;
+ am_gatewayID_t temp_GatewayID = 0;
am_gatewayID_t temp_GatewayIndex = 0;
- //if gatewayData is zero and the first Static Sink was already entered, the ID is created
+ // if gatewayData is zero and the first Static Sink was already entered, the ID is created
bool result;
if (gatewayData.gatewayID != 0 || mFirstStaticGateway)
{
- //check if the ID already exists
+ // check if the ID already exists
if (existGateway(gatewayData.gatewayID))
{
- gatewayID = gatewayData.gatewayID;
+ gatewayID = gatewayData.gatewayID;
return (E_ALREADY_EXISTS);
}
}
+
result = insertGatewayDB(gatewayData, temp_GatewayID);
- if( false == result )
- return (E_UNKNOWN);
+ if ( false == result )
+ {
+ return (E_UNKNOWN);
+ }
- temp_GatewayIndex = temp_GatewayID;
- //if the ID is not created, we add it to the query
+ temp_GatewayIndex = temp_GatewayID;
+ // if the ID is not created, we add it to the query
if (gatewayData.gatewayID == 0 && mFirstStaticGateway)
{
mFirstStaticGateway = false;
}
+
mMappedData.mGatewayMap[temp_GatewayIndex].gatewayID = temp_GatewayID;
- gatewayID = temp_GatewayID;
+ gatewayID = temp_GatewayID;
logVerbose("DatabaseHandler::enterGatewayDB entered new gateway with name", gatewayData.name, "sourceID:", gatewayData.sourceID, "sinkID:", gatewayData.sinkID, "assigned ID:", gatewayID);
@@ -877,85 +932,89 @@ am_Error_e CAmDatabaseHandlerMap::enterGatewayDB(const am_Gateway_s & gatewayDat
return (E_OK);
}
-bool CAmDatabaseHandlerMap::insertConverterDB(const am_Converter_s & converteData, am_converterID_t & converterID)
+bool CAmDatabaseHandlerMap::insertConverterDB(const am_Converter_s &converteData, am_converterID_t &converterID)
{
int16_t nextID = 0;
- if(mMappedData.increaseID(nextID, mMappedData.mCurrentConverterID, converteData.converterID))
- {
- converterID = nextID;
- mMappedData.mConverterMap[nextID] = converteData;
- mMappedData.mConverterMap[nextID].converterID = nextID;
- return (true);
- }
- else
- {
- converterID = 0;
- logVerbose(__METHOD_NAME__,"Max limit reached.");
- return (false);
- }
+ if (mMappedData.increaseID(nextID, mMappedData.mCurrentConverterID, converteData.converterID))
+ {
+ converterID = nextID;
+ mMappedData.mConverterMap[nextID] = converteData;
+ mMappedData.mConverterMap[nextID].converterID = nextID;
+ return (true);
+ }
+ else
+ {
+ converterID = 0;
+ logVerbose(__METHOD_NAME__, "Max limit reached.");
+ return (false);
+ }
}
-am_Error_e CAmDatabaseHandlerMap::enterConverterDB(const am_Converter_s & converterData, am_converterID_t & converterID)
+am_Error_e CAmDatabaseHandlerMap::enterConverterDB(const am_Converter_s &converterData, am_converterID_t &converterID)
{
- if(converterData.converterID>=DYNAMIC_ID_BOUNDARY)
+ if (converterData.converterID >= DYNAMIC_ID_BOUNDARY)
{
- logError(__METHOD_NAME__,"converterID must be below:",DYNAMIC_ID_BOUNDARY);
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "converterID must be below:", DYNAMIC_ID_BOUNDARY);
+ return (E_NOT_POSSIBLE);
}
- if(!existSink(converterData.sinkID))
+ if (!existSink(converterData.sinkID))
{
- logError(__METHOD_NAME__,"sinkID must exists");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "sinkID must exists");
+ return (E_NOT_POSSIBLE);
}
- if(!existSource(converterData.sourceID))
+ if (!existSource(converterData.sourceID))
{
- logError(__METHOD_NAME__,"sourceID must exists");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "sourceID must exists");
+ return (E_NOT_POSSIBLE);
}
- if(!existDomain(converterData.domainID))
+ if (!existDomain(converterData.domainID))
{
- logError(__METHOD_NAME__,"domainID must exists");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "domainID must exists");
+ return (E_NOT_POSSIBLE);
}
- if(converterData.name.empty())
+ if (converterData.name.empty())
{
- logError(__METHOD_NAME__,"converterName must not be empty");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "converterName must not be empty");
+ return (E_NOT_POSSIBLE);
}
- //might be that the sinks and sources are not there during registration time
- //assert(existSink(gatewayData.sinkID));
- //assert(existSource(gatewayData.sourceID));
+ // might be that the sinks and sources are not there during registration time
+ // assert(existSink(gatewayData.sinkID));
+ // assert(existSource(gatewayData.sourceID));
- am_converterID_t tempID = 0;
+ am_converterID_t tempID = 0;
am_converterID_t tempIndex = 0;
- //if gatewayData is zero and the first Static Sink was already entered, the ID is created
+ // if gatewayData is zero and the first Static Sink was already entered, the ID is created
bool result;
if (converterData.converterID != 0 || mFirstStaticConverter)
{
- //check if the ID already exists
+ // check if the ID already exists
if (existConverter(converterData.converterID))
{
- converterID = converterData.converterID;
+ converterID = converterData.converterID;
return (E_ALREADY_EXISTS);
}
}
+
result = insertConverterDB(converterData, tempID);
- if( false == result )
- return (E_UNKNOWN);
+ if ( false == result )
+ {
+ return (E_UNKNOWN);
+ }
- tempIndex = tempID;
- //if the ID is not created, we add it to the query
+ tempIndex = tempID;
+ // if the ID is not created, we add it to the query
if (converterData.converterID == 0 && mFirstStaticConverter)
{
- mFirstStaticConverter = false;
+ mFirstStaticConverter = false;
}
+
mMappedData.mConverterMap[tempIndex].converterID = tempID;
- converterID = tempID;
+ converterID = tempID;
logVerbose("DatabaseHandler::enterConverterDB entered new converter with name", converterData.name, "sourceID:", converterData.sourceID, "sinkID:", converterData.sinkID, "assigned ID:", converterID);
NOTIFY_OBSERVERS1(dboNewConverter, mMappedData.mConverterMap[tempIndex])
@@ -963,113 +1022,124 @@ am_Error_e CAmDatabaseHandlerMap::enterConverterDB(const am_Converter_s & conver
return (E_OK);
}
-void CAmDatabaseHandlerMap::dump( std::ostream & output ) const
+void CAmDatabaseHandlerMap::dump(std::ostream &output) const
{
- output << std::endl << "****************** DUMP START ******************" << std::endl;
- 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 << "]";
- output << std::endl << "****************** DUMP END ******************" << std::endl;
+ output << std::endl << "****************** DUMP START ******************" << std::endl;
+ 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 << "]";
+ }
+
+ output << std::endl << "****************** DUMP END ******************" << std::endl;
}
-bool CAmDatabaseHandlerMap::insertSourceDB(const am_Source_s & sourceData, am_sourceID_t & sourceID)
+bool CAmDatabaseHandlerMap::insertSourceDB(const am_Source_s &sourceData, am_sourceID_t &sourceID)
{
int16_t nextID = 0;
- if(mMappedData.increaseID(nextID, mMappedData.mCurrentSourceID, sourceData.sourceID))
- {
- sourceID = nextID;
- mMappedData.mSourceMap[nextID] = sourceData;
- mMappedData.mSourceMap[nextID].sourceID = nextID;
- filterDuplicateNotificationConfigurationTypes(mMappedData.mSourceMap[nextID].listNotificationConfigurations);
- filterDuplicateNotificationConfigurationTypes(mMappedData.mSourceMap[nextID].listMainNotificationConfigurations);
- return (true);
- }
- else
- {
- sourceID = 0;
- logVerbose(__METHOD_NAME__,"Max limit reached.");
- return (false);
- }
-}
-
-am_Error_e CAmDatabaseHandlerMap::enterSourceDB(const am_Source_s & sourceData, am_sourceID_t & sourceID)
-{
- if(sourceData.sourceID>=DYNAMIC_ID_BOUNDARY)
- {
- logError(__METHOD_NAME__,"sourceID must be below:",DYNAMIC_ID_BOUNDARY);
- return (E_NOT_POSSIBLE);
- }
- if(!existDomain(sourceData.domainID))
- {
- logError(__METHOD_NAME__,"domainID must be valid");
- return (E_NOT_POSSIBLE);
- }
- if(sourceData.name.empty())
- {
- logError(__METHOD_NAME__,"sourceName must not be zero");
- return (E_NOT_POSSIBLE);
- }
- if(!existSourceClass(sourceData.sourceClassID))
- {
- logError(__METHOD_NAME__,"sourceClassID must be valid");
- return (E_NOT_POSSIBLE);
- }
-
- if(!(sourceData.sourceState>=SS_UNKNNOWN && sourceData.sourceState<=SS_MAX))
- {
- logError(__METHOD_NAME__,"sourceState must be valid");
- return (E_NOT_POSSIBLE);
- }
-
- bool isFirstStatic = sourceData.sourceID == 0 && mFirstStaticSource;
- am_sourceID_t temp_SourceID = 0;
- am_sourceID_t temp_SourceIndex = 0;
- 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 )
- {
- am_sourceID_t oldSourceID = reservedSource->sourceID;
- mMappedData.mSourceMap[oldSourceID] = sourceData;
- mMappedData.mSourceMap[oldSourceID].reserved = 0;
- temp_SourceID = oldSourceID;
- temp_SourceIndex = oldSourceID;
- }
- else
- {
- bool result;
- if ( !isFirstStatic )
- {
- //check if the ID already exists
- if (existSourceNameOrID(sourceData.sourceID, sourceData.name))
- {
- sourceID = sourceData.sourceID;
- return (E_ALREADY_EXISTS);
- }
- }
- result = insertSourceDB(sourceData, temp_SourceID);
- if( false == result )
- return (E_UNKNOWN);
- temp_SourceIndex = temp_SourceID;
+ if (mMappedData.increaseID(nextID, mMappedData.mCurrentSourceID, sourceData.sourceID))
+ {
+ sourceID = nextID;
+ mMappedData.mSourceMap[nextID] = sourceData;
+ mMappedData.mSourceMap[nextID].sourceID = nextID;
+ filterDuplicateNotificationConfigurationTypes(mMappedData.mSourceMap[nextID].listNotificationConfigurations);
+ filterDuplicateNotificationConfigurationTypes(mMappedData.mSourceMap[nextID].listMainNotificationConfigurations);
+ return (true);
+ }
+ else
+ {
+ sourceID = 0;
+ logVerbose(__METHOD_NAME__, "Max limit reached.");
+ return (false);
+ }
+}
+
+am_Error_e CAmDatabaseHandlerMap::enterSourceDB(const am_Source_s &sourceData, am_sourceID_t &sourceID)
+{
+ if (sourceData.sourceID >= DYNAMIC_ID_BOUNDARY)
+ {
+ logError(__METHOD_NAME__, "sourceID must be below:", DYNAMIC_ID_BOUNDARY);
+ return (E_NOT_POSSIBLE);
+ }
+
+ if (!existDomain(sourceData.domainID))
+ {
+ logError(__METHOD_NAME__, "domainID must be valid");
+ return (E_NOT_POSSIBLE);
+ }
+
+ if (sourceData.name.empty())
+ {
+ logError(__METHOD_NAME__, "sourceName must not be zero");
+ return (E_NOT_POSSIBLE);
+ }
+
+ if (!existSourceClass(sourceData.sourceClassID))
+ {
+ logError(__METHOD_NAME__, "sourceClassID must be valid");
+ return (E_NOT_POSSIBLE);
+ }
+
+ if (!(sourceData.sourceState >= SS_UNKNNOWN && sourceData.sourceState <= SS_MAX))
+ {
+ logError(__METHOD_NAME__, "sourceState must be valid");
+ return (E_NOT_POSSIBLE);
+ }
+
+ bool isFirstStatic = sourceData.sourceID == 0 && mFirstStaticSource;
+ am_sourceID_t temp_SourceID = 0;
+ am_sourceID_t temp_SourceIndex = 0;
+ 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 )
+ {
+ am_sourceID_t oldSourceID = reservedSource->sourceID;
+ mMappedData.mSourceMap[oldSourceID] = sourceData;
+ mMappedData.mSourceMap[oldSourceID].reserved = 0;
+ temp_SourceID = oldSourceID;
+ temp_SourceIndex = oldSourceID;
+ }
+ else
+ {
+ bool result;
+ if ( !isFirstStatic )
+ {
+ // check if the ID already exists
+ if (existSourceNameOrID(sourceData.sourceID, sourceData.name))
+ {
+ sourceID = sourceData.sourceID;
+ return (E_ALREADY_EXISTS);
+ }
+ }
+
+ result = insertSourceDB(sourceData, temp_SourceID);
+ if ( false == result )
+ {
+ return (E_UNKNOWN);
+ }
+
+ temp_SourceIndex = temp_SourceID;
}
if ( isFirstStatic )
{
- //if the first static sink is entered, we need to set it onto the boundary if needed
+ // if the first static sink is entered, we need to set it onto the boundary if needed
mFirstStaticSource = false;
}
+
mMappedData.mSourceMap[temp_SourceIndex].sourceID = temp_SourceID;
- sourceID = temp_SourceID;
+ sourceID = temp_SourceID;
logVerbose("DatabaseHandler::enterSourceDB entered new source with name", sourceData.name, "domainID:", sourceData.domainID, "classID:", sourceData.sourceClassID, "visible:", sourceData.visible, "assigned ID:", sourceID);
@@ -1078,169 +1148,177 @@ am_Error_e CAmDatabaseHandlerMap::enterSourceDB(const am_Source_s & sourceData,
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::enterConnectionDB(const am_Connection_s& connection, am_connectionID_t& connectionID)
+am_Error_e CAmDatabaseHandlerMap::enterConnectionDB(const am_Connection_s &connection, am_connectionID_t &connectionID)
{
- if(connection.connectionID!=0)
+ if (connection.connectionID != 0)
{
- logError(__METHOD_NAME__,"connectionID must be 0!");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "connectionID must be 0!");
+ return (E_NOT_POSSIBLE);
}
- if(!existSink(connection.sinkID))
+ if (!existSink(connection.sinkID))
{
- logError(__METHOD_NAME__,"sinkID must exist!");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "sinkID must exist!");
+ return (E_NOT_POSSIBLE);
}
- if(!existSource(connection.sourceID))
+ if (!existSource(connection.sourceID))
{
- logError(__METHOD_NAME__,"sourceID must exist!");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "sourceID must exist!");
+ return (E_NOT_POSSIBLE);
}
- //connection format is not checked, because it's project specific
+
+ // connection format is not checked, because it's project specific
int16_t nextID = 0;
- if(mMappedData.increaseConnectionID(nextID))
- {
- connectionID = nextID;
- mMappedData.mConnectionMap[nextID] = connection;
- mMappedData.mConnectionMap[nextID].connectionID = nextID;
- mMappedData.mConnectionMap[nextID].reserved = true;
- }
- else
- {
- connectionID = 0;
- logVerbose(__METHOD_NAME__,"Max limit reached.");
- return (E_UNKNOWN);
- }
+ if (mMappedData.increaseConnectionID(nextID))
+ {
+ connectionID = nextID;
+ mMappedData.mConnectionMap[nextID] = connection;
+ mMappedData.mConnectionMap[nextID].connectionID = nextID;
+ mMappedData.mConnectionMap[nextID].reserved = true;
+ }
+ else
+ {
+ connectionID = 0;
+ logVerbose(__METHOD_NAME__, "Max limit reached.");
+ return (E_UNKNOWN);
+ }
logVerbose("DatabaseHandler::enterConnectionDB entered new connection sinkID=", connection.sinkID, "sourceID=", connection.sourceID, "connectionFormat=", connection.connectionFormat, "assigned ID=", connectionID);
return (E_OK);
}
-bool CAmDatabaseHandlerMap::insertSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID)
+bool CAmDatabaseHandlerMap::insertSinkClassDB(const am_SinkClass_s &sinkClass, am_sinkClass_t &sinkClassID)
{
int16_t nextID = 0;
- if(mMappedData.increaseID(nextID, mMappedData.mCurrentSinkClassesID, sinkClass.sinkClassID))
- {
- sinkClassID = nextID;
- mMappedData.mSinkClassesMap[nextID] = sinkClass;
- mMappedData.mSinkClassesMap[nextID].sinkClassID = nextID;
- return (true);
- }
- else
- {
- sinkClassID = 0;
- logVerbose(__METHOD_NAME__,"Max limit reached.");
- return (false);
- }
+ if (mMappedData.increaseID(nextID, mMappedData.mCurrentSinkClassesID, sinkClass.sinkClassID))
+ {
+ sinkClassID = nextID;
+ mMappedData.mSinkClassesMap[nextID] = sinkClass;
+ mMappedData.mSinkClassesMap[nextID].sinkClassID = nextID;
+ return (true);
+ }
+ else
+ {
+ sinkClassID = 0;
+ logVerbose(__METHOD_NAME__, "Max limit reached.");
+ return (false);
+ }
}
-am_Error_e CAmDatabaseHandlerMap::enterSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID)
+am_Error_e CAmDatabaseHandlerMap::enterSinkClassDB(const am_SinkClass_s &sinkClass, am_sinkClass_t &sinkClassID)
{
- if(sinkClass.sinkClassID>=DYNAMIC_ID_BOUNDARY)
+ if (sinkClass.sinkClassID >= DYNAMIC_ID_BOUNDARY)
{
- logError(__METHOD_NAME__,"sinkClassID must be <",DYNAMIC_ID_BOUNDARY);
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "sinkClassID must be <", DYNAMIC_ID_BOUNDARY);
+ return (E_NOT_POSSIBLE);
}
- if(sinkClass.name.empty())
+ if (sinkClass.name.empty())
{
- logError(__METHOD_NAME__,"name must not be empty");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "name must not be empty");
+ return (E_NOT_POSSIBLE);
}
- am_sinkClass_t temp_SinkClassID = 0;
+ am_sinkClass_t temp_SinkClassID = 0;
am_sinkClass_t temp_SinkClassIndex = 0;
- bool result;
- if (sinkClass.sinkClassID != 0 || mFirstStaticSinkClass)
- {
- //check if the ID already exists
- if (existSinkClass(sinkClass.sinkClassID))
- {
- sinkClassID = sinkClass.sinkClassID;
- return (E_ALREADY_EXISTS);
- }
- }
- result = insertSinkClassDB(sinkClass, temp_SinkClassID);
- if( false == result )
- return (E_UNKNOWN);
-
- temp_SinkClassIndex = temp_SinkClassID;
- //if the ID is not created, we add it to the query
- if (sinkClass.sinkClassID == 0 && mFirstStaticSinkClass)
- {
- mFirstStaticSinkClass = false;
- }
- mMappedData.mSinkClassesMap[temp_SinkClassIndex].sinkClassID = temp_SinkClassID;
- sinkClassID = temp_SinkClassID;
-
- //todo:change last_insert implementations for multithreaded usage...
+ bool result;
+ if (sinkClass.sinkClassID != 0 || mFirstStaticSinkClass)
+ {
+ // check if the ID already exists
+ if (existSinkClass(sinkClass.sinkClassID))
+ {
+ sinkClassID = sinkClass.sinkClassID;
+ return (E_ALREADY_EXISTS);
+ }
+ }
+
+ result = insertSinkClassDB(sinkClass, temp_SinkClassID);
+ if ( false == result )
+ {
+ return (E_UNKNOWN);
+ }
+
+ temp_SinkClassIndex = temp_SinkClassID;
+ // if the ID is not created, we add it to the query
+ if (sinkClass.sinkClassID == 0 && mFirstStaticSinkClass)
+ {
+ mFirstStaticSinkClass = false;
+ }
+
+ mMappedData.mSinkClassesMap[temp_SinkClassIndex].sinkClassID = temp_SinkClassID;
+ sinkClassID = temp_SinkClassID;
+
+ // todo:change last_insert implementations for multithreaded usage...
logVerbose("DatabaseHandler::enterSinkClassDB entered new sinkClass");
NOTIFY_OBSERVERS(dboNumberOfSinkClassesChanged)
return (E_OK);
}
-bool CAmDatabaseHandlerMap::insertSourceClassDB(am_sourceClass_t & sourceClassID, const am_SourceClass_s & sourceClass)
+bool CAmDatabaseHandlerMap::insertSourceClassDB(am_sourceClass_t &sourceClassID, const am_SourceClass_s &sourceClass)
{
int16_t nextID = 0;
- if(mMappedData.increaseID(nextID, mMappedData.mCurrentSourceClassesID, sourceClass.sourceClassID))
- {
- sourceClassID = nextID;
- mMappedData.mSourceClassesMap[nextID] = sourceClass;
- mMappedData.mSourceClassesMap[nextID].sourceClassID = nextID;
- return (true);
- }
- else
- {
- sourceClassID = 0;
- logVerbose(__METHOD_NAME__,"Max limit reached.");
- return (false);
- }
+ if (mMappedData.increaseID(nextID, mMappedData.mCurrentSourceClassesID, sourceClass.sourceClassID))
+ {
+ sourceClassID = nextID;
+ mMappedData.mSourceClassesMap[nextID] = sourceClass;
+ mMappedData.mSourceClassesMap[nextID].sourceClassID = nextID;
+ return (true);
+ }
+ else
+ {
+ sourceClassID = 0;
+ logVerbose(__METHOD_NAME__, "Max limit reached.");
+ return (false);
+ }
}
-am_Error_e CAmDatabaseHandlerMap::enterSourceClassDB(am_sourceClass_t & sourceClassID, const am_SourceClass_s & sourceClass)
+am_Error_e CAmDatabaseHandlerMap::enterSourceClassDB(am_sourceClass_t &sourceClassID, const am_SourceClass_s &sourceClass)
{
- if(sourceClass.sourceClassID>=DYNAMIC_ID_BOUNDARY)
+ if (sourceClass.sourceClassID >= DYNAMIC_ID_BOUNDARY)
{
- logError(__METHOD_NAME__,"sourceClassID must be <",DYNAMIC_ID_BOUNDARY);
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "sourceClassID must be <", DYNAMIC_ID_BOUNDARY);
+ return (E_NOT_POSSIBLE);
}
- if(sourceClass.name.empty())
+ if (sourceClass.name.empty())
{
- logError(__METHOD_NAME__,"name must not be empty");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "name must not be empty");
+ return (E_NOT_POSSIBLE);
}
-
- am_sourceClass_t temp_SourceClassID = 0;
+ am_sourceClass_t temp_SourceClassID = 0;
am_sourceClass_t temp_SourceClassIndex = 0;
- bool result;
- if (sourceClass.sourceClassID != 0 || mFirstStaticSourceClass)
- {
- //check if the ID already exists
- if (existSourceClass(sourceClass.sourceClassID))
- {
- sourceClassID = sourceClass.sourceClassID;
- return (E_ALREADY_EXISTS);
- }
- }
- result = insertSourceClassDB(temp_SourceClassID, sourceClass);
- if( false == result )
- return (E_UNKNOWN);
-
- temp_SourceClassIndex = temp_SourceClassID;
- //if the ID is not created, we add it to the query
- if (sourceClass.sourceClassID == 0 && mFirstStaticSourceClass)
- {
- mFirstStaticSinkClass = false;
- }
- mMappedData.mSourceClassesMap[temp_SourceClassIndex].sourceClassID = temp_SourceClassID;
- sourceClassID = temp_SourceClassID;
-
- //todo:change last_insert implementations for multithread usage...
+ bool result;
+ if (sourceClass.sourceClassID != 0 || mFirstStaticSourceClass)
+ {
+ // check if the ID already exists
+ if (existSourceClass(sourceClass.sourceClassID))
+ {
+ sourceClassID = sourceClass.sourceClassID;
+ return (E_ALREADY_EXISTS);
+ }
+ }
+
+ result = insertSourceClassDB(temp_SourceClassID, sourceClass);
+ if ( false == result )
+ {
+ return (E_UNKNOWN);
+ }
+
+ temp_SourceClassIndex = temp_SourceClassID;
+ // if the ID is not created, we add it to the query
+ if (sourceClass.sourceClassID == 0 && mFirstStaticSourceClass)
+ {
+ mFirstStaticSinkClass = false;
+ }
+
+ mMappedData.mSourceClassesMap[temp_SourceClassIndex].sourceClassID = temp_SourceClassID;
+ sourceClassID = temp_SourceClassID;
+
+ // todo:change last_insert implementations for multithread usage...
logVerbose("DatabaseHandler::enterSourceClassDB entered new sourceClass");
@@ -1249,13 +1327,13 @@ am_Error_e CAmDatabaseHandlerMap::enterSourceClassDB(am_sourceClass_t & sourceCl
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::enterSystemProperties(const std::vector<am_SystemProperty_s> & listSystemProperties)
+am_Error_e CAmDatabaseHandlerMap::enterSystemProperties(const std::vector<am_SystemProperty_s> &listSystemProperties)
{
- if(listSystemProperties.empty())
- {
- logError(__METHOD_NAME__,"listSystemProperties must not be empty");
- return (E_NOT_POSSIBLE);
- }
+ if (listSystemProperties.empty())
+ {
+ logError(__METHOD_NAME__, "listSystemProperties must not be empty");
+ return (E_NOT_POSSIBLE);
+ }
mMappedData.mSystemProperties = listSystemProperties;
@@ -1263,27 +1341,29 @@ am_Error_e CAmDatabaseHandlerMap::enterSystemProperties(const std::vector<am_Sys
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector<am_connectionID_t>& listConnectionID)
+am_Error_e CAmDatabaseHandlerMap::changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector<am_connectionID_t> &listConnectionID)
{
- if(mainconnectionID==0)
+ if (mainconnectionID == 0)
{
- logError(__METHOD_NAME__,"mainconnectionID must not be 0");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "mainconnectionID must not be 0");
+ return (E_NOT_POSSIBLE);
}
if (!existMainConnection(mainconnectionID))
{
- logError(__METHOD_NAME__,"existMainConnection must exist");
+ logError(__METHOD_NAME__, "existMainConnection must exist");
return (E_NON_EXISTENT);
}
int16_t delay = calculateDelayForRoute(listConnectionID);
- //now we replace the data in the main connection object with the new one
+ // now we replace the data in the main connection object with the new one
mMappedData.mMainConnectionMap[mainconnectionID].listConnectionID = listConnectionID;
- if (changeDelayMainConnection(delay,mainconnectionID) == E_NO_CHANGE)
+ if (changeDelayMainConnection(delay, mainconnectionID) == E_NO_CHANGE)
+ {
logError("DatabaseHandler::changeMainConnectionRouteDB error while changing mainConnectionDelay to ", delay);
+ }
logVerbose("DatabaseHandler::changeMainConnectionRouteDB entered new route:", mainconnectionID);
return (E_OK);
@@ -1291,21 +1371,21 @@ am_Error_e CAmDatabaseHandlerMap::changeMainConnectionRouteDB(const am_mainConne
am_Error_e CAmDatabaseHandlerMap::changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState)
{
- if(mainconnectionID==0)
+ if (mainconnectionID == 0)
{
- logError(__METHOD_NAME__,"mainconnectionID must not be 0");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "mainconnectionID must not be 0");
+ return (E_NOT_POSSIBLE);
}
- if(!(connectionState>=CS_UNKNOWN && connectionState<=CS_MAX))
+ if (!(connectionState >= CS_UNKNOWN && connectionState <= CS_MAX))
{
- logError(__METHOD_NAME__,"connectionState must be valid");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "connectionState must be valid");
+ return (E_NOT_POSSIBLE);
}
if (!existMainConnection(mainconnectionID))
{
- logError(__METHOD_NAME__,"existMainConnection must exist");
+ logError(__METHOD_NAME__, "existMainConnection must exist");
return (E_NON_EXISTENT);
}
@@ -1320,7 +1400,7 @@ am_Error_e CAmDatabaseHandlerMap::changeSinkMainVolumeDB(const am_mainVolume_t m
{
if (!existSink(sinkID))
{
- logError(__METHOD_NAME__,"sinkID must exist");
+ logError(__METHOD_NAME__, "sinkID must exist");
return (E_NON_EXISTENT);
}
@@ -1333,17 +1413,17 @@ am_Error_e CAmDatabaseHandlerMap::changeSinkMainVolumeDB(const am_mainVolume_t m
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::changeSinkAvailabilityDB(const am_Availability_s & availability, const am_sinkID_t sinkID)
+am_Error_e CAmDatabaseHandlerMap::changeSinkAvailabilityDB(const am_Availability_s &availability, const am_sinkID_t sinkID)
{
- if (!(availability.availability>=A_UNKNOWN && availability.availability<=A_MAX))
+ if (!(availability.availability >= A_UNKNOWN && availability.availability <= A_MAX))
{
- logError(__METHOD_NAME__,"availability must be valid");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "availability must be valid");
+ return (E_NOT_POSSIBLE);
}
if (!existSink(sinkID))
{
- logError(__METHOD_NAME__,"sinkID must exist");
+ logError(__METHOD_NAME__, "sinkID must exist");
return (E_NON_EXISTENT);
}
@@ -1353,23 +1433,24 @@ am_Error_e CAmDatabaseHandlerMap::changeSinkAvailabilityDB(const am_Availability
if (sinkVisible(sinkID))
{
- NOTIFY_OBSERVERS2(dboSinkAvailabilityChanged,sinkID, availability)
+ NOTIFY_OBSERVERS2(dboSinkAvailabilityChanged, sinkID, availability)
}
+
return (E_OK);
}
am_Error_e CAmDatabaseHandlerMap::changeDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID)
{
- if(!(domainState>=DS_UNKNOWN && domainState<=DS_MAX))
+ if (!(domainState >= DS_UNKNOWN && domainState <= DS_MAX))
{
- logError(__METHOD_NAME__,"domainState must be valid");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "domainState must be valid");
+ return (E_NOT_POSSIBLE);
}
if (!existDomain(domainID))
{
- logError(__METHOD_NAME__,"domainID must exist");
+ logError(__METHOD_NAME__, "domainID must exist");
return (E_NON_EXISTENT);
}
@@ -1382,15 +1463,15 @@ am_Error_e CAmDatabaseHandlerMap::changeDomainStateDB(const am_DomainState_e dom
am_Error_e CAmDatabaseHandlerMap::changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID)
{
- if(!(muteState>=MS_UNKNOWN && muteState<=MS_MAX))
+ if (!(muteState >= MS_UNKNOWN && muteState <= MS_MAX))
{
- logError(__METHOD_NAME__,"muteState must be valid");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "muteState must be valid");
+ return (E_NOT_POSSIBLE);
}
if (!existSink(sinkID))
{
- logError(__METHOD_NAME__,"sinkID must exist");
+ logError(__METHOD_NAME__, "sinkID must exist");
return (E_NON_EXISTENT);
}
@@ -1403,52 +1484,60 @@ am_Error_e CAmDatabaseHandlerMap::changeSinkMuteStateDB(const am_MuteState_e mut
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sinkID_t sinkID)
+am_Error_e CAmDatabaseHandlerMap::changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s &soundProperty, const am_sinkID_t sinkID)
{
if (!existSink(sinkID))
{
- logError(__METHOD_NAME__,"sinkID must exist");
+ logError(__METHOD_NAME__, "sinkID must exist");
return (E_NON_EXISTENT);
}
- am_Sink_Database_s & sink = mMappedData.mSinkMap[sinkID];
+
+ am_Sink_Database_s &sink = mMappedData.mSinkMap[sinkID];
std::vector<am_MainSoundProperty_s>::iterator elementIterator = sink.listMainSoundProperties.begin();
- for (;elementIterator != sink.listMainSoundProperties.end(); ++elementIterator)
- {
- if (elementIterator->type == soundProperty.type)
- {
- DB_COND_UPDATE_RIE(elementIterator->value, soundProperty.value);
- if(sink.cacheMainSoundProperties.size())
- sink.cacheMainSoundProperties[soundProperty.type] = soundProperty.value;
- break;
- }
- }
+ for (; elementIterator != sink.listMainSoundProperties.end(); ++elementIterator)
+ {
+ if (elementIterator->type == soundProperty.type)
+ {
+ DB_COND_UPDATE_RIE(elementIterator->value, soundProperty.value);
+ if (sink.cacheMainSoundProperties.size())
+ {
+ sink.cacheMainSoundProperties[soundProperty.type] = soundProperty.value;
+ }
+
+ break;
+ }
+ }
logVerbose("DatabaseHandler::changeMainSinkSoundPropertyDB changed MainSinkSoundProperty of sink:", sinkID, "type:", soundProperty.type, "to:", soundProperty.value);
NOTIFY_OBSERVERS2(dboMainSinkSoundPropertyChanged, sinkID, soundProperty)
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sourceID_t sourceID)
+am_Error_e CAmDatabaseHandlerMap::changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s &soundProperty, const am_sourceID_t sourceID)
{
if (!existSource(sourceID))
{
- logError(__METHOD_NAME__,"sourceID must exist");
+ logError(__METHOD_NAME__, "sourceID must exist");
return (E_NON_EXISTENT);
}
- am_Source_Database_s & source = mMappedData.mSourceMap.at(sourceID);
+
+ am_Source_Database_s &source = mMappedData.mSourceMap.at(sourceID);
std::vector<am_MainSoundProperty_s>::iterator elementIterator = source.listMainSoundProperties.begin();
- for (;elementIterator != source.listMainSoundProperties.end(); ++elementIterator)
- {
- if (elementIterator->type == soundProperty.type)
- {
- DB_COND_UPDATE_RIE(elementIterator->value, soundProperty.value);
- if(source.cacheMainSoundProperties.size())
- source.cacheMainSoundProperties[soundProperty.type] = soundProperty.value;
- break;
- }
- }
+ for (; elementIterator != source.listMainSoundProperties.end(); ++elementIterator)
+ {
+ if (elementIterator->type == soundProperty.type)
+ {
+ DB_COND_UPDATE_RIE(elementIterator->value, soundProperty.value);
+ if (source.cacheMainSoundProperties.size())
+ {
+ source.cacheMainSoundProperties[soundProperty.type] = soundProperty.value;
+ }
+
+ break;
+ }
+ }
logVerbose("DatabaseHandler::changeMainSourceSoundPropertyDB changed MainSinkSoundProperty of source:", sourceID, "type:", soundProperty.type, "to:", soundProperty.value);
@@ -1456,17 +1545,17 @@ am_Error_e CAmDatabaseHandlerMap::changeMainSourceSoundPropertyDB(const am_MainS
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::changeSourceAvailabilityDB(const am_Availability_s & availability, const am_sourceID_t sourceID)
+am_Error_e CAmDatabaseHandlerMap::changeSourceAvailabilityDB(const am_Availability_s &availability, const am_sourceID_t sourceID)
{
- if(!(availability.availability>=A_UNKNOWN && availability.availability<=A_MAX))
+ if (!(availability.availability >= A_UNKNOWN && availability.availability <= A_MAX))
{
- logError(__METHOD_NAME__,"availability must be valid");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "availability must be valid");
+ return (E_NOT_POSSIBLE);
}
if (!existSource(sourceID))
{
- logError(__METHOD_NAME__,"sourceID must exist");
+ logError(__METHOD_NAME__, "sourceID must exist");
return (E_NON_EXISTENT);
}
@@ -1476,19 +1565,22 @@ am_Error_e CAmDatabaseHandlerMap::changeSourceAvailabilityDB(const am_Availabili
if (sourceVisible(sourceID))
{
- NOTIFY_OBSERVERS2(dboSourceAvailabilityChanged, sourceID, availability)
+ NOTIFY_OBSERVERS2(dboSourceAvailabilityChanged, sourceID, availability)
}
+
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::changeSystemPropertyDB(const am_SystemProperty_s & property)
+am_Error_e CAmDatabaseHandlerMap::changeSystemPropertyDB(const am_SystemProperty_s &property)
{
std::vector<am_SystemProperty_s>::iterator elementIterator = mMappedData.mSystemProperties.begin();
- for (;elementIterator != mMappedData.mSystemProperties.end(); ++elementIterator)
- {
- if (elementIterator->type == property.type)
- DB_COND_UPDATE_RIE(elementIterator->value, property.value);
- }
+ for (; elementIterator != mMappedData.mSystemProperties.end(); ++elementIterator)
+ {
+ if (elementIterator->type == property.type)
+ {
+ DB_COND_UPDATE_RIE(elementIterator->value, property.value);
+ }
+ }
logVerbose("DatabaseHandler::changeSystemPropertyDB changed system property");
@@ -1502,16 +1594,19 @@ am_Error_e CAmDatabaseHandlerMap::removeMainConnectionDB(const am_mainConnection
if (!existMainConnection(mainConnectionID))
{
- logError(__METHOD_NAME__,"mainConnectionID must exist");
+ logError(__METHOD_NAME__, "mainConnectionID must exist");
return (E_NON_EXISTENT);
}
DB_COND_UPDATE_INIT;
DB_COND_UPDATE(mMappedData.mMainConnectionMap[mainConnectionID].mainConnectionID, CS_DISCONNECTED);
if (DB_COND_ISMODIFIED)
+ {
NOTIFY_OBSERVERS2(dboMainConnectionStateChanged, mainConnectionID, CS_DISCONNECTED)
- mMappedData.mMainConnectionMap.erase(mainConnectionID);
+ mMappedData.mMainConnectionMap.erase(mainConnectionID);
+ }
+
logVerbose("DatabaseHandler::removeMainConnectionDB removed:", mainConnectionID);
NOTIFY_OBSERVERS1(dboRemovedMainConnection, mainConnectionID)
@@ -1523,7 +1618,7 @@ am_Error_e CAmDatabaseHandlerMap::removeSinkDB(const am_sinkID_t sinkID)
if (!existSink(sinkID))
{
- logError(__METHOD_NAME__,"sinkID must exist");
+ logError(__METHOD_NAME__, "sinkID must exist");
return (E_NON_EXISTENT);
}
@@ -1531,7 +1626,7 @@ am_Error_e CAmDatabaseHandlerMap::removeSinkDB(const am_sinkID_t sinkID)
mMappedData.mSinkMap.erase(sinkID);
// todo: Check the tables SinkMainSoundProperty and SinkMainNotificationConfiguration with 'visible' set to true
- //if visible is true then delete SinkMainSoundProperty and SinkMainNotificationConfiguration ????
+ // if visible is true then delete SinkMainSoundProperty and SinkMainNotificationConfiguration ????
logVerbose("DatabaseHandler::removeSinkDB removed:", sinkID);
NOTIFY_OBSERVERS2(dboRemovedSink, sinkID, visible)
@@ -1544,7 +1639,7 @@ am_Error_e CAmDatabaseHandlerMap::removeSourceDB(const am_sourceID_t sourceID)
if (!existSource(sourceID))
{
- logError(__METHOD_NAME__,"sourceID must exist");
+ logError(__METHOD_NAME__, "sourceID must exist");
return (E_NON_EXISTENT);
}
@@ -1553,7 +1648,7 @@ am_Error_e CAmDatabaseHandlerMap::removeSourceDB(const am_sourceID_t sourceID)
mMappedData.mSourceMap.erase(sourceID);
// todo: Check the tables SourceMainSoundProperty and SourceMainNotificationConfiguration with 'visible' set to true
- //if visible is true then delete SourceMainSoundProperty and SourceMainNotificationConfiguration ????
+ // if visible is true then delete SourceMainSoundProperty and SourceMainNotificationConfiguration ????
logVerbose("DatabaseHandler::removeSourceDB removed:", sourceID);
NOTIFY_OBSERVERS2(dboRemovedSource, sourceID, visible)
@@ -1565,7 +1660,7 @@ am_Error_e CAmDatabaseHandlerMap::removeGatewayDB(const am_gatewayID_t gatewayID
if (!existGateway(gatewayID))
{
- logError(__METHOD_NAME__,"gatewayID must exist");
+ logError(__METHOD_NAME__, "gatewayID must exist");
return (E_NON_EXISTENT);
}
@@ -1581,7 +1676,7 @@ am_Error_e CAmDatabaseHandlerMap::removeConverterDB(const am_converterID_t conve
if (!existConverter(converterID))
{
- logError(__METHOD_NAME__,"converterID must exist");
+ logError(__METHOD_NAME__, "converterID must exist");
return (E_NON_EXISTENT);
}
@@ -1597,9 +1692,10 @@ am_Error_e CAmDatabaseHandlerMap::removeCrossfaderDB(const am_crossfaderID_t cro
if (!existCrossFader(crossfaderID))
{
- logError(__METHOD_NAME__,"crossfaderID must exist");
+ logError(__METHOD_NAME__, "crossfaderID must exist");
return (E_NON_EXISTENT);
}
+
mMappedData.mCrossfaderMap.erase(crossfaderID);
logVerbose("DatabaseHandler::removeCrossfaderDB removed:", crossfaderID);
@@ -1613,9 +1709,10 @@ am_Error_e CAmDatabaseHandlerMap::removeDomainDB(const am_domainID_t domainID)
if (!existDomain(domainID))
{
- logError(__METHOD_NAME__,"domainID must exist");
+ logError(__METHOD_NAME__, "domainID must exist");
return (E_NON_EXISTENT);
}
+
mMappedData.mDomainMap.erase(domainID);
logVerbose("DatabaseHandler::removeDomainDB removed:", domainID);
@@ -1629,7 +1726,7 @@ am_Error_e CAmDatabaseHandlerMap::removeSinkClassDB(const am_sinkClass_t sinkCla
if (!existSinkClass(sinkClassID))
{
- logError(__METHOD_NAME__,"sinkClassID must exist");
+ logError(__METHOD_NAME__, "sinkClassID must exist");
return (E_NON_EXISTENT);
}
@@ -1645,7 +1742,7 @@ am_Error_e CAmDatabaseHandlerMap::removeSourceClassDB(const am_sourceClass_t sou
if (!existSourceClass(sourceClassID))
{
- logError(__METHOD_NAME__,"sourceClassID must exist");
+ logError(__METHOD_NAME__, "sourceClassID must exist");
return (E_NON_EXISTENT);
}
@@ -1659,7 +1756,7 @@ am_Error_e CAmDatabaseHandlerMap::removeConnection(const am_connectionID_t conne
{
if (!existConnectionID(connectionID))
{
- logError(__METHOD_NAME__,"connectionID must exist",connectionID);
+ logError(__METHOD_NAME__, "connectionID must exist", connectionID);
return (E_NON_EXISTENT);
}
@@ -1669,87 +1766,95 @@ am_Error_e CAmDatabaseHandlerMap::removeConnection(const am_connectionID_t conne
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s & classInfo) const
+am_Error_e CAmDatabaseHandlerMap::getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s &classInfo) const
{
if (!existSource(sourceID))
{
- logWarning(__METHOD_NAME__,"sourceID must exist");
+ logWarning(__METHOD_NAME__, "sourceID must exist");
return (E_NON_EXISTENT);
}
+
am_Source_Database_s source = mMappedData.mSourceMap.at(sourceID);
- classInfo.sourceClassID = source.sourceClassID;
+ classInfo.sourceClassID = source.sourceClassID;
if (!existSourceClass(classInfo.sourceClassID))
{
return (E_NON_EXISTENT);
}
+
am_SourceClass_s tmpClass = mMappedData.mSourceClassesMap.at(classInfo.sourceClassID);
classInfo = tmpClass;
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s & sinkData) const
+am_Error_e CAmDatabaseHandlerMap::getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s &sinkData) const
{
if (!existSink(sinkID))
{
- logWarning(__METHOD_NAME__,"sinkID",sinkID,"does not exist");
+ logWarning(__METHOD_NAME__, "sinkID", sinkID, "does not exist");
return (E_NON_EXISTENT);
}
am_Sink_Database_s mappedSink = mMappedData.mSinkMap.at(sinkID);
- if( true == mappedSink.reserved )
- return (E_NON_EXISTENT);
- sinkData = mappedSink;
+ if ( true == mappedSink.reserved )
+ {
+ return (E_NON_EXISTENT);
+ }
+
+ sinkData = mappedSink;
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s & sourceData) const
+am_Error_e CAmDatabaseHandlerMap::getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s &sourceData) const
{
if (!existSource(sourceID))
{
- logWarning(__METHOD_NAME__,"sourceID",sourceID,"does not exist");
+ logWarning(__METHOD_NAME__, "sourceID", sourceID, "does not exist");
return (E_NON_EXISTENT);
}
am_Source_Database_s mappedSource = mMappedData.mSourceMap.at(sourceID);
- if( true == mappedSource.reserved )
- return (E_NON_EXISTENT);
+ if ( true == mappedSource.reserved )
+ {
+ return (E_NON_EXISTENT);
+ }
sourceData = mappedSource;
return (E_OK);
}
-am_Error_e am::CAmDatabaseHandlerMap::getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s & mainConnectionData) const
+am_Error_e am::CAmDatabaseHandlerMap::getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s &mainConnectionData) const
{
if (!existMainConnection(mainConnectionID))
{
- logError(__METHOD_NAME__,"mainConnectionID must exist");
+ logError(__METHOD_NAME__, "mainConnectionID must exist");
return (E_NON_EXISTENT);
}
+
am_MainConnection_s temp = mMappedData.mMainConnectionMap.at(mainConnectionID);
mainConnectionData = temp;
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::changeSinkClassInfoDB(const am_SinkClass_s& sinkClass)
+am_Error_e CAmDatabaseHandlerMap::changeSinkClassInfoDB(const am_SinkClass_s &sinkClass)
{
- if(sinkClass.listClassProperties.empty())
+ if (sinkClass.listClassProperties.empty())
{
- logError(__METHOD_NAME__,"listClassProperties must not be empty");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "listClassProperties must not be empty");
+ return (E_NOT_POSSIBLE);
}
- //check if the ID already exists
+ // check if the ID already exists
if (!existSinkClass(sinkClass.sinkClassID))
{
- logError(__METHOD_NAME__,"sinkClassID must exist");
+ logError(__METHOD_NAME__, "sinkClassID must exist");
return (E_NON_EXISTENT);
}
@@ -1759,18 +1864,18 @@ am_Error_e CAmDatabaseHandlerMap::changeSinkClassInfoDB(const am_SinkClass_s& si
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::changeSourceClassInfoDB(const am_SourceClass_s& sourceClass)
+am_Error_e CAmDatabaseHandlerMap::changeSourceClassInfoDB(const am_SourceClass_s &sourceClass)
{
- if(sourceClass.listClassProperties.empty())
+ if (sourceClass.listClassProperties.empty())
{
- logError(__METHOD_NAME__,"listClassProperties must not be empty");
- return (E_NOT_POSSIBLE);
+ logError(__METHOD_NAME__, "listClassProperties must not be empty");
+ return (E_NOT_POSSIBLE);
}
- //check if the ID already exists
+ // check if the ID already exists
if (!existSourceClass(sourceClass.sourceClassID))
{
- logError(__METHOD_NAME__,"sourceClassID must exist");
+ logError(__METHOD_NAME__, "sourceClassID must exist");
return (E_NON_EXISTENT);
}
@@ -1780,33 +1885,35 @@ am_Error_e CAmDatabaseHandlerMap::changeSourceClassInfoDB(const am_SourceClass_s
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s & sinkClass) const
+am_Error_e CAmDatabaseHandlerMap::getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s &sinkClass) const
{
if (!existSink(sinkID))
{
- logWarning(__METHOD_NAME__,"sinkID must exist");
+ logWarning(__METHOD_NAME__, "sinkID must exist");
return (E_NON_EXISTENT);
}
+
am_Sink_Database_s sink = mMappedData.mSinkMap.at(sinkID);
- sinkClass.sinkClassID = sink.sinkClassID;
+ sinkClass.sinkClassID = sink.sinkClassID;
if (!existSinkClass(sinkClass.sinkClassID))
{
- logWarning(__METHOD_NAME__,"sinkClassID must exist");
+ logWarning(__METHOD_NAME__, "sinkClassID must exist");
return (E_NON_EXISTENT);
}
+
am_SinkClass_s tmpSinkClass = mMappedData.mSinkClassesMap.at(sinkClass.sinkClassID);
sinkClass = tmpSinkClass;
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s & gatewayData) const
+am_Error_e CAmDatabaseHandlerMap::getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s &gatewayData) const
{
if (!existGateway(gatewayID))
{
- logWarning(__METHOD_NAME__,"gatewayID must exist");
+ logWarning(__METHOD_NAME__, "gatewayID must exist");
return (E_NON_EXISTENT);
}
@@ -1816,11 +1923,11 @@ am_Error_e CAmDatabaseHandlerMap::getGatewayInfoDB(const am_gatewayID_t gatewayI
}
-am_Error_e CAmDatabaseHandlerMap::getConverterInfoDB(const am_converterID_t converterID, am_Converter_s& converterData) const
+am_Error_e CAmDatabaseHandlerMap::getConverterInfoDB(const am_converterID_t converterID, am_Converter_s &converterData) const
{
if (!existConverter(converterID))
{
- logWarning(__METHOD_NAME__,"converterID must exist");
+ logWarning(__METHOD_NAME__, "converterID must exist");
return (E_NON_EXISTENT);
}
@@ -1830,11 +1937,11 @@ am_Error_e CAmDatabaseHandlerMap::getConverterInfoDB(const am_converterID_t conv
}
-am_Error_e CAmDatabaseHandlerMap::getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s & crossfaderData) const
+am_Error_e CAmDatabaseHandlerMap::getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s &crossfaderData) const
{
if (!existCrossFader(crossfaderID))
{
- logWarning(__METHOD_NAME__,"crossfaderID must exist");
+ logWarning(__METHOD_NAME__, "crossfaderID must exist");
return (E_NON_EXISTENT);
}
@@ -1843,411 +1950,442 @@ am_Error_e CAmDatabaseHandlerMap::getCrossfaderInfoDB(const am_crossfaderID_t cr
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t> & listSinkID) const
+am_Error_e CAmDatabaseHandlerMap::getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t> &listSinkID) const
{
listSinkID.clear();
if (!existDomain(domainID))
{
- logWarning(__METHOD_NAME__,"domainID must exist");
+ logWarning(__METHOD_NAME__, "domainID must exist");
return (E_NON_EXISTENT);
}
std::unordered_map<am_sinkID_t, am_Sink_Database_s>::const_iterator elementIterator = mMappedData.mSinkMap.begin();
- for (;elementIterator != mMappedData.mSinkMap.end(); ++elementIterator)
- {
- if (0==elementIterator->second.reserved && domainID==elementIterator->second.domainID)
- listSinkID.push_back(elementIterator->second.sinkID);
- }
+ for (; elementIterator != mMappedData.mSinkMap.end(); ++elementIterator)
+ {
+ if (0 == elementIterator->second.reserved && domainID == elementIterator->second.domainID)
+ {
+ listSinkID.push_back(elementIterator->second.sinkID);
+ }
+ }
+
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t> & listSourceID) const
+am_Error_e CAmDatabaseHandlerMap::getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t> &listSourceID) const
{
listSourceID.clear();
if (!existDomain(domainID))
{
- logWarning(__METHOD_NAME__,"domainID must exist");
+ logWarning(__METHOD_NAME__, "domainID must exist");
return (E_NON_EXISTENT);
}
- AmMapSource::const_iterator elementIterator = mMappedData.mSourceMap.begin();
- for (;elementIterator != mMappedData.mSourceMap.end(); ++elementIterator)
- {
- if (0==elementIterator->second.reserved && domainID==elementIterator->second.domainID)
- listSourceID.push_back(elementIterator->second.sourceID);
- }
+
+ AmMapSource::const_iterator elementIterator = mMappedData.mSourceMap.begin();
+ for (; elementIterator != mMappedData.mSourceMap.end(); ++elementIterator)
+ {
+ if (0 == elementIterator->second.reserved && domainID == elementIterator->second.domainID)
+ {
+ listSourceID.push_back(elementIterator->second.sourceID);
+ }
+ }
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t> & listCrossfader) const
+am_Error_e CAmDatabaseHandlerMap::getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t> &listCrossfader) const
{
listCrossfader.clear();
if (!existDomain(domainID))
{
- logWarning(__METHOD_NAME__,"domainID must exist");
+ logWarning(__METHOD_NAME__, "domainID must exist");
return (E_NON_EXISTENT);
}
AmMapSource::const_iterator sourceIterator = mMappedData.mSourceMap.begin();
- for (;sourceIterator != mMappedData.mSourceMap.end(); ++sourceIterator)
- {
- if (domainID==sourceIterator->second.domainID)
- {
- AmMapCrossfader::const_iterator elementIterator = mMappedData.mCrossfaderMap.begin();
- for (;elementIterator != mMappedData.mCrossfaderMap.end(); ++elementIterator)
- {
- if ( sourceIterator->second.sourceID==elementIterator->second.sourceID )
- listCrossfader.push_back(elementIterator->second.crossfaderID);
- }
- }
- }
+ for (; sourceIterator != mMappedData.mSourceMap.end(); ++sourceIterator)
+ {
+ if (domainID == sourceIterator->second.domainID)
+ {
+ AmMapCrossfader::const_iterator elementIterator = mMappedData.mCrossfaderMap.begin();
+ for (; elementIterator != mMappedData.mCrossfaderMap.end(); ++elementIterator)
+ {
+ if ( sourceIterator->second.sourceID == elementIterator->second.sourceID )
+ {
+ listCrossfader.push_back(elementIterator->second.crossfaderID);
+ }
+ }
+ }
+ }
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t> & listGatewaysID) const
+am_Error_e CAmDatabaseHandlerMap::getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t> &listGatewaysID) const
{
listGatewaysID.clear();
if (!existDomain(domainID))
{
- logWarning(__METHOD_NAME__,"domainID must exist");
+ logWarning(__METHOD_NAME__, "domainID must exist");
return (E_NON_EXISTENT);
}
AmMapGateway::const_iterator elementIterator = mMappedData.mGatewayMap.begin();
- for (;elementIterator != mMappedData.mGatewayMap.end(); ++elementIterator)
- {
- if (domainID==elementIterator->second.controlDomainID)
- listGatewaysID.push_back(elementIterator->second.gatewayID);
- }
+ for (; elementIterator != mMappedData.mGatewayMap.end(); ++elementIterator)
+ {
+ if (domainID == elementIterator->second.controlDomainID)
+ {
+ listGatewaysID.push_back(elementIterator->second.gatewayID);
+ }
+ }
+
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListConvertersOfDomain(const am_domainID_t domainID, std::vector<am_converterID_t>& listConvertersID) const
+am_Error_e CAmDatabaseHandlerMap::getListConvertersOfDomain(const am_domainID_t domainID, std::vector<am_converterID_t> &listConvertersID) const
{
listConvertersID.clear();
if (!existDomain(domainID))
{
- logWarning(__METHOD_NAME__,"domainID must exist");
+ logWarning(__METHOD_NAME__, "domainID must exist");
return (E_NON_EXISTENT);
}
AmMapConverter::const_iterator elementIterator = mMappedData.mConverterMap.begin();
- for (;elementIterator != mMappedData.mConverterMap.end(); ++elementIterator)
- {
- if (domainID==elementIterator->second.domainID)
- listConvertersID.push_back(elementIterator->second.converterID);
- }
+ for (; elementIterator != mMappedData.mConverterMap.end(); ++elementIterator)
+ {
+ if (domainID == elementIterator->second.domainID)
+ {
+ listConvertersID.push_back(elementIterator->second.converterID);
+ }
+ }
+
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListMainConnections(std::vector<am_MainConnection_s> & listMainConnections) const
+am_Error_e CAmDatabaseHandlerMap::getListMainConnections(std::vector<am_MainConnection_s> &listMainConnections) const
{
listMainConnections.clear();
AmMapMainConnection::const_iterator elementIterator = mMappedData.mMainConnectionMap.begin();
- for (;elementIterator != mMappedData.mMainConnectionMap.end(); ++elementIterator)
+ for (; elementIterator != mMappedData.mMainConnectionMap.end(); ++elementIterator)
{
- listMainConnections.push_back(elementIterator->second);
+ listMainConnections.push_back(elementIterator->second);
}
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListDomains(std::vector<am_Domain_s> & listDomains) const
+am_Error_e CAmDatabaseHandlerMap::getListDomains(std::vector<am_Domain_s> &listDomains) const
{
listDomains.clear();
AmMapDomain::const_iterator elementIterator = mMappedData.mDomainMap.begin();
- for (;elementIterator != mMappedData.mDomainMap.end(); ++elementIterator)
- {
- if( 0==elementIterator->second.reserved )
- listDomains.push_back(elementIterator->second);
- }
+ for (; elementIterator != mMappedData.mDomainMap.end(); ++elementIterator)
+ {
+ if ( 0 == elementIterator->second.reserved )
+ {
+ listDomains.push_back(elementIterator->second);
+ }
+ }
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListConnections(std::vector<am_Connection_s> & listConnections) const
+am_Error_e CAmDatabaseHandlerMap::getListConnections(std::vector<am_Connection_s> &listConnections) const
{
listConnections.clear();
AmMapConnection::const_iterator elementIterator = mMappedData.mConnectionMap.begin();
- for (;elementIterator != mMappedData.mConnectionMap.end(); ++elementIterator)
- {
- if( 0==elementIterator->second.reserved )
- listConnections.push_back(elementIterator->second);
- }
+ for (; elementIterator != mMappedData.mConnectionMap.end(); ++elementIterator)
+ {
+ if ( 0 == elementIterator->second.reserved )
+ {
+ listConnections.push_back(elementIterator->second);
+ }
+ }
- return (E_OK);
+ return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListConnectionsReserved(std::vector<am_Connection_s> & listConnections) const
+am_Error_e CAmDatabaseHandlerMap::getListConnectionsReserved(std::vector<am_Connection_s> &listConnections) const
{
listConnections.clear();
AmMapConnection::const_iterator elementIterator = mMappedData.mConnectionMap.begin();
- for (;elementIterator != mMappedData.mConnectionMap.end(); ++elementIterator)
- {
- if( elementIterator->second.reserved )
- listConnections.push_back(elementIterator->second);
- }
+ for (; elementIterator != mMappedData.mConnectionMap.end(); ++elementIterator)
+ {
+ if ( elementIterator->second.reserved )
+ {
+ listConnections.push_back(elementIterator->second);
+ }
+ }
- return (E_OK);
+ return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListSinks(std::vector<am_Sink_s> & listSinks) const
+am_Error_e CAmDatabaseHandlerMap::getListSinks(std::vector<am_Sink_s> &listSinks) const
{
listSinks.clear();
- std::for_each(mMappedData.mSinkMap.begin(), mMappedData.mSinkMap.end(), [&](const std::pair<am_sinkID_t, am_Sink_Database_s>& ref) {
- if( 0==ref.second.reserved )
- listSinks.push_back(ref.second);
- });
+ std::for_each(mMappedData.mSinkMap.begin(), mMappedData.mSinkMap.end(), [&](const std::pair<am_sinkID_t, am_Sink_Database_s> &ref) {
+ if ( 0 == ref.second.reserved )
+ {
+ listSinks.push_back(ref.second);
+ }
+ });
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListSources(std::vector<am_Source_s> & listSources) const
+am_Error_e CAmDatabaseHandlerMap::getListSources(std::vector<am_Source_s> &listSources) const
{
listSources.clear();
- std::for_each(mMappedData.mSourceMap.begin(), mMappedData.mSourceMap.end(), [&](const std::pair<am_sourceID_t, am_Source_Database_s>& ref) {
- if( 0==ref.second.reserved )
- {
- listSources.push_back(ref.second);
- }
- });
+ std::for_each(mMappedData.mSourceMap.begin(), mMappedData.mSourceMap.end(), [&](const std::pair<am_sourceID_t, am_Source_Database_s> &ref) {
+ if ( 0 == ref.second.reserved )
+ {
+ listSources.push_back(ref.second);
+ }
+ });
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListSourceClasses(std::vector<am_SourceClass_s> & listSourceClasses) const
+am_Error_e CAmDatabaseHandlerMap::getListSourceClasses(std::vector<am_SourceClass_s> &listSourceClasses) const
{
listSourceClasses.clear();
- std::for_each(mMappedData.mSourceClassesMap.begin(), mMappedData.mSourceClassesMap.end(), [&](const std::pair<am_sourceClass_t, am_SourceClass_s>& ref) {
- listSourceClasses.push_back(ref.second);
- });
+ std::for_each(mMappedData.mSourceClassesMap.begin(), mMappedData.mSourceClassesMap.end(), [&](const std::pair<am_sourceClass_t, am_SourceClass_s> &ref) {
+ listSourceClasses.push_back(ref.second);
+ });
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListCrossfaders(std::vector<am_Crossfader_s> & listCrossfaders) const
+am_Error_e CAmDatabaseHandlerMap::getListCrossfaders(std::vector<am_Crossfader_s> &listCrossfaders) const
{
listCrossfaders.clear();
- std::for_each(mMappedData.mCrossfaderMap.begin(), mMappedData.mCrossfaderMap.end(), [&](const std::pair<am_crossfaderID_t, am_Crossfader_s>& ref) {
- listCrossfaders.push_back(ref.second);
- });
+ std::for_each(mMappedData.mCrossfaderMap.begin(), mMappedData.mCrossfaderMap.end(), [&](const std::pair<am_crossfaderID_t, am_Crossfader_s> &ref) {
+ listCrossfaders.push_back(ref.second);
+ });
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListGateways(std::vector<am_Gateway_s> & listGateways) const
+am_Error_e CAmDatabaseHandlerMap::getListGateways(std::vector<am_Gateway_s> &listGateways) const
{
listGateways.clear();
- std::for_each(mMappedData.mGatewayMap.begin(), mMappedData.mGatewayMap.end(), [&](const std::pair<am_gatewayID_t, am_Gateway_s>& ref) {
- listGateways.push_back(ref.second);
- });
+ std::for_each(mMappedData.mGatewayMap.begin(), mMappedData.mGatewayMap.end(), [&](const std::pair<am_gatewayID_t, am_Gateway_s> &ref) {
+ listGateways.push_back(ref.second);
+ });
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListConverters(std::vector<am_Converter_s> & listConverters) const
+am_Error_e CAmDatabaseHandlerMap::getListConverters(std::vector<am_Converter_s> &listConverters) const
{
- listConverters.clear();
+ listConverters.clear();
- std::for_each(mMappedData.mConverterMap.begin(), mMappedData.mConverterMap.end(), [&](const std::pair<am_converterID_t, am_Converter_s>& ref) {
- listConverters.push_back(ref.second);
- });
+ std::for_each(mMappedData.mConverterMap.begin(), mMappedData.mConverterMap.end(), [&](const std::pair<am_converterID_t, am_Converter_s> &ref) {
+ listConverters.push_back(ref.second);
+ });
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListSinkClasses(std::vector<am_SinkClass_s> & listSinkClasses) const
+am_Error_e CAmDatabaseHandlerMap::getListSinkClasses(std::vector<am_SinkClass_s> &listSinkClasses) const
{
listSinkClasses.clear();
- std::for_each(mMappedData.mSinkClassesMap.begin(), mMappedData.mSinkClassesMap.end(), [&](const std::pair<am_gatewayID_t, am_SinkClass_s>& ref) {
- listSinkClasses.push_back(ref.second);
- });
+ std::for_each(mMappedData.mSinkClassesMap.begin(), mMappedData.mSinkClassesMap.end(), [&](const std::pair<am_gatewayID_t, am_SinkClass_s> &ref) {
+ listSinkClasses.push_back(ref.second);
+ });
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListVisibleMainConnections(std::vector<am_MainConnectionType_s> & listConnections) const
+am_Error_e CAmDatabaseHandlerMap::getListVisibleMainConnections(std::vector<am_MainConnectionType_s> &listConnections) const
{
listConnections.clear();
- std::for_each(mMappedData.mMainConnectionMap.begin(), mMappedData.mMainConnectionMap.end(), [&](const std::pair<am_mainConnectionID_t, am_MainConnection_Database_s>& ref) {
- listConnections.emplace_back();
- ref.second.getMainConnectionType(listConnections.back());
- });
+ std::for_each(mMappedData.mMainConnectionMap.begin(), mMappedData.mMainConnectionMap.end(), [&](const std::pair<am_mainConnectionID_t, am_MainConnection_Database_s> &ref) {
+ listConnections.emplace_back();
+ ref.second.getMainConnectionType(listConnections.back());
+ });
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListMainSinks(std::vector<am_SinkType_s> & listMainSinks) const
+am_Error_e CAmDatabaseHandlerMap::getListMainSinks(std::vector<am_SinkType_s> &listMainSinks) const
{
listMainSinks.clear();
- std::for_each(mMappedData.mSinkMap.begin(), mMappedData.mSinkMap.end(), [&](const std::pair<am_sinkID_t, am_Sink_Database_s>& ref) {
- if( 0==ref.second.reserved && 1==ref.second.visible )
- {
- listMainSinks.emplace_back();
- ref.second.getSinkType(listMainSinks.back());
- }
- });
+ std::for_each(mMappedData.mSinkMap.begin(), mMappedData.mSinkMap.end(), [&](const std::pair<am_sinkID_t, am_Sink_Database_s> &ref) {
+ if ( 0 == ref.second.reserved && 1 == ref.second.visible )
+ {
+ listMainSinks.emplace_back();
+ ref.second.getSinkType(listMainSinks.back());
+ }
+ });
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListMainSources(std::vector<am_SourceType_s> & listMainSources) const
+am_Error_e CAmDatabaseHandlerMap::getListMainSources(std::vector<am_SourceType_s> &listMainSources) const
{
listMainSources.clear();
- std::for_each(mMappedData.mSourceMap.begin(), mMappedData.mSourceMap.end(), [&](const std::pair<am_sourceID_t, am_Source_Database_s>& ref) {
- if( 0==ref.second.reserved && 1==ref.second.visible )
- {
- listMainSources.emplace_back();
- ref.second.getSourceType(listMainSources.back());
- }
- });
+ std::for_each(mMappedData.mSourceMap.begin(), mMappedData.mSourceMap.end(), [&](const std::pair<am_sourceID_t, am_Source_Database_s> &ref) {
+ if ( 0 == ref.second.reserved && 1 == ref.second.visible )
+ {
+ listMainSources.emplace_back();
+ ref.second.getSourceType(listMainSources.back());
+ }
+ });
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s> & listSoundProperties) const
+am_Error_e CAmDatabaseHandlerMap::getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s> &listSoundProperties) const
{
if (!existSink(sinkID))
{
- logWarning(__METHOD_NAME__,"sinkID must exist");
- return E_NON_EXISTENT;
+ logWarning(__METHOD_NAME__, "sinkID must exist");
+ return E_NON_EXISTENT;
}
- const am_Sink_s & sink = mMappedData.mSinkMap.at(sinkID);
+ const am_Sink_s &sink = mMappedData.mSinkMap.at(sinkID);
listSoundProperties = sink.listMainSoundProperties;
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s> & listSourceProperties) const
+am_Error_e CAmDatabaseHandlerMap::getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s> &listSourceProperties) const
{
if (!existSource(sourceID))
{
- logWarning(__METHOD_NAME__,"sourceID must exist");
- return E_NON_EXISTENT;
+ logWarning(__METHOD_NAME__, "sourceID must exist");
+ return E_NON_EXISTENT;
}
- const am_Source_s & source = mMappedData.mSourceMap.at(sourceID);
+
+ const am_Source_s &source = mMappedData.mSourceMap.at(sourceID);
listSourceProperties = source.listMainSoundProperties;
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s>& listSoundproperties) const
+am_Error_e CAmDatabaseHandlerMap::getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s> &listSoundproperties) const
{
if (!existSink(sinkID))
{
- logWarning(__METHOD_NAME__,"sinkID must exist");
- return E_NON_EXISTENT;
+ logWarning(__METHOD_NAME__, "sinkID must exist");
+ return E_NON_EXISTENT;
}
- const am_Sink_Database_s & sink = mMappedData.mSinkMap.at(sinkID);
+ const am_Sink_Database_s &sink = mMappedData.mSinkMap.at(sinkID);
listSoundproperties = sink.listSoundProperties;
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s>& listSoundproperties) const
+am_Error_e CAmDatabaseHandlerMap::getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s> &listSoundproperties) const
{
- if (!existSource(sourceID))
+ if (!existSource(sourceID))
{
- logWarning(__METHOD_NAME__,"sourceID must exist");
- return E_NON_EXISTENT;
+ logWarning(__METHOD_NAME__, "sourceID must exist");
+ return E_NON_EXISTENT;
}
- const am_Source_Database_s & source = mMappedData.mSourceMap.at(sourceID);
- listSoundproperties = source.listSoundProperties;
+ const am_Source_Database_s &source = mMappedData.mSourceMap.at(sourceID);
+ listSoundproperties = source.listSoundProperties;
- return (E_OK);
+ return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListSystemProperties(std::vector<am_SystemProperty_s> & listSystemProperties) const
+am_Error_e CAmDatabaseHandlerMap::getListSystemProperties(std::vector<am_SystemProperty_s> &listSystemProperties) const
{
- listSystemProperties = mMappedData.mSystemProperties;
+ listSystemProperties = mMappedData.mSystemProperties;
return (E_OK);
}
-am_Error_e am::CAmDatabaseHandlerMap::getListSinkConnectionFormats(const am_sinkID_t sinkID, std::vector<am_CustomConnectionFormat_t> & listConnectionFormats) const
+am_Error_e am::CAmDatabaseHandlerMap::getListSinkConnectionFormats(const am_sinkID_t sinkID, std::vector<am_CustomConnectionFormat_t> &listConnectionFormats) const
{
- if (!existSink(sinkID))
- {
- logWarning(__METHOD_NAME__,"sinkID must exist");
- return E_NON_EXISTENT;
- }
- const am_Sink_s & sink = mMappedData.mSinkMap.at(sinkID);
- listConnectionFormats = sink.listConnectionFormats;
+ if (!existSink(sinkID))
+ {
+ logWarning(__METHOD_NAME__, "sinkID must exist");
+ return E_NON_EXISTENT;
+ }
+
+ const am_Sink_s &sink = mMappedData.mSinkMap.at(sinkID);
+ listConnectionFormats = sink.listConnectionFormats;
return (E_OK);
}
-am_Error_e am::CAmDatabaseHandlerMap::getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector<am_CustomConnectionFormat_t> & listConnectionFormats) const
+am_Error_e am::CAmDatabaseHandlerMap::getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector<am_CustomConnectionFormat_t> &listConnectionFormats) const
{
- if (!existSource(sourceID))
- {
- logWarning(__METHOD_NAME__,"sourceID must exist");
- return E_NON_EXISTENT;
- }
- const am_Source_s & source = mMappedData.mSourceMap.at(sourceID);
+ if (!existSource(sourceID))
+ {
+ logWarning(__METHOD_NAME__, "sourceID must exist");
+ return E_NON_EXISTENT;
+ }
+
+ const am_Source_s &source = mMappedData.mSourceMap.at(sourceID);
listConnectionFormats = source.listConnectionFormats;
return (E_OK);
}
-am_Error_e am::CAmDatabaseHandlerMap::getListGatewayConnectionFormats(const am_gatewayID_t gatewayID, std::vector<bool> & listConnectionFormat) const
+am_Error_e am::CAmDatabaseHandlerMap::getListGatewayConnectionFormats(const am_gatewayID_t gatewayID, std::vector<bool> &listConnectionFormat) const
{
- if (!existGateway(gatewayID))
- {
- logWarning(__METHOD_NAME__,"gatewayID must exist");
- return E_NON_EXISTENT;
- }
+ if (!existGateway(gatewayID))
+ {
+ logWarning(__METHOD_NAME__, "gatewayID must exist");
+ return E_NON_EXISTENT;
+ }
+
ListConnectionFormat::const_iterator iter = mListConnectionFormat.begin();
iter = mListConnectionFormat.find(gatewayID);
if (iter == mListConnectionFormat.end())
{
- logWarning("DatabaseHandler::getListGatewayConnectionFormats database error with convertionFormat");
+ logWarning("DatabaseHandler::getListGatewayConnectionFormats database error with convertionFormat");
return E_NON_EXISTENT;
}
+
listConnectionFormat = iter->second;
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t & delay) const
+am_Error_e CAmDatabaseHandlerMap::getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t &delay) const
{
if (!existMainConnection(mainConnectionID))
{
- logWarning(__METHOD_NAME__,"mainConnectionID must exist");
- return E_NON_EXISTENT;
+ logWarning(__METHOD_NAME__, "mainConnectionID must exist");
+ return E_NON_EXISTENT;
}
+
delay = -1;
- const am_MainConnection_s & mainConnection = mMappedData.mMainConnectionMap.at(mainConnectionID);
+ const am_MainConnection_s &mainConnection = mMappedData.mMainConnectionMap.at(mainConnectionID);
delay = mainConnection.delay;
if (delay == -1)
+ {
return (E_NOT_POSSIBLE);
+ }
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::changeDelayMainConnection(const am_timeSync_t & delay, const am_mainConnectionID_t & connectionID)
+am_Error_e CAmDatabaseHandlerMap::changeDelayMainConnection(const am_timeSync_t &delay, const am_mainConnectionID_t &connectionID)
{
if (!existMainConnection(connectionID))
{
- logError(__METHOD_NAME__,"connectionID must exist");
- return E_NON_EXISTENT;
+ logError(__METHOD_NAME__, "connectionID must exist");
+ return E_NON_EXISTENT;
}
+
DB_COND_UPDATE_RIE(mMappedData.mMainConnectionMap[connectionID].delay, delay);
NOTIFY_OBSERVERS2(dboTimingInformationChanged, connectionID, delay)
return (E_OK);
@@ -2260,7 +2398,7 @@ am_Error_e CAmDatabaseHandlerMap::changeDelayMainConnection(const am_timeSync_t
*/
bool CAmDatabaseHandlerMap::existMainConnection(const am_mainConnectionID_t mainConnectionID) const
{
- return existsObjectWithKeyInMap(mainConnectionID, mMappedData.mMainConnectionMap);
+ return existsObjectWithKeyInMap(mainConnectionID, mMappedData.mMainConnectionMap);
}
/**
@@ -2270,11 +2408,13 @@ bool CAmDatabaseHandlerMap::existMainConnection(const am_mainConnectionID_t main
*/
bool CAmDatabaseHandlerMap::existSource(const am_sourceID_t sourceID) const
{
- am_Source_Database_s const * source = objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
- if( NULL!=source )
- return (0==source->reserved);
+ am_Source_Database_s const *source = objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
+ if ( NULL != source )
+ {
+ return (0 == source->reserved);
+ }
- return false;
+ return false;
}
/**
@@ -2283,7 +2423,7 @@ bool CAmDatabaseHandlerMap::existSource(const am_sourceID_t sourceID) const
* @param name the name
* @return true if it exits
*/
-bool CAmDatabaseHandlerMap::existSourceNameOrID(const am_sourceID_t sourceID, const std::string & name) const
+bool CAmDatabaseHandlerMap::existSourceNameOrID(const am_sourceID_t sourceID, const std::string &name) const
{
return sourceWithNameOrID(sourceID, name);
}
@@ -2293,7 +2433,7 @@ bool CAmDatabaseHandlerMap::existSourceNameOrID(const am_sourceID_t sourceID, co
* @param name the name
* @return true if it exits
*/
-bool CAmDatabaseHandlerMap::existSourceName(const std::string & name) const
+bool CAmDatabaseHandlerMap::existSourceName(const std::string &name) const
{
return existSourceNameOrID(mMappedData.mCurrentSourceID.mMax, name);
}
@@ -2305,17 +2445,18 @@ bool CAmDatabaseHandlerMap::existSourceName(const std::string & name) const
*/
bool CAmDatabaseHandlerMap::existSink(const am_sinkID_t sinkID) const
{
- bool returnVal = false;
- AmMapSink::const_iterator elementIterator = mMappedData.mSinkMap.begin();
- for (;elementIterator != mMappedData.mSinkMap.end(); ++elementIterator)
- {
- if( 0==elementIterator->second.reserved &&
- sinkID==elementIterator->second.sinkID)
- {
- returnVal = true;
- break;
- }
- }
+ bool returnVal = false;
+ AmMapSink::const_iterator elementIterator = mMappedData.mSinkMap.begin();
+ for (; elementIterator != mMappedData.mSinkMap.end(); ++elementIterator)
+ {
+ if ( 0 == elementIterator->second.reserved &&
+ sinkID == elementIterator->second.sinkID)
+ {
+ returnVal = true;
+ break;
+ }
+ }
+
return (returnVal);
}
@@ -2325,13 +2466,13 @@ bool CAmDatabaseHandlerMap::existSink(const am_sinkID_t sinkID) const
* @param name the name
* @return source structure if exists.
*/
-const CAmDatabaseHandlerMap::am_Source_Database_s * CAmDatabaseHandlerMap::sourceWithNameOrID(const am_sourceID_t sourceID, const std::string & name) const
+const CAmDatabaseHandlerMap::am_Source_Database_s *CAmDatabaseHandlerMap::sourceWithNameOrID(const am_sourceID_t sourceID, const std::string &name) const
{
- std::function<bool(const CAmDatabaseHandlerMap::am_Source_Database_s & refObject)> comparator = [&](const CAmDatabaseHandlerMap::am_Source_Database_s & source)->bool{
- return ( 0==source.reserved &&
- (sourceID==source.sourceID || name.compare(source.name)==0));
- };
- return objectMatchingPredicate(mMappedData.mSourceMap, comparator);
+ std::function<bool(const CAmDatabaseHandlerMap::am_Source_Database_s &refObject)> comparator = [&](const CAmDatabaseHandlerMap::am_Source_Database_s &source) -> bool {
+ return (0 == source.reserved &&
+ (sourceID == source.sourceID || name.compare(source.name) == 0));
+ };
+ return objectMatchingPredicate(mMappedData.mSourceMap, comparator);
}
/**
@@ -2340,13 +2481,13 @@ const CAmDatabaseHandlerMap::am_Source_Database_s * CAmDatabaseHandlerMap::sour
* @param name the name
* @return sink structure if exists.
*/
-const CAmDatabaseHandlerMap::am_Sink_Database_s * CAmDatabaseHandlerMap::sinkWithNameOrID(const am_sinkID_t sinkID, const std::string & name) const
+const CAmDatabaseHandlerMap::am_Sink_Database_s *CAmDatabaseHandlerMap::sinkWithNameOrID(const am_sinkID_t sinkID, const std::string &name) const
{
- std::function<bool(const CAmDatabaseHandlerMap::am_Sink_Database_s & refObject)> comparator = [&](const CAmDatabaseHandlerMap::am_Sink_Database_s & sink)->bool{
- return ( 0==sink.reserved &&
- (sinkID==sink.sinkID || name.compare(sink.name)==0));
- };
- return objectMatchingPredicate(mMappedData.mSinkMap, comparator);
+ std::function<bool(const CAmDatabaseHandlerMap::am_Sink_Database_s &refObject)> comparator = [&](const CAmDatabaseHandlerMap::am_Sink_Database_s &sink) -> bool {
+ return (0 == sink.reserved &&
+ (sinkID == sink.sinkID || name.compare(sink.name) == 0));
+ };
+ return objectMatchingPredicate(mMappedData.mSinkMap, comparator);
}
/**
@@ -2355,9 +2496,9 @@ const CAmDatabaseHandlerMap::am_Sink_Database_s * CAmDatabaseHandlerMap::sinkWit
* @param name the name
* @return true if it exists.
*/
-bool CAmDatabaseHandlerMap::existSinkNameOrID(const am_sinkID_t sinkID, const std::string & name) const
+bool CAmDatabaseHandlerMap::existSinkNameOrID(const am_sinkID_t sinkID, const std::string &name) const
{
- return sinkWithNameOrID( sinkID, name)!=NULL;
+ return sinkWithNameOrID(sinkID, name) != NULL;
}
/**
@@ -2365,7 +2506,7 @@ bool CAmDatabaseHandlerMap::existSinkNameOrID(const am_sinkID_t sinkID, const st
* @param name the name
* @return true if it exists
*/
-bool CAmDatabaseHandlerMap::existSinkName(const std::string & name) const
+bool CAmDatabaseHandlerMap::existSinkName(const std::string &name) const
{
return existSinkNameOrID(mMappedData.mCurrentSinkID.mMax, name);
}
@@ -2377,11 +2518,13 @@ bool CAmDatabaseHandlerMap::existSinkName(const std::string & name) const
*/
bool CAmDatabaseHandlerMap::existDomain(const am_domainID_t domainID) const
{
- am_Domain_Database_s const * source = objectForKeyIfExistsInMap(domainID, mMappedData.mDomainMap);
- if( NULL!=source )
- return (0==source->reserved);
+ am_Domain_Database_s const *source = objectForKeyIfExistsInMap(domainID, mMappedData.mDomainMap);
+ if ( NULL != source )
+ {
+ return (0 == source->reserved);
+ }
- return false;
+ return false;
}
/**
@@ -2391,51 +2534,54 @@ bool CAmDatabaseHandlerMap::existDomain(const am_domainID_t domainID) const
*/
bool CAmDatabaseHandlerMap::existGateway(const am_gatewayID_t gatewayID) const
{
- return existsObjectWithKeyInMap(gatewayID, mMappedData.mGatewayMap);
+ return existsObjectWithKeyInMap(gatewayID, mMappedData.mGatewayMap);
}
bool CAmDatabaseHandlerMap::existConverter(const am_converterID_t converterID) const
{
- return existsObjectWithKeyInMap(converterID, mMappedData.mConverterMap);
+ return existsObjectWithKeyInMap(converterID, mMappedData.mConverterMap);
}
-am_Error_e CAmDatabaseHandlerMap::getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t & domainID) const
+am_Error_e CAmDatabaseHandlerMap::getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t &domainID) const
{
- domainID=0;
+ domainID = 0;
- am_Source_Database_s const * source = objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
- if( NULL!=source )
+ am_Source_Database_s const *source = objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
+ if ( NULL != source )
{
- domainID = source->domainID;
- return E_OK;
+ domainID = source->domainID;
+ return E_OK;
}
+
return E_NON_EXISTENT;
}
-am_Error_e am::CAmDatabaseHandlerMap::getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t & domainID) const
+am_Error_e am::CAmDatabaseHandlerMap::getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t &domainID) const
{
- domainID=0;
+ domainID = 0;
- am_Sink_Database_s const * source = objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
- if( NULL!=source )
- {
- domainID = source->domainID;
- return E_OK;
- }
- return E_NON_EXISTENT;
+ am_Sink_Database_s const *source = objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
+ if ( NULL != source )
+ {
+ domainID = source->domainID;
+ return E_OK;
+ }
+
+ return E_NON_EXISTENT;
}
-am_Error_e am::CAmDatabaseHandlerMap::getDomainOfCrossfader(const am_converterID_t crossfader, am_domainID_t & domainID) const
+am_Error_e am::CAmDatabaseHandlerMap::getDomainOfCrossfader(const am_converterID_t crossfader, am_domainID_t &domainID) const
{
- domainID=0;
+ domainID = 0;
- am_Crossfader_Database_s const * cross = objectForKeyIfExistsInMap(crossfader, mMappedData.mCrossfaderMap);
- if( NULL!=cross )
- {
- getDomainOfSource(cross->sinkID_A,domainID);
- return E_OK;
- }
- return E_NON_EXISTENT;
+ am_Crossfader_Database_s const *cross = objectForKeyIfExistsInMap(crossfader, mMappedData.mCrossfaderMap);
+ if ( NULL != cross )
+ {
+ getDomainOfSource(cross->sinkID_A, domainID);
+ return E_OK;
+ }
+
+ return E_NON_EXISTENT;
}
/**
@@ -2445,7 +2591,7 @@ am_Error_e am::CAmDatabaseHandlerMap::getDomainOfCrossfader(const am_converterID
*/
bool CAmDatabaseHandlerMap::existSinkClass(const am_sinkClass_t sinkClassID) const
{
- return existsObjectWithKeyInMap(sinkClassID, mMappedData.mSinkClassesMap);
+ return existsObjectWithKeyInMap(sinkClassID, mMappedData.mSinkClassesMap);
}
/**
@@ -2455,27 +2601,27 @@ bool CAmDatabaseHandlerMap::existSinkClass(const am_sinkClass_t sinkClassID) con
*/
bool CAmDatabaseHandlerMap::existSourceClass(const am_sourceClass_t sourceClassID) const
{
- return existsObjectWithKeyInMap(sourceClassID, mMappedData.mSourceClassesMap);
+ return existsObjectWithKeyInMap(sourceClassID, mMappedData.mSourceClassesMap);
}
am_Error_e CAmDatabaseHandlerMap::changeConnectionTimingInformation(const am_connectionID_t connectionID, const am_timeSync_t delay)
{
- if(!existConnectionID(connectionID))
- {
- logError(__METHOD_NAME__,"connectionID must exist");
- return (E_NON_EXISTENT);
- }
+ if (!existConnectionID(connectionID))
+ {
+ logError(__METHOD_NAME__, "connectionID must exist");
+ return (E_NON_EXISTENT);
+ }
mMappedData.mConnectionMap[connectionID].delay = delay;
- //now we need to find all mainConnections that use the changed connection and update their timing
+ // now we need to find all mainConnections that use the changed connection and update their timing
- //first get all route tables for all mainconnections
- am_Error_e error = E_OK;
- AmMapMainConnection::const_iterator iter = mMappedData.mMainConnectionMap.begin();
- for(; iter != mMappedData.mMainConnectionMap.end(); ++iter)
+ // first get all route tables for all mainconnections
+ am_Error_e error = E_OK;
+ AmMapMainConnection::const_iterator iter = mMappedData.mMainConnectionMap.begin();
+ for (; iter != mMappedData.mMainConnectionMap.end(); ++iter)
{
- const am_MainConnection_s & mainConnection = iter->second;
+ const am_MainConnection_s &mainConnection = iter->second;
if (std::find(mainConnection.listConnectionID.begin(), mainConnection.listConnectionID.end(), connectionID) != mainConnection.listConnectionID.end())
{
// Got it.
@@ -2488,31 +2634,36 @@ am_Error_e CAmDatabaseHandlerMap::changeConnectionTimingInformation(const am_con
am_Error_e CAmDatabaseHandlerMap::changeConnectionFinal(const am_connectionID_t connectionID)
{
- am_Connection_Database_s const * connection = objectForKeyIfExistsInMap(connectionID, mMappedData.mConnectionMap);
- if( NULL!=connection )
+ am_Connection_Database_s const *connection = objectForKeyIfExistsInMap(connectionID, mMappedData.mConnectionMap);
+ if ( NULL != connection )
{
- mMappedData.mConnectionMap.at(connectionID).reserved = false;
- return E_OK;
+ mMappedData.mConnectionMap.at(connectionID).reserved = false;
+ return E_OK;
}
- logError(__METHOD_NAME__,"connectionID must exist");
+
+ logError(__METHOD_NAME__, "connectionID must exist");
return (E_NON_EXISTENT);
}
am_timeSync_t CAmDatabaseHandlerMap::calculateMainConnectionDelay(const am_mainConnectionID_t mainConnectionID) const
{
if (!existMainConnection(mainConnectionID))
- return -1;
- const am_MainConnection_s & mainConnection = mMappedData.mMainConnectionMap.at(mainConnectionID);
- am_timeSync_t delay = 0;
- std::vector<am_connectionID_t>::const_iterator iter = mainConnection.listConnectionID.begin();
- for(;iter<mainConnection.listConnectionID.end(); ++iter)
- {
- am_Connection_Database_s const * source = objectForKeyIfExistsInMap(*iter, mMappedData.mConnectionMap);
- if( NULL!=source )
- {
- delay += std::max(source->delay, static_cast<am_timeSync_t>(0));
- }
- }
+ {
+ return -1;
+ }
+
+ const am_MainConnection_s &mainConnection = mMappedData.mMainConnectionMap.at(mainConnectionID);
+ am_timeSync_t delay = 0;
+ std::vector<am_connectionID_t>::const_iterator iter = mainConnection.listConnectionID.begin();
+ for (; iter < mainConnection.listConnectionID.end(); ++iter)
+ {
+ am_Connection_Database_s const *source = objectForKeyIfExistsInMap(*iter, mMappedData.mConnectionMap);
+ if ( NULL != source )
+ {
+ delay += std::max(source->delay, static_cast<am_timeSync_t>(0));
+ }
+ }
+
return (delay == 0 ? -1 : std::min(delay, static_cast<am_timeSync_t>(SHRT_MAX)));
}
@@ -2530,9 +2681,10 @@ bool CAmDatabaseHandlerMap::sourceVisible(const am_sourceID_t sourceID) const
{
if (!existSource(sourceID))
{
- logError(__METHOD_NAME__,"sourceID must exist");
- return false;
+ logError(__METHOD_NAME__, "sourceID must exist");
+ return false;
}
+
am_Source_Database_s source = mMappedData.mSourceMap.at(sourceID);
return source.visible;
}
@@ -2544,13 +2696,16 @@ bool CAmDatabaseHandlerMap::sourceVisible(const am_sourceID_t sourceID) const
*/
bool CAmDatabaseHandlerMap::sinkVisible(const am_sinkID_t sinkID) const
{
- am_Sink_Database_s const * source = objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
- if( NULL!=source )
- {
- if(0==source->reserved)
- return source->visible;
- }
- return false;
+ am_Sink_Database_s const *source = objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
+ if ( NULL != source )
+ {
+ if (0 == source->reserved)
+ {
+ return source->visible;
+ }
+ }
+
+ return false;
}
/**
@@ -2559,15 +2714,15 @@ bool CAmDatabaseHandlerMap::sinkVisible(const am_sinkID_t sinkID) const
* @param connection the connection to be checked
* @return true if connections exists
*/
-bool CAmDatabaseHandlerMap::existConnection(const am_Connection_s & connection) const
+bool CAmDatabaseHandlerMap::existConnection(const am_Connection_s &connection) const
{
- am_Connection_Database_s const * connectionObject = objectMatchingPredicate<am_Connection_Database_s, am_connectionID_t>(mMappedData.mConnectionMap, [&](const am_Connection_Database_s & obj){
- return false==obj.reserved &&
- connection.sinkID == obj.sinkID &&
- connection.sourceID == obj.sourceID &&
- connection.connectionFormat == obj.connectionFormat;
- });
- return ( NULL!=connectionObject );
+ am_Connection_Database_s const *connectionObject = objectMatchingPredicate<am_Connection_Database_s, am_connectionID_t>(mMappedData.mConnectionMap, [&](const am_Connection_Database_s &obj){
+ return false == obj.reserved &&
+ connection.sinkID == obj.sinkID &&
+ connection.sourceID == obj.sourceID &&
+ connection.connectionFormat == obj.connectionFormat;
+ });
+ return (NULL != connectionObject);
}
/**
@@ -2577,12 +2732,13 @@ bool CAmDatabaseHandlerMap::existConnection(const am_Connection_s & connection)
*/
bool CAmDatabaseHandlerMap::existConnectionID(const am_connectionID_t connectionID) const
{
- am_Connection_Database_s const * connection = objectForKeyIfExistsInMap(connectionID, mMappedData.mConnectionMap);
- if( NULL!=connection )
- {
- return (true);
- }
- return false;
+ am_Connection_Database_s const *connection = objectForKeyIfExistsInMap(connectionID, mMappedData.mConnectionMap);
+ if ( NULL != connection )
+ {
+ return (true);
+ }
+
+ return false;
}
/**
@@ -2592,297 +2748,324 @@ bool CAmDatabaseHandlerMap::existConnectionID(const am_connectionID_t connection
*/
bool CAmDatabaseHandlerMap::existCrossFader(const am_crossfaderID_t crossfaderID) const
{
- return existsObjectWithKeyInMap(crossfaderID, mMappedData.mCrossfaderMap);
+ return existsObjectWithKeyInMap(crossfaderID, mMappedData.mCrossfaderMap);
}
-am_Error_e CAmDatabaseHandlerMap::getSoureState(const am_sourceID_t sourceID, am_SourceState_e & sourceState) const
+am_Error_e CAmDatabaseHandlerMap::getSoureState(const am_sourceID_t sourceID, am_SourceState_e &sourceState) const
{
- am_Source_Database_s const * source = objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
- if( NULL!=source )
- {
- sourceState = source->sourceState;
- return (E_OK);
- }
- else
- {
- sourceState = SS_UNKNNOWN;
- return (E_NON_EXISTENT);
- }
+ am_Source_Database_s const *source = objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
+ if ( NULL != source )
+ {
+ sourceState = source->sourceState;
+ return (E_OK);
+ }
+ else
+ {
+ sourceState = SS_UNKNNOWN;
+ return (E_NON_EXISTENT);
+ }
}
am_Error_e CAmDatabaseHandlerMap::changeSourceState(const am_sourceID_t sourceID, const am_SourceState_e sourceState)
{
- if(!(sourceState>=SS_UNKNNOWN && sourceState<=SS_MAX))
- {
- logError(__METHOD_NAME__,"sourceState must be valid");
- return (E_NOT_POSSIBLE);
- }
+ if (!(sourceState >= SS_UNKNNOWN && sourceState <= SS_MAX))
+ {
+ logError(__METHOD_NAME__, "sourceState must be valid");
+ return (E_NOT_POSSIBLE);
+ }
- if(existSource(sourceID))
+ if (existSource(sourceID))
{
- mMappedData.mSourceMap.at(sourceID).sourceState = sourceState;
- return (E_OK);
- }
- logError(__METHOD_NAME__,"sourceID must exist");
- return (E_NON_EXISTENT);
+ mMappedData.mSourceMap.at(sourceID).sourceState = sourceState;
+ return (E_OK);
+ }
+
+ logError(__METHOD_NAME__, "sourceID must exist");
+ return (E_NON_EXISTENT);
}
am_Error_e CAmDatabaseHandlerMap::changeSourceInterruptState(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)
{
- assert(sourceID!=0);
- assert(interruptState>=IS_UNKNOWN && interruptState<=IS_MAX);
- if(existSource(sourceID))
+ assert(sourceID != 0);
+ assert(interruptState >= IS_UNKNOWN && interruptState <= IS_MAX);
+ if (existSource(sourceID))
{
mMappedData.mSourceMap.at(sourceID).interruptState = interruptState;
return (E_OK);
}
+
+ return (E_NON_EXISTENT);
+}
+
+am_Error_e CAmDatabaseHandlerMap::getSinkMainVolume(const am_sinkID_t sinkID, am_mainVolume_t &mainVolume) const
+{
+
+ am_Sink_Database_s const *source = objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
+ if ( NULL != source )
+ {
+ mainVolume = source->mainVolume;
+ return (E_OK);
+ }
+
+ mainVolume = -1;
+ logWarning(__METHOD_NAME__, "sinkID must be valid");
+ return (E_NON_EXISTENT);
+}
+
+am_Error_e CAmDatabaseHandlerMap::getSinkVolume(const am_sinkID_t sinkID, am_volume_t &volume) const
+{
+
+ am_Sink_Database_s const *source = objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
+ if ( NULL != source )
+ {
+ volume = source->volume;
+ return (E_OK);
+ }
+
+ volume = -1;
+ logWarning(__METHOD_NAME__, "sinkID must be valid");
+ return (E_NON_EXISTENT);
+}
+
+am_Error_e CAmDatabaseHandlerMap::getSourceVolume(const am_sourceID_t sourceID, am_volume_t &volume) const
+{
+ am_Source_Database_s const *source = objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
+ if ( NULL != source )
+ {
+ volume = source->volume;
+ return (E_OK);
+ }
+
+ volume = -1;
+ logWarning(__METHOD_NAME__, "sourceID must be valid");
+ return (E_NON_EXISTENT);
+}
+
+am_Error_e CAmDatabaseHandlerMap::getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomSoundPropertyType_t propertyType, int16_t &value) const
+{
+
+ am_Sink_Database_s *pObject = (am_Sink_Database_s *)objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
+ if ( NULL != pObject )
+ {
+ if (pObject->listSoundProperties.size() > 0 && 0 == pObject->cacheSoundProperties.size())
+ {
+ std::vector<am_SoundProperty_s>::const_iterator iter = pObject->listSoundProperties.begin();
+ for (; iter < pObject->listSoundProperties.end(); ++iter)
+ {
+ pObject->cacheSoundProperties[iter->type] = iter->value;
+ }
+ }
+
+ auto it = pObject->cacheSoundProperties.find(propertyType);
+ if (it != pObject->cacheSoundProperties.end())
+ {
+ value = it->second;
+ return (E_OK);
+ }
+ }
+
+ value = -1;
+ logWarning(__METHOD_NAME__, "sinkID must be valid");
+ return (E_NON_EXISTENT);
+}
+
+am_Error_e CAmDatabaseHandlerMap::getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomSoundPropertyType_t propertyType, int16_t &value) const
+{
+ am_Source_Database_s *pObject = (am_Source_Database_s *)objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
+ if ( NULL != pObject )
+ {
+ if (pObject->listSoundProperties.size() > 0 && 0 == pObject->cacheSoundProperties.size())
+ {
+ std::vector<am_SoundProperty_s>::const_iterator iter = pObject->listSoundProperties.begin();
+ for (; iter < pObject->listSoundProperties.end(); ++iter)
+ {
+ pObject->cacheSoundProperties[iter->type] = iter->value;
+ }
+ }
+
+ auto it = pObject->cacheSoundProperties.find(propertyType);
+ if (it != pObject->cacheSoundProperties.end())
+ {
+ value = it->second;
+ return (E_OK);
+ }
+ }
+
+ value = -1;
+ logWarning(__METHOD_NAME__, "sourceID must be valid");
+ return (E_NON_EXISTENT);
+}
+
+am_Error_e CAmDatabaseHandlerMap::getMainSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t &value) const
+{
+ am_Sink_Database_s *pObject = (am_Sink_Database_s *)objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
+ if ( NULL != pObject )
+ {
+ if (pObject->listMainSoundProperties.size() > 0 && 0 == pObject->cacheMainSoundProperties.size())
+ {
+ std::vector<am_MainSoundProperty_s>::const_iterator iter = pObject->listMainSoundProperties.begin();
+ for (; iter < pObject->listMainSoundProperties.end(); ++iter)
+ {
+ pObject->cacheMainSoundProperties[iter->type] = iter->value;
+ }
+ }
+
+ auto it = pObject->cacheMainSoundProperties.find(propertyType);
+ if (it != pObject->cacheMainSoundProperties.end())
+ {
+ value = it->second;
+ return (E_OK);
+ }
+ }
+
+ value = -1;
+ logWarning(__METHOD_NAME__, "sinkID must be valid");
+ return (E_NON_EXISTENT);
+}
+
+am_Error_e CAmDatabaseHandlerMap::getMainSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t &value) const
+{
+
+ am_Source_Database_s *pObject = (am_Source_Database_s *)objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
+ if ( NULL != pObject )
+ {
+ if (pObject->listMainSoundProperties.size() > 0 && 0 == pObject->cacheMainSoundProperties.size())
+ {
+ std::vector<am_MainSoundProperty_s>::const_iterator iter = pObject->listMainSoundProperties.begin();
+ for (; iter < pObject->listMainSoundProperties.end(); ++iter)
+ {
+ pObject->cacheMainSoundProperties[iter->type] = iter->value;
+ }
+ }
+
+ auto it = pObject->cacheMainSoundProperties.find(propertyType);
+ if (it != pObject->cacheMainSoundProperties.end())
+ {
+ value = it->second;
+ return (E_OK);
+ }
+ }
+
+ value = -1;
+ logWarning(__METHOD_NAME__, "sourceID must be valid");
+ return (E_NON_EXISTENT);
+}
+
+am_Error_e CAmDatabaseHandlerMap::getDomainState(const am_domainID_t domainID, am_DomainState_e &state) const
+{
+
+ am_Domain_Database_s const *source = objectForKeyIfExistsInMap(domainID, mMappedData.mDomainMap);
+ if ( NULL != source )
+ {
+ state = source->state;
+ return (E_OK);
+ }
+
+ state = DS_UNKNOWN;
+ logWarning(__METHOD_NAME__, "domainID must be valid");
return (E_NON_EXISTENT);
}
+am_Error_e CAmDatabaseHandlerMap::peekDomain(const std::string &name, am_domainID_t &domainID)
+{
+ domainID = 0;
-am_Error_e CAmDatabaseHandlerMap::getSinkMainVolume(const am_sinkID_t sinkID, am_mainVolume_t& mainVolume) const {
-
-
- am_Sink_Database_s const * source = objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
- if( NULL!=source )
- {
- mainVolume = source->mainVolume;
- return (E_OK);
- }
- mainVolume = -1;
- logWarning(__METHOD_NAME__,"sinkID must be valid");
- return (E_NON_EXISTENT);
-}
-
-am_Error_e CAmDatabaseHandlerMap::getSinkVolume(const am_sinkID_t sinkID, am_volume_t & volume) const
-{
-
- am_Sink_Database_s const * source = objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
- if( NULL!=source )
- {
- volume = source->volume;
- return (E_OK);
- }
- volume = -1;
- logWarning(__METHOD_NAME__,"sinkID must be valid");
- return (E_NON_EXISTENT);
-}
-
-am_Error_e CAmDatabaseHandlerMap::getSourceVolume(const am_sourceID_t sourceID, am_volume_t & volume) const
-{
- am_Source_Database_s const * source = objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
- if( NULL!=source )
- {
- volume = source->volume;
- return (E_OK);
- }
- volume = -1;
- logWarning(__METHOD_NAME__,"sourceID must be valid");
- return (E_NON_EXISTENT);
-}
-
-am_Error_e CAmDatabaseHandlerMap::getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomSoundPropertyType_t propertyType, int16_t & value) const
-{
-
- am_Sink_Database_s * pObject = (am_Sink_Database_s *)objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
- if( NULL!=pObject )
- {
- if(pObject->listSoundProperties.size()>0 && 0==pObject->cacheSoundProperties.size())
- {
- std::vector<am_SoundProperty_s>::const_iterator iter = pObject->listSoundProperties.begin();
- for(; iter<pObject->listSoundProperties.end(); ++iter)
- pObject->cacheSoundProperties[iter->type] = iter->value;
- }
- auto it = pObject->cacheSoundProperties.find(propertyType);
- if(it!=pObject->cacheSoundProperties.end())
- {
- value = it->second;
- return (E_OK);
- }
- }
- value = -1;
- logWarning(__METHOD_NAME__,"sinkID must be valid");
- return (E_NON_EXISTENT);
-}
-
-am_Error_e CAmDatabaseHandlerMap::getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomSoundPropertyType_t propertyType, int16_t & value) const
-{
- am_Source_Database_s * pObject = (am_Source_Database_s *)objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
- if( NULL!=pObject )
- {
- if(pObject->listSoundProperties.size()>0 && 0==pObject->cacheSoundProperties.size())
- {
- std::vector<am_SoundProperty_s>::const_iterator iter = pObject->listSoundProperties.begin();
- for(; iter<pObject->listSoundProperties.end(); ++iter)
- pObject->cacheSoundProperties[iter->type] = iter->value;
- }
- auto it = pObject->cacheSoundProperties.find(propertyType);
- if(it!=pObject->cacheSoundProperties.end())
- {
- value = it->second;
- return (E_OK);
- }
- }
- value = -1;
- logWarning(__METHOD_NAME__,"sourceID must be valid");
- return (E_NON_EXISTENT);
-}
-
-am_Error_e CAmDatabaseHandlerMap::getMainSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const
-{
- am_Sink_Database_s * pObject = (am_Sink_Database_s *)objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
- if( NULL!=pObject )
- {
- if(pObject->listMainSoundProperties.size()>0 && 0==pObject->cacheMainSoundProperties.size())
- {
- std::vector<am_MainSoundProperty_s>::const_iterator iter = pObject->listMainSoundProperties.begin();
- for(; iter<pObject->listMainSoundProperties.end(); ++iter)
- pObject->cacheMainSoundProperties[iter->type] = iter->value;
- }
- auto it = pObject->cacheMainSoundProperties.find(propertyType);
- if(it!=pObject->cacheMainSoundProperties.end())
- {
- value = it->second;
- return (E_OK);
- }
- }
- value = -1;
- logWarning(__METHOD_NAME__,"sinkID must be valid");
- return (E_NON_EXISTENT);
-}
-
-am_Error_e CAmDatabaseHandlerMap::getMainSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const
-{
-
- am_Source_Database_s * pObject = (am_Source_Database_s *)objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
- if( NULL!=pObject )
- {
- if(pObject->listMainSoundProperties.size()>0 && 0==pObject->cacheMainSoundProperties.size())
- {
- std::vector<am_MainSoundProperty_s>::const_iterator iter = pObject->listMainSoundProperties.begin();
- for(; iter<pObject->listMainSoundProperties.end(); ++iter)
- pObject->cacheMainSoundProperties[iter->type] = iter->value;
- }
- auto it = pObject->cacheMainSoundProperties.find(propertyType);
- if(it!=pObject->cacheMainSoundProperties.end())
- {
- value = it->second;
- return (E_OK);
- }
- }
-
- value = -1;
- logWarning(__METHOD_NAME__,"sourceID must be valid");
- return (E_NON_EXISTENT);
-}
-
-am_Error_e CAmDatabaseHandlerMap::getDomainState(const am_domainID_t domainID, am_DomainState_e& state) const
-{
-
- am_Domain_Database_s const * source = objectForKeyIfExistsInMap(domainID, mMappedData.mDomainMap);
- if( NULL!=source )
- {
- state = source->state;
- return (E_OK);
- }
- state = DS_UNKNOWN;
- logWarning(__METHOD_NAME__,"domainID must be valid");
- return (E_NON_EXISTENT);
-}
-
-am_Error_e CAmDatabaseHandlerMap::peekDomain(const std::string & name, am_domainID_t & domainID)
-{
- domainID=0;
-
- am_Domain_Database_s const *reservedDomain = objectMatchingPredicate<am_Domain_Database_s, am_domainID_t>(mMappedData.mDomainMap, [&](const am_Domain_Database_s & obj){
- return name.compare(obj.name)==0;
- });
-
- if( NULL != reservedDomain )
- {
- domainID = reservedDomain->domainID;
- return E_OK;
+ am_Domain_Database_s const *reservedDomain = objectMatchingPredicate<am_Domain_Database_s, am_domainID_t>(mMappedData.mDomainMap, [&](const am_Domain_Database_s &obj){
+ return name.compare(obj.name) == 0;
+ });
+
+ if ( NULL != reservedDomain )
+ {
+ domainID = reservedDomain->domainID;
+ return E_OK;
}
else
{
- int16_t nextID = 0;
- if( mMappedData.increaseID( nextID, mMappedData.mCurrentDomainID) )
- {
- domainID = nextID;
- am_Domain_Database_s domain;
- domain.domainID = nextID;
- domain.name = name;
- domain.reserved = 1;
- mMappedData.mDomainMap[nextID] = domain;
- return E_OK;
- }
- return E_UNKNOWN;
+ int16_t nextID = 0;
+ if ( mMappedData.increaseID(nextID, mMappedData.mCurrentDomainID))
+ {
+ domainID = nextID;
+ am_Domain_Database_s domain;
+ domain.domainID = nextID;
+ domain.name = name;
+ domain.reserved = 1;
+ mMappedData.mDomainMap[nextID] = domain;
+ return E_OK;
+ }
+
+ return E_UNKNOWN;
}
+
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::peekSink(const std::string & name, am_sinkID_t & sinkID)
+am_Error_e CAmDatabaseHandlerMap::peekSink(const std::string &name, am_sinkID_t &sinkID)
{
- am_Sink_Database_s const *reservedSink = objectMatchingPredicate<am_Sink_Database_s, am_sinkID_t>(mMappedData.mSinkMap, [&](const am_Sink_Database_s & obj){
- return name.compare(obj.name)==0;
- });
- if( NULL!=reservedSink )
+ am_Sink_Database_s const *reservedSink = objectMatchingPredicate<am_Sink_Database_s, am_sinkID_t>(mMappedData.mSinkMap, [&](const am_Sink_Database_s &obj){
+ return name.compare(obj.name) == 0;
+ });
+ if ( NULL != reservedSink )
{
- sinkID = reservedSink->sinkID;
- return E_OK;
+ sinkID = reservedSink->sinkID;
+ return E_OK;
}
else
{
- int16_t nextID = 0;
- if(mMappedData.increaseID(nextID, mMappedData.mCurrentSinkID))
- {
- if(mFirstStaticSink)
- {
- nextID = DYNAMIC_ID_BOUNDARY;
- mFirstStaticSink = false;
- }
- sinkID = nextID;
- am_Sink_Database_s object;
- object.sinkID = nextID;
- object.name = name;
- object.reserved = 1;
- mMappedData.mSinkMap[nextID] = object;
- return E_OK;
- }
- return E_UNKNOWN;
+ int16_t nextID = 0;
+ if (mMappedData.increaseID(nextID, mMappedData.mCurrentSinkID))
+ {
+ if (mFirstStaticSink)
+ {
+ nextID = DYNAMIC_ID_BOUNDARY;
+ mFirstStaticSink = false;
+ }
+
+ sinkID = nextID;
+ am_Sink_Database_s object;
+ object.sinkID = nextID;
+ object.name = name;
+ object.reserved = 1;
+ mMappedData.mSinkMap[nextID] = object;
+ return E_OK;
+ }
+
+ return E_UNKNOWN;
}
}
-am_Error_e CAmDatabaseHandlerMap::peekSource(const std::string & name, am_sourceID_t & sourceID)
+am_Error_e CAmDatabaseHandlerMap::peekSource(const std::string &name, am_sourceID_t &sourceID)
{
- am_Source_Database_s const *reservedSrc = objectMatchingPredicate<am_Source_Database_s, am_sourceID_t>(mMappedData.mSourceMap, [&](const am_Source_Database_s & obj){
- return name.compare(obj.name)==0;
- });
- if( NULL!=reservedSrc )
+ am_Source_Database_s const *reservedSrc = objectMatchingPredicate<am_Source_Database_s, am_sourceID_t>(mMappedData.mSourceMap, [&](const am_Source_Database_s &obj){
+ return name.compare(obj.name) == 0;
+ });
+ if ( NULL != reservedSrc )
{
- sourceID = reservedSrc->sourceID;
- return E_OK;
+ sourceID = reservedSrc->sourceID;
+ return E_OK;
}
else
{
- int16_t nextID = 0;
- if(mMappedData.increaseID(nextID, mMappedData.mCurrentSourceID))
- {
- if(mFirstStaticSource)
- {
-// nextID = DYNAMIC_ID_BOUNDARY;
- mFirstStaticSource = false;
- }
- sourceID = nextID;
- am_Source_Database_s object;
- object.sourceID = nextID;
- object.name = name;
- object.reserved = 1;
- mMappedData.mSourceMap[nextID] = object;
- return E_OK;
- }
- else
- return E_UNKNOWN;
+ int16_t nextID = 0;
+ if (mMappedData.increaseID(nextID, mMappedData.mCurrentSourceID))
+ {
+ if (mFirstStaticSource)
+ {
+// nextID = DYNAMIC_ID_BOUNDARY;
+ mFirstStaticSource = false;
+ }
+
+ sourceID = nextID;
+ am_Source_Database_s object;
+ object.sourceID = nextID;
+ object.name = name;
+ object.reserved = 1;
+ mMappedData.mSourceMap[nextID] = object;
+ return E_OK;
+ }
+ else
+ {
+ return E_UNKNOWN;
+ }
}
}
@@ -2890,7 +3073,7 @@ am_Error_e CAmDatabaseHandlerMap::changeSinkVolume(const am_sinkID_t sinkID, con
{
if (!existSink(sinkID))
{
- logError(__METHOD_NAME__,"sinkID must be valid");
+ logError(__METHOD_NAME__, "sinkID must be valid");
return (E_NON_EXISTENT);
}
@@ -2902,60 +3085,70 @@ am_Error_e CAmDatabaseHandlerMap::changeSourceVolume(const am_sourceID_t sourceI
{
if (!existSource(sourceID))
{
- logError(__METHOD_NAME__,"sourceID must be valid");
+ logError(__METHOD_NAME__, "sourceID must be valid");
return (E_NON_EXISTENT);
}
+
mMappedData.mSourceMap[sourceID].volume = volume;
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::changeSourceSoundPropertyDB(const am_SoundProperty_s & soundProperty, const am_sourceID_t sourceID)
+am_Error_e CAmDatabaseHandlerMap::changeSourceSoundPropertyDB(const am_SoundProperty_s &soundProperty, const am_sourceID_t sourceID)
{
if (!existSource(sourceID))
{
- logError(__METHOD_NAME__,"sourceID must be valid");
+ logError(__METHOD_NAME__, "sourceID must be valid");
return (E_NON_EXISTENT);
}
- am_Source_Database_s & source = mMappedData.mSourceMap[sourceID];
- std::vector<am_SoundProperty_s>::iterator iter = source.listSoundProperties.begin();
- for(; iter<source.listSoundProperties.end(); ++iter)
- {
- if( soundProperty.type == iter->type )
- {
- iter->value = soundProperty.value;
- if(source.cacheSoundProperties.size())
- source.cacheSoundProperties[soundProperty.type] = soundProperty.value;
- return (E_OK);
- }
- }
- logError(__METHOD_NAME__,"soundproperty type must be valid source:",sourceID,"type",soundProperty.type);
- return (E_NON_EXISTENT);
+ am_Source_Database_s &source = mMappedData.mSourceMap[sourceID];
+ std::vector<am_SoundProperty_s>::iterator iter = source.listSoundProperties.begin();
+ for (; iter < source.listSoundProperties.end(); ++iter)
+ {
+ if ( soundProperty.type == iter->type )
+ {
+ iter->value = soundProperty.value;
+ if (source.cacheSoundProperties.size())
+ {
+ source.cacheSoundProperties[soundProperty.type] = soundProperty.value;
+ }
+
+ return (E_OK);
+ }
+ }
+
+ logError(__METHOD_NAME__, "soundproperty type must be valid source:", sourceID, "type", soundProperty.type);
+ return (E_NON_EXISTENT);
}
-am_Error_e CAmDatabaseHandlerMap::changeSinkSoundPropertyDB(const am_SoundProperty_s & soundProperty, const am_sinkID_t sinkID)
+am_Error_e CAmDatabaseHandlerMap::changeSinkSoundPropertyDB(const am_SoundProperty_s &soundProperty, const am_sinkID_t sinkID)
{
if (!existSink(sinkID))
{
- logError(__METHOD_NAME__,"sinkID must be valid");
+ logError(__METHOD_NAME__, "sinkID must be valid");
return (E_NON_EXISTENT);
}
- am_Sink_Database_s & sink = mMappedData.mSinkMap[sinkID];
+
+ am_Sink_Database_s &sink = mMappedData.mSinkMap[sinkID];
std::vector<am_SoundProperty_s>::iterator iter = sink.listSoundProperties.begin();
- for(; iter<sink.listSoundProperties.end(); ++iter)
- {
- if( soundProperty.type == iter->type )
- {
- iter->value = soundProperty.value;
- if(sink.cacheSoundProperties.size())
- sink.cacheSoundProperties[soundProperty.type] = soundProperty.value;
- return (E_OK);
- }
- }
- logError(__METHOD_NAME__,"soundproperty type must be valid sinkID:",sinkID,"type",soundProperty.type);
- return (E_NON_EXISTENT);
+ for (; iter < sink.listSoundProperties.end(); ++iter)
+ {
+ if ( soundProperty.type == iter->type )
+ {
+ iter->value = soundProperty.value;
+ if (sink.cacheSoundProperties.size())
+ {
+ sink.cacheSoundProperties[soundProperty.type] = soundProperty.value;
+ }
+
+ return (E_OK);
+ }
+ }
+
+ logError(__METHOD_NAME__, "soundproperty type must be valid sinkID:", sinkID, "type", soundProperty.type);
+ return (E_NON_EXISTENT);
}
am_Error_e CAmDatabaseHandlerMap::changeCrossFaderHotSink(const am_crossfaderID_t crossfaderID, const am_HotSink_e hotsink)
@@ -2963,7 +3156,7 @@ am_Error_e CAmDatabaseHandlerMap::changeCrossFaderHotSink(const am_crossfaderID_
if (!existCrossFader(crossfaderID))
{
- logError(__METHOD_NAME__,"crossfaderID must be valid");
+ logError(__METHOD_NAME__, "crossfaderID must be valid");
return (E_NON_EXISTENT);
}
@@ -2971,67 +3164,74 @@ am_Error_e CAmDatabaseHandlerMap::changeCrossFaderHotSink(const am_crossfaderID_
return (E_OK);
}
-bool CAmDatabaseHandlerMap::isComponentConnected(const am_Gateway_s & gateway) const
+bool CAmDatabaseHandlerMap::isComponentConnected(const am_Gateway_s &gateway) const
{
- bool ret = isConnected(gateway);
- return ret;
+ bool ret = isConnected(gateway);
+ return ret;
}
-bool CAmDatabaseHandlerMap::isComponentConnected(const am_Converter_s & converter) const
+bool CAmDatabaseHandlerMap::isComponentConnected(const am_Converter_s &converter) const
{
- bool ret = isConnected(converter);
- return ret;
+ bool ret = isConnected(converter);
+ return ret;
}
-am_Error_e am::CAmDatabaseHandlerMap::peekSinkClassID(const std::string & name, am_sinkClass_t & sinkClassID)
+am_Error_e am::CAmDatabaseHandlerMap::peekSinkClassID(const std::string &name, am_sinkClass_t &sinkClassID)
{
if (name.empty())
+ {
return (E_NON_EXISTENT);
- am_SinkClass_Database_s const *reserved = objectMatchingPredicate<am_SinkClass_Database_s, am_sinkClass_t>(mMappedData.mSinkClassesMap, [&](const am_SinkClass_Database_s & obj){
- return name.compare(obj.name)==0;
- });
- if( NULL!=reserved )
- {
- sinkClassID = reserved->sinkClassID;
- return E_OK;
- }
- return (E_NON_EXISTENT);
+ }
+
+ am_SinkClass_Database_s const *reserved = objectMatchingPredicate<am_SinkClass_Database_s, am_sinkClass_t>(mMappedData.mSinkClassesMap, [&](const am_SinkClass_Database_s &obj){
+ return name.compare(obj.name) == 0;
+ });
+ if ( NULL != reserved )
+ {
+ sinkClassID = reserved->sinkClassID;
+ return E_OK;
+ }
+
+ return (E_NON_EXISTENT);
}
-am_Error_e am::CAmDatabaseHandlerMap::peekSourceClassID(const std::string & name, am_sourceClass_t & sourceClassID)
+am_Error_e am::CAmDatabaseHandlerMap::peekSourceClassID(const std::string &name, am_sourceClass_t &sourceClassID)
{
if (name.empty())
+ {
return (E_NON_EXISTENT);
- am_SourceClass_Database_s const *ptrSource = objectMatchingPredicate<am_SourceClass_Database_s, am_sourceClass_t>(mMappedData.mSourceClassesMap, [&](const am_SourceClass_Database_s & obj){
- return name.compare(obj.name)==0;
- });
- if( NULL!=ptrSource )
- {
- sourceClassID = ptrSource->sourceClassID;
- return E_OK;
- }
- return (E_NON_EXISTENT);
-}
+ }
+ am_SourceClass_Database_s const *ptrSource = objectMatchingPredicate<am_SourceClass_Database_s, am_sourceClass_t>(mMappedData.mSourceClassesMap, [&](const am_SourceClass_Database_s &obj){
+ return name.compare(obj.name) == 0;
+ });
+ if ( NULL != ptrSource )
+ {
+ sourceClassID = ptrSource->sourceClassID;
+ return E_OK;
+ }
-am_Error_e CAmDatabaseHandlerMap::changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
+ return (E_NON_EXISTENT);
+}
+
+am_Error_e CAmDatabaseHandlerMap::changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s> &listSoundProperties, const std::vector<am_CustomConnectionFormat_t> &listConnectionFormats, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties)
{
if (!existSource(sourceID))
{
- logError(__METHOD_NAME__,"sourceID must be valid");
+ logError(__METHOD_NAME__, "sourceID must be valid");
return (E_NON_EXISTENT);
}
DB_COND_UPDATE_INIT;
- am_sourceClass_t sourceClassOut(sourceClassID);
+ am_sourceClass_t sourceClassOut(sourceClassID);
std::vector<am_MainSoundProperty_s> listMainSoundPropertiesOut(listMainSoundProperties);
- //check if sinkClass needs to be changed
+ // check if sinkClass needs to be changed
std::unordered_map<am_sourceID_t, am_Source_Database_s>::iterator iter = mMappedData.mSourceMap.begin();
- for(; iter!=mMappedData.mSourceMap.end(); ++iter)
+ for (; iter != mMappedData.mSourceMap.end(); ++iter)
{
- if( iter->second.sourceID == sourceID )
+ if ( iter->second.sourceID == sourceID )
{
if (sourceClassID != 0)
{
@@ -3041,24 +3241,25 @@ am_Error_e CAmDatabaseHandlerMap::changeSourceDB(const am_sourceID_t sourceID, c
{
sourceClassOut = iter->second.sourceClassID;
}
+
break;
}
}
- //check if soundProperties need to be updated
+ // check if soundProperties need to be updated
if (!listSoundProperties.empty())
{
mMappedData.mSourceMap.at(sourceID).listSoundProperties = listSoundProperties;
mMappedData.mSourceMap.at(sourceID).cacheSoundProperties.clear();
}
- //check if we have to update the list of connectionformats
+ // check if we have to update the list of connectionformats
if (!listConnectionFormats.empty())
{
mMappedData.mSourceMap.at(sourceID).listConnectionFormats = listConnectionFormats;
}
- //then we need to check if we need to update the listMainSoundProperties
+ // then we need to check if we need to update the listMainSoundProperties
if (sourceVisible(sourceID))
{
if (!listMainSoundProperties.empty())
@@ -3068,7 +3269,7 @@ am_Error_e CAmDatabaseHandlerMap::changeSourceDB(const am_sourceID_t sourceID, c
}
else
{
- getListMainSourceSoundProperties(sourceID,listMainSoundPropertiesOut);
+ getListMainSourceSoundProperties(sourceID, listMainSoundPropertiesOut);
}
}
@@ -3076,7 +3277,7 @@ am_Error_e CAmDatabaseHandlerMap::changeSourceDB(const am_sourceID_t sourceID, c
{
logVerbose("DatabaseHandler::changeSource changed changeSource of source:", sourceID);
- NOTIFY_OBSERVERS4(dboSourceUpdated, sourceID,sourceClassOut,listMainSoundPropertiesOut,sourceVisible(sourceID))
+ NOTIFY_OBSERVERS4(dboSourceUpdated, sourceID, sourceClassOut, listMainSoundPropertiesOut, sourceVisible(sourceID))
}
@@ -3084,21 +3285,21 @@ am_Error_e CAmDatabaseHandlerMap::changeSourceDB(const am_sourceID_t sourceID, c
}
-am_Error_e CAmDatabaseHandlerMap::changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
+am_Error_e CAmDatabaseHandlerMap::changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s> &listSoundProperties, const std::vector<am_CustomConnectionFormat_t> &listConnectionFormats, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties)
{
DB_COND_UPDATE_INIT;
- am_sinkClass_t sinkClassOut(sinkClassID);
+ am_sinkClass_t sinkClassOut(sinkClassID);
std::vector<am_MainSoundProperty_s> listMainSoundPropertiesOut(listMainSoundProperties);
if (!existSink(sinkID))
{
- logError(__METHOD_NAME__,"sinkID must be valid");
+ logError(__METHOD_NAME__, "sinkID must be valid");
return (E_NON_EXISTENT);
}
std::unordered_map<am_sinkID_t, am_Sink_Database_s>::iterator iter = mMappedData.mSinkMap.begin();
- for(; iter!=mMappedData.mSinkMap.end(); ++iter)
+ for (; iter != mMappedData.mSinkMap.end(); ++iter)
{
if (iter->second.sinkID == sinkID)
{
@@ -3110,24 +3311,25 @@ am_Error_e CAmDatabaseHandlerMap::changeSinkDB(const am_sinkID_t sinkID, const a
{
sinkClassOut = iter->second.sinkClassID;
}
+
break;
}
}
- //check if soundProperties need to be updated
+ // check if soundProperties need to be updated
if (!listSoundProperties.empty())
{
mMappedData.mSinkMap.at(sinkID).listSoundProperties = listSoundProperties;
mMappedData.mSinkMap.at(sinkID).cacheSoundProperties.clear();
}
- //check if we have to update the list of connectionformats
+ // check if we have to update the list of connectionformats
if (!listConnectionFormats.empty())
{
mMappedData.mSinkMap.at(sinkID).listConnectionFormats = listConnectionFormats;
}
- //then we need to check if we need to update the listMainSoundProperties
+ // then we need to check if we need to update the listMainSoundProperties
if (sinkVisible(sinkID))
{
if (!listMainSoundProperties.empty())
@@ -3135,9 +3337,9 @@ am_Error_e CAmDatabaseHandlerMap::changeSinkDB(const am_sinkID_t sinkID, const a
DB_COND_UPDATE(mMappedData.mSinkMap.at(sinkID).listMainSoundProperties, listMainSoundProperties);
mMappedData.mSinkMap.at(sinkID).cacheMainSoundProperties.clear();
}
- else //read out the properties
+ else // read out the properties
{
- getListMainSinkSoundProperties(sinkID,listMainSoundPropertiesOut);
+ getListMainSinkSoundProperties(sinkID, listMainSoundPropertiesOut);
}
}
@@ -3145,33 +3347,34 @@ am_Error_e CAmDatabaseHandlerMap::changeSinkDB(const am_sinkID_t sinkID, const a
{
logVerbose("DatabaseHandler::changeSink changed changeSink of sink:", sinkID);
- NOTIFY_OBSERVERS4(dboSinkUpdated, sinkID,sinkClassOut,listMainSoundPropertiesOut,sinkVisible(sinkID))
+ NOTIFY_OBSERVERS4(dboSinkUpdated, sinkID, sinkClassOut, listMainSoundPropertiesOut, sinkVisible(sinkID))
}
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListMainSinkNotificationConfigurations(const am_sinkID_t sinkID, std::vector<am_NotificationConfiguration_s>& listMainNotificationConfigurations)
+am_Error_e CAmDatabaseHandlerMap::getListMainSinkNotificationConfigurations(const am_sinkID_t sinkID, std::vector<am_NotificationConfiguration_s> &listMainNotificationConfigurations)
{
if (!existSink(sinkID))
{
- logWarning(__METHOD_NAME__,"sinkID must be valid");
+ logWarning(__METHOD_NAME__, "sinkID must be valid");
return (E_DATABASE_ERROR);
}
+
listMainNotificationConfigurations.clear();
listMainNotificationConfigurations = mMappedData.mSinkMap.at(sinkID).listMainNotificationConfigurations;
- return (E_OK);
+ return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::getListMainSourceNotificationConfigurations(const am_sourceID_t sourceID, std::vector<am_NotificationConfiguration_s>& listMainNotificationConfigurations)
+am_Error_e CAmDatabaseHandlerMap::getListMainSourceNotificationConfigurations(const am_sourceID_t sourceID, std::vector<am_NotificationConfiguration_s> &listMainNotificationConfigurations)
{
if (!existSource(sourceID))
{
- logWarning(__METHOD_NAME__,"sourceID must be valid");
+ logWarning(__METHOD_NAME__, "sourceID must be valid");
return (E_DATABASE_ERROR);
}
@@ -3180,22 +3383,25 @@ am_Error_e CAmDatabaseHandlerMap::getListMainSourceNotificationConfigurations(co
return (E_OK);
}
-bool changeMainNotificationConfiguration(std::vector<am_NotificationConfiguration_s> & listMainNotificationConfigurations,
- const am_NotificationConfiguration_s & mainNotificationConfiguration)
+bool changeMainNotificationConfiguration(std::vector<am_NotificationConfiguration_s> &listMainNotificationConfigurations,
+ const am_NotificationConfiguration_s &mainNotificationConfiguration)
{
std::vector<am_NotificationConfiguration_s>::iterator iter = listMainNotificationConfigurations.begin();
- for(; iter<listMainNotificationConfigurations.end(); ++iter)
+ for (; iter < listMainNotificationConfigurations.end(); ++iter)
{
- if( mainNotificationConfiguration.type == iter->type )
+ if ( mainNotificationConfiguration.type == iter->type )
{
#ifdef WITH_DATABASE_CHANGE_CHECK
- if( iter->status == mainNotificationConfiguration.status && iter->parameter == mainNotificationConfiguration.parameter )
+ if ( iter->status == mainNotificationConfiguration.status && iter->parameter == mainNotificationConfiguration.parameter )
+ {
return false;
+ }
#endif
*iter = mainNotificationConfiguration;
return true;
}
}
+
return false;
}
@@ -3204,13 +3410,16 @@ am_Error_e CAmDatabaseHandlerMap::changeMainSinkNotificationConfigurationDB(cons
if (!existSink(sinkID))
{
- logError(__METHOD_NAME__,"sinkID must be valid");
+ logError(__METHOD_NAME__, "sinkID must be valid");
return (E_NON_EXISTENT);
}
- if(!changeMainNotificationConfiguration(mMappedData.mSinkMap.at(sinkID).listMainNotificationConfigurations, mainNotificationConfiguration))
- return (E_NO_CHANGE);
- logVerbose("DatabaseHandler::changeMainSinkNotificationConfigurationDB changed MainNotificationConfiguration of source:", sinkID, "type:", mainNotificationConfiguration.type, "to status=", mainNotificationConfiguration.status, "and parameter=",mainNotificationConfiguration.parameter);
+ if (!changeMainNotificationConfiguration(mMappedData.mSinkMap.at(sinkID).listMainNotificationConfigurations, mainNotificationConfiguration))
+ {
+ return (E_NO_CHANGE);
+ }
+
+ logVerbose("DatabaseHandler::changeMainSinkNotificationConfigurationDB changed MainNotificationConfiguration of source:", sinkID, "type:", mainNotificationConfiguration.type, "to status=", mainNotificationConfiguration.status, "and parameter=", mainNotificationConfiguration.parameter);
NOTIFY_OBSERVERS2(dboSinkMainNotificationConfigurationChanged, sinkID, mainNotificationConfiguration)
@@ -3222,96 +3431,99 @@ am_Error_e CAmDatabaseHandlerMap::changeMainSourceNotificationConfigurationDB(co
if (!existSource(sourceID))
{
- logError(__METHOD_NAME__,"sourceID must be valid");
+ logError(__METHOD_NAME__, "sourceID must be valid");
return (E_NON_EXISTENT);
}
- if(!changeMainNotificationConfiguration(mMappedData.mSourceMap.at(sourceID).listMainNotificationConfigurations, mainNotificationConfiguration))
- return (E_NO_CHANGE);
+ if (!changeMainNotificationConfiguration(mMappedData.mSourceMap.at(sourceID).listMainNotificationConfigurations, mainNotificationConfiguration))
+ {
+ return (E_NO_CHANGE);
+ }
- logVerbose("DatabaseHandler::changeMainSourceNotificationConfigurationDB changed MainNotificationConfiguration of source:", sourceID, "type:", mainNotificationConfiguration.type, "to status=", mainNotificationConfiguration.status, "and parameter=",mainNotificationConfiguration.parameter);
+ logVerbose("DatabaseHandler::changeMainSourceNotificationConfigurationDB changed MainNotificationConfiguration of source:", sourceID, "type:", mainNotificationConfiguration.type, "to status=", mainNotificationConfiguration.status, "and parameter=", mainNotificationConfiguration.parameter);
NOTIFY_OBSERVERS2(dboSourceMainNotificationConfigurationChanged, sourceID, mainNotificationConfiguration)
return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t>& listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t>& listSinkConnectionFormats, const std::vector<bool>& convertionMatrix)
+am_Error_e CAmDatabaseHandlerMap::changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t> &listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t> &listSinkConnectionFormats, const std::vector<bool> &convertionMatrix)
{
- if (!existGateway(gatewayID))
- {
- logError(__METHOD_NAME__,"gatewayID must be valid");
- return (E_NON_EXISTENT);
- }
+ if (!existGateway(gatewayID))
+ {
+ logError(__METHOD_NAME__, "gatewayID must be valid");
+ return (E_NON_EXISTENT);
+ }
- if (!listSourceConnectionFormats.empty())
- {
- mMappedData.mGatewayMap.at(gatewayID).listSourceFormats = listSourceConnectionFormats;
- }
+ if (!listSourceConnectionFormats.empty())
+ {
+ mMappedData.mGatewayMap.at(gatewayID).listSourceFormats = listSourceConnectionFormats;
+ }
- if (!listSinkConnectionFormats.empty())
- {
- mMappedData.mGatewayMap.at(gatewayID).listSinkFormats = listSinkConnectionFormats;
- }
+ if (!listSinkConnectionFormats.empty())
+ {
+ mMappedData.mGatewayMap.at(gatewayID).listSinkFormats = listSinkConnectionFormats;
+ }
- if (!convertionMatrix.empty())
- {
- mListConnectionFormat.clear();
- mListConnectionFormat.insert(std::make_pair(gatewayID, convertionMatrix));
- }
+ if (!convertionMatrix.empty())
+ {
+ mListConnectionFormat.clear();
+ mListConnectionFormat.insert(std::make_pair(gatewayID, convertionMatrix));
+ }
- logVerbose("DatabaseHandler::changeGatewayDB changed Gateway with ID", gatewayID);
+ logVerbose("DatabaseHandler::changeGatewayDB changed Gateway with ID", gatewayID);
- //todo: check if observer needs to be adopted.
- return (E_OK);
+ // todo: check if observer needs to be adopted.
+ return (E_OK);
}
-am_Error_e CAmDatabaseHandlerMap::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)
+am_Error_e CAmDatabaseHandlerMap::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)
{
- if (!existConverter(converterID))
- {
- logError(__METHOD_NAME__,"converterID must be valid");
- return (E_NON_EXISTENT);
- }
+ if (!existConverter(converterID))
+ {
+ logError(__METHOD_NAME__, "converterID must be valid");
+ return (E_NON_EXISTENT);
+ }
- if (!listSourceConnectionFormats.empty())
- {
- mMappedData.mConverterMap.at(converterID).listSourceFormats = listSourceConnectionFormats;
- }
+ if (!listSourceConnectionFormats.empty())
+ {
+ mMappedData.mConverterMap.at(converterID).listSourceFormats = listSourceConnectionFormats;
+ }
- if (!listSinkConnectionFormats.empty())
- {
- mMappedData.mConverterMap.at(converterID).listSinkFormats = listSinkConnectionFormats;
- }
+ if (!listSinkConnectionFormats.empty())
+ {
+ mMappedData.mConverterMap.at(converterID).listSinkFormats = listSinkConnectionFormats;
+ }
- if (!convertionMatrix.empty())
- {
- mListConnectionFormat.clear();
- mListConnectionFormat.insert(std::make_pair(converterID, convertionMatrix));
- }
+ if (!convertionMatrix.empty())
+ {
+ mListConnectionFormat.clear();
+ mListConnectionFormat.insert(std::make_pair(converterID, convertionMatrix));
+ }
- logVerbose("DatabaseHandler::changeConverterDB changed Gateway with ID", converterID);
+ logVerbose("DatabaseHandler::changeConverterDB changed Gateway with ID", converterID);
- //todo: check if observer needs to be adopted.
- return (E_OK);
+ // todo: check if observer needs to be adopted.
+ return (E_OK);
}
-bool changeNotificationConfiguration(std::vector<am_NotificationConfiguration_s> & listNotificationConfigurations, const am_NotificationConfiguration_s & notificationConfiguration)
+bool changeNotificationConfiguration(std::vector<am_NotificationConfiguration_s> &listNotificationConfigurations, const am_NotificationConfiguration_s &notificationConfiguration)
{
- bool changed = false;
- std::vector<am_NotificationConfiguration_s>::iterator iter = listNotificationConfigurations.begin();
- for(; iter<listNotificationConfigurations.end(); ++iter)
- {
- if( notificationConfiguration.type == iter->type )
- {
- iter->status = notificationConfiguration.status;
- iter->parameter = notificationConfiguration.parameter;
- changed |= true;
- }
- }
- return changed;
+ bool changed = false;
+ std::vector<am_NotificationConfiguration_s>::iterator iter = listNotificationConfigurations.begin();
+ for (; iter < listNotificationConfigurations.end(); ++iter)
+ {
+ if ( notificationConfiguration.type == iter->type )
+ {
+ iter->status = notificationConfiguration.status;
+ iter->parameter = notificationConfiguration.parameter;
+ changed |= true;
+ }
+ }
+
+ return changed;
}
am_Error_e CAmDatabaseHandlerMap::changeSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration)
@@ -3319,15 +3531,18 @@ am_Error_e CAmDatabaseHandlerMap::changeSinkNotificationConfigurationDB(const am
if (!existSink(sinkID))
{
- logError(__METHOD_NAME__,"sinkID must be valid");
+ logError(__METHOD_NAME__, "sinkID must be valid");
return (E_NON_EXISTENT);
}
- if(!changeNotificationConfiguration(mMappedData.mSinkMap.at(sinkID).listNotificationConfigurations, notificationConfiguration))
- return (E_NO_CHANGE);
- logVerbose("DatabaseHandler::changeMainSinkNotificationConfigurationDB changed MainNotificationConfiguration of source:", sinkID, "type:", notificationConfiguration.type, "to status=", notificationConfiguration.status, "and parameter=",notificationConfiguration.parameter);
+ if (!changeNotificationConfiguration(mMappedData.mSinkMap.at(sinkID).listNotificationConfigurations, notificationConfiguration))
+ {
+ return (E_NO_CHANGE);
+ }
+
+ logVerbose("DatabaseHandler::changeMainSinkNotificationConfigurationDB changed MainNotificationConfiguration of source:", sinkID, "type:", notificationConfiguration.type, "to status=", notificationConfiguration.status, "and parameter=", notificationConfiguration.parameter);
- //todo:: inform obsever here...
+ // todo:: inform obsever here...
return (E_NON_EXISTENT);
}
@@ -3336,84 +3551,101 @@ am_Error_e CAmDatabaseHandlerMap::changeSourceNotificationConfigurationDB(const
if (!existSource(sourceID))
{
- logError(__METHOD_NAME__,"sourceID must be valid");
+ logError(__METHOD_NAME__, "sourceID must be valid");
return (E_NON_EXISTENT);
}
- if(!changeNotificationConfiguration(mMappedData.mSourceMap.at(sourceID).listNotificationConfigurations, notificationConfiguration))
- return (E_NO_CHANGE);
+ if (!changeNotificationConfiguration(mMappedData.mSourceMap.at(sourceID).listNotificationConfigurations, notificationConfiguration))
+ {
+ return (E_NO_CHANGE);
+ }
- logVerbose("DatabaseHandler::changeSourceNotificationConfigurationDB changed MainNotificationConfiguration of source:", sourceID, "type:", notificationConfiguration.type, "to status=", notificationConfiguration.status, "and parameter=",notificationConfiguration.parameter);
+ logVerbose("DatabaseHandler::changeSourceNotificationConfigurationDB changed MainNotificationConfiguration of source:", sourceID, "type:", notificationConfiguration.type, "to status=", notificationConfiguration.status, "and parameter=", notificationConfiguration.parameter);
- //todo:: implement observer function
+ // todo:: implement observer function
return (E_NON_EXISTENT);
}
-am_Error_e CAmDatabaseHandlerMap::enumerateSources(std::function<void(const am_Source_s & element)> cb) const
+am_Error_e CAmDatabaseHandlerMap::enumerateSources(std::function<void(const am_Source_s &element)> cb) const
{
- for(auto it = mMappedData.mSourceMap.begin(); it!=mMappedData.mSourceMap.end(); it++)
- {
- const am_Source_Database_s *pObject = &it->second;
- if( 0==pObject->reserved )
- cb(*pObject);
- }
- return E_OK;
+ for (auto it = mMappedData.mSourceMap.begin(); it != mMappedData.mSourceMap.end(); it++)
+ {
+ const am_Source_Database_s *pObject = &it->second;
+ if ( 0 == pObject->reserved )
+ {
+ cb(*pObject);
+ }
+ }
+
+ return E_OK;
}
-am_Error_e CAmDatabaseHandlerMap::enumerateSinks(std::function<void(const am_Sink_s & element)> cb) const
+am_Error_e CAmDatabaseHandlerMap::enumerateSinks(std::function<void(const am_Sink_s &element)> cb) const
{
- for(auto it = mMappedData.mSinkMap.begin(); it!=mMappedData.mSinkMap.end(); it++)
- {
- const am_Sink_Database_s *pObject = &it->second;
- if( 0==pObject->reserved )
- cb(*pObject);
- }
- return E_OK;
+ for (auto it = mMappedData.mSinkMap.begin(); it != mMappedData.mSinkMap.end(); it++)
+ {
+ const am_Sink_Database_s *pObject = &it->second;
+ if ( 0 == pObject->reserved )
+ {
+ cb(*pObject);
+ }
+ }
+
+ return E_OK;
}
-am_Error_e CAmDatabaseHandlerMap::enumerateGateways(std::function<void(const am_Gateway_s & element)> cb) const
+am_Error_e CAmDatabaseHandlerMap::enumerateGateways(std::function<void(const am_Gateway_s &element)> cb) const
{
- for(auto it = mMappedData.mGatewayMap.begin(); it!=mMappedData.mGatewayMap.end(); it++)
- {
- const am_Gateway_s *pObject = &it->second;
- cb(*pObject);
- }
- return E_OK;
+ for (auto it = mMappedData.mGatewayMap.begin(); it != mMappedData.mGatewayMap.end(); it++)
+ {
+ const am_Gateway_s *pObject = &it->second;
+ cb(*pObject);
+ }
+
+ return E_OK;
}
-am_Error_e CAmDatabaseHandlerMap::enumerateConverters(std::function<void(const am_Converter_s & element)> cb) const
+am_Error_e CAmDatabaseHandlerMap::enumerateConverters(std::function<void(const am_Converter_s &element)> cb) const
{
- for(auto it = mMappedData.mConverterMap.begin(); it!=mMappedData.mConverterMap.end(); it++)
- {
- const am_Converter_s *pObject = &it->second;
- cb(*pObject);
- }
- return E_OK;
+ for (auto it = mMappedData.mConverterMap.begin(); it != mMappedData.mConverterMap.end(); it++)
+ {
+ const am_Converter_s *pObject = &it->second;
+ cb(*pObject);
+ }
+
+ return E_OK;
}
-bool CAmDatabaseHandlerMap::registerObserver(IAmDatabaseObserver * iObserver) {
- assert(iObserver!=NULL);
- if (std::find(mDatabaseObservers.begin(), mDatabaseObservers.end(), iObserver) == mDatabaseObservers.end())
- {
- mDatabaseObservers.push_back(static_cast<AmDatabaseObserverCallbacks*>(iObserver));
- static_cast<AmDatabaseObserverCallbacks*>(iObserver)->mpDatabaseHandler = this;
- 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);
- static_cast<AmDatabaseObserverCallbacks*>(iObserver)->mpDatabaseHandler = nullptr;
- return true;
- }
- return false;
-}
-
-unsigned CAmDatabaseHandlerMap::countObservers() {
- return mDatabaseObservers.size();
+bool CAmDatabaseHandlerMap::registerObserver(IAmDatabaseObserver *iObserver)
+{
+ assert(iObserver != NULL);
+ if (std::find(mDatabaseObservers.begin(), mDatabaseObservers.end(), iObserver) == mDatabaseObservers.end())
+ {
+ mDatabaseObservers.push_back(static_cast<AmDatabaseObserverCallbacks *>(iObserver));
+ static_cast<AmDatabaseObserverCallbacks *>(iObserver)->mpDatabaseHandler = this;
+ 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);
+ static_cast<AmDatabaseObserverCallbacks *>(iObserver)->mpDatabaseHandler = nullptr;
+ return true;
+ }
+
+ return false;
+}
+
+unsigned CAmDatabaseHandlerMap::countObservers()
+{
+ return mDatabaseObservers.size();
}
}
diff --git a/AudioManagerCore/src/CAmLog.cpp b/AudioManagerCore/src/CAmLog.cpp
index 5e58f27..6562eed 100644
--- a/AudioManagerCore/src/CAmLog.cpp
+++ b/AudioManagerCore/src/CAmLog.cpp
@@ -23,79 +23,84 @@
#include "CAmLog.h"
-
void CAmLog::CAmFileLogger::generateLogFilename(std::string &result)
{
- static uint32_t logFileID = 1;
- time_t rawtime;
- time (&rawtime);
+ static uint32_t logFileID = 1;
+ time_t rawtime;
+ time(&rawtime);
- std::ostringstream stream;
- stream << DEFAULT_LOG_FOLDER << DEFAULT_LOGFILE_PREFIX << logFileID << "_" << rawtime << DEFAULT_LOGFILE_EXT;
- logFileID++;
- result = stream.str();
+ std::ostringstream stream;
+ stream << DEFAULT_LOG_FOLDER << DEFAULT_LOGFILE_PREFIX << logFileID << "_" << rawtime << DEFAULT_LOGFILE_EXT;
+ logFileID++;
+ result = stream.str();
}
CAmLog::CAmFileLogger::~CAmFileLogger()
{
- if (mOutputStream)
- {
- std::ofstream* of = static_cast<std::ofstream*>(mOutputStream);
- of->close();
- DEL(mOutputStream);
- }
+ if (mOutputStream)
+ {
+ std::ofstream *of = static_cast<std::ofstream *>(mOutputStream);
+ of->close();
+ DEL(mOutputStream);
+ }
}
-CAmLog::CAmLog(const eCAmLogType type ):mLogType(type)
+CAmLog::CAmLog(const eCAmLogType type)
+ : mLogType(type)
{
- instantiateLogger(type);
+ instantiateLogger(type);
}
-CAmLog::CAmLog():mLogType(eCAmLogStdout)
+CAmLog::CAmLog()
+ : mLogType(eCAmLogStdout)
{
- instantiateLogger((const eCAmLogType)eCAmLogStdout);
+ instantiateLogger((const eCAmLogType)eCAmLogStdout);
}
CAmLog::~CAmLog()
{
- releaseLogger();
+ releaseLogger();
}
void CAmLog::releaseLogger()
{
- if(mLogger)
- DEL(mLogger);
+ if (mLogger)
+ {
+ DEL(mLogger);
+ }
}
-void CAmLog::instantiateLogger( const eCAmLogType type)
+void CAmLog::instantiateLogger(const eCAmLogType type)
{
- if( eCAmLogStdout == type )
- mLogger = new CAmStdOutLogger();
- else if( eCAmLogFile == type )
- {
- std::string filename("");
- CAmLog::CAmFileLogger::generateLogFilename(filename);
- mLogger = new CAmFileLogger(filename);
- }
+ if ( eCAmLogStdout == type )
+ {
+ mLogger = new CAmStdOutLogger();
+ }
+ else if ( eCAmLogFile == type )
+ {
+ std::string filename("");
+ CAmLog::CAmFileLogger::generateLogFilename(filename);
+ mLogger = new CAmFileLogger(filename);
+ }
}
CAmLog *CAmLog::getDefaultLog()
{
- static CAmLog theInstance;
- return &theInstance;
+ static CAmLog theInstance;
+ return &theInstance;
}
-void CAmLog::setLogType( const eCAmLogType type)
+void CAmLog::setLogType(const eCAmLogType type)
{
- if(mLogType!=type)
- {
- mLogType = type;
- releaseLogger();
- instantiateLogger(type);
- }
+ if (mLogType != type)
+ {
+ mLogType = type;
+ releaseLogger();
+ instantiateLogger(type);
+ }
}
eCAmLogType CAmLog::getLogType() const
{
- return mLogType;
+ return mLogType;
}
diff --git a/AudioManagerCore/src/CAmRouter.cpp b/AudioManagerCore/src/CAmRouter.cpp
index 3c9bee4..042916d 100644
--- a/AudioManagerCore/src/CAmRouter.cpp
+++ b/AudioManagerCore/src/CAmRouter.cpp
@@ -34,964 +34,1047 @@
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);
- }
-
- 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)
- {
+template<class X>
+void getMergeConnectionFormats(const X *element, const am_CustomConnectionFormat_t connectionFormat,
+ const std::vector<am_CustomConnectionFormat_t> &listConnectionFormats, std::vector<am_CustomConnectionFormat_t> &outListMergeConnectionFormats)
+{
+ std::vector<am_CustomConnectionFormat_t> listRestrictedConnectionFormats;
+ CAmRouter::getRestrictedOutputFormats(element->convertionMatrix, element->listSourceFormats, element->listSinkFormats, connectionFormat,
+ listRestrictedConnectionFormats);
+ std::sort(listRestrictedConnectionFormats.begin(), listRestrictedConnectionFormats.end()); // todo: this might be not needed if we use strictly sorted input
+ std::insert_iterator<std::vector<am_CustomConnectionFormat_t> > inserter(outListMergeConnectionFormats, outListMergeConnectionFormats.begin());
+ set_intersection(listConnectionFormats.begin(), listConnectionFormats.end(), listRestrictedConnectionFormats.begin(),
+ listRestrictedConnectionFormats.end(), inserter);
+}
+
+CAmRouter::CAmRouter(IAmDatabaseHandler *iDatabaseHandler, CAmControlSender *iSender)
+ : CAmDatabaseHandlerMap::AmDatabaseObserverCallbacks()
+ , mpDatabaseHandler(iDatabaseHandler)
+ , mpControlSender(iSender)
+ , 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;
+ dboNewSource = [&](const am_Source_s &source){
+ mUpdateGraphNodesAction = true;
};
- dboNewGateway = [&](const am_Gateway_s& gateway)
- {
- mUpdateGraphNodesAction=true;
+ dboNewGateway = [&](const am_Gateway_s &gateway){
+ mUpdateGraphNodesAction = true;
};
- dboNewConverter = [&](const am_Converter_s& coverter)
- {
- mUpdateGraphNodesAction=true;
+ dboNewConverter = [&](const am_Converter_s &coverter){
+ mUpdateGraphNodesAction = true;
};
- dboRemovedSink = [&](const am_sinkID_t sinkID, const bool visible)
- {
- mUpdateGraphNodesAction=true;
+ dboRemovedSink = [&](const am_sinkID_t sinkID, const bool visible){
+ mUpdateGraphNodesAction = true;
};
- dboRemovedSource = [&](const am_sourceID_t sourceID, const bool visible)
- {
- mUpdateGraphNodesAction=true;
+ dboRemovedSource = [&](const am_sourceID_t sourceID, const bool visible){
+ mUpdateGraphNodesAction = true;
};
- dboRemoveGateway = [&](const am_gatewayID_t gatewayID)
- {
- mUpdateGraphNodesAction=true;
+ dboRemoveGateway = [&](const am_gatewayID_t gatewayID){
+ mUpdateGraphNodesAction = true;
};
- dboRemoveConverter = [&](const am_converterID_t converterID)
- {
- mUpdateGraphNodesAction=true;
+ dboRemoveConverter = [&](const am_converterID_t converterID){
+ mUpdateGraphNodesAction = true;
};
- }
-
- 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()
+{
+}
- am_Error_e CAmRouter::getRoute(const bool onlyfree, const am_Source_s & aSource, const am_Sink_s & aSink, std::vector<am_Route_s> & listRoutes)
+/**
+ * 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)
{
- return getRoute(onlyfree, aSource.sourceID, aSink.sinkID, listRoutes);
+ load();
+ mUpdateGraphNodesAction = false;
}
- am_Error_e CAmRouter::getRouteFromLoadedNodes(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID,
- std::vector<am_Route_s> & returnList)
- {
- returnList.clear();
-
- CAmRoutingNode* pRootSource = sourceNodeWithID(sourceID);
- CAmRoutingNode* pRootSink = sinkNodeWithID(sinkID);
+ return getRouteFromLoadedNodes(onlyfree, sourceID, sinkID, returnList);
+}
- 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)
+{
+ return getRoute(onlyfree, aSource.sourceID, aSink.sinkID, listRoutes);
+}
- //try to find paths without cycles
- am_Error_e error = getFirstNShortestPaths(onlyfree, 0, mMaxPathCount, *pRootSource, *pRootSink, returnList);
+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();
- //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);
- }
+ CAmRoutingNode *pRootSource = sourceNodeWithID(sourceID);
+ CAmRoutingNode *pRootSink = sinkNodeWithID(sinkID);
- /* For shortest path use the following call:
- *
- * error = getShortestPath(*pRootSource, *pRootSink, listRoutes);
- */
- return error;
+ if (!pRootSource || !pRootSink)
+ {
+ return E_NON_EXISTENT;
}
- am_Error_e CAmRouter::getRouteFromLoadedNodes(const bool onlyfree, const am_Source_s & aSource, const am_Sink_s & aSink,
- std::vector<am_Route_s> & listRoutes)
+ // try to find paths without cycles
+ am_Error_e error = getFirstNShortestPaths(onlyfree, 0, mMaxPathCount, *pRootSource, *pRootSink, returnList);
+
+ // if no paths have been found, we start a second search with cycles.
+ if (!returnList.size() && mMaxAllowedCycles > 0)
{
- return getRouteFromLoadedNodes(onlyfree, aSource.sourceID, aSink.sinkID, listRoutes);
+ error = getFirstNShortestPaths(onlyfree, mMaxAllowedCycles, mMaxPathCount, *pRootSource, *pRootSink, returnList);
}
- void CAmRouter::load()
- {
- clear();
+ /* For shortest path use the following call:
+ *
+ * error = getShortestPath(*pRootSource, *pRootSink, listRoutes);
+ */
+ return error;
+}
- am_RoutingNodeData_s nodeDataSrc;
- nodeDataSrc.type = CAmNodeDataType::SOURCE;
- mpDatabaseHandler->enumerateSources([&](const am_Source_s & obj)
- {
- nodeDataSrc.data.source = (am_Source_s*)&obj;
+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);
+}
+
+void CAmRouter::load()
+{
+ clear();
+
+ 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;
+ 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;
+ 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;
+ am_RoutingNodeData_s nodeDataConverter;
+ nodeDataConverter.type = CAmNodeDataType::CONVERTER;
+ mpDatabaseHandler->enumerateConverters([&](const am_Converter_s &obj){
+ nodeDataConverter.data.converter = (am_Converter_s *)&obj;
auto node = &mRoutingGraph.addNode(nodeDataConverter);
mNodeListConverters[nodeDataConverter.data.converter->domainID].push_back(node);
});
- constructConverterConnections();
- constructGatewayConnections();
- constructSourceSinkConnections();
+ constructConverterConnections();
+ constructGatewayConnections();
+ constructSourceSinkConnections();
#ifdef TRACE_GRAPH
- mRoutingGraph.trace([&](const CAmRoutingNode & node, const std::vector<CAmVertex<am_RoutingNodeData_s,uint16_t>*> & list)
- {
- std::cout << "Node " << node.getIndex() << ":";
- ((CAmRoutingNode &)node).getData().trace();
- std::cout << "-->[";
- int count = 0;
- std::for_each(list.begin(), list.end(), [&](const CAmVertex<am_RoutingNodeData_s,uint16_t>* refVertex)
- {
- am::CAmNode<am::am_RoutingNodeData_s>* data = refVertex->getNode();
- if(count>0)
- std::cout << ", ";
- std::cout << "Node " << data->getIndex() << ":";
- data->getData().trace();
- count++;
- });
- std::cout << "]" << std::endl;
+ mRoutingGraph.trace([&](const CAmRoutingNode &node, const std::vector<CAmVertex<am_RoutingNodeData_s, uint16_t> *> &list){
+ std::cout << "Node " << node.getIndex() << ":";
+ ((CAmRoutingNode &)node).getData().trace();
+ std::cout << "-->[";
+ int count = 0;
+ std::for_each(list.begin(), list.end(), [&](const CAmVertex<am_RoutingNodeData_s, uint16_t> *refVertex){
+ am::CAmNode<am::am_RoutingNodeData_s> *data = refVertex->getNode();
+ if (count > 0)
+ {
+ std::cout << ", ";
+ }
+
+ std::cout << "Node " << data->getIndex() << ":";
+ data->getData().trace();
+ count++;
});
-#endif
+ std::cout << "]" << std::endl;
+ });
+#endif // ifdef TRACE_GRAPH
- }
+}
- void CAmRouter::clear()
- {
- mRoutingGraph.clear();
- mNodeListSources.clear();
- mNodeListSinks.clear();
- mNodeListGateways.clear();
- mNodeListConverters.clear();
- }
+void CAmRouter::clear()
+{
+ mRoutingGraph.clear();
+ mNodeListSources.clear();
+ mNodeListSinks.clear();
+ mNodeListGateways.clear();
+ mNodeListConverters.clear();
+}
- CAmRoutingNode* CAmRouter::sinkNodeWithID(const am_sinkID_t sinkID)
+CAmRoutingNode *CAmRouter::sinkNodeWithID(const am_sinkID_t sinkID)
+{
+ CAmRoutingNode *result = NULL;
+ for (auto it = mNodeListSinks.begin(); it != mNodeListSinks.end(); it++)
{
- CAmRoutingNode* result = NULL;
- for (auto it = mNodeListSinks.begin(); it != mNodeListSinks.end(); it++)
+ result = sinkNodeWithID(sinkID, it->first);
+ if (result)
{
- result = sinkNodeWithID(sinkID, it->first);
- if (result)
- return result;
+ return result;
}
- return result;
}
- CAmRoutingNode* CAmRouter::sinkNodeWithID(const am_sinkID_t sinkID, const am_domainID_t domainID)
+ 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())
{
- 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;
+ result = *iter;
}
- CAmRoutingNode* CAmRouter::sourceNodeWithID(const am_sourceID_t sourceID)
+ return result;
+}
+
+CAmRoutingNode *CAmRouter::sourceNodeWithID(const am_sourceID_t sourceID)
+{
+ CAmRoutingNode *result = NULL;
+ for (auto it = mNodeListSources.begin(); it != mNodeListSources.end(); it++)
{
- CAmRoutingNode* result = NULL;
- for (auto it = mNodeListSources.begin(); it != mNodeListSources.end(); it++)
+ result = sourceNodeWithID(sourceID, it->first);
+ if (result)
{
- result = sourceNodeWithID(sourceID, it->first);
- if (result)
- return result;
+ return result;
}
- return result;
}
- CAmRoutingNode* CAmRouter::sourceNodeWithID(const am_sourceID_t sourceID, const am_domainID_t domainID)
+ 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())
{
- 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;
+ result = *iter;
}
- CAmRoutingNode* CAmRouter::converterNodeWithSinkID(const am_sinkID_t sinkID, const am_domainID_t domainID)
+ 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())
{
- 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;
+ result = *iter;
}
- CAmRoutingNode* CAmRouter::gatewayNodeWithSinkID(const am_sinkID_t sinkID)
+ return result;
+}
+
+CAmRoutingNode *CAmRouter::gatewayNodeWithSinkID(const am_sinkID_t sinkID)
+{
+ for (auto it = mNodeListGateways.begin(); it != mNodeListGateways.end(); it++)
{
- 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())
{
- 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 *iter;
}
- return NULL;
}
- void CAmRouter::constructSourceSinkConnections()
+ return NULL;
+}
+
+void CAmRouter::constructSourceSinkConnections()
+{
+ std::vector<am_CustomConnectionFormat_t> intersection;
+ for (auto itSrc = mNodeListSources.begin(); itSrc != mNodeListSources.end(); itSrc++)
{
- 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++)
{
- 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* 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
{
- 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);
- }
+ mRoutingGraph.connectNodes(*srcNode, *sinkNode, CF_UNKNOWN, 1);
}
}
}
}
+}
- void CAmRouter::constructGatewayConnections()
+void CAmRouter::constructGatewayConnections()
+{
+ std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
+ for (auto iter = mNodeListGateways.begin(); iter != mNodeListGateways.end(); iter++)
{
- 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++)
{
- 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)
{
- 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))
{
- 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)
{
- 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);
- }
+ // 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;
+void CAmRouter::constructConverterConnections()
+{
+ std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
- for (auto iter = mNodeListConverters.begin(); iter != mNodeListConverters.end(); iter++)
+ for (auto iter = mNodeListConverters.begin(); iter != mNodeListConverters.end(); iter++)
+ {
+ for (auto it = iter->second.begin(); it != iter->second.end(); it++)
{
- 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)
{
- 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))
{
- 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)
{
- 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);
- }
+ // Connections hidden_sink->converter->hidden_source
+ mRoutingGraph.connectNodes(*converterSinkNode, *converterNode, CF_UNKNOWN, 1);
+ mRoutingGraph.connectNodes(*converterNode, *converterSourceNode, CF_UNKNOWN, 1);
}
}
}
}
}
+}
- void CAmRouter::getVerticesForSource(const CAmRoutingNode & node, CAmRoutingListVertices & list)
+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++)
{
- 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
{
- 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);
- }
+ list.emplace_back(sinkNode, CF_UNKNOWN, 1);
}
}
+}
- void CAmRouter::getVerticesForSink(const CAmRoutingNode & node, CAmRoutingListVertices & list)
+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)
{
- am_RoutingNodeData_s & sinkNodeData = ((CAmRoutingNode*) &node)->getData();
- std::vector<am_CustomConnectionFormat_t> intersection;
- am_Sink_s * sink = sinkNodeData.data.sink;
+ std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
+ am_RoutingNodeData_s &converterData = converterNode->getData();
+ am_Converter_s *converter = converterData.data.converter;
- CAmRoutingNode *converterNode = converterNodeWithSinkID(sink->sinkID, sink->domainID);
- if (converterNode)
+ if (getAllowedFormatsFromConvMatrix(converter->convertionMatrix, converter->listSourceFormats, converter->listSinkFormats, sourceFormats,
+ sinkFormats))
{
- std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
- am_RoutingNodeData_s & converterData = converterNode->getData();
- am_Converter_s * converter = converterData.data.converter;
-
- if (getAllowedFormatsFromConvMatrix(converter->convertionMatrix, converter->listSourceFormats, converter->listSinkFormats, sourceFormats,
- sinkFormats))
- list.emplace_back(converterNode, CF_UNKNOWN, 1);
+ list.emplace_back(converterNode, CF_UNKNOWN, 1);
}
- else
+ }
+ else
+ {
+ std::vector<am_CustomConnectionFormat_t> sourceFormats, sinkFormats;
+ CAmRoutingNode *gatewayNode = gatewayNodeWithSinkID(sink->sinkID);
+ if (gatewayNode)
{
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;
+ 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);
+ if (getAllowedFormatsFromConvMatrix(gateway->convertionMatrix, gateway->listSourceFormats, gateway->listSinkFormats, sourceFormats,
+ sinkFormats))
+ {
+ list.emplace_back(gatewayNode, CF_UNKNOWN, 1);
}
}
-
}
+}
- void CAmRouter::getVerticesForConverter(const CAmRoutingNode & node, CAmRoutingListVertices & list)
+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))
{
- 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)
{
- CAmRoutingNode *converterSourceNode = this->sourceNodeWithID(converter->sourceID, converter->domainID);
- if (converterSourceNode)
- {
- list.emplace_back(converterSourceNode, CF_UNKNOWN, 1);
- }
+ list.emplace_back(converterSourceNode, CF_UNKNOWN, 1);
}
}
+}
- void CAmRouter::getVerticesForGateway(const CAmRoutingNode & node, CAmRoutingListVertices & list)
+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))
{
- 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)
{
- CAmRoutingNode *gatewaySourceNode = this->sourceNodeWithID(gateway->sourceID, gateway->domainSourceID);
- if (gatewaySourceNode)
- {
- //Connections hidden_sink->gateway->hidden_source
- list.emplace_back(gatewaySourceNode, CF_UNKNOWN, 1);
- }
+ // Connections hidden_sink->gateway->hidden_source
+ list.emplace_back(gatewaySourceNode, CF_UNKNOWN, 1);
}
}
+}
- void CAmRouter::getVerticesForNode(const CAmRoutingNode & node, CAmRoutingListVertices & list)
+void CAmRouter::getVerticesForNode(const CAmRoutingNode &node, CAmRoutingListVertices &list)
+{
+ am_RoutingNodeData_s &nodeData = ((CAmRoutingNode *)&node)->getData();
+ if (nodeData.type == CAmNodeDataType::SOURCE)
{
- am_RoutingNodeData_s & nodeData = ((CAmRoutingNode*) &node)->getData();
- if (nodeData.type == CAmNodeDataType::SOURCE)
+ getVerticesForSource(node, list);
+ }
+ else if (nodeData.type == CAmNodeDataType::SINK)
+ {
+ getVerticesForSink(node, list);
+ }
+ else if (nodeData.type == CAmNodeDataType::CONVERTER)
+ {
+ getVerticesForConverter(node, list);
+ }
+ else if (nodeData.type == CAmNodeDataType::GATEWAY)
+ {
+ getVerticesForGateway(node, list);
+ }
+}
+
+am_Error_e CAmRouter::determineConnectionFormatsForPath(am_Route_s &routeObjects, std::vector<CAmRoutingNode *> &nodes, std::vector<am_Route_s> &result)
+{
+ std::vector<am_RoutingElement_s>::iterator routingElementIterator = routeObjects.route.begin();
+ std::vector<CAmRoutingNode *>::iterator nodeIterator = nodes.begin();
+ if (routingElementIterator != routeObjects.route.end() && nodeIterator != nodes.end())
+ {
+ return doConnectionFormatsForPath(routeObjects, nodes, routingElementIterator, nodeIterator, result);
+ }
+
+ return E_OK;
+}
+
+am_Error_e CAmRouter::doConnectionFormatsForPath(am_Route_s &routeObjects, std::vector<CAmRoutingNode *> &nodes,
+ std::vector<am_RoutingElement_s>::iterator routingElementIterator, std::vector<CAmRoutingNode *>::iterator nodeIterator,
+ std::vector<am_Route_s> &result)
+{
+ am_Error_e returnError = E_NOT_POSSIBLE;
+ std::vector<am_CustomConnectionFormat_t> listConnectionFormats;
+ std::vector<am_CustomConnectionFormat_t> listMergeConnectionFormats;
+
+ std::vector<CAmRoutingNode *>::iterator currentNodeIterator = nodeIterator;
+ std::vector<am_RoutingElement_s>::iterator currentRoutingElementIterator = routingElementIterator;
+
+ if (currentRoutingElementIterator != routeObjects.route.begin())
+ {
+ std::vector<am_CustomConnectionFormat_t> listConnectionFormats;
+ std::vector<am_RoutingElement_s>::iterator tempIterator = (currentRoutingElementIterator - 1);
+ CAmRoutingNode *currentNode = *currentNodeIterator;
+ if ((returnError = getSourceSinkPossibleConnectionFormats(currentNodeIterator + 1, currentNodeIterator + 2, listConnectionFormats)) != E_OK)
{
- getVerticesForSource(node, list);
+ return returnError;
}
- else if (nodeData.type == CAmNodeDataType::SINK)
+
+ if (currentNode->getData().type == CAmNodeDataType::GATEWAY)
{
- getVerticesForSink(node, list);
+ am_Gateway_s *gateway = currentNode->getData().data.gateway;
+ getMergeConnectionFormats(gateway, tempIterator->connectionFormat, listConnectionFormats, listMergeConnectionFormats);
}
- else if (nodeData.type == CAmNodeDataType::CONVERTER)
+ else if (currentNode->getData().type == CAmNodeDataType::CONVERTER)
{
- getVerticesForConverter(node, list);
+ am_Converter_s *converter = currentNode->getData().data.converter;
+ getMergeConnectionFormats(converter, tempIterator->connectionFormat, listConnectionFormats, listMergeConnectionFormats);
}
- else if (nodeData.type == CAmNodeDataType::GATEWAY)
+ else
{
- getVerticesForGateway(node, list);
+ return (E_UNKNOWN);
}
- }
- 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;
+ currentNodeIterator += 3;
}
-
- 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)
+ else
{
- am_Error_e returnError = E_NOT_POSSIBLE;
- std::vector<am_CustomConnectionFormat_t> listConnectionFormats;
- std::vector<am_CustomConnectionFormat_t> listMergeConnectionFormats;
+ CAmRoutingNode *currentNode = *currentNodeIterator;
+ if (currentNode->getData().type != CAmNodeDataType::SOURCE)
+ {
+ return (E_UNKNOWN);
+ }
- std::vector<CAmRoutingNode*>::iterator currentNodeIterator = nodeIterator;
- std::vector<am_RoutingElement_s>::iterator currentRoutingElementIterator = routingElementIterator;
+ currentNodeIterator++;
- if (currentRoutingElementIterator != routeObjects.route.begin())
+ if (currentNodeIterator == nodes.end())
{
- 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;
+ return (E_UNKNOWN);
}
- else
+
+ CAmRoutingNode *nodeSink = *currentNodeIterator;
+ if (nodeSink->getData().type != CAmNodeDataType::SINK)
{
- 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
+ return (E_UNKNOWN);
}
- //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())
+
+ 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)
{
- for (; connectionFormatIterator != listPriorityConnectionFormats.end(); ++connectionFormatIterator)
- {
- currentRoutingElementIterator->connectionFormat = *connectionFormatIterator;
- result.push_back(routeObjects);
- }
+ currentRoutingElementIterator->connectionFormat = *connectionFormatIterator;
+ result.push_back(routeObjects);
}
- else
+ }
+ else
+ {
+ for (; connectionFormatIterator != listPriorityConnectionFormats.end(); ++connectionFormatIterator)
{
- for (; connectionFormatIterator != listPriorityConnectionFormats.end(); ++connectionFormatIterator)
- {
- currentRoutingElementIterator->connectionFormat = *connectionFormatIterator;
- doConnectionFormatsForPath(routeObjects, nodes, nextIterator, currentNodeIterator, result);
- }
+ currentRoutingElementIterator->connectionFormat = *connectionFormatIterator;
+ doConnectionFormatsForPath(routeObjects, nodes, nextIterator, currentNodeIterator, result);
}
- return (E_OK);
}
- am_Error_e CAmRouter::cfPermutationsForPath(am_Route_s shortestRoute, std::vector<CAmRoutingNode*> resultNodesPath, std::vector<am_Route_s>& resultPath)
+ return (E_OK);
+}
+
+am_Error_e CAmRouter::cfPermutationsForPath(am_Route_s shortestRoute, std::vector<CAmRoutingNode *> resultNodesPath, std::vector<am_Route_s> &resultPath)
+{
+ std::vector<am_Route_s> result;
+ am_Error_e err = determineConnectionFormatsForPath(shortestRoute, resultNodesPath, result);
+ if (err != E_UNKNOWN)
{
- 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());
+ resultPath.insert(resultPath.end(), result.begin(), result.end());
#ifdef TRACE_GRAPH
- std::cout
+ std::cout
<< "Determined connection formats for path from source:"
<< shortestRoute.sourceID << " to sink:" << shortestRoute.sinkID
<< "\n";
- for (auto routeConnectionFormats : result)
+ for (auto routeConnectionFormats : result)
+ {
+ std::cout << "[";
+ for (auto it = routeConnectionFormats.route.begin(); it != routeConnectionFormats.route.end(); it++)
{
- std::cout << "[";
- for (auto it = routeConnectionFormats.route.begin();it != routeConnectionFormats.route.end(); it++)
+ am_RoutingElement_s &routingElement = *it;
+ if (it - routeConnectionFormats.route.begin() > 0)
{
- am_RoutingElement_s& routingElement = *it;
- if (it - routeConnectionFormats.route.begin() > 0)
std::cout << " -> ";
-
- std::cout << routingElement.sourceID << ":"
- << routingElement.sinkID << " CF:"
- << routingElement.connectionFormat << " D:"
- << routingElement.domainID;
}
- std::cout << "]\n";
+
+ std::cout << routingElement.sourceID << ":"
+ << routingElement.sinkID << " CF:"
+ << routingElement.connectionFormat << " D:"
+ << routingElement.domainID;
}
-#endif
+
+ std::cout << "]\n";
}
+#endif // ifdef TRACE_GRAPH
+ }
+
#ifdef TRACE_GRAPH
- else
- {
- std::cout
+ else
+ {
+ std::cout
<< "Error by determining connection formats for path from source:"
<< shortestRoute.sourceID << " to sink:" << shortestRoute.sinkID
<< "\n";
- }
-#endif
- return err;
}
+#endif // ifdef TRACE_GRAPH
+ return err;
+}
- am_Error_e CAmRouter::getShortestPath(CAmRoutingNode & aSource, CAmRoutingNode & aSink, std::vector<am_Route_s> & resultPath)
- {
- am_Error_e err = E_OK;
- am_Route_s shortestRoute;
- std::vector<CAmRoutingNode*> resultNodesPath;
- am_RoutingNodeData_s & sinkNodeData = aSink.getData();
- am_RoutingNodeData_s & sourceNodeData = aSource.getData();
- shortestRoute.sinkID = sinkNodeData.data.sink->sinkID;
- shortestRoute.sourceID = sourceNodeData.data.source->sourceID;
-
- mRoutingGraph.getShortestPath(aSource, aSink, [&shortestRoute, &resultNodesPath](const am_GraphPathPosition_e position, CAmRoutingNode & object)
- {
- am_RoutingElement_s * element;
- //reverse order
- resultNodesPath.insert(resultNodesPath.begin(), (CAmRoutingNode*)&object);
- am_RoutingNodeData_s & routingData = object.getData();
- if(routingData.type==CAmNodeDataType::SINK)
- {
- auto iter = shortestRoute.route.emplace(shortestRoute.route.begin());
- element = &(*iter);
- element->domainID = routingData.data.sink->domainID;
- element->sinkID = routingData.data.sink->sinkID;
- element->connectionFormat = CF_UNKNOWN;
- }
- else if(routingData.type==CAmNodeDataType::SOURCE)
- {
- element->domainID = routingData.data.source->domainID;
- element->sourceID = routingData.data.source->sourceID;
- element->connectionFormat = CF_UNKNOWN;
- }
- });
+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;
+ if (shortestRoute.route.size())
+ {
+ err = cfPermutationsForPath(shortestRoute, resultNodesPath, resultPath);
}
- int CAmRouter::insertPostion(const std::vector<CAmRoutingNode*>& path, const std::vector<std::vector<CAmRoutingNode*> >& nodes)
+ return err;
+}
+
+int CAmRouter::insertPostion(const std::vector<CAmRoutingNode *> &path, const std::vector<std::vector<CAmRoutingNode *> > &nodes)
+{
+ int index = 0;
+ if (!nodes.empty())
{
- int index = 0;
- if (!nodes.empty())
+ auto itNodes = nodes.begin();
+ for (; itNodes != nodes.end(); itNodes++)
{
- auto itNodes = nodes.begin();
- for (; itNodes != nodes.end(); itNodes++)
+ if (itNodes->size() > path.size())
{
- if (itNodes->size() > path.size())
- break;
+ break;
}
- if (itNodes == nodes.end())
- index = nodes.size();
- else
- index = itNodes - nodes.begin();
}
- return index;
+
+ if (itNodes == nodes.end())
+ {
+ index = nodes.size();
+ }
+ else
+ {
+ index = itNodes - nodes.begin();
+ }
}
- am_Error_e CAmRouter::getFirstNShortestPaths(const bool onlyFree, const unsigned cycles, const unsigned maxPathCount, CAmRoutingNode & aSource,
- CAmRoutingNode & aSink, std::vector<am_Route_s> & resultPath)
+ return index;
+}
+
+am_Error_e CAmRouter::getFirstNShortestPaths(const bool onlyFree, const unsigned cycles, const unsigned maxPathCount, CAmRoutingNode &aSource,
+ CAmRoutingNode &aSink, std::vector<am_Route_s> &resultPath)
+{
+ if (aSource.getData().type != CAmNodeDataType::SOURCE || aSink.getData().type != CAmNodeDataType::SINK)
{
- 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());
+ return E_NOT_POSSIBLE;
+ }
- auto cbShouldVisitNode = [&visitedDomains, &cycles, &onlyFree, this](const CAmRoutingNode * node)->bool
- {
- if(CAmRouter::shouldGoInDomain(visitedDomains, node->getData().domainID(), cycles))
+ 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_RoutingNodeData_s &nodeData = node->getData();
+ if (am_RoutingNodeData_s::GATEWAY == nodeData.type)
{
- const am_Gateway_s * gateway = nodeData.data.gateway;
+ const am_Gateway_s *gateway = nodeData.data.gateway;
return (!onlyFree || !isComponentConnected(*gateway));
}
- else if(am_RoutingNodeData_s::CONVERTER==nodeData.type)
+ else if (am_RoutingNodeData_s::CONVERTER == nodeData.type)
{
- const am_Converter_s * converter = nodeData.data.converter;
+ 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)
- {
+ 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.emplace(nodes.begin() + index);
+ paths.emplace(paths.begin() + index);
nodes[index] = path;
- am_Route_s & nextRoute = paths[index];
- nextRoute.sinkID = sinkID;
+ 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_RoutingElement_s *element;
+ for (auto it = path.begin(); it != path.end(); it++)
{
- am_RoutingNodeData_s & routingData = (*it)->getData();
- if(routingData.type==CAmNodeDataType::SOURCE)
+ 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 = &(*iter);
+ element->domainID = routingData.data.source->domainID;
+ element->sourceID = routingData.data.source->sourceID;
element->connectionFormat = CF_UNKNOWN;
}
- else if(routingData.type==CAmNodeDataType::SINK)
+ else if (routingData.type == CAmNodeDataType::SINK)
{
- element->domainID = routingData.data.sink->domainID;
- element->sinkID = routingData.data.sink->sinkID;
+ 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++)
+ 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)
{
- cfError = cfPermutationsForPath(*it, nodes[it - paths.begin()], resultPath);
- if (E_OK == cfError)
- {
- pathsFound += (resultPath.size() > 0);
- }
+ pathsFound += (resultPath.size() > 0);
}
- if (pathsFound)
- return E_OK;
- else
- return E_NOT_POSSIBLE;
}
- bool CAmRouter::shouldGoInDomain(const std::vector<am_domainID_t> & visitedDomains, const am_domainID_t nodeDomainID, const unsigned maxCyclesNumber)
+ if (pathsFound)
+ {
+ return E_OK;
+ }
+ else
{
- unsigned recourseCounter(0);
- if (visitedDomains.size())
+ return E_NOT_POSSIBLE;
+ }
+}
+
+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)
{
- if (visitedDomains.back() == nodeDomainID)
- return true;
- unsigned count = 0;
- am_domainID_t lastDomain = 0;
- for (auto it = visitedDomains.begin(); it != visitedDomains.end() - 1; it++)
+ return true;
+ }
+
+ unsigned count = 0;
+ am_domainID_t lastDomain = 0;
+ for (auto it = visitedDomains.begin(); it != visitedDomains.end() - 1; it++)
+ {
+ if (lastDomain != *it)
{
- if (lastDomain != *it)
+ if (nodeDomainID == *it)
{
- if (nodeDomainID == *it)
+ recourseCounter++;
+ if (recourseCounter > maxCyclesNumber)
{
- recourseCounter++;
- if (recourseCounter > maxCyclesNumber)
- return false;
+ return false;
}
- lastDomain = *it;
}
+
+ lastDomain = *it;
}
}
- return true;
}
- bool CAmRouter::shouldGoInDomain(const std::vector<am_domainID_t> & visitedDomains, const am_domainID_t nodeDomainID)
+ return true;
+}
+
+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();
+
+ if (sizeSourceFormats == 0 || sizeSinkFormats == 0 || sizeConvertionMatrix == 0 || sizeConvertionMatrix != sizeSinkFormats * sizeSourceFormats)
{
- return CAmRouter::shouldGoInDomain(visitedDomains, nodeDomainID, mMaxAllowedCycles);
+ return false;
}
- 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)
+ std::vector<bool>::const_iterator iterator = convertionMatrix.begin();
+ for (; iterator != convertionMatrix.end(); ++iterator)
{
- 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)
+ if (true == *iterator)
{
- return false;
+ 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));
}
-
- std::vector<bool>::const_iterator iterator = convertionMatrix.begin();
- for (; iterator != convertionMatrix.end(); ++iterator)
- {
- if (true == *iterator)
- {
- const size_t index = iterator - convertionMatrix.begin();
- size_t idx = index % sizeSourceFormats;
- sourceFormats.push_back(listSourceFormats.at(idx));
- idx = index / sizeSourceFormats;
- sinkFormats.push_back(listSinkFormats.at(idx));
- }
- }
- return sourceFormats.size() > 0;
}
- void CAmRouter::listPossibleConnectionFormats(std::vector<am_CustomConnectionFormat_t> & inListSourceFormats,
- std::vector<am_CustomConnectionFormat_t> & inListSinkFormats, std::vector<am_CustomConnectionFormat_t> & outListFormats)
- {
- std::sort(inListSourceFormats.begin(), inListSourceFormats.end());
- std::sort(inListSinkFormats.begin(), inListSinkFormats.end());
- std::insert_iterator<std::vector<am_CustomConnectionFormat_t> > inserter(outListFormats, outListFormats.begin());
- set_intersection(inListSourceFormats.begin(), inListSourceFormats.end(), inListSinkFormats.begin(), inListSinkFormats.end(), inserter);
- }
+ return sourceFormats.size() > 0;
+}
- 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();
+void CAmRouter::listPossibleConnectionFormats(std::vector<am_CustomConnectionFormat_t> &inListSourceFormats,
+ std::vector<am_CustomConnectionFormat_t> &inListSinkFormats, std::vector<am_CustomConnectionFormat_t> &outListFormats)
+{
+ std::sort(inListSourceFormats.begin(), inListSourceFormats.end());
+ std::sort(inListSinkFormats.begin(), inListSinkFormats.end());
+ std::insert_iterator<std::vector<am_CustomConnectionFormat_t> > inserter(outListFormats, outListFormats.begin());
+ set_intersection(inListSourceFormats.begin(), inListSourceFormats.end(), inListSinkFormats.begin(), inListSinkFormats.end(), inserter);
+}
+
+bool CAmRouter::getRestrictedOutputFormats(const std::vector<bool> &convertionMatrix, const std::vector<am_CustomConnectionFormat_t> &listSourceFormats,
+ const std::vector<am_CustomConnectionFormat_t> &listSinkFormats, const am_CustomConnectionFormat_t connectionFormat,
+ std::vector<am_CustomConnectionFormat_t> &listFormats)
+{
+ listFormats.clear();
+ std::vector<am_CustomConnectionFormat_t>::const_iterator rowSinkIterator = listSinkFormats.begin();
+ std::vector<bool>::const_iterator matrixIterator = convertionMatrix.begin();
- //find the row number of the sink
- rowSinkIterator = find(listSinkFormats.begin(), listSinkFormats.end(), connectionFormat);
- int rowNumberSink = rowSinkIterator - listSinkFormats.begin();
+ // 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);
+ // go through the convertionMatrix and find out if the conversion is possible, if yes, add connectionFormat ...
+ std::advance(matrixIterator, rowNumberSink);
- //iterate line-wise through the matrix and add more formats
- do
+ // iterate line-wise through the matrix and add more formats
+ do
+ {
+ if (*matrixIterator)
{
- if (*matrixIterator)
- {
- listFormats.push_back(listSourceFormats.at((matrixIterator - convertionMatrix.begin()) / listSinkFormats.size()));
- }
- std::advance(matrixIterator, listSinkFormats.size());
- } while (convertionMatrix.end() - matrixIterator > 0);
+ listFormats.push_back(listSourceFormats.at((matrixIterator - convertionMatrix.begin()) / listSinkFormats.size()));
+ }
+
+ std::advance(matrixIterator, listSinkFormats.size());
+ } while (convertionMatrix.end() - matrixIterator > 0);
+
+ return listFormats.size();
+}
- return listFormats.size();
+am_Error_e CAmRouter::getSourceSinkPossibleConnectionFormats(std::vector<CAmRoutingNode *>::iterator iteratorSource,
+ std::vector<CAmRoutingNode *>::iterator iteratorSink, std::vector<am_CustomConnectionFormat_t> &outConnectionFormats)
+{
+ CAmRoutingNode *nodeSink = *iteratorSink;
+ if (nodeSink->getData().type != CAmNodeDataType::SINK)
+ {
+ return (E_UNKNOWN);
}
- am_Error_e CAmRouter::getSourceSinkPossibleConnectionFormats(std::vector<CAmRoutingNode*>::iterator iteratorSource,
- std::vector<CAmRoutingNode*>::iterator iteratorSink, std::vector<am_CustomConnectionFormat_t> & outConnectionFormats)
+ CAmRoutingNode *nodeSource = *iteratorSource;
+ if (nodeSource->getData().type != CAmNodeDataType::SOURCE)
{
- CAmRoutingNode * nodeSink = *iteratorSink;
- if (nodeSink->getData().type != CAmNodeDataType::SINK)
- return (E_UNKNOWN);
+ 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);
- 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, const bool onlyFree)
+{
- 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;
+ }
- 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;
+ }
- 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))
+ 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_RoutingNodeData_s &nodeData = node->getData();
+ if (am_RoutingNodeData_s::GATEWAY == nodeData.type)
{
- const am_Gateway_s * gateway = nodeData.data.gateway;
+ const am_Gateway_s *gateway = nodeData.data.gateway;
return (!onlyFree || !isComponentConnected(*gateway));
}
- else if(am_RoutingNodeData_s::CONVERTER==nodeData.type)
+ else if (am_RoutingNodeData_s::CONVERTER == nodeData.type)
{
- const am_Converter_s * converter = nodeData.data.converter;
+ const am_Converter_s *converter = nodeData.data.converter;
return (!onlyFree || !isComponentConnected(*converter));
}
+
return true;
}
+
return false;
- }, [&visitedDomains](const CAmRoutingNode * node)
- {
+ }, [&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)
+ }, [&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)
{
- 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;
- }
- }
- });
+ 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++)
+ for (auto it = paths.begin(); successCount < mMaxPathCount && it != paths.end(); it++)
+ {
+ if (cfPermutationsForPath(*it, resultNodesPath[it - paths.begin()], resultPath) == E_UNKNOWN)
{
- if (cfPermutationsForPath(*it, resultNodesPath[it - paths.begin()], resultPath) == E_UNKNOWN)
- errorsCount++;
- else
- successCount++;
+ errorsCount++;
}
+ else
+ {
+ successCount++;
+ }
+ }
- if (successCount)
- return E_OK;
- if (errorsCount)
- return E_NOT_POSSIBLE;
+ if (successCount)
+ {
return E_OK;
}
+ if (errorsCount)
+ {
+ return E_NOT_POSSIBLE;
+ }
+
+ return E_OK;
+}
+
}
diff --git a/AudioManagerCore/src/CAmRoutingReceiver.cpp b/AudioManagerCore/src/CAmRoutingReceiver.cpp
index b3815cd..f372df9 100644
--- a/AudioManagerCore/src/CAmRoutingReceiver.cpp
+++ b/AudioManagerCore/src/CAmRoutingReceiver.cpp
@@ -30,50 +30,50 @@
#include "CAmDltWrapper.h"
#include "CAmSocketHandler.h"
-#define __METHOD_NAME__ std::string (std::string("CAmRoutingReceiver::") + __func__)
+#define __METHOD_NAME__ std::string(std::string("CAmRoutingReceiver::") + __func__)
namespace am
{
-CAmRoutingReceiver::CAmRoutingReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler) :
- mpDatabaseHandler(iDatabaseHandler),
- mpRoutingSender(iRoutingSender),
- mpControlSender(iControlSender),
- mpSocketHandler(iSocketHandler),
- mpDBusWrapper(NULL),
- mListStartupHandles(),
- mListRundownHandles(),
- handleCount(0),
- mWaitStartup(false),
- mWaitRundown(false),
- mLastStartupError(E_OK),
- mLastRundownError(E_OK)
-{
- assert(mpDatabaseHandler!=NULL);
- assert(mpRoutingSender!=NULL);
- assert(mpControlSender!=NULL);
- assert(mpSocketHandler!=NULL);
-}
-
-CAmRoutingReceiver::CAmRoutingReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler, CAmDbusWrapper *iDBusWrapper) :
- mpDatabaseHandler(iDatabaseHandler),
- mpRoutingSender(iRoutingSender),
- mpControlSender(iControlSender),
- mpSocketHandler(iSocketHandler),
- mpDBusWrapper(iDBusWrapper),
- mListStartupHandles(),
- mListRundownHandles(),
- handleCount(0),
- mWaitStartup(false),
- mWaitRundown(false),
- mLastStartupError(E_OK),
- mLastRundownError(E_OK)
-{
- assert(mpDatabaseHandler!=NULL);
- assert(mpRoutingSender!=NULL);
- assert(mpControlSender!=NULL);
- assert(mpSocketHandler!=NULL);
- assert(mpDBusWrapper!=NULL);
+CAmRoutingReceiver::CAmRoutingReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler)
+ : mpDatabaseHandler(iDatabaseHandler)
+ , mpRoutingSender(iRoutingSender)
+ , mpControlSender(iControlSender)
+ , mpSocketHandler(iSocketHandler)
+ , mpDBusWrapper(NULL)
+ , mListStartupHandles()
+ , mListRundownHandles()
+ , handleCount(0)
+ , mWaitStartup(false)
+ , mWaitRundown(false)
+ , mLastStartupError(E_OK)
+ , mLastRundownError(E_OK)
+{
+ assert(mpDatabaseHandler != NULL);
+ assert(mpRoutingSender != NULL);
+ assert(mpControlSender != NULL);
+ assert(mpSocketHandler != NULL);
+}
+
+CAmRoutingReceiver::CAmRoutingReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler, CAmDbusWrapper *iDBusWrapper)
+ : mpDatabaseHandler(iDatabaseHandler)
+ , mpRoutingSender(iRoutingSender)
+ , mpControlSender(iControlSender)
+ , mpSocketHandler(iSocketHandler)
+ , mpDBusWrapper(iDBusWrapper)
+ , mListStartupHandles()
+ , mListRundownHandles()
+ , handleCount(0)
+ , mWaitStartup(false)
+ , mWaitRundown(false)
+ , mLastStartupError(E_OK)
+ , mLastRundownError(E_OK)
+{
+ assert(mpDatabaseHandler != NULL);
+ assert(mpRoutingSender != NULL);
+ assert(mpControlSender != NULL);
+ assert(mpSocketHandler != NULL);
+ assert(mpDBusWrapper != NULL);
}
CAmRoutingReceiver::~CAmRoutingReceiver()
@@ -88,138 +88,142 @@ void CAmRoutingReceiver::handleCallback(const am_Handle_s handle, const am_Error
}
else
{
- mpRoutingSender->removeHandle(handle);
- }
+ mpRoutingSender->removeHandle(handle);
+ }
}
void CAmRoutingReceiver::ackConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)
{
- logInfo(__METHOD_NAME__,"handle=",handle,"connectionID=",connectionID,"error=",error);
+ logInfo(__METHOD_NAME__, "handle=", handle, "connectionID=", connectionID, "error=", error);
if (error == am_Error_e::E_OK)
{
mpRoutingSender->writeToDatabaseAndRemove(handle);
}
else
{
- //only remove connection of handle was found
- if(mpRoutingSender->removeHandle(handle)==0)
- {
- mpDatabaseHandler->removeConnection(connectionID);
- mpRoutingSender->removeConnectionLookup(connectionID);
- }
+ // only remove connection of handle was found
+ if (mpRoutingSender->removeHandle(handle) == 0)
+ {
+ mpDatabaseHandler->removeConnection(connectionID);
+ mpRoutingSender->removeConnectionLookup(connectionID);
+ }
}
+
mpControlSender->cbAckConnect(handle, error);
}
void CAmRoutingReceiver::ackDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)
{
- logInfo(__METHOD_NAME__,"handle=",handle,"connectionID=",connectionID,"error=",error);
- //only remove connection of handle was found
- if(mpRoutingSender->removeHandle(handle) == 0)
- {
- mpRoutingSender->removeConnectionLookup(connectionID);
- }
+ logInfo(__METHOD_NAME__, "handle=", handle, "connectionID=", connectionID, "error=", error);
+ // only remove connection of handle was found
+ if (mpRoutingSender->removeHandle(handle) == 0)
+ {
+ mpRoutingSender->removeConnectionLookup(connectionID);
+ }
+
mpControlSender->cbAckDisconnect(handle, error);
}
void CAmRoutingReceiver::ackSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
{
- logInfo(__METHOD_NAME__,"handle=",handle,"volume=",volume,"error=",error);
- if(error == E_OK)
+ logInfo(__METHOD_NAME__, "handle=", handle, "volume=", volume, "error=", error);
+ if (error == E_OK)
{
- mpRoutingSender->checkVolume(handle,volume);
- }
-
- if (error== am_Error_e::E_OK || error== am_Error_e::E_ABORTED)
+ mpRoutingSender->checkVolume(handle, volume);
+ }
+
+ if (error == am_Error_e::E_OK || error == am_Error_e::E_ABORTED)
{
- mpRoutingSender->writeToDatabaseAndRemove(handle);
+ mpRoutingSender->writeToDatabaseAndRemove(handle);
}
else
{
- mpRoutingSender->removeHandle(handle);
- }
+ mpRoutingSender->removeHandle(handle);
+ }
+
mpControlSender->cbAckSetSinkVolumeChange(handle, volume, error);
}
void CAmRoutingReceiver::ackSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
{
- logInfo(__METHOD_NAME__,"handle=",handle,"volume=",volume,"error=",error);
- if(error == E_OK)
+ logInfo(__METHOD_NAME__, "handle=", handle, "volume=", volume, "error=", error);
+ if (error == E_OK)
{
- mpRoutingSender->checkVolume(handle,volume);
+ mpRoutingSender->checkVolume(handle, volume);
}
- if (error== am_Error_e::E_OK || error== am_Error_e::E_ABORTED)
+ if (error == am_Error_e::E_OK || error == am_Error_e::E_ABORTED)
{
- mpRoutingSender->writeToDatabaseAndRemove(handle);
+ mpRoutingSender->writeToDatabaseAndRemove(handle);
}
else
{
- mpRoutingSender->removeHandle(handle);
- }
+ mpRoutingSender->removeHandle(handle);
+ }
+
mpControlSender->cbAckSetSourceVolumeChange(handle, volume, error);
}
void CAmRoutingReceiver::ackSetSourceState(const am_Handle_s handle, const am_Error_e error)
{
- logInfo(__METHOD_NAME__,"handle=",handle,"error=",error);
- handleCallback(handle,error);
+ logInfo(__METHOD_NAME__, "handle=", handle, "error=", error);
+ handleCallback(handle, error);
mpControlSender->cbAckSetSourceState(handle, error);
}
void CAmRoutingReceiver::ackSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error)
{
- logInfo(__METHOD_NAME__,"handle=",handle,"error=",error);
- handleCallback(handle,error);
+ logInfo(__METHOD_NAME__, "handle=", handle, "error=", error);
+ handleCallback(handle, error);
mpControlSender->cbAckSetSinkSoundProperty(handle, error);
}
void am::CAmRoutingReceiver::ackSetSinkSoundProperties(const am_Handle_s handle, const am_Error_e error)
{
- logInfo(__METHOD_NAME__,"handle=",handle,"error=",error);
- handleCallback(handle,error);
+ logInfo(__METHOD_NAME__, "handle=", handle, "error=", error);
+ handleCallback(handle, error);
mpControlSender->cbAckSetSinkSoundProperties(handle, error);
}
void CAmRoutingReceiver::ackSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error)
{
- logInfo(__METHOD_NAME__,"handle=",handle,"error=",error);
- handleCallback(handle,error);
+ logInfo(__METHOD_NAME__, "handle=", handle, "error=", error);
+ handleCallback(handle, error);
mpControlSender->cbAckSetSourceSoundProperty(handle, error);
}
void am::CAmRoutingReceiver::ackSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error)
{
- logInfo(__METHOD_NAME__,"handle=",handle,"error=",error);
- handleCallback(handle,error);
+ logInfo(__METHOD_NAME__, "handle=", handle, "error=", error);
+ handleCallback(handle, error);
mpControlSender->cbAckSetSourceSoundProperties(handle, error);
}
void CAmRoutingReceiver::ackCrossFading(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error)
{
- logInfo(__METHOD_NAME__,"handle=",handle,"hotsink=",hotSink,"error=",error);
- handleCallback(handle,error);
+ logInfo(__METHOD_NAME__, "handle=", handle, "hotsink=", hotSink, "error=", error);
+ handleCallback(handle, error);
mpControlSender->cbAckCrossFade(handle, hotSink, error);
}
void CAmRoutingReceiver::ackSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)
{
- logInfo(__METHOD_NAME__,"handle=",handle,"sourceID=",sourceID,"volume=",volume);
+ logInfo(__METHOD_NAME__, "handle=", handle, "sourceID=", sourceID, "volume=", volume);
mpControlSender->hookSystemSourceVolumeTick(handle, sourceID, volume);
}
void CAmRoutingReceiver::ackSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)
{
- logInfo(__METHOD_NAME__,"handle=",handle,"sinkID=",sinkID,"volume=",volume);
+ logInfo(__METHOD_NAME__, "handle=", handle, "sinkID=", sinkID, "volume=", volume);
mpControlSender->hookSystemSinkVolumeTick(handle, sinkID, volume);
}
-am_Error_e CAmRoutingReceiver::peekDomain(const std::string & name, am_domainID_t & domainID)
-{
+am_Error_e CAmRoutingReceiver::peekDomain(const std::string &name, am_domainID_t &domainID)
+{
return (mpDatabaseHandler->peekDomain(name, domainID));
}
-am_Error_e CAmRoutingReceiver::registerDomain(const am_Domain_s & domainData, am_domainID_t & domainID)
+am_Error_e CAmRoutingReceiver::registerDomain(const am_Domain_s &domainData, am_domainID_t &domainID)
{
return (mpControlSender->hookSystemRegisterDomain(domainData, domainID));
}
@@ -229,14 +233,14 @@ am_Error_e CAmRoutingReceiver::deregisterDomain(const am_domainID_t domainID)
return (mpControlSender->hookSystemDeregisterDomain(domainID));
}
-am_Error_e CAmRoutingReceiver::registerGateway(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
+am_Error_e CAmRoutingReceiver::registerGateway(const am_Gateway_s &gatewayData, am_gatewayID_t &gatewayID)
{
return (mpControlSender->hookSystemRegisterGateway(gatewayData, gatewayID));
}
-am_Error_e CAmRoutingReceiver::registerConverter(const am_Converter_s& converterData, am_converterID_t& converterID)
+am_Error_e CAmRoutingReceiver::registerConverter(const am_Converter_s &converterData, am_converterID_t &converterID)
{
- return (mpControlSender->hookSystemRegisterConverter(converterData, converterID));
+ return (mpControlSender->hookSystemRegisterConverter(converterData, converterID));
}
am_Error_e CAmRoutingReceiver::deregisterGateway(const am_gatewayID_t gatewayID)
@@ -244,17 +248,17 @@ am_Error_e CAmRoutingReceiver::deregisterGateway(const am_gatewayID_t gatewayID)
return (mpControlSender->hookSystemDeregisterGateway(gatewayID));
}
-am_Error_e CAmRoutingReceiver::deregisterConverter(const am_converterID_t converterID)
+am_Error_e CAmRoutingReceiver::deregisterConverter(const am_converterID_t converterID)
{
- return (mpControlSender->hookSystemDeregisterConverter(converterID));
+ return (mpControlSender->hookSystemDeregisterConverter(converterID));
}
-am_Error_e CAmRoutingReceiver::peekSink(const std::string& name, am_sinkID_t & sinkID)
+am_Error_e CAmRoutingReceiver::peekSink(const std::string &name, am_sinkID_t &sinkID)
{
return (mpDatabaseHandler->peekSink(name, sinkID));
}
-am_Error_e CAmRoutingReceiver::registerSink(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
+am_Error_e CAmRoutingReceiver::registerSink(const am_Sink_s &sinkData, am_sinkID_t &sinkID)
{
return (mpControlSender->hookSystemRegisterSink(sinkData, sinkID));
}
@@ -264,12 +268,12 @@ am_Error_e CAmRoutingReceiver::deregisterSink(const am_sinkID_t sinkID)
return (mpControlSender->hookSystemDeregisterSink(sinkID));
}
-am_Error_e CAmRoutingReceiver::peekSource(const std::string & name, am_sourceID_t & sourceID)
+am_Error_e CAmRoutingReceiver::peekSource(const std::string &name, am_sourceID_t &sourceID)
{
return (mpDatabaseHandler->peekSource(name, sourceID));
}
-am_Error_e CAmRoutingReceiver::registerSource(const am_Source_s & sourceData, am_sourceID_t & sourceID)
+am_Error_e CAmRoutingReceiver::registerSource(const am_Source_s &sourceData, am_sourceID_t &sourceID)
{
return (mpControlSender->hookSystemRegisterSource(sourceData, sourceID));
}
@@ -279,7 +283,7 @@ am_Error_e CAmRoutingReceiver::deregisterSource(const am_sourceID_t sourceID)
return (mpControlSender->hookSystemDeregisterSource(sourceID));
}
-am_Error_e CAmRoutingReceiver::registerCrossfader(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
+am_Error_e CAmRoutingReceiver::registerCrossfader(const am_Crossfader_s &crossfaderData, am_crossfaderID_t &crossfaderID)
{
return (mpControlSender->hookSystemRegisterCrossfader(crossfaderData, crossfaderID));
}
@@ -304,12 +308,12 @@ void CAmRoutingReceiver::hookDomainRegistrationComplete(const am_domainID_t doma
mpControlSender->hookSystemDomainRegistrationComplete(domainID);
}
-void CAmRoutingReceiver::hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s & availability)
+void CAmRoutingReceiver::hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s &availability)
{
mpControlSender->hookSystemSinkAvailablityStateChange(sinkID, availability);
}
-void CAmRoutingReceiver::hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s & availability)
+void CAmRoutingReceiver::hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s &availability)
{
mpControlSender->hookSystemSourceAvailablityStateChange(sourceID, availability);
}
@@ -322,157 +326,167 @@ void CAmRoutingReceiver::hookDomainStateChange(const am_domainID_t domainID, con
void CAmRoutingReceiver::hookTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t delay)
{
mpDatabaseHandler->changeConnectionTimingInformation(connectionID, delay);
- mpControlSender->hookSystemSingleTimingInformationChanged(connectionID,delay);
+ mpControlSender->hookSystemSingleTimingInformationChanged(connectionID, delay);
}
-void CAmRoutingReceiver::sendChangedData(const std::vector<am_EarlyData_s> & earlyData)
+void CAmRoutingReceiver::sendChangedData(const std::vector<am_EarlyData_s> &earlyData)
{
mpControlSender->hookSystemReceiveEarlyData(earlyData);
}
-am_Error_e CAmRoutingReceiver::peekSinkClassID(const std::string& name, am_sinkClass_t& sinkClassID)
+am_Error_e CAmRoutingReceiver::peekSinkClassID(const std::string &name, am_sinkClass_t &sinkClassID)
{
return (mpDatabaseHandler->peekSinkClassID(name, sinkClassID));
}
-am_Error_e CAmRoutingReceiver::peekSourceClassID(const std::string& name, am_sourceClass_t& sourceClassID)
+am_Error_e CAmRoutingReceiver::peekSourceClassID(const std::string &name, am_sourceClass_t &sourceClassID)
{
return (mpDatabaseHandler->peekSourceClassID(name, sourceClassID));
}
#ifdef WITH_DBUS_WRAPPER
-am_Error_e CAmRoutingReceiver::getDBusConnectionWrapper(CAmDbusWrapper *& dbusConnectionWrapper) const
+am_Error_e CAmRoutingReceiver::getDBusConnectionWrapper(CAmDbusWrapper * &dbusConnectionWrapper) const
{
dbusConnectionWrapper = mpDBusWrapper;
return (E_OK);
#else
-am_Error_e CAmRoutingReceiver::getDBusConnectionWrapper(CAmDbusWrapper *& ) const
+am_Error_e CAmRoutingReceiver::getDBusConnectionWrapper(CAmDbusWrapper * &) const
{
return (E_UNKNOWN);
-#endif
+#endif // ifdef WITH_DBUS_WRAPPER
}
-am_Error_e CAmRoutingReceiver::getSocketHandler(CAmSocketHandler *& socketHandler) const
+am_Error_e CAmRoutingReceiver::getSocketHandler(CAmSocketHandler * &socketHandler) const
{
socketHandler = mpSocketHandler;
return (E_OK);
}
-void CAmRoutingReceiver::getInterfaceVersion(std::string & version) const
+void CAmRoutingReceiver::getInterfaceVersion(std::string &version) const
{
version = RoutingVersion;
}
-void CAmRoutingReceiver::confirmRoutingReady(const uint16_t handle, const am_Error_e error)
+void CAmRoutingReceiver::confirmRoutingReady(const uint16_t handle, const am_Error_e error)
{
- if (error!=E_OK)
- mLastStartupError=error;
+ if (error != E_OK)
+ {
+ mLastStartupError = error;
+ }
+
mListStartupHandles.erase(std::remove(mListStartupHandles.begin(), mListStartupHandles.end(), handle), mListStartupHandles.end());
if (mWaitStartup && mListStartupHandles.empty())
+ {
mpControlSender->confirmRoutingReady(mLastStartupError);
+ }
}
void CAmRoutingReceiver::confirmRoutingRundown(const uint16_t handle, const am_Error_e error)
{
- if (error!=E_OK)
- mLastRundownError=error;
+ if (error != E_OK)
+ {
+ mLastRundownError = error;
+ }
+
mListRundownHandles.erase(std::remove(mListRundownHandles.begin(), mListRundownHandles.end(), handle), mListRundownHandles.end());
if (mWaitRundown && mListRundownHandles.empty())
+ {
mpControlSender->confirmRoutingRundown(mLastRundownError);
+ }
}
uint16_t am::CAmRoutingReceiver::getStartupHandle()
{
- uint16_t handle = ++handleCount; //todo: handle overflow
+ uint16_t handle = ++handleCount; // todo: handle overflow
mListStartupHandles.push_back(handle);
return (handle);
}
uint16_t am::CAmRoutingReceiver::getRundownHandle()
{
- uint16_t handle = ++handleCount; //todo: handle overflow
+ uint16_t handle = ++handleCount; // todo: handle overflow
mListRundownHandles.push_back(handle);
return (handle);
}
void am::CAmRoutingReceiver::waitOnStartup(bool startup)
{
- mWaitStartup = startup;
- mLastStartupError=E_OK;
+ mWaitStartup = startup;
+ mLastStartupError = E_OK;
}
void CAmRoutingReceiver::ackSinkNotificationConfiguration(const am_Handle_s handle, const am_Error_e error)
{
- logInfo(__METHOD_NAME__,"handle=",handle,"error=",error);
- handleCallback(handle,error);
- mpControlSender->cbAckSetSinkNotificationConfiguration(handle,error);
+ logInfo(__METHOD_NAME__, "handle=", handle, "error=", error);
+ handleCallback(handle, error);
+ mpControlSender->cbAckSetSinkNotificationConfiguration(handle, error);
}
void CAmRoutingReceiver::ackSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error)
{
- logInfo(__METHOD_NAME__,"handle=",handle,"error=",error);
- handleCallback(handle,error);
- mpControlSender->cbAckSetSourceNotificationConfiguration(handle,error);
+ logInfo(__METHOD_NAME__, "handle=", handle, "error=", error);
+ handleCallback(handle, error);
+ mpControlSender->cbAckSetSourceNotificationConfiguration(handle, error);
}
-am_Error_e CAmRoutingReceiver::updateGateway(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t>& listSourceFormats, const std::vector<am_CustomConnectionFormat_t>& listSinkFormats, const std::vector<bool>& convertionMatrix)
+am_Error_e CAmRoutingReceiver::updateGateway(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t> &listSourceFormats, const std::vector<am_CustomConnectionFormat_t> &listSinkFormats, const std::vector<bool> &convertionMatrix)
{
- return (mpControlSender->hookSystemUpdateGateway(gatewayID,listSourceFormats,listSinkFormats,convertionMatrix));
+ return (mpControlSender->hookSystemUpdateGateway(gatewayID, listSourceFormats, listSinkFormats, convertionMatrix));
}
-am_Error_e CAmRoutingReceiver::updateConverter(const am_converterID_t converterID, const std::vector<am_CustomConnectionFormat_t>& listSourceFormats, const std::vector<am_CustomConnectionFormat_t>& listSinkFormats, const std::vector<bool>& convertionMatrix)
+am_Error_e CAmRoutingReceiver::updateConverter(const am_converterID_t converterID, const std::vector<am_CustomConnectionFormat_t> &listSourceFormats, const std::vector<am_CustomConnectionFormat_t> &listSinkFormats, const std::vector<bool> &convertionMatrix)
{
- return (mpControlSender->hookSystemUpdateConverter(converterID,listSourceFormats,listSinkFormats,convertionMatrix));
+ return (mpControlSender->hookSystemUpdateConverter(converterID, listSourceFormats, listSinkFormats, convertionMatrix));
}
-am_Error_e CAmRoutingReceiver::updateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
+am_Error_e CAmRoutingReceiver::updateSink(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s> &listSoundProperties, const std::vector<am_CustomConnectionFormat_t> &listConnectionFormats, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties)
{
- return (mpControlSender->hookSystemUpdateSink(sinkID,sinkClassID,listSoundProperties,listConnectionFormats,listMainSoundProperties));
+ return (mpControlSender->hookSystemUpdateSink(sinkID, sinkClassID, listSoundProperties, listConnectionFormats, listMainSoundProperties));
}
-am_Error_e CAmRoutingReceiver::updateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
+am_Error_e CAmRoutingReceiver::updateSource(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s> &listSoundProperties, const std::vector<am_CustomConnectionFormat_t> &listConnectionFormats, const std::vector<am_MainSoundProperty_s> &listMainSoundProperties)
{
- return (mpControlSender->hookSystemUpdateSource(sourceID,sourceClassID,listSoundProperties,listConnectionFormats,listMainSoundProperties));
+ return (mpControlSender->hookSystemUpdateSource(sourceID, sourceClassID, listSoundProperties, listConnectionFormats, listMainSoundProperties));
}
-void CAmRoutingReceiver::ackSetVolumes(const am_Handle_s handle, const std::vector<am_Volumes_s>& listvolumes, const am_Error_e error)
+void CAmRoutingReceiver::ackSetVolumes(const am_Handle_s handle, const std::vector<am_Volumes_s> &listvolumes, const am_Error_e error)
{
- logInfo(__METHOD_NAME__,"handle=",handle,"error=",error);
- handleCallback(handle,error);
- mpControlSender->cbAckSetVolume(handle,listvolumes,error);
+ logInfo(__METHOD_NAME__, "handle=", handle, "error=", error);
+ handleCallback(handle, error);
+ mpControlSender->cbAckSetVolume(handle, listvolumes, error);
}
-void CAmRoutingReceiver::hookSinkNotificationDataChange(const am_sinkID_t sinkID, const am_NotificationPayload_s& payload)
+void CAmRoutingReceiver::hookSinkNotificationDataChange(const am_sinkID_t sinkID, const am_NotificationPayload_s &payload)
{
- logInfo(__METHOD_NAME__,"sinkID=",sinkID,"type=",payload.type,"notificationValue=",payload.value);
- mpControlSender->hookSinkNotificationDataChanged(sinkID,payload);
+ logInfo(__METHOD_NAME__, "sinkID=", sinkID, "type=", payload.type, "notificationValue=", payload.value);
+ mpControlSender->hookSinkNotificationDataChanged(sinkID, payload);
}
-void CAmRoutingReceiver::hookSourceNotificationDataChange(const am_sourceID_t sourceID, const am_NotificationPayload_s& payload)
+void CAmRoutingReceiver::hookSourceNotificationDataChange(const am_sourceID_t sourceID, const am_NotificationPayload_s &payload)
{
- logInfo(__METHOD_NAME__,"sinkID=",sourceID,"type=",payload.type,"notificationValue=",payload.value);
- mpControlSender->hookSourceNotificationDataChanged(sourceID,payload);
+ logInfo(__METHOD_NAME__, "sinkID=", sourceID, "type=", payload.type, "notificationValue=", payload.value);
+ mpControlSender->hookSourceNotificationDataChanged(sourceID, payload);
}
-am_Error_e CAmRoutingReceiver::getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t& domainID) const
+am_Error_e CAmRoutingReceiver::getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t &domainID) const
{
- return (mpDatabaseHandler->getDomainOfSink(sinkID,domainID));
+ return (mpDatabaseHandler->getDomainOfSink(sinkID, domainID));
}
-am_Error_e CAmRoutingReceiver::getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t& domainID) const
+am_Error_e CAmRoutingReceiver::getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t &domainID) const
{
- return (mpDatabaseHandler->getDomainOfSource(sourceID,domainID));
+ return (mpDatabaseHandler->getDomainOfSource(sourceID, domainID));
}
-am_Error_e CAmRoutingReceiver::getDomainOfCrossfader(const am_crossfaderID_t crossfader, am_domainID_t& domainID) const
+am_Error_e CAmRoutingReceiver::getDomainOfCrossfader(const am_crossfaderID_t crossfader, am_domainID_t &domainID) const
{
- return (mpDatabaseHandler->getDomainOfCrossfader(crossfader,domainID));
+ return (mpDatabaseHandler->getDomainOfCrossfader(crossfader, domainID));
}
void CAmRoutingReceiver::waitOnRundown(bool rundown)
{
- mWaitRundown = rundown;
- mLastRundownError=E_OK;
+ mWaitRundown = rundown;
+ mLastRundownError = E_OK;
}
}
diff --git a/AudioManagerCore/src/CAmRoutingSender.cpp b/AudioManagerCore/src/CAmRoutingSender.cpp
index 9c6e658..cb66fe9 100644
--- a/AudioManagerCore/src/CAmRoutingSender.cpp
+++ b/AudioManagerCore/src/CAmRoutingSender.cpp
@@ -40,78 +40,79 @@
namespace am
{
-#define REQUIRED_INTERFACE_VERSION_MAJOR 1 //!< major interface version. All versions smaller than this will be rejected
+#define REQUIRED_INTERFACE_VERSION_MAJOR 1 //!< major interface version. All versions smaller than this will be rejected
#define REQUIRED_INTERFACE_VERSION_MINOR 0 //!< minor interface version. All versions smaller than this will be rejected
-#define __METHOD_NAME__ std::string (std::string("CAmRoutingSender::") + __func__)
+#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) {
+ const std::vector<std::string> &listOfPluginDirectories,
+ IAmDatabaseHandler *databaseHandler)
+ : mHandleCount(0)
+ , mlistActiveHandles()
+ , mListInterfaces()
+ , mMapConnectionInterface()
+ , mMapCrossfaderInterface()
+ , mMapDomainInterface()
+ , mMapSinkInterface()
+ , mMapSourceInterface()
+ , mpRoutingReceiver()
+ , mpDatabaseHandler(databaseHandler)
+{
loadPlugins(listOfPluginDirectories);
- 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);
- };
+ 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);
- };
+ removeSinkLookup(sinkID);
+ };
dboRemovedSource = [&](const am_sourceID_t sourceID, const bool visible) {
- removeSourceLookup(sourceID);
- };
+ removeSourceLookup(sourceID);
+ };
dboRemoveDomain = [&](const am_domainID_t domainID) {
- removeDomainLookup(domainID);
- };
- //todo: removeGateway implement something
- //todo: removeConverter implement something
+ removeDomainLookup(domainID);
+ };
+ // todo: removeGateway implement something
+ // todo: removeConverter implement something
dboRemoveCrossfader = [&](const am_crossfaderID_t crossfaderID) {
- removeCrossfaderLookup(crossfaderID);
- };
+ removeCrossfaderLookup(crossfaderID);
+ };
}
-void CAmRoutingSender::loadPlugins(const std::vector<std::string>& listOfPluginDirectories)
+void CAmRoutingSender::loadPlugins(const std::vector<std::string> &listOfPluginDirectories)
{
if (listOfPluginDirectories.empty())
{
- logError(__METHOD_NAME__,"List of routingplugins is 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> 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);
+ 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);
+ logError(__METHOD_NAME__, "Error opening directory: ", directoryName);
continue;
}
@@ -120,10 +121,10 @@ void CAmRoutingSender::loadPlugins(const std::vector<std::string>& listOfPluginD
while ((itemInDirectory = readdir(directory)))
{
unsigned char entryType = itemInDirectory->d_type;
- std::string entryName = itemInDirectory->d_name;
- std::string fullName = *dirIter + "/" + entryName;
+ std::string entryName = itemInDirectory->d_name;
+ std::string fullName = *dirIter + "/" + entryName;
- bool regularFile = (entryType == DT_REG || entryType == DT_LNK);
+ 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
@@ -133,7 +134,7 @@ void CAmRoutingSender::loadPlugins(const std::vector<std::string>& listOfPluginD
if (stat(fullName.c_str(), &buf))
{
- logInfo(__METHOD_NAME__,"Failed to stat file: ", entryName, errno);
+ logInfo(__METHOD_NAME__, "Failed to stat file: ", entryName, errno);
continue;
}
@@ -142,7 +143,7 @@ void CAmRoutingSender::loadPlugins(const std::vector<std::string>& listOfPluginD
if (regularFile && sharedLibExtension)
{
- logInfo(__METHOD_NAME__,"adding file: ", entryName);
+ logInfo(__METHOD_NAME__, "adding file: ", entryName);
std::string name(directoryName);
sharedLibraryNameList.push_back(name + "/" + entryName);
}
@@ -156,28 +157,28 @@ void CAmRoutingSender::loadPlugins(const std::vector<std::string>& listOfPluginD
}
// iterate all communicator plugins and start them
- std::vector<std::string>::iterator iter = sharedLibraryNameList.begin();
+ 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);
+ 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");
+ 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");
+ logError(__METHOD_NAME__, "initialization of plugin ", *iter, "failed. Entry Function not callable");
dlclose(tempLibHandle);
continue;
}
@@ -185,7 +186,7 @@ void CAmRoutingSender::loadPlugins(const std::vector<std::string>& listOfPluginD
InterfaceNamePairs routerInterface;
routerInterface.routingInterface = router;
- //check libversion
+ // check libversion
std::string version, cVersion(RoutingVersion);
router->getInterfaceVersion(version);
uint16_t minorVersion, majorVersion, cMinorVersion, cMajorVersion;
@@ -196,12 +197,12 @@ void CAmRoutingSender::loadPlugins(const std::vector<std::string>& listOfPluginD
if (majorVersion < cMajorVersion || ((majorVersion == cMajorVersion) && (minorVersion > cMinorVersion)))
{
- logError(__METHOD_NAME__,"Routing initialization failed. Version of Interface to old");
+ 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....
+ // 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);
@@ -211,13 +212,13 @@ void CAmRoutingSender::loadPlugins(const std::vector<std::string>& listOfPluginD
CAmRoutingSender::~CAmRoutingSender()
{
- //unloadLibraries();
+ // unloadLibraries();
HandlesMap::iterator it = mlistActiveHandles.begin();
- //every open handle is assumed to be an error...
+ // every open handle is assumed to be an error...
for (; it != mlistActiveHandles.end(); ++it)
{
- logError(__METHOD_NAME__,"The action for the handle",it->first,"is still open");
+ logError(__METHOD_NAME__, "The action for the handle", it->first, "is still open");
}
}
@@ -226,7 +227,7 @@ am_Error_e CAmRoutingSender::startupInterfaces(CAmRoutingReceiver *iRoutingRecei
mpRoutingReceiver = iRoutingReceiver;
am_Error_e returnError = E_OK;
- std::vector<InterfaceNamePairs>::iterator iter = mListInterfaces.begin();
+ std::vector<InterfaceNamePairs>::iterator iter = mListInterfaces.begin();
std::vector<InterfaceNamePairs>::iterator iterEnd = mListInterfaces.end();
for (; iter < iterEnd; ++iter)
{
@@ -236,410 +237,428 @@ am_Error_e CAmRoutingSender::startupInterfaces(CAmRoutingReceiver *iRoutingRecei
returnError = error;
}
}
+
return (returnError);
}
-am_Error_e CAmRoutingSender::asyncAbort(const am_Handle_s& handle)
+am_Error_e CAmRoutingSender::asyncAbort(const am_Handle_s &handle)
{
- auto iter (mlistActiveHandles.find(handle));
+ auto iter(mlistActiveHandles.find(handle));
if (iter == mlistActiveHandles.end())
{
- logError(__METHOD_NAME__,"Could not find handle",handle);
- return (E_NON_EXISTENT);
+ logError(__METHOD_NAME__, "Could not find handle", handle);
+ return (E_NON_EXISTENT);
}
- logInfo(__METHOD_NAME__," handle", handle);
- return (iter->second->returnInterface()->asyncAbort(handle));
+
+ logInfo(__METHOD_NAME__, " handle", handle);
+ return (iter->second->returnInterface()->asyncAbort(handle));
}
-am_Error_e CAmRoutingSender::asyncConnect(am_Handle_s& handle, am_connectionID_t& connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_CustomConnectionFormat_t connectionFormat)
+am_Error_e CAmRoutingSender::asyncConnect(am_Handle_s &handle, am_connectionID_t &connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_CustomConnectionFormat_t connectionFormat)
{
- auto iter (mMapSinkInterface.find(sinkID));
- if (iter == mMapSinkInterface.end())
- {
- logError(__METHOD_NAME__,"Could not find sink",sinkID);
- return (E_NON_EXISTENT);
- }
-
- if(handleExists(handle))
- {
- if (handle.handleType==am_Handle_e::H_CONNECT)
- {
- logInfo(__METHOD_NAME__,"Resending for handle",handle);
- }
- else
- {
- logError(__METHOD_NAME__,"Handle exists but wrong type",handle);
- return(E_UNKNOWN);
- }
- }
- else
- {
-
- am_Connection_s tempConnection;
- tempConnection.sinkID = sinkID;
- tempConnection.sourceID = sourceID;
- tempConnection.connectionFormat = connectionFormat;
- tempConnection.connectionID = 0;
- tempConnection.delay=-1;
-
- am_Error_e connError(mpDatabaseHandler->enterConnectionDB(tempConnection, connectionID));
- if (connError)
- {
- return(connError);
- }
- mMapConnectionInterface.insert(std::make_pair(connectionID, iter->second));
- auto handleData = std::make_shared<handleConnect>(iter->second,connectionID,mpDatabaseHandler);
- handle = createHandle(handleData, am_Handle_e::H_CONNECT);
- }
-
- logInfo(__METHOD_NAME__,"connectionID=",connectionID,"connectionFormat=", connectionFormat, "sourceID=", sourceID, "sinkID=", sinkID,"handle=",handle);
- am_Error_e syncError(iter->second->asyncConnect(handle, connectionID, sourceID, sinkID, connectionFormat));
- if (syncError)
- {
- removeHandle(handle);
- logError(__METHOD_NAME__,"Error while calling connect connectionID:",connectionID,"sourceID:",sourceID,"sinkID:",sinkID,"connectionFormat:",connectionFormat,"handle",handle);
- mpDatabaseHandler->removeConnection(connectionID);
- }
- return(syncError);
+ auto iter(mMapSinkInterface.find(sinkID));
+ if (iter == mMapSinkInterface.end())
+ {
+ logError(__METHOD_NAME__, "Could not find sink", sinkID);
+ return (E_NON_EXISTENT);
+ }
+
+ if (handleExists(handle))
+ {
+ if (handle.handleType == am_Handle_e::H_CONNECT)
+ {
+ logInfo(__METHOD_NAME__, "Resending for handle", handle);
+ }
+ else
+ {
+ logError(__METHOD_NAME__, "Handle exists but wrong type", handle);
+ return(E_UNKNOWN);
+ }
+ }
+ else
+ {
+
+ am_Connection_s tempConnection;
+ tempConnection.sinkID = sinkID;
+ tempConnection.sourceID = sourceID;
+ tempConnection.connectionFormat = connectionFormat;
+ tempConnection.connectionID = 0;
+ tempConnection.delay = -1;
+
+ am_Error_e connError(mpDatabaseHandler->enterConnectionDB(tempConnection, connectionID));
+ if (connError)
+ {
+ return(connError);
+ }
+
+ mMapConnectionInterface.insert(std::make_pair(connectionID, iter->second));
+ auto handleData = std::make_shared<handleConnect>(iter->second, connectionID, mpDatabaseHandler);
+ handle = createHandle(handleData, am_Handle_e::H_CONNECT);
+ }
+
+ logInfo(__METHOD_NAME__, "connectionID=", connectionID, "connectionFormat=", connectionFormat, "sourceID=", sourceID, "sinkID=", sinkID, "handle=", handle);
+ am_Error_e syncError(iter->second->asyncConnect(handle, connectionID, sourceID, sinkID, connectionFormat));
+ if (syncError)
+ {
+ removeHandle(handle);
+ logError(__METHOD_NAME__, "Error while calling connect connectionID:", connectionID, "sourceID:", sourceID, "sinkID:", sinkID, "connectionFormat:", connectionFormat, "handle", handle);
+ mpDatabaseHandler->removeConnection(connectionID);
+ }
+
+ return(syncError);
}
-am_Error_e CAmRoutingSender::asyncDisconnect(am_Handle_s& handle, const am_connectionID_t connectionID)
+am_Error_e CAmRoutingSender::asyncDisconnect(am_Handle_s &handle, const am_connectionID_t connectionID)
{
- auto iter(mMapConnectionInterface.find(connectionID));
- if (iter == mMapConnectionInterface.end())
- {
- logError(__METHOD_NAME__,"Could not find connection",connectionID);
- return (E_NON_EXISTENT);
- }
-
- if(handleExists(handle))
- {
- if (handle.handleType==am_Handle_e::H_DISCONNECT)
- {
- logInfo(__METHOD_NAME__,"Resending for handle",handle);
- }
- else
- {
- logError(__METHOD_NAME__,"Handle exists but wrong type",handle);
- return(E_UNKNOWN);
- }
+ auto iter(mMapConnectionInterface.find(connectionID));
+ if (iter == mMapConnectionInterface.end())
+ {
+ logError(__METHOD_NAME__, "Could not find connection", connectionID);
+ return (E_NON_EXISTENT);
+ }
+
+ if (handleExists(handle))
+ {
+ if (handle.handleType == am_Handle_e::H_DISCONNECT)
+ {
+ logInfo(__METHOD_NAME__, "Resending for handle", handle);
+ }
+ else
+ {
+ logError(__METHOD_NAME__, "Handle exists but wrong type", handle);
+ return(E_UNKNOWN);
+ }
}
else
{
- auto handleData = std::make_shared<handleDisconnect>(iter->second,connectionID,mpDatabaseHandler,this);
- handle = createHandle(handleData, am_Handle_e::H_DISCONNECT);
- }
-
- logInfo(__METHOD_NAME__,"connectionID=", connectionID, "handle=",handle);
- am_Error_e syncError(iter->second->asyncDisconnect(handle, connectionID));
- if (syncError)
- {
- removeHandle(handle);
- logError(__METHOD_NAME__,"Error while calling disconnect connectionID:",connectionID,"handle",handle);
- }
- return(syncError);
+ auto handleData = std::make_shared<handleDisconnect>(iter->second, connectionID, mpDatabaseHandler, this);
+ handle = createHandle(handleData, am_Handle_e::H_DISCONNECT);
+ }
+
+ logInfo(__METHOD_NAME__, "connectionID=", connectionID, "handle=", handle);
+ am_Error_e syncError(iter->second->asyncDisconnect(handle, connectionID));
+ if (syncError)
+ {
+ removeHandle(handle);
+ logError(__METHOD_NAME__, "Error while calling disconnect connectionID:", connectionID, "handle", handle);
+ }
+
+ return(syncError);
}
-am_Error_e CAmRoutingSender::asyncSetSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time)
+am_Error_e CAmRoutingSender::asyncSetSinkVolume(am_Handle_s &handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time)
{
- auto iter (mMapSinkInterface.find(sinkID));
- if (iter == mMapSinkInterface.end())
- {
- logError(__METHOD_NAME__,"Could not find sink",sinkID);
- return (E_NON_EXISTENT);
- }
-
- if(handleExists(handle))
- {
- if (handle.handleType==am_Handle_e::H_SETSINKVOLUME)
- {
- logInfo(__METHOD_NAME__,"Resending for handle",handle);
- }
- else
- {
- logError(__METHOD_NAME__,"Handle exists but wrong type",handle);
- return(E_UNKNOWN);
- }
- }
- else
- {
- auto handleData = std::make_shared<handleSinkVolume>(iter->second,sinkID,mpDatabaseHandler,volume);
+ auto iter(mMapSinkInterface.find(sinkID));
+ if (iter == mMapSinkInterface.end())
+ {
+ logError(__METHOD_NAME__, "Could not find sink", sinkID);
+ return (E_NON_EXISTENT);
+ }
+
+ if (handleExists(handle))
+ {
+ if (handle.handleType == am_Handle_e::H_SETSINKVOLUME)
+ {
+ logInfo(__METHOD_NAME__, "Resending for handle", handle);
+ }
+ else
+ {
+ logError(__METHOD_NAME__, "Handle exists but wrong type", handle);
+ return(E_UNKNOWN);
+ }
+ }
+ else
+ {
+ auto handleData = std::make_shared<handleSinkVolume>(iter->second, sinkID, mpDatabaseHandler, volume);
handle = createHandle(handleData, H_SETSINKVOLUME);
}
-
- logInfo(__METHOD_NAME__,"sinkID=", sinkID, "volume=", volume, "ramp=", ramp, "time=", time,"handle=",handle);
- am_Error_e syncError(iter->second->asyncSetSinkVolume(handle, sinkID, volume, ramp, time));
- if (syncError)
- {
- removeHandle(handle);
- logError(__METHOD_NAME__,"Error while calling asyncSetSinkVolume sinkID:",sinkID,"handle:",handle,"volume:",volume,"ramp:",ramp,"time:",time);
- }
- return(syncError);
+
+ logInfo(__METHOD_NAME__, "sinkID=", sinkID, "volume=", volume, "ramp=", ramp, "time=", time, "handle=", handle);
+ am_Error_e syncError(iter->second->asyncSetSinkVolume(handle, sinkID, volume, ramp, time));
+ if (syncError)
+ {
+ removeHandle(handle);
+ logError(__METHOD_NAME__, "Error while calling asyncSetSinkVolume sinkID:", sinkID, "handle:", handle, "volume:", volume, "ramp:", ramp, "time:", time);
+ }
+
+ return(syncError);
}
-am_Error_e CAmRoutingSender::asyncSetSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time)
+am_Error_e CAmRoutingSender::asyncSetSourceVolume(am_Handle_s &handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time)
{
- auto iter (mMapSourceInterface.find(sourceID));
- if (iter == mMapSourceInterface.end())
- {
- logError(__METHOD_NAME__,"Could not find sourceID",sourceID);
- return (E_NON_EXISTENT);
- }
-
- if(handleExists(handle))
- {
- if (handle.handleType==am_Handle_e::H_SETSOURCEVOLUME)
- {
- logInfo(__METHOD_NAME__,"Resending for handle",handle);
- }
- else
- {
- logError(__METHOD_NAME__,"Handle exists but wrong type",handle);
- return(E_UNKNOWN);
- }
- }
- else
- {
- auto handleData = std::make_shared<handleSourceVolume>(iter->second,sourceID,mpDatabaseHandler,volume);
+ auto iter(mMapSourceInterface.find(sourceID));
+ if (iter == mMapSourceInterface.end())
+ {
+ logError(__METHOD_NAME__, "Could not find sourceID", sourceID);
+ return (E_NON_EXISTENT);
+ }
+
+ if (handleExists(handle))
+ {
+ if (handle.handleType == am_Handle_e::H_SETSOURCEVOLUME)
+ {
+ logInfo(__METHOD_NAME__, "Resending for handle", handle);
+ }
+ else
+ {
+ logError(__METHOD_NAME__, "Handle exists but wrong type", handle);
+ return(E_UNKNOWN);
+ }
+ }
+ else
+ {
+ auto handleData = std::make_shared<handleSourceVolume>(iter->second, sourceID, mpDatabaseHandler, volume);
handle = createHandle(handleData, H_SETSOURCEVOLUME);
}
-
- logInfo(__METHOD_NAME__,"sourceID=", sourceID,"volume=", volume, "ramp=", ramp, "time=", time,"handle=",handle);
- am_Error_e syncError(iter->second->asyncSetSourceVolume(handle, sourceID, volume, ramp, time));
- if (syncError)
- {
- removeHandle(handle);
- logError(__METHOD_NAME__,"Error while calling asyncSetSourceVolume sourceID:",sourceID,"handle:",handle,"volume:",volume,"ramp:",ramp,"time:",time);
- }
- return(syncError);
+
+ logInfo(__METHOD_NAME__, "sourceID=", sourceID, "volume=", volume, "ramp=", ramp, "time=", time, "handle=", handle);
+ am_Error_e syncError(iter->second->asyncSetSourceVolume(handle, sourceID, volume, ramp, time));
+ if (syncError)
+ {
+ removeHandle(handle);
+ logError(__METHOD_NAME__, "Error while calling asyncSetSourceVolume sourceID:", sourceID, "handle:", handle, "volume:", volume, "ramp:", ramp, "time:", time);
+ }
+
+ return(syncError);
}
-am_Error_e CAmRoutingSender::asyncSetSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state)
+am_Error_e CAmRoutingSender::asyncSetSourceState(am_Handle_s &handle, const am_sourceID_t sourceID, const am_SourceState_e state)
{
- auto iter (mMapSourceInterface.find(sourceID));
- if (iter == mMapSourceInterface.end())
- {
- logError(__METHOD_NAME__,"Could not find sourceID",sourceID);
- return (E_NON_EXISTENT);
- }
-
- if(handleExists(handle))
- {
- if (handle.handleType==am_Handle_e::H_SETSOURCESTATE)
- {
- logInfo(__METHOD_NAME__,"Resending for handle",handle);
- }
- else
- {
- logError(__METHOD_NAME__,"Handle exists but wrong type",handle);
- return(E_UNKNOWN);
- }
- }
- else
- {
- auto handleData = std::make_shared<handleSourceState>(iter->second,sourceID,state,mpDatabaseHandler);
- handle = createHandle(handleData, H_SETSOURCESTATE);
- }
- logInfo(__METHOD_NAME__,"sourceID=", sourceID, "state=", state,"handle=",handle);
- am_Error_e syncError(iter->second->asyncSetSourceState(handle, sourceID, state));
- if (syncError)
- {
- removeHandle(handle);
- logError(__METHOD_NAME__,"Error while calling asyncSetSourceState sourceID:",sourceID,"handle:",handle,"state:",state);
- }
- return(syncError);
+ auto iter(mMapSourceInterface.find(sourceID));
+ if (iter == mMapSourceInterface.end())
+ {
+ logError(__METHOD_NAME__, "Could not find sourceID", sourceID);
+ return (E_NON_EXISTENT);
+ }
+
+ if (handleExists(handle))
+ {
+ if (handle.handleType == am_Handle_e::H_SETSOURCESTATE)
+ {
+ logInfo(__METHOD_NAME__, "Resending for handle", handle);
+ }
+ else
+ {
+ logError(__METHOD_NAME__, "Handle exists but wrong type", handle);
+ return(E_UNKNOWN);
+ }
+ }
+ else
+ {
+ auto handleData = std::make_shared<handleSourceState>(iter->second, sourceID, state, mpDatabaseHandler);
+ handle = createHandle(handleData, H_SETSOURCESTATE);
+ }
+
+ logInfo(__METHOD_NAME__, "sourceID=", sourceID, "state=", state, "handle=", handle);
+ am_Error_e syncError(iter->second->asyncSetSourceState(handle, sourceID, state));
+ if (syncError)
+ {
+ removeHandle(handle);
+ logError(__METHOD_NAME__, "Error while calling asyncSetSourceState sourceID:", sourceID, "handle:", handle, "state:", state);
+ }
+
+ return(syncError);
}
-am_Error_e CAmRoutingSender::asyncSetSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s & soundProperty)
+am_Error_e CAmRoutingSender::asyncSetSinkSoundProperty(am_Handle_s &handle, const am_sinkID_t sinkID, const am_SoundProperty_s &soundProperty)
{
- auto iter (mMapSinkInterface.find(sinkID));
- if (iter == mMapSinkInterface.end())
- {
- logError(__METHOD_NAME__,"Could not find sink",sinkID);
- return (E_NON_EXISTENT);
- }
-
- if(handleExists(handle))
- {
- if (handle.handleType==am_Handle_e::H_SETSINKSOUNDPROPERTY)
- {
- logInfo(__METHOD_NAME__,"Resending for handle",handle);
- }
- else
- {
- logError(__METHOD_NAME__,"Handle exists but wrong type",handle);
- return(E_UNKNOWN);
- }
- }
- else
- {
- auto handleData = std::make_shared<handleSinkSoundProperty>(iter->second,sinkID,soundProperty,mpDatabaseHandler);
+ auto iter(mMapSinkInterface.find(sinkID));
+ if (iter == mMapSinkInterface.end())
+ {
+ logError(__METHOD_NAME__, "Could not find sink", sinkID);
+ return (E_NON_EXISTENT);
+ }
+
+ if (handleExists(handle))
+ {
+ if (handle.handleType == am_Handle_e::H_SETSINKSOUNDPROPERTY)
+ {
+ logInfo(__METHOD_NAME__, "Resending for handle", handle);
+ }
+ else
+ {
+ logError(__METHOD_NAME__, "Handle exists but wrong type", handle);
+ return(E_UNKNOWN);
+ }
+ }
+ else
+ {
+ auto handleData = std::make_shared<handleSinkSoundProperty>(iter->second, sinkID, soundProperty, mpDatabaseHandler);
handle = createHandle(handleData, H_SETSINKSOUNDPROPERTY);
- }
-
- logInfo(__METHOD_NAME__,"sinkID=", sinkID, "soundProperty.Type=", soundProperty.type, "soundProperty.value=", soundProperty.value,"handle=",handle);
- am_Error_e syncError(iter->second->asyncSetSinkSoundProperty(handle, sinkID, soundProperty));
- if (syncError)
- {
- removeHandle(handle);
- logError(__METHOD_NAME__,"Error while calling asyncSetSinkSoundProperty sinkID:",sinkID,"handle:",handle,"soundProperty:",soundProperty.type,soundProperty.value);
- }
- return(syncError);
+ }
+
+ logInfo(__METHOD_NAME__, "sinkID=", sinkID, "soundProperty.Type=", soundProperty.type, "soundProperty.value=", soundProperty.value, "handle=", handle);
+ am_Error_e syncError(iter->second->asyncSetSinkSoundProperty(handle, sinkID, soundProperty));
+ if (syncError)
+ {
+ removeHandle(handle);
+ logError(__METHOD_NAME__, "Error while calling asyncSetSinkSoundProperty sinkID:", sinkID, "handle:", handle, "soundProperty:", soundProperty.type, soundProperty.value);
+ }
+
+ return(syncError);
}
-am_Error_e CAmRoutingSender::asyncSetSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s & soundProperty)
+am_Error_e CAmRoutingSender::asyncSetSourceSoundProperty(am_Handle_s &handle, const am_sourceID_t sourceID, const am_SoundProperty_s &soundProperty)
{
- auto iter (mMapSourceInterface.find(sourceID));
- if (iter == mMapSourceInterface.end())
- {
- logError(__METHOD_NAME__,"Could not find sourceID",sourceID);
- return (E_NON_EXISTENT);
- }
-
- if(handleExists(handle))
- {
- if (handle.handleType==am_Handle_e::H_SETSOURCESOUNDPROPERTY)
- {
- logInfo(__METHOD_NAME__,"Resending for handle",handle);
- }
- else
- {
- logError(__METHOD_NAME__,"Handle exists but wrong type",handle);
- return(E_UNKNOWN);
- }
- }
- else
- {
- auto handleData = std::make_shared<handleSourceSoundProperty>(iter->second,sourceID,soundProperty,mpDatabaseHandler);
+ auto iter(mMapSourceInterface.find(sourceID));
+ if (iter == mMapSourceInterface.end())
+ {
+ logError(__METHOD_NAME__, "Could not find sourceID", sourceID);
+ return (E_NON_EXISTENT);
+ }
+
+ if (handleExists(handle))
+ {
+ if (handle.handleType == am_Handle_e::H_SETSOURCESOUNDPROPERTY)
+ {
+ logInfo(__METHOD_NAME__, "Resending for handle", handle);
+ }
+ else
+ {
+ logError(__METHOD_NAME__, "Handle exists but wrong type", handle);
+ return(E_UNKNOWN);
+ }
+ }
+ else
+ {
+ auto handleData = std::make_shared<handleSourceSoundProperty>(iter->second, sourceID, soundProperty, mpDatabaseHandler);
handle = createHandle(handleData, H_SETSOURCESOUNDPROPERTY);
}
- logInfo(__METHOD_NAME__,"sourceID=", sourceID, "soundProperty.Type=", soundProperty.type, "soundProperty.value=", soundProperty.value,"handle=",handle);
- am_Error_e syncError(iter->second->asyncSetSourceSoundProperty(handle, sourceID, soundProperty));
- if (syncError)
- {
- removeHandle(handle);
- logError(__METHOD_NAME__,"Error while calling asyncSetSourceSoundProperty sourceID:",sourceID,"handle:",handle,"soundProperty:",soundProperty.type,soundProperty.value);
- }
- return(syncError);
+
+ logInfo(__METHOD_NAME__, "sourceID=", sourceID, "soundProperty.Type=", soundProperty.type, "soundProperty.value=", soundProperty.value, "handle=", handle);
+ am_Error_e syncError(iter->second->asyncSetSourceSoundProperty(handle, sourceID, soundProperty));
+ if (syncError)
+ {
+ removeHandle(handle);
+ logError(__METHOD_NAME__, "Error while calling asyncSetSourceSoundProperty sourceID:", sourceID, "handle:", handle, "soundProperty:", soundProperty.type, soundProperty.value);
+ }
+
+ return(syncError);
}
-am_Error_e CAmRoutingSender::asyncSetSourceSoundProperties(am_Handle_s& handle, const std::vector<am_SoundProperty_s> & listSoundProperties, const am_sourceID_t sourceID)
+am_Error_e CAmRoutingSender::asyncSetSourceSoundProperties(am_Handle_s &handle, const std::vector<am_SoundProperty_s> &listSoundProperties, const am_sourceID_t sourceID)
{
- auto iter (mMapSourceInterface.find(sourceID));
- if (iter == mMapSourceInterface.end())
- {
- logError(__METHOD_NAME__,"Could not find sourceID",sourceID);
- return (E_NON_EXISTENT);
- }
-
- if(handleExists(handle))
- {
- if (handle.handleType==am_Handle_e::H_SETSOURCESOUNDPROPERTIES)
- {
- logInfo(__METHOD_NAME__,"Resending for handle",handle);
- }
- else
- {
- logError(__METHOD_NAME__,"Handle exists but wrong type",handle);
- return(E_UNKNOWN);
- }
- }
- else
- {
- auto handleData = std::make_shared<handleSourceSoundProperties>(iter->second,sourceID,listSoundProperties,mpDatabaseHandler);
+ auto iter(mMapSourceInterface.find(sourceID));
+ if (iter == mMapSourceInterface.end())
+ {
+ logError(__METHOD_NAME__, "Could not find sourceID", sourceID);
+ return (E_NON_EXISTENT);
+ }
+
+ if (handleExists(handle))
+ {
+ if (handle.handleType == am_Handle_e::H_SETSOURCESOUNDPROPERTIES)
+ {
+ logInfo(__METHOD_NAME__, "Resending for handle", handle);
+ }
+ else
+ {
+ logError(__METHOD_NAME__, "Handle exists but wrong type", handle);
+ return(E_UNKNOWN);
+ }
+ }
+ else
+ {
+ auto handleData = std::make_shared<handleSourceSoundProperties>(iter->second, sourceID, listSoundProperties, mpDatabaseHandler);
handle = createHandle(handleData, H_SETSOURCESOUNDPROPERTIES);
}
-
- logInfo(__METHOD_NAME__,"sourceID=", sourceID);
- am_Error_e syncError(iter->second->asyncSetSourceSoundProperties(handle, sourceID, listSoundProperties));
- if (syncError)
- {
- removeHandle(handle);
- logError(__METHOD_NAME__,"Error while calling asyncSetSourceSoundProperties sourceID:",sourceID,"handle:",handle);
- }
- return(syncError);
+
+ logInfo(__METHOD_NAME__, "sourceID=", sourceID);
+ am_Error_e syncError(iter->second->asyncSetSourceSoundProperties(handle, sourceID, listSoundProperties));
+ if (syncError)
+ {
+ removeHandle(handle);
+ logError(__METHOD_NAME__, "Error while calling asyncSetSourceSoundProperties sourceID:", sourceID, "handle:", handle);
+ }
+
+ return(syncError);
}
-am_Error_e CAmRoutingSender::asyncSetSinkSoundProperties(am_Handle_s& handle, const std::vector<am_SoundProperty_s> & listSoundProperties, const am_sinkID_t sinkID)
+am_Error_e CAmRoutingSender::asyncSetSinkSoundProperties(am_Handle_s &handle, const std::vector<am_SoundProperty_s> &listSoundProperties, const am_sinkID_t sinkID)
{
- auto iter (mMapSinkInterface.find(sinkID));
- if (iter == mMapSinkInterface.end())
- {
- logError(__METHOD_NAME__,"Could not find sink",sinkID);
- return (E_NON_EXISTENT);
- }
-
- if(handleExists(handle))
- {
- if (handle.handleType==am_Handle_e::H_SETSINKSOUNDPROPERTIES)
- {
- logInfo(__METHOD_NAME__,"Resending for handle",handle);
- }
- else
- {
- logError(__METHOD_NAME__,"Handle exists but wrong type",handle);
- return(E_UNKNOWN);
- }
- }
- else
- {
- auto handleData = std::make_shared<handleSinkSoundProperties>(iter->second,sinkID,listSoundProperties,mpDatabaseHandler);
+ auto iter(mMapSinkInterface.find(sinkID));
+ if (iter == mMapSinkInterface.end())
+ {
+ logError(__METHOD_NAME__, "Could not find sink", sinkID);
+ return (E_NON_EXISTENT);
+ }
+
+ if (handleExists(handle))
+ {
+ if (handle.handleType == am_Handle_e::H_SETSINKSOUNDPROPERTIES)
+ {
+ logInfo(__METHOD_NAME__, "Resending for handle", handle);
+ }
+ else
+ {
+ logError(__METHOD_NAME__, "Handle exists but wrong type", handle);
+ return(E_UNKNOWN);
+ }
+ }
+ else
+ {
+ auto handleData = std::make_shared<handleSinkSoundProperties>(iter->second, sinkID, listSoundProperties, mpDatabaseHandler);
handle = createHandle(handleData, H_SETSINKSOUNDPROPERTIES);
}
-
- logInfo(__METHOD_NAME__,"sinkID=", sinkID,"handle=",handle);
- am_Error_e syncError(iter->second->asyncSetSinkSoundProperties(handle, sinkID, listSoundProperties));
- if (syncError)
- {
- removeHandle(handle);
- logError(__METHOD_NAME__,"Error while calling asyncSetSinkSoundProperties sinkID:",sinkID,"handle:",handle);
- }
- return(syncError);
+
+ logInfo(__METHOD_NAME__, "sinkID=", sinkID, "handle=", handle);
+ am_Error_e syncError(iter->second->asyncSetSinkSoundProperties(handle, sinkID, listSoundProperties));
+ if (syncError)
+ {
+ removeHandle(handle);
+ logError(__METHOD_NAME__, "Error while calling asyncSetSinkSoundProperties sinkID:", sinkID, "handle:", handle);
+ }
+
+ return(syncError);
}
-am_Error_e CAmRoutingSender::asyncCrossFade(am_Handle_s& handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_CustomRampType_t rampType, const am_time_t time)
+am_Error_e CAmRoutingSender::asyncCrossFade(am_Handle_s &handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_CustomRampType_t rampType, const am_time_t time)
{
- auto iter (mMapCrossfaderInterface.find(crossfaderID));
- if (iter == mMapCrossfaderInterface.end())
- {
- logError(__METHOD_NAME__,"Could not find crossfaderID",crossfaderID);
- return (E_NON_EXISTENT);
- }
-
- if(handleExists(handle))
- {
- if (handle.handleType==am_Handle_e::H_CROSSFADE)
- {
- logInfo(__METHOD_NAME__,"Resending for handle",handle);
- }
- else
- {
- logError(__METHOD_NAME__,"Handle exists but wrong type",handle);
- return(E_UNKNOWN);
- }
- }
- else
- {
- auto handleData = std::make_shared<handleCrossFader>(iter->second,crossfaderID,hotSink,mpDatabaseHandler);
+ auto iter(mMapCrossfaderInterface.find(crossfaderID));
+ if (iter == mMapCrossfaderInterface.end())
+ {
+ logError(__METHOD_NAME__, "Could not find crossfaderID", crossfaderID);
+ return (E_NON_EXISTENT);
+ }
+
+ if (handleExists(handle))
+ {
+ if (handle.handleType == am_Handle_e::H_CROSSFADE)
+ {
+ logInfo(__METHOD_NAME__, "Resending for handle", handle);
+ }
+ else
+ {
+ logError(__METHOD_NAME__, "Handle exists but wrong type", handle);
+ return(E_UNKNOWN);
+ }
+ }
+ else
+ {
+ auto handleData = std::make_shared<handleCrossFader>(iter->second, crossfaderID, hotSink, mpDatabaseHandler);
handle = createHandle(handleData, H_CROSSFADE);
- }
-
- logInfo(__METHOD_NAME__,"hotSource=", hotSink, "crossfaderID=", crossfaderID, "rampType=", rampType, "rampTime=", time,"handle=",handle);
- am_Error_e syncError(iter->second->asyncCrossFade(handle, crossfaderID, hotSink, rampType, time));
- if (syncError)
- {
- removeHandle(handle);
- }
- return(syncError);
+ }
+
+ logInfo(__METHOD_NAME__, "hotSource=", hotSink, "crossfaderID=", crossfaderID, "rampType=", rampType, "rampTime=", time, "handle=", handle);
+ am_Error_e syncError(iter->second->asyncCrossFade(handle, crossfaderID, hotSink, rampType, time));
+ if (syncError)
+ {
+ removeHandle(handle);
+ }
+
+ return(syncError);
}
am_Error_e CAmRoutingSender::setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState)
{
- logInfo(__METHOD_NAME__,"domainID=", domainID, "domainState=", domainState);
+ logInfo(__METHOD_NAME__, "domainID=", domainID, "domainState=", domainState);
DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
iter = mMapDomainInterface.find(domainID);
if (iter != mMapDomainInterface.end())
+ {
return (iter->second->setDomainState(domainID, domainState));
+ }
+
return (E_NON_EXISTENT);
}
@@ -648,9 +667,9 @@ am_Error_e CAmRoutingSender::setDomainState(const am_domainID_t domainID, const
* this adds the domain to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface.
* This must be done whenever a domain is registered.
*/
-am_Error_e CAmRoutingSender::addDomainLookup(const am_Domain_s& domainData)
+am_Error_e CAmRoutingSender::addDomainLookup(const am_Domain_s &domainData)
{
- std::vector<InterfaceNamePairs>::iterator iter = mListInterfaces.begin();
+ std::vector<InterfaceNamePairs>::iterator iter = mListInterfaces.begin();
std::vector<InterfaceNamePairs>::iterator iterEnd = mListInterfaces.end();
for (; iter < iterEnd; ++iter)
{
@@ -660,7 +679,8 @@ am_Error_e CAmRoutingSender::addDomainLookup(const am_Domain_s& domainData)
return (E_OK);
}
}
- logError(__PRETTY_FUNCTION__," Could not find busname for bus",domainData.busname);
+
+ logError(__PRETTY_FUNCTION__, " Could not find busname for bus", domainData.busname);
return (E_UNKNOWN);
}
@@ -669,7 +689,7 @@ am_Error_e CAmRoutingSender::addDomainLookup(const am_Domain_s& domainData)
* this adds the Source to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface.
* This must be done whenever a Source is registered.
*/
-am_Error_e CAmRoutingSender::addSourceLookup(const am_Source_s& sourceData)
+am_Error_e CAmRoutingSender::addSourceLookup(const am_Source_s &sourceData)
{
DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
iter = mMapDomainInterface.find(sourceData.domainID);
@@ -678,7 +698,8 @@ am_Error_e CAmRoutingSender::addSourceLookup(const am_Source_s& sourceData)
mMapSourceInterface.insert(std::make_pair(sourceData.sourceID, iter->second));
return (E_OK);
}
- logError(__PRETTY_FUNCTION__," Could not find domainInterface for domainID",sourceData.domainID);
+
+ logError(__PRETTY_FUNCTION__, " Could not find domainInterface for domainID", sourceData.domainID);
return (E_UNKNOWN);
}
@@ -687,7 +708,7 @@ am_Error_e CAmRoutingSender::addSourceLookup(const am_Source_s& sourceData)
* this adds the Sink to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface.
* This must be done whenever a Sink is registered.
*/
-am_Error_e CAmRoutingSender::addSinkLookup(const am_Sink_s& sinkData)
+am_Error_e CAmRoutingSender::addSinkLookup(const am_Sink_s &sinkData)
{
DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
iter = mMapDomainInterface.find(sinkData.domainID);
@@ -696,7 +717,8 @@ am_Error_e CAmRoutingSender::addSinkLookup(const am_Sink_s& sinkData)
mMapSinkInterface.insert(std::make_pair(sinkData.sinkID, iter->second));
return (E_OK);
}
- logError(__PRETTY_FUNCTION__,"Could not find domainInterface for domainID",sinkData.domainID);
+
+ logError(__PRETTY_FUNCTION__, "Could not find domainInterface for domainID", sinkData.domainID);
return (E_UNKNOWN);
}
@@ -705,7 +727,7 @@ am_Error_e CAmRoutingSender::addSinkLookup(const am_Sink_s& sinkData)
* this adds the Crossfader to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface.
* This must be done whenever a Crossfader is registered.
*/
-am_Error_e CAmRoutingSender::addCrossfaderLookup(const am_Crossfader_s& crossfaderData)
+am_Error_e CAmRoutingSender::addCrossfaderLookup(const am_Crossfader_s &crossfaderData)
{
DomainInterfaceMap::iterator iter = mMapSourceInterface.begin();
iter = mMapSourceInterface.find(crossfaderData.sourceID);
@@ -714,7 +736,8 @@ am_Error_e CAmRoutingSender::addCrossfaderLookup(const am_Crossfader_s& crossfad
mMapSourceInterface.insert(std::make_pair(crossfaderData.crossfaderID, iter->second));
return (E_OK);
}
- logError(__PRETTY_FUNCTION__," Could not find sourceInterface for source",crossfaderData.sourceID);
+
+ logError(__PRETTY_FUNCTION__, " Could not find sourceInterface for source", crossfaderData.sourceID);
return (E_UNKNOWN);
}
@@ -791,17 +814,18 @@ am_Error_e CAmRoutingSender::removeCrossfaderLookup(const am_crossfaderID_t cros
* @param handle to be removed
* @return E_OK in case of success
*/
-am_Error_e CAmRoutingSender::removeHandle(const am_Handle_s& handle)
+am_Error_e CAmRoutingSender::removeHandle(const am_Handle_s &handle)
{
if (mlistActiveHandles.erase(handle))
{
return (E_OK);
}
- logError(__METHOD_NAME__,"Could not remove handle",handle.handle);
+
+ logError(__METHOD_NAME__, "Could not remove handle", handle.handle);
return (E_NON_EXISTENT);
}
-am_Error_e CAmRoutingSender::getListHandles(std::vector<am_Handle_s> & listHandles) const
+am_Error_e CAmRoutingSender::getListHandles(std::vector<am_Handle_s> &listHandles) const
{
listHandles.clear();
HandlesMap::const_iterator it = mlistActiveHandles.begin();
@@ -809,6 +833,7 @@ am_Error_e CAmRoutingSender::getListHandles(std::vector<am_Handle_s> & listHandl
{
listHandles.push_back(it->first);
}
+
return (E_OK);
}
@@ -822,30 +847,32 @@ am_Handle_s CAmRoutingSender::createHandle(std::shared_ptr<handleDataBase> handl
{
am_Handle_s handle;
handle.handleType = type;
-
- 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);
- }
- }
-
- logError(__METHOD_NAME__,"could not create new handle, all handles in use!");
- handle.handle=0;
-
+
+ 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);
+ }
+ }
+
+ logError(__METHOD_NAME__, "could not create new handle, all handles in use!");
+ handle.handle = 0;
+
return(handle);
}
@@ -853,19 +880,19 @@ void CAmRoutingSender::setRoutingReady()
{
mpRoutingReceiver->waitOnStartup(false);
- //create a list of handles
+ // create a list of handles
std::vector<uint16_t> listStartupHandles;
for (size_t i = 0; i < mListInterfaces.size(); i++)
{
listStartupHandles.push_back(mpRoutingReceiver->getStartupHandle());
}
- //set the receiver ready to wait for replies
+ // set the receiver ready to wait for replies
mpRoutingReceiver->waitOnStartup(true);
- std::vector<InterfaceNamePairs>::iterator iter = mListInterfaces.begin();
+ std::vector<InterfaceNamePairs>::iterator iter = mListInterfaces.begin();
std::vector<InterfaceNamePairs>::iterator iterEnd = mListInterfaces.end();
- std::vector<uint16_t>::const_iterator handleIter(listStartupHandles.begin());
+ std::vector<uint16_t>::const_iterator handleIter(listStartupHandles.begin());
for (; iter < iterEnd; ++iter)
{
(*iter).routingInterface->setRoutingReady(*(handleIter++));
@@ -875,301 +902,328 @@ void CAmRoutingSender::setRoutingReady()
void CAmRoutingSender::setRoutingRundown()
{
mpRoutingReceiver->waitOnRundown(false);
- //create a list of handles
+ // create a list of handles
std::vector<uint16_t> listStartupHandles;
for (size_t i = 0; i < mListInterfaces.size(); i++)
{
listStartupHandles.push_back(mpRoutingReceiver->getRundownHandle());
}
- //set the receiver ready to wait for replies
+ // set the receiver ready to wait for replies
mpRoutingReceiver->waitOnRundown(true);
- std::vector<InterfaceNamePairs>::iterator iter = mListInterfaces.begin();
+ std::vector<InterfaceNamePairs>::iterator iter = mListInterfaces.begin();
std::vector<InterfaceNamePairs>::iterator iterEnd = mListInterfaces.end();
- std::vector<uint16_t>::const_iterator handleIter(listStartupHandles.begin());
+ std::vector<uint16_t>::const_iterator handleIter(listStartupHandles.begin());
for (; iter < iterEnd; ++iter)
{
(*iter).routingInterface->setRoutingRundown(*(handleIter++));
}
}
-am_Error_e CAmRoutingSender::asyncSetVolumes(am_Handle_s& handle, const std::vector<am_Volumes_s>& listVolumes)
+am_Error_e CAmRoutingSender::asyncSetVolumes(am_Handle_s &handle, const std::vector<am_Volumes_s> &listVolumes)
{
- IAmRoutingSend* pRoutingInterface(NULL);
+ IAmRoutingSend *pRoutingInterface(NULL);
if (listVolumes.empty())
+ {
return (E_NOT_POSSIBLE);
+ }
- //we need an interface so lets get either the sink or source ID from the first entry in the listVolumes
- if (listVolumes[0].volumeType==VT_SINK)
+ // we need an interface so lets get either the sink or source ID from the first entry in the listVolumes
+ if (listVolumes[0].volumeType == VT_SINK)
{
- am_sinkID_t sinkID=listVolumes[0].volumeID.sink;
- SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
+ am_sinkID_t sinkID = listVolumes[0].volumeID.sink;
+ SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
iter = mMapSinkInterface.find(sinkID);
- if(iter!=mMapSinkInterface.end())
- pRoutingInterface=iter->second;
+ if (iter != mMapSinkInterface.end())
+ {
+ pRoutingInterface = iter->second;
+ }
else
+ {
return(E_NON_EXISTENT);
+ }
}
-
- else if (listVolumes[0].volumeType==VT_SOURCE)
+ else if (listVolumes[0].volumeType == VT_SOURCE)
{
- am_sourceID_t sourceID=listVolumes[0].volumeID.source;
- SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
+ am_sourceID_t sourceID = listVolumes[0].volumeID.source;
+ SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
iter = mMapSourceInterface.find(sourceID);
- if (iter!=mMapSourceInterface.end())
- pRoutingInterface=iter->second;
+ if (iter != mMapSourceInterface.end())
+ {
+ pRoutingInterface = iter->second;
+ }
else
+ {
return(E_NON_EXISTENT);
+ }
}
else
+ {
return (E_NON_EXISTENT);
+ }
- auto handleData = std::make_shared<handleSetVolumes>(pRoutingInterface,listVolumes,mpDatabaseHandler);
+ auto handleData = std::make_shared<handleSetVolumes>(pRoutingInterface, listVolumes, mpDatabaseHandler);
handle = createHandle(handleData, H_SETVOLUMES);
logInfo(__METHOD_NAME__, "handle=", handle);
am_Error_e syncError(pRoutingInterface->asyncSetVolumes(handle, listVolumes));
if (syncError)
- {
- removeHandle(handle);
- }
- return(syncError);
+ {
+ removeHandle(handle);
+ }
+
+ return(syncError);
}
-am_Error_e CAmRoutingSender::asyncSetSinkNotificationConfiguration(am_Handle_s& handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& notificationConfiguration)
+am_Error_e CAmRoutingSender::asyncSetSinkNotificationConfiguration(am_Handle_s &handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s &notificationConfiguration)
{
- auto iter (mMapSinkInterface.find(sinkID));
- if (iter == mMapSinkInterface.end())
- {
- logError(__METHOD_NAME__,"Could not find sink",sinkID);
- return (E_NON_EXISTENT);
- }
-
- if(handleExists(handle))
- {
- if (handle.handleType==am_Handle_e::H_SETSINKNOTIFICATION)
- {
- logInfo(__METHOD_NAME__,"Resending for handle",handle);
- }
- else
- {
- logError(__METHOD_NAME__,"Handle exists but wrong type",handle);
- return(E_UNKNOWN);
- }
- }
- else
- {
- auto handleData = std::make_shared<handleSetSinkNotificationConfiguration>(iter->second,sinkID,notificationConfiguration,mpDatabaseHandler);
+ auto iter(mMapSinkInterface.find(sinkID));
+ if (iter == mMapSinkInterface.end())
+ {
+ logError(__METHOD_NAME__, "Could not find sink", sinkID);
+ return (E_NON_EXISTENT);
+ }
+
+ if (handleExists(handle))
+ {
+ if (handle.handleType == am_Handle_e::H_SETSINKNOTIFICATION)
+ {
+ logInfo(__METHOD_NAME__, "Resending for handle", handle);
+ }
+ else
+ {
+ logError(__METHOD_NAME__, "Handle exists but wrong type", handle);
+ return(E_UNKNOWN);
+ }
+ }
+ else
+ {
+ auto handleData = std::make_shared<handleSetSinkNotificationConfiguration>(iter->second, sinkID, notificationConfiguration, mpDatabaseHandler);
handle = createHandle(handleData, H_SETSINKNOTIFICATION);
}
- logInfo(__METHOD_NAME__,"sinkID=",sinkID,"notificationConfiguration.type=",notificationConfiguration.type,"notificationConfiguration.status",notificationConfiguration.status,"notificationConfiguration.parameter",notificationConfiguration.parameter);
- am_Error_e syncError(iter->second->asyncSetSinkNotificationConfiguration(handle, sinkID, notificationConfiguration));
- if (syncError)
- {
- removeHandle(handle);
- logError(__METHOD_NAME__,"Error while calling asyncSetSinkNotificationConfiguration sinkID:",sinkID,"handle:",handle);
- }
- return(syncError);
+ logInfo(__METHOD_NAME__, "sinkID=", sinkID, "notificationConfiguration.type=", notificationConfiguration.type, "notificationConfiguration.status", notificationConfiguration.status, "notificationConfiguration.parameter", notificationConfiguration.parameter);
+ am_Error_e syncError(iter->second->asyncSetSinkNotificationConfiguration(handle, sinkID, notificationConfiguration));
+ if (syncError)
+ {
+ removeHandle(handle);
+ logError(__METHOD_NAME__, "Error while calling asyncSetSinkNotificationConfiguration sinkID:", sinkID, "handle:", handle);
+ }
+
+ return(syncError);
}
-am_Error_e CAmRoutingSender::asyncSetSourceNotificationConfiguration(am_Handle_s& handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& notificationConfiguration)
+am_Error_e CAmRoutingSender::asyncSetSourceNotificationConfiguration(am_Handle_s &handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s &notificationConfiguration)
{
- auto iter (mMapSourceInterface.find(sourceID));
- if (iter == mMapSourceInterface.end())
- {
- logError(__METHOD_NAME__,"Could not find sourceID",sourceID);
- return (E_NON_EXISTENT);
- }
-
- if(handleExists(handle))
- {
- if (handle.handleType==am_Handle_e::H_SETSOURCENOTIFICATION)
- {
- logInfo(__METHOD_NAME__,"Resending for handle",handle);
- }
- else
- {
- logError(__METHOD_NAME__,"Handle exists but wrong type",handle);
- return(E_UNKNOWN);
- }
- }
- else
- {
- auto handleData = std::make_shared<handleSetSourceNotificationConfiguration>(iter->second,sourceID,notificationConfiguration,mpDatabaseHandler);
+ auto iter(mMapSourceInterface.find(sourceID));
+ if (iter == mMapSourceInterface.end())
+ {
+ logError(__METHOD_NAME__, "Could not find sourceID", sourceID);
+ return (E_NON_EXISTENT);
+ }
+
+ if (handleExists(handle))
+ {
+ if (handle.handleType == am_Handle_e::H_SETSOURCENOTIFICATION)
+ {
+ logInfo(__METHOD_NAME__, "Resending for handle", handle);
+ }
+ else
+ {
+ logError(__METHOD_NAME__, "Handle exists but wrong type", handle);
+ return(E_UNKNOWN);
+ }
+ }
+ else
+ {
+ auto handleData = std::make_shared<handleSetSourceNotificationConfiguration>(iter->second, sourceID, notificationConfiguration, mpDatabaseHandler);
handle = createHandle(handleData, H_SETSOURCENOTIFICATION);
}
- logInfo(__METHOD_NAME__,"sourceID=",sourceID,"notificationConfiguration.type=",notificationConfiguration.type,"notificationConfiguration.status",notificationConfiguration.status,"notificationConfiguration.parameter",notificationConfiguration.parameter);
- am_Error_e syncError(iter->second->asyncSetSourceNotificationConfiguration(handle, sourceID, notificationConfiguration));
- if (syncError)
- {
- removeHandle(handle);
- logError(__METHOD_NAME__,"Error while calling asyncSetSourceNotificationConfiguration sourceID:",sourceID,"handle:",handle);
- }
- return(syncError);
+ logInfo(__METHOD_NAME__, "sourceID=", sourceID, "notificationConfiguration.type=", notificationConfiguration.type, "notificationConfiguration.status", notificationConfiguration.status, "notificationConfiguration.parameter", notificationConfiguration.parameter);
+ am_Error_e syncError(iter->second->asyncSetSourceNotificationConfiguration(handle, sourceID, notificationConfiguration));
+ if (syncError)
+ {
+ removeHandle(handle);
+ logError(__METHOD_NAME__, "Error while calling asyncSetSourceNotificationConfiguration sourceID:", sourceID, "handle:", handle);
+ }
+
+ return(syncError);
}
void CAmRoutingSender::unloadLibraries(void)
{
- std::vector<void*>::iterator iterator = mListLibraryHandles.begin();
+ std::vector<void *>::iterator iterator = mListLibraryHandles.begin();
for (; iterator < mListLibraryHandles.end(); ++iterator)
{
dlclose(*iterator);
}
+
mListLibraryHandles.clear();
}
-am_Error_e CAmRoutingSender::getListPlugins(std::vector<std::string>& interfaces) const
+am_Error_e CAmRoutingSender::getListPlugins(std::vector<std::string> &interfaces) const
{
std::vector<InterfaceNamePairs>::const_iterator it = mListInterfaces.begin();
for (; it != mListInterfaces.end(); ++it)
{
interfaces.push_back(it->busName);
}
+
return (E_OK);
}
-void CAmRoutingSender::getInterfaceVersion(std::string & version) const
+void CAmRoutingSender::getInterfaceVersion(std::string &version) const
{
version = RoutingVersion;
}
-am_Error_e CAmRoutingSender::resyncConnectionState(const am_domainID_t domainID,std::vector<am_Connection_s>& listOfExistingConnections)
+
+am_Error_e CAmRoutingSender::resyncConnectionState(const am_domainID_t domainID, std::vector<am_Connection_s> &listOfExistingConnections)
{
DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
iter = mMapDomainInterface.find(domainID);
if (iter != mMapDomainInterface.end())
+ {
return (iter->second->resyncConnectionState(domainID, listOfExistingConnections));
+ }
+
return (E_NON_EXISTENT);
}
am_Error_e CAmRoutingSender::writeToDatabaseAndRemove(const am_Handle_s handle)
{
auto it(mlistActiveHandles.find(handle));
- if (it!=mlistActiveHandles.end())
+ if (it != mlistActiveHandles.end())
{
- am_Error_e error(it->second->writeDataToDatabase());
- mlistActiveHandles.erase(handle);
+ am_Error_e error(it->second->writeDataToDatabase());
+ mlistActiveHandles.erase(handle);
return (error);
}
- logError(__METHOD_NAME__,"could not find handle data for handle",handle);
- return (am_Error_e::E_NON_EXISTENT);
+
+ logError(__METHOD_NAME__, "could not find handle data for handle", handle);
+ return (am_Error_e::E_NON_EXISTENT);
}
void CAmRoutingSender::checkVolume(const am_Handle_s handle, const am_volume_t volume)
{
auto it(mlistActiveHandles.find(handle));
- if (it!=mlistActiveHandles.end())
+ if (it != mlistActiveHandles.end())
{
- handleVolumeBase* basePtr = static_cast<handleVolumeBase*>(it->second.get());
- if (basePtr->returnVolume()!=volume)
- {
- logError(__METHOD_NAME__,"volume returned for handle does not match: ",volume,"expected:",basePtr->returnVolume());
- }
- return;
+ handleVolumeBase *basePtr = static_cast<handleVolumeBase *>(it->second.get());
+ if (basePtr->returnVolume() != volume)
+ {
+ logError(__METHOD_NAME__, "volume returned for handle does not match: ", volume, "expected:", basePtr->returnVolume());
+ }
+
+ return;
}
- logError(__METHOD_NAME__,"could not find handle data for handle",handle);
+
+ logError(__METHOD_NAME__, "could not find handle data for handle", handle);
}
bool CAmRoutingSender::handleExists(const am_Handle_s handle)
{
auto iter(mlistActiveHandles.find(handle));
- if (iter!=mlistActiveHandles.end())
+ if (iter != mlistActiveHandles.end())
{
- return (true);
- }
- return (false);
+ return (true);
+ }
+
+ return (false);
}
am_Error_e CAmRoutingSender::handleSinkSoundProperty::writeDataToDatabase()
{
- return (mpDatabaseHandler->changeSinkSoundPropertyDB(mSoundProperty,mSinkID));
+ return (mpDatabaseHandler->changeSinkSoundPropertyDB(mSoundProperty, mSinkID));
}
am_Error_e CAmRoutingSender::handleSinkSoundProperties::writeDataToDatabase()
{
- std::vector<am_SoundProperty_s>::const_iterator it = mlistSoundProperties.begin();
- for (; it != mlistSoundProperties.end(); ++it)
- {
- mpDatabaseHandler->changeSinkSoundPropertyDB(*it, mSinkID);
- }
- return (am_Error_e::E_OK);
+ std::vector<am_SoundProperty_s>::const_iterator it = mlistSoundProperties.begin();
+ for (; it != mlistSoundProperties.end(); ++it)
+ {
+ mpDatabaseHandler->changeSinkSoundPropertyDB(*it, mSinkID);
+ }
+
+ return (am_Error_e::E_OK);
}
am_Error_e CAmRoutingSender::handleSourceSoundProperty::writeDataToDatabase()
{
- return (mpDatabaseHandler->changeSourceSoundPropertyDB(mSoundProperty,mSourceID));
+ return (mpDatabaseHandler->changeSourceSoundPropertyDB(mSoundProperty, mSourceID));
}
am_Error_e CAmRoutingSender::handleSourceSoundProperties::writeDataToDatabase()
{
- std::vector<am_SoundProperty_s>::const_iterator it = mlistSoundProperties.begin();
- for (; it != mlistSoundProperties.end(); ++it)
- {
- mpDatabaseHandler->changeSourceSoundPropertyDB(*it, mSourceID);
- }
- return (am_Error_e::E_OK);
+ std::vector<am_SoundProperty_s>::const_iterator it = mlistSoundProperties.begin();
+ for (; it != mlistSoundProperties.end(); ++it)
+ {
+ mpDatabaseHandler->changeSourceSoundPropertyDB(*it, mSourceID);
+ }
+
+ return (am_Error_e::E_OK);
}
am_Error_e CAmRoutingSender::handleSourceState::writeDataToDatabase()
{
- return (mpDatabaseHandler->changeSourceState(mSourceID,mSourceState));
+ return (mpDatabaseHandler->changeSourceState(mSourceID, mSourceState));
}
am_Error_e CAmRoutingSender::handleSourceVolume::writeDataToDatabase()
{
- return (mpDatabaseHandler->changeSourceVolume(mSourceID,returnVolume()));
+ return (mpDatabaseHandler->changeSourceVolume(mSourceID, returnVolume()));
}
am_Error_e CAmRoutingSender::handleSinkVolume::writeDataToDatabase()
{
- return (mpDatabaseHandler->changeSinkVolume(mSinkID,returnVolume()));
+ return (mpDatabaseHandler->changeSinkVolume(mSinkID, returnVolume()));
}
am_Error_e CAmRoutingSender::handleCrossFader::writeDataToDatabase()
{
- return (mpDatabaseHandler->changeCrossFaderHotSink(mCrossfaderID, mHotSink));
+ return (mpDatabaseHandler->changeCrossFaderHotSink(mCrossfaderID, mHotSink));
}
am_Error_e CAmRoutingSender::handleConnect::writeDataToDatabase()
{
- mConnectionPending = false;
- return (mpDatabaseHandler->changeConnectionFinal(mConnectionID));
+ mConnectionPending = false;
+ return (mpDatabaseHandler->changeConnectionFinal(mConnectionID));
}
am_Error_e CAmRoutingSender::handleDisconnect::writeDataToDatabase()
{
- return E_OK;
+ return E_OK;
}
am_Error_e CAmRoutingSender::handleSetVolumes::writeDataToDatabase()
{
- std::vector<am_Volumes_s>::const_iterator iterator (mlistVolumes.begin());
-
- for (;iterator!=mlistVolumes.end();++iterator)
- {
- if (iterator->volumeType==VT_SINK)
- {
- return (mpDatabaseHandler->changeSinkVolume(iterator->volumeID.sink,iterator->volume));
- }
- else if (iterator->volumeType==VT_SOURCE)
- {
- return (mpDatabaseHandler->changeSourceVolume(iterator->volumeID.source,iterator->volume));
- }
- }
- return (am_Error_e::E_WRONG_FORMAT);
+ std::vector<am_Volumes_s>::const_iterator iterator(mlistVolumes.begin());
+
+ for (; iterator != mlistVolumes.end(); ++iterator)
+ {
+ if (iterator->volumeType == VT_SINK)
+ {
+ return (mpDatabaseHandler->changeSinkVolume(iterator->volumeID.sink, iterator->volume));
+ }
+ else if (iterator->volumeType == VT_SOURCE)
+ {
+ return (mpDatabaseHandler->changeSourceVolume(iterator->volumeID.source, iterator->volume));
+ }
+ }
+
+ return (am_Error_e::E_WRONG_FORMAT);
}
am_Error_e CAmRoutingSender::handleSetSinkNotificationConfiguration::writeDataToDatabase()
{
- return (mpDatabaseHandler->changeSinkNotificationConfigurationDB(mSinkID,mNotificationConfiguration));
+ return (mpDatabaseHandler->changeSinkNotificationConfigurationDB(mSinkID, mNotificationConfiguration));
}
am_Error_e CAmRoutingSender::handleSetSourceNotificationConfiguration::writeDataToDatabase()
{
- return (mpDatabaseHandler->changeSourceNotificationConfigurationDB(mSourceID,mNotificationConfiguration));
+ return (mpDatabaseHandler->changeSourceNotificationConfigurationDB(mSourceID, mNotificationConfiguration));
}
am_Error_e CAmRoutingSender::removeConnectionLookup(const am_connectionID_t connectionID)
@@ -1181,21 +1235,21 @@ am_Error_e CAmRoutingSender::removeConnectionLookup(const am_connectionID_t conn
mMapConnectionInterface.erase(iter);
return (E_OK);
}
+
return (E_UNKNOWN);
}
CAmRoutingSender::handleConnect::~handleConnect()
{
- if (mConnectionPending)
- {
- mpDatabaseHandler->removeConnection(mConnectionID);
- }
+ if (mConnectionPending)
+ {
+ mpDatabaseHandler->removeConnection(mConnectionID);
+ }
}
CAmRoutingSender::handleDisconnect::~handleDisconnect()
{
- mpDatabaseHandler->removeConnection(mConnectionID);
+ mpDatabaseHandler->removeConnection(mConnectionID);
}
}
-
diff --git a/AudioManagerDaemon/src/main.cpp b/AudioManagerDaemon/src/main.cpp
index 171d6ef..1567265 100755..100644
--- a/AudioManagerDaemon/src/main.cpp
+++ b/AudioManagerDaemon/src/main.cpp
@@ -25,15 +25,15 @@
#include "audiomanagerconfig.h"
#ifdef WITH_CAPI_WRAPPER
- #include "CAmCommonAPIWrapper.h"
+# include "CAmCommonAPIWrapper.h"
#endif
#ifdef WITH_DBUS_WRAPPER
- #include "CAmDbusWrapper.h"
+# include "CAmDbusWrapper.h"
#endif
#ifdef WITH_SYSTEMD_WATCHDOG
- #include "CAmWatchdog.h"
+# include "CAmWatchdog.h"
#endif
#include <sys/resource.h>
@@ -61,40 +61,39 @@
#include "CAmDatabaseHandlerMap.h"
#ifndef AUDIOMANGER_APP_ID
- #define AUDIOMANGER_APP_ID "AUDI"
+# define AUDIOMANGER_APP_ID "AUDI"
#endif
#ifndef AUDIOMANGER_APP_DESCRIPTION
- #define AUDIOMANGER_APP_DESCRIPTION "AudioManager"
+# define AUDIOMANGER_APP_DESCRIPTION "AudioManager"
#endif
-
using namespace am;
-//we need these because we parse them beforehand.
+// we need these because we parse them beforehand.
std::vector<std::string> listCommandPluginDirs;
std::vector<std::string> listRoutingPluginDirs;
// List of signals to be handled with signalfd
-std::vector<uint8_t> listOfSignalsFD = {SIGHUP, SIGTERM, SIGCHLD};
-
-//commandline options used by the Audiomanager itself
-TCLAP::ValueArg<std::string> controllerPlugin("c","controllerPlugin","use controllerPlugin full path with .so ending",false,CONTROLLER_PLUGIN_DIR,"string");
-TCLAP::ValueArg<std::string> additionalCommandPluginDirs("L","additionalCommandPluginDirs","additional path for looking for command plugins, can be used after -l option",false," ","string");
-TCLAP::ValueArg<std::string> additionalRoutingPluginDirs("R","additionalRoutingPluginDirs","additional path for looking for routing plugins, can be used after -r option ",false," ","string");
-TCLAP::ValueArg<std::string> routingPluginDir("r","RoutingPluginDir","path for looking for routing plugins",false," ","string");
-TCLAP::ValueArg<std::string> commandPluginDir("l","CommandPluginDir","path for looking for command plugins",false," ","string");
-TCLAP::ValueArg<std::string> dltLogFilename("F","dltLogFilename","the name of the logfile, absolute path. Only if logging is et to file",false," ","string");
-TCLAP::ValueArg<unsigned int> dltOutput ("O","dltOutput","defines where logs are written. 0=dlt-daemon(default), 1=command line, 2=file ",false,0,"int");
-TCLAP::SwitchArg dltEnable ("e","dltEnable","Enables or disables dlt logging. Default = enabled",true);
-TCLAP::SwitchArg dbusWrapperTypeBool ("T","dbusType","DbusType to be used by CAmDbusWrapper: if option is selected, DBUS_SYSTEM is used otherwise DBUS_SESSION",false);
-TCLAP::SwitchArg currentSettings("i","currentSettings","print current settings and exit",false);
-TCLAP::SwitchArg daemonizeAM("d","daemonize","daemonize Audiomanager. Better use systemd...",false);
+std::vector<uint8_t> listOfSignalsFD = { SIGHUP, SIGTERM, SIGCHLD };
+
+// commandline options used by the Audiomanager itself
+TCLAP::ValueArg<std::string> controllerPlugin("c", "controllerPlugin", "use controllerPlugin full path with .so ending", false, CONTROLLER_PLUGIN_DIR, "string");
+TCLAP::ValueArg<std::string> additionalCommandPluginDirs("L", "additionalCommandPluginDirs", "additional path for looking for command plugins, can be used after -l option", false, " ", "string");
+TCLAP::ValueArg<std::string> additionalRoutingPluginDirs("R", "additionalRoutingPluginDirs", "additional path for looking for routing plugins, can be used after -r option ", false, " ", "string");
+TCLAP::ValueArg<std::string> routingPluginDir("r", "RoutingPluginDir", "path for looking for routing plugins", false, " ", "string");
+TCLAP::ValueArg<std::string> commandPluginDir("l", "CommandPluginDir", "path for looking for command plugins", false, " ", "string");
+TCLAP::ValueArg<std::string> dltLogFilename("F", "dltLogFilename", "the name of the logfile, absolute path. Only if logging is et to file", false, " ", "string");
+TCLAP::ValueArg<unsigned int> dltOutput("O", "dltOutput", "defines where logs are written. 0=dlt-daemon(default), 1=command line, 2=file ", false, 0, "int");
+TCLAP::SwitchArg dltEnable("e", "dltEnable", "Enables or disables dlt logging. Default = enabled", true);
+TCLAP::SwitchArg dbusWrapperTypeBool("T", "dbusType", "DbusType to be used by CAmDbusWrapper: if option is selected, DBUS_SYSTEM is used otherwise DBUS_SESSION", false);
+TCLAP::SwitchArg currentSettings("i", "currentSettings", "print current settings and exit", false);
+TCLAP::SwitchArg daemonizeAM("d", "daemonize", "daemonize Audiomanager. Better use systemd...", false);
int fd0, fd1, fd2;
#ifdef WITH_DBUS_WRAPPER
- DBusBusType dbusWrapperType=DBUS_BUS_SESSION;
+DBusBusType dbusWrapperType = DBUS_BUS_SESSION;
#endif
/**
@@ -157,29 +156,28 @@ void daemonize()
}
}
-
-
void printCmdInformation()
{
- printf("\n\n\nCurrent settings:\n\n");
- printf("\tAudioManagerDaemon Version:\t\t%s\n", DAEMONVERSION EXTRAVERSIONINFO);
- printf("\tControllerPlugin: \t\t\t%s\n", controllerPlugin.getValue().c_str());
- printf("\tDirectories of CommandPlugins: \t\t\n");
- std::vector<std::string>::const_iterator dirIter = listCommandPluginDirs.begin();
+ printf("\n\n\nCurrent settings:\n\n");
+ printf("\tAudioManagerDaemon Version:\t\t%s\n", DAEMONVERSION EXTRAVERSIONINFO);
+ printf("\tControllerPlugin: \t\t\t%s\n", controllerPlugin.getValue().c_str());
+ printf("\tDirectories of CommandPlugins: \t\t\n");
+ std::vector<std::string>::const_iterator dirIter = listCommandPluginDirs.begin();
std::vector<std::string>::const_iterator dirIterEnd = listCommandPluginDirs.end();
for (; dirIter < dirIterEnd; ++dirIter)
{
- printf("\t \t\t%s\n", dirIter->c_str());
+ printf("\t \t\t%s\n", dirIter->c_str());
}
- printf("\tDirectories of RoutingPlugins: \t\t\n");
- dirIter = listRoutingPluginDirs.begin();
+ printf("\tDirectories of RoutingPlugins: \t\t\n");
+ dirIter = listRoutingPluginDirs.begin();
dirIterEnd = listRoutingPluginDirs.end();
for (; dirIter < dirIterEnd; ++dirIter)
{
- printf("\t \t\t%s\n", dirIter->c_str());
+ printf("\t \t\t%s\n", dirIter->c_str());
}
- exit(0);
+
+ exit(0);
}
/**
@@ -190,36 +188,35 @@ void printCmdInformation()
*/
static void signalHandler(int sig, siginfo_t *siginfo, void *context)
{
- (void) sig;
- (void) siginfo;
- (void) context;
- logInfo("signal handler was called, signal",sig);
+ (void)sig;
+ (void)siginfo;
+ (void)context;
+ logInfo("signal handler was called, signal", sig);
switch (sig)
{
- /*ctl +c lets call direct controllerRundown, because we might be blocked at the moment.
- But there is the risk of interrupting something important */
- case SIGINT:
- CAmControlSender::CallsetControllerRundown(sig);
- break;
-
- /* huch- we are getting killed. Better take the fast but risky way: */
- case SIGQUIT:
- CAmControlSender::CallsetControllerRundown(sig);
- break;
- default:
- break;
+ /*ctl +c lets call direct controllerRundown, because we might be blocked at the moment.
+ * But there is the risk of interrupting something important */
+ case SIGINT:
+ CAmControlSender::CallsetControllerRundown(sig);
+ break;
+
+ /* huch- we are getting killed. Better take the fast but risky way: */
+ case SIGQUIT:
+ CAmControlSender::CallsetControllerRundown(sig);
+ break;
+ default:
+ break;
}
}
-
void mainProgram(int argc, char *argv[])
{
- //initialize the commandline parser, and add all neccessary commands
+ // initialize the commandline parser, and add all neccessary commands
try
{
- TCLAP::CmdLine* cmd(CAmCommandLineSingleton::instanciateOnce("The team of the AudioManager wishes you a nice day!",' ', DAEMONVERSION EXTRAVERSIONINFO,true));
+ TCLAP::CmdLine *cmd(CAmCommandLineSingleton::instanciateOnce("The team of the AudioManager wishes you a nice day!", ' ', DAEMONVERSION EXTRAVERSIONINFO, true));
cmd->add(controllerPlugin);
cmd->add(additionalCommandPluginDirs);
cmd->add(commandPluginDir);
@@ -235,40 +232,43 @@ void mainProgram(int argc, char *argv[])
#endif
}
catch (TCLAP::ArgException &e) // catch any exceptions
- { std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl; }
+ {
+ std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl;
+ }
- //hen and egg. We need to parse a part of the commandline options to get the paths of the controller and the plugins.
- //So we do some little parsing first and the real parsing later so that the plugins can profit from that.
- CAmCommandLineSingleton::instance()->preparse(argc,argv);
- if (daemonizeAM.getValue())
- {
- daemonize();
- }
+ // hen and egg. We need to parse a part of the commandline options to get the paths of the controller and the plugins.
+ // So we do some little parsing first and the real parsing later so that the plugins can profit from that.
+ CAmCommandLineSingleton::instance()->preparse(argc, argv);
+ if (daemonizeAM.getValue())
+ {
+ daemonize();
+ }
- CAmDltWrapper::instanctiateOnce(AUDIOMANGER_APP_ID, AUDIOMANGER_APP_DESCRIPTION ,dltEnable.getValue(),static_cast<am::CAmDltWrapper::logDestination>(dltOutput.getValue()),dltLogFilename.getValue());
+ CAmDltWrapper::instanctiateOnce(AUDIOMANGER_APP_ID, AUDIOMANGER_APP_DESCRIPTION, dltEnable.getValue(), static_cast<am::CAmDltWrapper::logDestination>(dltOutput.getValue()), dltLogFilename.getValue());
- //Instantiate all classes. Keep in same order !
+ // Instantiate all classes. Keep in same order !
CAmSocketHandler iSocketHandler;
- if(iSocketHandler.fatalErrorOccurred())
+ if (iSocketHandler.fatalErrorOccurred())
{
throw std::runtime_error(std::string("CAmSocketHandler: Could not create pipe or file descriptor is invalid."));
}
- if(E_OK != iSocketHandler.listenToSignals(listOfSignalsFD))
+ if (E_OK != iSocketHandler.listenToSignals(listOfSignalsFD))
{
- logWarning("CAmSocketHandler failed to register itself as signal handler.");
+ logWarning("CAmSocketHandler failed to register itself as signal handler.");
}
- //Register signal handler
+
+ // Register signal handler
sh_pollHandle_t signalHandler;
- iSocketHandler.addSignalHandler([&](const sh_pollHandle_t handle, const signalfd_siginfo & info, void* userData){
+ iSocketHandler.addSignalHandler([&](const sh_pollHandle_t handle, const signalfd_siginfo &info, void *userData){
- unsigned sig = info.ssi_signo;
- unsigned user = info.ssi_uid;
+ unsigned sig = info.ssi_signo;
+ unsigned user = info.ssi_uid;
- logInfo("signal handler was called from user", user, "with signal ",sig);
+ logInfo("signal handler was called from user", user, "with signal ", sig);
- switch (sig)
- {
+ switch (sig)
+ {
/* more friendly here assuming systemd wants to stop us, so we can use the mainloop */
case SIGTERM:
CAmControlSender::CallsetControllerRundownSafe(sig);
@@ -280,102 +280,106 @@ void mainProgram(int argc, char *argv[])
break;
default:
break;
- }
- },signalHandler,NULL);
+ }
+ }, signalHandler, NULL);
- if(commandPluginDir.isSet())
+ if (commandPluginDir.isSet())
{
- listCommandPluginDirs.clear();
- listCommandPluginDirs.push_back(commandPluginDir.getValue());
+ listCommandPluginDirs.clear();
+ listCommandPluginDirs.push_back(commandPluginDir.getValue());
}
if (additionalCommandPluginDirs.isSet())
{
- listCommandPluginDirs.push_back(additionalCommandPluginDirs.getValue());
+ listCommandPluginDirs.push_back(additionalCommandPluginDirs.getValue());
}
- if(routingPluginDir.isSet())
+ if (routingPluginDir.isSet())
{
- listRoutingPluginDirs.clear();
- listRoutingPluginDirs.push_back(routingPluginDir.getValue());
+ listRoutingPluginDirs.clear();
+ listRoutingPluginDirs.push_back(routingPluginDir.getValue());
}
if (additionalRoutingPluginDirs.isSet())
{
- listRoutingPluginDirs.push_back(additionalRoutingPluginDirs.getValue());
+ listRoutingPluginDirs.push_back(additionalRoutingPluginDirs.getValue());
}
- //in this place, the plugins can get the gloval commandlineparser via CAmCommandLineSingleton::instance() and add their options to the commandline
- //this must be done in the constructor.
- //later when the plugins are started, the commandline is already parsed and the objects defined before can be used to get the neccesary information
-
+ // in this place, the plugins can get the gloval commandlineparser via CAmCommandLineSingleton::instance() and add their options to the commandline
+ // this must be done in the constructor.
+ // 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);
+ CAmRoutingSender iRoutingSender(listRoutingPluginDirs, pDatabaseHandler);
CAmCommandSender iCommandSender(listCommandPluginDirs, &iSocketHandler);
- CAmControlSender iControlSender(controllerPlugin.getValue(),&iSocketHandler);
+ CAmControlSender iControlSender(controllerPlugin.getValue(), &iSocketHandler);
try
{
- //parse the commandline options
- CAmCommandLineSingleton::instance()->reset();
- CAmCommandLineSingleton::instance()->parse(argc,argv);
- if (currentSettings.getValue())
- {
- printCmdInformation();
- }
+ // parse the commandline options
+ CAmCommandLineSingleton::instance()->reset();
+ CAmCommandLineSingleton::instance()->parse(argc, argv);
+ if (currentSettings.getValue())
+ {
+ printCmdInformation();
+ }
}
catch (TCLAP::ArgException &e) // catch any exceptions
- { std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl; }
+ {
+ std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl;
+ }
logInfo("The Audiomanager is started");
logInfo("The version of the Audiomanager", DAEMONVERSION EXTRAVERSIONINFO);
#ifdef WITH_CAPI_WRAPPER
- //We instantiate a singleton with the current socket handler, which loads the common-api runtime.
+ // We instantiate a singleton with the current socket handler, which loads the common-api runtime.
CAmCommonAPIWrapper *pCAPIWrapper = CAmCommonAPIWrapper::instantiateOnce(&iSocketHandler, "AudioManager");
#endif /*WITH_CAPI_WRAPPER */
#ifdef WITH_DBUS_WRAPPER
if (dbusWrapperTypeBool.getValue())
- dbusWrapperType=DBUS_BUS_SYSTEM;
- CAmDbusWrapper iDBusWrapper(&iSocketHandler,dbusWrapperType);
+ {
+ dbusWrapperType = DBUS_BUS_SYSTEM;
+ }
+ CAmDbusWrapper iDBusWrapper(&iSocketHandler, dbusWrapperType);
#endif /*WITH_DBUS_WRAPPER */
#ifdef WITH_SYSTEMD_WATCHDOG
CAmWatchdog iWatchdog(&iSocketHandler);
#endif /*WITH_SYSTEMD_WATCHDOG*/
-CAmRouter iRouter(pDatabaseHandler, &iControlSender);
+ CAmRouter iRouter(pDatabaseHandler, &iControlSender);
#ifdef WITH_DBUS_WRAPPER
CAmCommandReceiver iCommandReceiver(pDatabaseHandler, &iControlSender, &iSocketHandler, &iDBusWrapper);
CAmRoutingReceiver iRoutingReceiver(pDatabaseHandler, &iRoutingSender, &iControlSender, &iSocketHandler, &iDBusWrapper);
#else /*WITH_DBUS_WRAPPER*/
- CAmCommandReceiver iCommandReceiver(pDatabaseHandler,&iControlSender,&iSocketHandler);
- CAmRoutingReceiver iRoutingReceiver(pDatabaseHandler,&iRoutingSender,&iControlSender,&iSocketHandler);
+ CAmCommandReceiver iCommandReceiver(pDatabaseHandler, &iControlSender, &iSocketHandler);
+ CAmRoutingReceiver iRoutingReceiver(pDatabaseHandler, &iRoutingSender, &iControlSender, &iSocketHandler);
#endif /*WITH_DBUS_WRAPPER*/
-CAmControlReceiver iControlReceiver(pDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter);
+ CAmControlReceiver iControlReceiver(pDatabaseHandler, &iRoutingSender, &iCommandSender, &iSocketHandler, &iRouter);
-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);
-iCommandSender.startupInterfaces(&iCommandReceiver);
-iRoutingSender.startupInterfaces(&iRoutingReceiver);
+ 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);
+ iCommandSender.startupInterfaces(&iCommandReceiver);
+ iRoutingSender.startupInterfaces(&iRoutingReceiver);
-//when the routingInterface is done, all plugins are loaded:
-iControlSender.setControllerReady();
+// when the routingInterface is done, all plugins are loaded:
+ iControlSender.setControllerReady();
#ifdef WITH_SYSTEMD_WATCHDOG
iWatchdog.startWatchdog();
#endif /*WITH_SYSTEMD_WATCHDOG*/
- //start the mainloop here....
+ // start the mainloop here....
iSocketHandler.start_listenting();
}
@@ -385,21 +389,21 @@ iControlSender.setControllerReady();
* @param argv
* @return
*/
-int main(int argc, char *argv[], char** envp)
+int main(int argc, char *argv[], char * *envp)
{
- (void) envp;
+ (void)envp;
listCommandPluginDirs.push_back(std::string(DEFAULT_PLUGIN_COMMAND_DIR));
listRoutingPluginDirs.push_back(std::string(DEFAULT_PLUGIN_ROUTING_DIR));
- //critical signals are registered here:
+ // critical signals are registered here:
struct sigaction signalAction;
memset(&signalAction, '\0', sizeof(signalAction));
signalAction.sa_sigaction = &signalHandler;
- signalAction.sa_flags = SA_SIGINFO;
+ signalAction.sa_flags = SA_SIGINFO;
sigaction(SIGINT, &signalAction, NULL);
sigaction(SIGQUIT, &signalAction, NULL);
-
- //register new out of memory handler
+
+ // register new out of memory handler
std::set_new_handler(&OutOfMemoryHandler);
sigset_t signal_mask;
@@ -416,14 +420,13 @@ int main(int argc, char *argv[], char** envp)
throw std::runtime_error(std::string("Couldn't set mask for potential future threads"));
}
- //we do this to catch all exceptions and have a graceful ending just in case
- mainProgram(argc,argv);
+ // we do this to catch all exceptions and have a graceful ending just in case
+ mainProgram(argc, argv);
}
-
- catch (std::exception& exc)
+ catch (std::exception &exc)
{
logError("The AudioManager ended by throwing the exception", exc.what());
- std::cerr<<"The AudioManager ended by throwing an exception "<<exc.what()<<std::endl;
+ std::cerr << "The AudioManager ended by throwing an exception " << exc.what() << std::endl;
exit(EXIT_FAILURE);
}
@@ -433,4 +436,3 @@ int main(int argc, char *argv[], char** envp)
exit(0);
}
-
diff --git a/AudioManagerUtilities/include/CAmCommandLineSingleton.h b/AudioManagerUtilities/include/CAmCommandLineSingleton.h
index 10d92d4..4a1f081 100644
--- a/AudioManagerUtilities/include/CAmCommandLineSingleton.h
+++ b/AudioManagerUtilities/include/CAmCommandLineSingleton.h
@@ -21,7 +21,6 @@
*
*/
-
#ifndef AUDIOMANAGERUTILITIES_INCLUDE_CAMCOMMANDLINESINGLETON_H_
#define AUDIOMANAGERUTILITIES_INCLUDE_CAMCOMMANDLINESINGLETON_H_
@@ -29,21 +28,22 @@
namespace am {
-class CAmCommandLineSingleton {
+class CAmCommandLineSingleton
+{
public:
- static TCLAP::CmdLine* instanciateOnce(const std::string& message,
- const char delimiter = ' ',
- const std::string& version = "none",
- bool helpAndVersion = true);
-
- static TCLAP::CmdLine* instance();
-
- static void deleteInstance();
-
+ static TCLAP::CmdLine *instanciateOnce(const std::string &message,
+ const char delimiter = ' ',
+ const std::string &version = "none",
+ bool helpAndVersion = true);
+
+ static TCLAP::CmdLine *instance();
+
+ static void deleteInstance();
+
private:
- CAmCommandLineSingleton();
- virtual ~CAmCommandLineSingleton();
+ CAmCommandLineSingleton();
+ virtual ~CAmCommandLineSingleton();
};
} /* namespace am */
diff --git a/AudioManagerUtilities/include/CAmCommonAPIWrapper.h b/AudioManagerUtilities/include/CAmCommonAPIWrapper.h
index a83b5b3..a384f33 100644
--- a/AudioManagerUtilities/include/CAmCommonAPIWrapper.h
+++ b/AudioManagerUtilities/include/CAmCommonAPIWrapper.h
@@ -15,7 +15,6 @@
* For further information see http://www.genivi.org/.
*/
-
#ifndef COMMONAPIWRAPPER_H_
#define COMMONAPIWRAPPER_H_
@@ -27,9 +26,9 @@
#include <cassert>
#include <CommonAPI/CommonAPI.hpp>
#ifndef COMMONAPI_INTERNAL_COMPILATION
-#define COMMONAPI_INTERNAL_COMPILATION
-#include <CommonAPI/MainLoopContext.hpp>
-#undef COMMONAPI_INTERNAL_COMPILATION
+# define COMMONAPI_INTERNAL_COMPILATION
+# include <CommonAPI/MainLoopContext.hpp>
+# undef COMMONAPI_INTERNAL_COMPILATION
#endif
#include <CommonAPI/Utils.hpp>
#include "audiomanagerconfig.h"
@@ -48,247 +47,251 @@ class CAmSocketHandler;
class CAmCommonAPIWrapper
{
- void commonPrepareCallback(const sh_pollHandle_t handle, void* userData);
- TAmShPollPrepare<CAmCommonAPIWrapper> pCommonPrepareCallback;
+ void commonPrepareCallback(const sh_pollHandle_t handle, void *userData);
+
+ TAmShPollPrepare<CAmCommonAPIWrapper> pCommonPrepareCallback;
+
+ bool commonDispatchCallback(const sh_pollHandle_t handle, void *userData);
- bool commonDispatchCallback(const sh_pollHandle_t handle, void* userData);
TAmShPollDispatch<CAmCommonAPIWrapper> pCommonDispatchCallback;
- void commonFireCallback(const pollfd pollfd, const sh_pollHandle_t, void*);
+ void commonFireCallback(const pollfd pollfd, const sh_pollHandle_t, void *);
+
TAmShPollFired<CAmCommonAPIWrapper> pCommonFireCallback;
- bool commonCheckCallback(const sh_pollHandle_t handle, void*);
+ bool commonCheckCallback(const sh_pollHandle_t handle, void *);
+
TAmShPollCheck<CAmCommonAPIWrapper> pCommonCheckCallback;
- void commonTimerCallback(sh_timerHandle_t handle, void* userData);
+ void commonTimerCallback(sh_timerHandle_t handle, void *userData);
+
TAmShTimerCallBack<CAmCommonAPIWrapper> pCommonTimerCallback;
- struct timerHandles
+ struct timerHandles
{
sh_timerHandle_t handle;
- CommonAPI::Timeout* timeout;
+ CommonAPI::Timeout *timeout;
};
- CAmSocketHandler *mpSocketHandler; //!< pointer to the sockethandler
+ CAmSocketHandler *mpSocketHandler; //!< pointer to the sockethandler
- std::shared_ptr<CommonAPI::Runtime> mRuntime;
- std::shared_ptr<CommonAPI::MainLoopContext> mContext;
+ std::shared_ptr<CommonAPI::Runtime> mRuntime;
+ std::shared_ptr<CommonAPI::MainLoopContext> mContext;
CommonAPI::DispatchSourceListenerSubscription mDispatchSourceListenerSubscription;
- CommonAPI::WatchListenerSubscription mWatchListenerSubscription;
- CommonAPI::TimeoutSourceListenerSubscription mTimeoutSourceListenerSubscription;
- CommonAPI::WakeupListenerSubscription mWakeupListenerSubscription;
- std::multimap<CommonAPI::DispatchPriority, CommonAPI::DispatchSource*> mRegisteredDispatchSources;
- std::map<int,CommonAPI::Watch*> mMapWatches;
- CommonAPI::Watch* mWatchToCheck;
- std::list<CommonAPI::DispatchSource*> mSourcesToDispatch;
- std::vector<timerHandles> mpListTimerhandles;
-
- void registerDispatchSource(CommonAPI::DispatchSource* dispatchSource, const CommonAPI::DispatchPriority dispatchPriority);
- void deregisterDispatchSource(CommonAPI::DispatchSource* dispatchSource);
- void registerWatch(CommonAPI::Watch* watch, const CommonAPI::DispatchPriority dispatchPriority);
- void deregisterWatch(CommonAPI::Watch* watch);
- void registerTimeout(CommonAPI::Timeout* timeout, const CommonAPI::DispatchPriority dispatchPriority);
- void deregisterTimeout(CommonAPI::Timeout* timeout);
- void wakeup();
+ CommonAPI::WatchListenerSubscription mWatchListenerSubscription;
+ CommonAPI::TimeoutSourceListenerSubscription mTimeoutSourceListenerSubscription;
+ CommonAPI::WakeupListenerSubscription mWakeupListenerSubscription;
+ std::multimap<CommonAPI::DispatchPriority, CommonAPI::DispatchSource *> mRegisteredDispatchSources;
+ std::map<int, CommonAPI::Watch *> mMapWatches;
+ CommonAPI::Watch *mWatchToCheck;
+ std::list<CommonAPI::DispatchSource *> mSourcesToDispatch;
+ std::vector<timerHandles> mpListTimerhandles;
+
+ void registerDispatchSource(CommonAPI::DispatchSource *dispatchSource, const CommonAPI::DispatchPriority dispatchPriority);
+ void deregisterDispatchSource(CommonAPI::DispatchSource *dispatchSource);
+ void registerWatch(CommonAPI::Watch *watch, const CommonAPI::DispatchPriority dispatchPriority);
+ void deregisterWatch(CommonAPI::Watch *watch);
+ void registerTimeout(CommonAPI::Timeout *timeout, const CommonAPI::DispatchPriority dispatchPriority);
+ void deregisterTimeout(CommonAPI::Timeout *timeout);
+ void wakeup();
protected:
- CAmCommonAPIWrapper(CAmSocketHandler* socketHandler, const std::string & applicationName = "") ;
+ CAmCommonAPIWrapper(CAmSocketHandler *socketHandler, const std::string &applicationName = "");
public:
virtual ~CAmCommonAPIWrapper();
- /**
- * \brief Returns an already instantiated object.
- *
- * This method should be called after the instantiateOnce(...) has been called with non null socket handler parameter.
- *
- * @return The common-api wrapper object.
- */
- static CAmCommonAPIWrapper* getInstance();
-
- /**
- * \brief Deletes the instanciated object
- */
- static void deleteInstance();
-
- /**
- * \brief Creates a singleton instance attached to the provided socket handler object.
- *
- * This method should be called only once because it instantiates a single object.
- * Otherwise it will throw an exception.
- * The first call of this method with non null parameter loads the common-api and attaches it to the main loop.
- *
- * @param socketHandler: A pointer to socket handler or NULL
- *
- * @return The common-api wrapper object.
- */
- static CAmCommonAPIWrapper* instantiateOnce(CAmSocketHandler* socketHandler, const std::string & applicationName = "");
-
-
- /**
- * \brief Getter for the socket handler.
- *
- * @return Pointer to the socket handler.
- */
- CAmSocketHandler *getSocketHandler() const { return mpSocketHandler; }
-
- /**
- * \brief Deprecated method. This class is used only in single connection applications and no connectionId is needed. Instead you should use bool registerService(const std::shared_ptr<TStubImp> & shStub, const std::string & domain, const std::string & instance).
- *
- *
- * Example: std::shared_ptr<ConcreteStubClass> aStub;
- * registerService( aStub, "local", "com.your_company.instance_name", "service-name");
- *
- * @param shStub: Shared pointer to a stub instance
- * @param domain: A string with the domain name, usually "local"
- * @param instance: Common-api instance string as example "com.your_company.instance_name"
- * @param connectionId: A string connection id, which is used by CommonAPI to group applications
- *
- */
- template <class TStubImp> bool __attribute__((deprecated)) registerService(const std::shared_ptr<TStubImp> & shStub, const std::string & domain, const std::string & instance, const CommonAPI::ConnectionId_t __attribute__((__unused__)) & /*connectionId*/)
- {
- return mRuntime->registerService(domain, instance, shStub, mContext);
- }
-
- /**
- * \brief Register stub objects.
- *
- * Example: std::shared_ptr<ConcreteStubClass> aStub;
- * registerService( aStub, "local", "com.your_company.instance_name");
- *
- * @param shStub: Shared pointer to a stub instance
- * @param domain: A string with the domain name, usually "local"
- * @param instance: Common-api instance string as example "com.your_company.instance_name"
- *
- */
- template <class TStubImp> bool registerService(const std::shared_ptr<TStubImp> & shStub, const std::string & domain, const std::string & instance)
- {
- return mRuntime->registerService(domain, instance, shStub, mContext);
- }
-
- /**
- * \brief Unregister stub objects.
- *
- * @param domain: A string with the domain name, usually "local"
- * @param interface: Common-api interface string as example "com.your_company.interface_name"
- * @param instance: Common-api instance string as example "com.your_company.instance_name"
- *
- */
- bool unregisterService(const std::string &domain, const std::string &interface, const std::string &instance)
- {
- return mRuntime->unregisterService(domain, interface, instance);
- }
-
- /**
- * \brief Deprecated method. Instead you should use bool registerService(const std::shared_ptr<TStubImp> & shStub, const std::string & domain, const std::string & instance).
- *
- * Register stub objects.
- *
- * Example: std::shared_ptr<ConcreteStubClass> aStub;
- * registerService( aStub, "local:com.your_company.interface_name:com.your_company.instance_name");
- *
- * @param shStub: Shared pointer to a stub instance
- * @param address: Complete common-api address as example "local:com.your_company.interface_name:com.your_company.instance_name"
- *
- */
- template <class TStubImp> bool __attribute__((deprecated)) registerStub(const std::shared_ptr<TStubImp> & shStub, const std::string & address)
- {
- std::vector<std::string> parts = CommonAPI::split(address, ':');
- assert(parts.size()==3);
-
- return registerService(shStub, parts[0], parts[2]);
- }
-
- /**
- * \brief Deprecated method. Instead you should use bool unregisterService(const std::string &domain, const std::string &interface, const std::string &instance).
- *
- * Unregister stub objects.
- *
- * @param address: Complete common-api address as example "local:com.your_company.interface_name:com.your_company.instance_name"
- *
- */
- bool __attribute__((deprecated)) unregisterStub(const std::string & address)
- {
- std::vector<std::string> parts = CommonAPI::split(address, ':');
- assert(parts.size()==3);
-
- return unregisterService(parts[0], parts[1], parts[2]);
- }
-
- /**
- * \brief Deprecated method. This class is used only in single connection applications and no connectionId is needed. Instead you should use buildProxy(const std::string &domain, const std::string &instance).
- *
- * Example: std::shared_ptr<AProxyClass<>> aProxy = buildProxy<AProxyClass>("local", "com.your_company.instance_name", "client-name");
- *
- * @param domain: A string with the domain name, usually "local"
- * @param instance: Common-api instance string as example "com.your_company.instance_name"
- * @param connectionId: A string connection id, which is used by CommonAPI to group applications
- *
- * @return A proxy object.
- */
- template<template<typename ...> class ProxyClass, typename ... AttributeExtensions>
- std::shared_ptr<ProxyClass<AttributeExtensions...>> __attribute__((deprecated)) buildProxy(const std::string &domain, const std::string &instance, const CommonAPI::ConnectionId_t __attribute__((__unused__)) & /*connectionId*/)
- {
- return mRuntime->buildProxy<ProxyClass>(domain, instance, mContext);
- }
-
- /**
- * \brief Build proxy objects.
- *
- * Example: std::shared_ptr<AProxyClass<>> aProxy = buildProxy<AProxyClass>("local", "com.your_company.instance_name");
- *
- * @param domain: A string with the domain name, usually "local"
- * @param instance: Common-api instance string as example "com.your_company.instance_name"
- *
- * @return A proxy object.
- */
- template<template<typename ...> class ProxyClass, typename ... AttributeExtensions>
- std::shared_ptr<ProxyClass<AttributeExtensions...>> buildProxy(const std::string &domain, const std::string &instance)
- {
- return mRuntime->buildProxy<ProxyClass>(domain, instance, mContext);
- }
-
-
- /**
- * \brief Deprecated method. Instead you should use buildProxy(const std::string &domain, const std::string &instance).
- *
- * Build proxy objects.
- * Example: std::shared_ptr<AProxyClass<>> aProxy = buildProxy<AProxyClass>("local:com.your_company.interface_name:com.your_company.instance_name");
- *
- * @param address: Complete common-api address as example "local:com.your_company.interface_name:com.your_company.instance_name"
- *
- * @return A proxy object.
- */
- template<template<typename ...> class ProxyClass, typename ... AttributeExtensions>
- std::shared_ptr<ProxyClass<AttributeExtensions...>> __attribute__((deprecated)) buildProxy(const std::string & address)
- {
- std::vector<std::string> parts=CommonAPI::split(address, ':');
- assert(parts.size()==3);
-
- return buildProxy<ProxyClass>(parts[0], parts[2]);
- }
+ /**
+ * \brief Returns an already instantiated object.
+ *
+ * This method should be called after the instantiateOnce(...) has been called with non null socket handler parameter.
+ *
+ * @return The common-api wrapper object.
+ */
+ static CAmCommonAPIWrapper *getInstance();
+
+ /**
+ * \brief Deletes the instanciated object
+ */
+ static void deleteInstance();
+
+ /**
+ * \brief Creates a singleton instance attached to the provided socket handler object.
+ *
+ * This method should be called only once because it instantiates a single object.
+ * Otherwise it will throw an exception.
+ * The first call of this method with non null parameter loads the common-api and attaches it to the main loop.
+ *
+ * @param socketHandler: A pointer to socket handler or NULL
+ *
+ * @return The common-api wrapper object.
+ */
+ static CAmCommonAPIWrapper *instantiateOnce(CAmSocketHandler *socketHandler, const std::string &applicationName = "");
+
+ /**
+ * \brief Getter for the socket handler.
+ *
+ * @return Pointer to the socket handler.
+ */
+ CAmSocketHandler *getSocketHandler() const { return mpSocketHandler; }
+
+ /**
+ * \brief Deprecated method. This class is used only in single connection applications and no connectionId is needed. Instead you should use bool registerService(const std::shared_ptr<TStubImp> & shStub, const std::string & domain, const std::string & instance).
+ *
+ *
+ * Example: std::shared_ptr<ConcreteStubClass> aStub;
+ * registerService( aStub, "local", "com.your_company.instance_name", "service-name");
+ *
+ * @param shStub: Shared pointer to a stub instance
+ * @param domain: A string with the domain name, usually "local"
+ * @param instance: Common-api instance string as example "com.your_company.instance_name"
+ * @param connectionId: A string connection id, which is used by CommonAPI to group applications
+ *
+ */
+ template <class TStubImp>
+ bool __attribute__((deprecated)) registerService(const std::shared_ptr<TStubImp> &shStub, const std::string &domain, const std::string &instance, const CommonAPI::ConnectionId_t __attribute__((__unused__)) & /*connectionId*/)
+ {
+ return mRuntime->registerService(domain, instance, shStub, mContext);
+ }
+
+ /**
+ * \brief Register stub objects.
+ *
+ * Example: std::shared_ptr<ConcreteStubClass> aStub;
+ * registerService( aStub, "local", "com.your_company.instance_name");
+ *
+ * @param shStub: Shared pointer to a stub instance
+ * @param domain: A string with the domain name, usually "local"
+ * @param instance: Common-api instance string as example "com.your_company.instance_name"
+ *
+ */
+ template <class TStubImp>
+ bool registerService(const std::shared_ptr<TStubImp> &shStub, const std::string &domain, const std::string &instance)
+ {
+ return mRuntime->registerService(domain, instance, shStub, mContext);
+ }
+
+ /**
+ * \brief Unregister stub objects.
+ *
+ * @param domain: A string with the domain name, usually "local"
+ * @param interface: Common-api interface string as example "com.your_company.interface_name"
+ * @param instance: Common-api instance string as example "com.your_company.instance_name"
+ *
+ */
+ bool unregisterService(const std::string &domain, const std::string &interface, const std::string &instance)
+ {
+ return mRuntime->unregisterService(domain, interface, instance);
+ }
+
+ /**
+ * \brief Deprecated method. Instead you should use bool registerService(const std::shared_ptr<TStubImp> & shStub, const std::string & domain, const std::string & instance).
+ *
+ * Register stub objects.
+ *
+ * Example: std::shared_ptr<ConcreteStubClass> aStub;
+ * registerService( aStub, "local:com.your_company.interface_name:com.your_company.instance_name");
+ *
+ * @param shStub: Shared pointer to a stub instance
+ * @param address: Complete common-api address as example "local:com.your_company.interface_name:com.your_company.instance_name"
+ *
+ */
+ template <class TStubImp>
+ bool __attribute__((deprecated)) registerStub(const std::shared_ptr<TStubImp> &shStub, const std::string &address)
+ {
+ std::vector<std::string> parts = CommonAPI::split(address, ':');
+ assert(parts.size() == 3);
+
+ return registerService(shStub, parts[0], parts[2]);
+ }
+
+ /**
+ * \brief Deprecated method. Instead you should use bool unregisterService(const std::string &domain, const std::string &interface, const std::string &instance).
+ *
+ * Unregister stub objects.
+ *
+ * @param address: Complete common-api address as example "local:com.your_company.interface_name:com.your_company.instance_name"
+ *
+ */
+ bool __attribute__((deprecated)) unregisterStub(const std::string &address)
+ {
+ std::vector<std::string> parts = CommonAPI::split(address, ':');
+ assert(parts.size() == 3);
+
+ return unregisterService(parts[0], parts[1], parts[2]);
+ }
+
+ /**
+ * \brief Deprecated method. This class is used only in single connection applications and no connectionId is needed. Instead you should use buildProxy(const std::string &domain, const std::string &instance).
+ *
+ * Example: std::shared_ptr<AProxyClass<>> aProxy = buildProxy<AProxyClass>("local", "com.your_company.instance_name", "client-name");
+ *
+ * @param domain: A string with the domain name, usually "local"
+ * @param instance: Common-api instance string as example "com.your_company.instance_name"
+ * @param connectionId: A string connection id, which is used by CommonAPI to group applications
+ *
+ * @return A proxy object.
+ */
+ template<template<typename...> class ProxyClass, typename... AttributeExtensions>
+ std::shared_ptr<ProxyClass<AttributeExtensions...> > __attribute__((deprecated)) buildProxy(const std::string &domain, const std::string &instance, const CommonAPI::ConnectionId_t __attribute__((__unused__)) & /*connectionId*/)
+ {
+ return mRuntime->buildProxy<ProxyClass>(domain, instance, mContext);
+ }
+
+ /**
+ * \brief Build proxy objects.
+ *
+ * Example: std::shared_ptr<AProxyClass<>> aProxy = buildProxy<AProxyClass>("local", "com.your_company.instance_name");
+ *
+ * @param domain: A string with the domain name, usually "local"
+ * @param instance: Common-api instance string as example "com.your_company.instance_name"
+ *
+ * @return A proxy object.
+ */
+ template<template<typename...> class ProxyClass, typename... AttributeExtensions>
+ std::shared_ptr<ProxyClass<AttributeExtensions...> > buildProxy(const std::string &domain, const std::string &instance)
+ {
+ return mRuntime->buildProxy<ProxyClass>(domain, instance, mContext);
+ }
+
+ /**
+ * \brief Deprecated method. Instead you should use buildProxy(const std::string &domain, const std::string &instance).
+ *
+ * Build proxy objects.
+ * Example: std::shared_ptr<AProxyClass<>> aProxy = buildProxy<AProxyClass>("local:com.your_company.interface_name:com.your_company.instance_name");
+ *
+ * @param address: Complete common-api address as example "local:com.your_company.interface_name:com.your_company.instance_name"
+ *
+ * @return A proxy object.
+ */
+ template<template<typename...> class ProxyClass, typename... AttributeExtensions>
+ std::shared_ptr<ProxyClass<AttributeExtensions...> > __attribute__((deprecated)) buildProxy(const std::string &address)
+ {
+ std::vector<std::string> parts = CommonAPI::split(address, ':');
+ assert(parts.size() == 3);
-};
+ return buildProxy<ProxyClass>(parts[0], parts[2]);
+ }
+};
-//Alias
-extern CAmCommonAPIWrapper* (*getCAPI)();
+// Alias
+extern CAmCommonAPIWrapper *(*getCAPI)();
#ifndef AMCAPI
- #define AMCAPI getCAPI()
+# define AMCAPI getCAPI()
#endif
#ifndef AM_CAPI
- #define AM_CAPI getCAPI()
+# define AM_CAPI getCAPI()
#endif
#ifndef CAPI
- #define CAPI getCAPI()
+# define CAPI getCAPI()
#endif
-
}
#endif /* COMMONAPIWRAPPER_H_ */
diff --git a/AudioManagerUtilities/include/CAmDbusWrapper.h b/AudioManagerUtilities/include/CAmDbusWrapper.h
index 0352c35..37ecf6b 100644
--- a/AudioManagerUtilities/include/CAmDbusWrapper.h
+++ b/AudioManagerUtilities/include/CAmDbusWrapper.h
@@ -37,54 +37,60 @@ namespace am
class CAmDbusWrapper
{
public:
- CAmDbusWrapper(CAmSocketHandler* socketHandler,DBusBusType type=DBUS_BUS_SESSION,
- const std::string& prefix = DBUS_SERVICE_PREFIX, const std::string& objectPath = DBUS_SERVICE_OBJECT_PATH);
+ CAmDbusWrapper(CAmSocketHandler *socketHandler, DBusBusType type = DBUS_BUS_SESSION,
+ const std::string &prefix = DBUS_SERVICE_PREFIX, const std::string &objectPath = DBUS_SERVICE_OBJECT_PATH);
virtual ~CAmDbusWrapper();
- void registerCallback(const DBusObjectPathVTable* vtable, const std::string& path, void* userdata, const std::string& prefix = DBUS_SERVICE_OBJECT_PATH);
- void registerSignalWatch(DBusHandleMessageFunction handler, const std::string& rule, void* userdata);
- void getDBusConnection(DBusConnection*& connection) const;
+ void registerCallback(const DBusObjectPathVTable *vtable, const std::string &path, void *userdata, const std::string &prefix = DBUS_SERVICE_OBJECT_PATH);
+ void registerSignalWatch(DBusHandleMessageFunction handler, const std::string &rule, void *userdata);
+ void getDBusConnection(DBusConnection * &connection) const;
static dbus_bool_t addWatch(DBusWatch *watch, void *userData);
static void removeWatch(DBusWatch *watch, void *userData);
static void toogleWatch(DBusWatch *watch, void *userData);
- static dbus_bool_t addTimeout(DBusTimeout *timeout, void* userData);
- static void removeTimeout(DBusTimeout *timeout, void* userData);
- static void toggleTimeout(DBusTimeout *timeout, void* userData);
+ static dbus_bool_t addTimeout(DBusTimeout *timeout, void *userData);
+ static void removeTimeout(DBusTimeout *timeout, void *userData);
+ static void toggleTimeout(DBusTimeout *timeout, void *userData);
+
+ void dbusPrepareCallback(const sh_pollHandle_t handle, void *userData);
- void dbusPrepareCallback(const sh_pollHandle_t handle, void* userData);
TAmShPollPrepare<CAmDbusWrapper> pDbusPrepareCallback;
- bool dbusDispatchCallback(const sh_pollHandle_t handle, void* userData);
+ bool dbusDispatchCallback(const sh_pollHandle_t handle, void *userData);
+
TAmShPollDispatch<CAmDbusWrapper> pDbusDispatchCallback;
- void dbusFireCallback(const pollfd pollfd, const sh_pollHandle_t handle, void* userData);
+ void dbusFireCallback(const pollfd pollfd, const sh_pollHandle_t handle, void *userData);
+
TAmShPollFired<CAmDbusWrapper> pDbusFireCallback;
- bool dbusCheckCallback(const sh_pollHandle_t handle, void* userData);
+ bool dbusCheckCallback(const sh_pollHandle_t handle, void *userData);
+
TAmShPollCheck<CAmDbusWrapper> pDbusCheckCallback;
- void dbusTimerCallback(sh_timerHandle_t handle, void* userData);
+ void dbusTimerCallback(sh_timerHandle_t handle, void *userData);
+
TAmShTimerCallBack<CAmDbusWrapper> pDbusTimerCallback;
private:
- static CAmDbusWrapper* mpReference; //!< reference to the dbus instance
+ static CAmDbusWrapper *mpReference; //!< reference to the dbus instance
static DBusHandlerResult cbRootIntrospection(DBusConnection *conn, DBusMessage *msg, void *reference);
- dbus_bool_t addWatchDelegate(DBusWatch * watch, void* userData);
+ dbus_bool_t addWatchDelegate(DBusWatch *watch, void *userData);
void removeWatchDelegate(DBusWatch *watch, void *userData);
void toogleWatchDelegate(DBusWatch *watch, void *userData);
- dbus_bool_t addTimeoutDelegate(DBusTimeout *timeout, void* userData);
- void removeTimeoutDelegate(DBusTimeout *timeout, void* userData);
- void toggleTimeoutDelegate(DBusTimeout *timeout, void* userData);
- DBusObjectPathVTable mObjectPathVTable; //!< the vpathtable
- DBusConnection* mpDbusConnection; //!< pointer to the dbus connection used
- DBusError mDBusError; //!< dbuserror
- std::vector<std::string> mListNodes; //!< holds a list of all nodes of the dbus
- std::vector<sh_timerHandle_t*> mpListTimerhandles; //!< pointer to the timer handles
- CAmSocketHandler *mpSocketHandler; //!< pointer to the sockethandler
- std::map<DBusWatch*, sh_pollHandle_t> mMapHandleWatch; //!< map to the handle watches
- DBusBusType mDbusType;
+ dbus_bool_t addTimeoutDelegate(DBusTimeout *timeout, void *userData);
+ void removeTimeoutDelegate(DBusTimeout *timeout, void *userData);
+ void toggleTimeoutDelegate(DBusTimeout *timeout, void *userData);
+
+ DBusObjectPathVTable mObjectPathVTable; //!< the vpathtable
+ DBusConnection *mpDbusConnection; //!< pointer to the dbus connection used
+ DBusError mDBusError; //!< dbuserror
+ std::vector<std::string> mListNodes; //!< holds a list of all nodes of the dbus
+ std::vector<sh_timerHandle_t *> mpListTimerhandles; //!< pointer to the timer handles
+ CAmSocketHandler *mpSocketHandler; //!< pointer to the sockethandler
+ std::map<DBusWatch *, sh_pollHandle_t> mMapHandleWatch; //!< map to the handle watches
+ DBusBusType mDbusType;
};
}
diff --git a/AudioManagerUtilities/include/CAmDltWrapper.h b/AudioManagerUtilities/include/CAmDltWrapper.h
index 4d725d8..b6772d9 100644
--- a/AudioManagerUtilities/include/CAmDltWrapper.h
+++ b/AudioManagerUtilities/include/CAmDltWrapper.h
@@ -29,67 +29,67 @@
#include "audiomanagertypes.h"
#ifdef WITH_DLT
- #include <dlt.h>
+# include <dlt.h>
#else
- #include <stdint.h>
- #include <sstream>
+# include <stdint.h>
+# include <sstream>
- #define DLT_USER_BUF_MAX_SIZE 2048
+# define DLT_USER_BUF_MAX_SIZE 2048
- /**
- * This structure is used for every context used in an application.
- */
- typedef struct
- {
- char contextID[4]; /**< context id */
- int32_t log_level_pos; /**< offset in user-application context field */
- int32_t log_level_user; /** any message above this log level is not logged */
- } DltContext;
+/**
+ * This structure is used for every context used in an application.
+ */
+typedef struct
+{
+ char contextID[4]; /**< context id */
+ int32_t log_level_pos; /**< offset in user-application context field */
+ int32_t log_level_user; /** any message above this log level is not logged */
+} DltContext;
- /**
- * Definition of DLT trace status
- */
- typedef enum
- {
- DLT_TRACE_STATUS_DEFAULT = -1, /**< Default trace status */
- DLT_TRACE_STATUS_OFF = 0x00, /**< Trace status: Off */
- DLT_TRACE_STATUS_ON = 0x01 /**< Trace status: On */
- } DltTraceStatusType;
+/**
+ * Definition of DLT trace status
+ */
+typedef enum
+{
+ DLT_TRACE_STATUS_DEFAULT = -1, /**< Default trace status */
+ DLT_TRACE_STATUS_OFF = 0x00, /**< Trace status: Off */
+ DLT_TRACE_STATUS_ON = 0x01 /**< Trace status: On */
+} DltTraceStatusType;
- /**
- * This structure is used for context data used in an application.
- */
- typedef struct
- {
- DltContext *handle; /**< pointer to DltContext */
- std::stringstream buffer; /**< buffer for building log message*/
- int32_t log_level; /**< log level */
- int32_t trace_status; /**< trace status */
- int32_t args_num; /**< number of arguments for extended header*/
- uint8_t mcnt; /**< message counter */
- char* context_description; /**< description of context */
- } DltContextData;
+/**
+ * This structure is used for context data used in an application.
+ */
+typedef struct
+{
+ DltContext *handle; /**< pointer to DltContext */
+ std::stringstream buffer; /**< buffer for building log message*/
+ int32_t log_level; /**< log level */
+ int32_t trace_status; /**< trace status */
+ int32_t args_num; /**< number of arguments for extended header*/
+ uint8_t mcnt; /**< message counter */
+ char *context_description; /**< description of context */
+} DltContextData;
- /**
- * Definitions of DLT log level
- */
- typedef enum
- {
- DLT_LOG_DEFAULT = -1, /**< Default log level */
- DLT_LOG_OFF = 0x00, /**< Log level off */
- DLT_LOG_FATAL = 0x01, /**< fatal system error */
- DLT_LOG_ERROR = 0x02, /**< error with impact to correct functionality */
- DLT_LOG_WARN = 0x03, /**< warning, correct behaviour could not be ensured */
- DLT_LOG_INFO = 0x04, /**< informational */
- DLT_LOG_DEBUG = 0x05, /**< debug */
- DLT_LOG_VERBOSE = 0x06 /**< highest grade of information */
- } DltLogLevelType;
-
- #define DLT_DEFAULT_LOG_LEVEL DLT_LOG_INFO
- #define DLT_DECLARE_CONTEXT(CONTEXT) \
+/**
+ * Definitions of DLT log level
+ */
+typedef enum
+{
+ DLT_LOG_DEFAULT = -1, /**< Default log level */
+ DLT_LOG_OFF = 0x00, /**< Log level off */
+ DLT_LOG_FATAL = 0x01, /**< fatal system error */
+ DLT_LOG_ERROR = 0x02, /**< error with impact to correct functionality */
+ DLT_LOG_WARN = 0x03, /**< warning, correct behaviour could not be ensured */
+ DLT_LOG_INFO = 0x04, /**< informational */
+ DLT_LOG_DEBUG = 0x05, /**< debug */
+ DLT_LOG_VERBOSE = 0x06 /**< highest grade of information */
+} DltLogLevelType;
+
+# define DLT_DEFAULT_LOG_LEVEL DLT_LOG_INFO
+# define DLT_DECLARE_CONTEXT(CONTEXT) \
DltContext CONTEXT;
- #define DLT_IMPORT_CONTEXT(CONTEXT) \
+# define DLT_IMPORT_CONTEXT(CONTEXT) \
extern DltContext CONTEXT;
#endif // WITH_DLT
@@ -112,13 +112,13 @@ public:
*/
typedef struct
{
- DltContext *handle; /**< pointer to DltContext */
- std::stringstream buffer; /**< buffer for building log message*/
- int32_t log_level; /**< log level */
- int32_t trace_status; /**< trace status */
- int32_t args_num; /**< number of arguments for extended header*/
- uint8_t mcnt; /**< message counter */
- char* context_description; /**< description of context */
+ DltContext *handle; /**< pointer to DltContext */
+ std::stringstream buffer; /**< buffer for building log message*/
+ int32_t log_level; /**< log level */
+ int32_t trace_status; /**< trace status */
+ int32_t args_num; /**< number of arguments for extended header*/
+ uint8_t mcnt; /**< message counter */
+ char *context_description; /**< description of context */
} NoDltContextData;
/*
@@ -126,9 +126,9 @@ public:
*/
enum logDestination
{
- DAEMON=0, //!< logging with the DLT daemon
- COMMAND_LINE=1, //!< logging with commandline
- FILE_OUT =2 //!< logging into a file
+ DAEMON = 0, //!< logging with the DLT daemon
+ COMMAND_LINE = 1, //!< logging with commandline
+ FILE_OUT = 2 //!< logging into a file
};
/**
@@ -140,39 +140,42 @@ public:
* @param Filename the filename with absolute path where the log shall be written. only needed if logDest==FILE_OUT
* @param onlyError if set to true, only errors will be logged. just valid for commandline and file logs, default value = false
*/
- static CAmDltWrapper* instanctiateOnce(const char *appid, const char * description, const bool debugEnabled = true, const logDestination logDest = logDestination::DAEMON, const std::string Filename="",bool onlyError=false);
-
+ static CAmDltWrapper *instanctiateOnce(const char *appid, const char *description, const bool debugEnabled = true, const logDestination logDest = logDestination::DAEMON, const std::string Filename = "", bool onlyError = false);
+
/**
* get the Wrapper Instance
*/
- static CAmDltWrapper* instance();
+ static CAmDltWrapper *instance();
/**
* register a context
*/
- void registerContext(DltContext& handle, const char *contextid, const char * description);
- void registerContext(DltContext& handle, const char *contextid, const char * description, const DltLogLevelType level, const DltTraceStatusType status);
- void unregisterContext(DltContext& handle);
+ void registerContext(DltContext &handle, const char *contextid, const char *description);
+ void registerContext(DltContext &handle, const char *contextid, const char *description, const DltLogLevelType level, const DltTraceStatusType status);
+ void unregisterContext(DltContext &handle);
bool getEnabled();
+
~CAmDltWrapper();
- bool init(DltLogLevelType loglevel, DltContext* context = NULL);
+ bool init(DltLogLevelType loglevel, DltContext *context = NULL);
+
bool checkLogLevel(DltLogLevelType logLevel)
{
#ifdef WITH_DLT
- #ifdef DLT_IS_LOG_LEVEL_ENABLED
+# ifdef DLT_IS_LOG_LEVEL_ENABLED
if (mlogDestination == logDestination::DAEMON)
{
return (dlt_user_is_logLevel_enabled(&mDltContext, logLevel) == DLT_RETURN_TRUE);
}
- #else
+# else
(void)logLevel;
- #endif
+# endif // ifdef DLT_IS_LOG_LEVEL_ENABLED
return true;
-#else
+#else // ifdef WITH_DLT
return (logLevel <= mDltContext.log_level_user);
-#endif
+#endif // ifdef WITH_DLT
}
+
void deinit();
void send();
void append(const int8_t value);
@@ -183,48 +186,51 @@ public:
void append(const uint32_t value);
void append(const uint64_t value);
void append(const int64_t value);
- void append(const std::string& value);
+ void append(const std::string &value);
void append(const bool value);
- void append(const std::vector<uint8_t> & data);
-
- template<class T> void appendNoDLT(T value)
+ void append(const std::vector<uint8_t> &data);
+
+ template<class T>
+ void appendNoDLT(T value)
{
- mNoDltContextData.buffer << value <<" ";
+ mNoDltContextData.buffer << value << " ";
}
// specialization for const char*
- template<typename T = const char*> void append(const char* value)
+ template<typename T = const char *>
+ void append(const char *value)
{
- #ifdef WITH_DLT
- if (mlogDestination == logDestination::DAEMON)
- {
- dlt_user_log_write_string(&mDltContextData, value);
- }
- else
- {
- mNoDltContextData.buffer << std::string(value);
- }
- #else
+#ifdef WITH_DLT
+ if (mlogDestination == logDestination::DAEMON)
+ {
+ dlt_user_log_write_string(&mDltContextData, value);
+ }
+ else
+ {
mNoDltContextData.buffer << std::string(value);
- #endif //WITH_DLT
+ }
+#else // ifdef WITH_DLT
+ mNoDltContextData.buffer << std::string(value);
+#endif // WITH_DLT
}
private:
- static const std::vector<const char*> mStr_error;
- static const std::vector<const char*> mStr_sourceState;
- static const std::vector<const char*> mStr_MuteState;
- static const std::vector<const char*> mStr_DomainState;
- static const std::vector<const char*> mStr_ConnectionState;
- static const std::vector<const char*> mStr_Availability;
- static const std::vector<const char*> mStr_Interrupt;
- static const std::vector<const char*> mStr_Handle;
- static const std::vector<const char*> mStr_NotificationStatus;
+ static const std::vector<const char *> mStr_error;
+ static const std::vector<const char *> mStr_sourceState;
+ static const std::vector<const char *> mStr_MuteState;
+ static const std::vector<const char *> mStr_DomainState;
+ static const std::vector<const char *> mStr_ConnectionState;
+ static const std::vector<const char *> mStr_Availability;
+ static const std::vector<const char *> mStr_Interrupt;
+ static const std::vector<const char *> mStr_Handle;
+ static const std::vector<const char *> mStr_NotificationStatus;
public:
// specialization for const am_Error_e
- template<typename T = const am_Error_e> void append(const am_Error_e value)
+ template<typename T = const am_Error_e>
+ void append(const am_Error_e value)
{
if (static_cast<std::size_t>(value) >= mStr_error.size())
{
@@ -232,11 +238,13 @@ public:
append(static_cast<uint16_t>(value));
return;
}
+
append(mStr_error[value]);
}
// specialization for const am_Error_e
- template<typename T = const am_SourceState_e> void append(const am_SourceState_e value)
+ template<typename T = const am_SourceState_e>
+ void append(const am_SourceState_e value)
{
if (static_cast<std::size_t>(value) >= mStr_sourceState.size())
{
@@ -244,11 +252,12 @@ public:
append(static_cast<uint16_t>(value));
return;
}
+
append(mStr_sourceState[value]);
}
-
- template<typename T = const am_MuteState_e> void append(const am_MuteState_e value)
+ template<typename T = const am_MuteState_e>
+ void append(const am_MuteState_e value)
{
if (static_cast<std::size_t>(value) >= mStr_MuteState.size())
{
@@ -256,10 +265,12 @@ public:
append(static_cast<uint16_t>(value));
return;
}
+
append(mStr_MuteState[value]);
}
- template<typename T = const am_DomainState_e> void append(const am_DomainState_e value)
+ template<typename T = const am_DomainState_e>
+ void append(const am_DomainState_e value)
{
if (static_cast<std::size_t>(value) >= mStr_DomainState.size())
{
@@ -267,10 +278,12 @@ public:
append(static_cast<uint16_t>(value));
return;
}
+
append(mStr_DomainState[value]);
}
- template<typename T = const am_ConnectionState_e> void append(const am_ConnectionState_e value)
+ template<typename T = const am_ConnectionState_e>
+ void append(const am_ConnectionState_e value)
{
if (static_cast<std::size_t>(value) >= mStr_ConnectionState.size())
{
@@ -278,10 +291,12 @@ public:
append(static_cast<uint16_t>(value));
return;
}
+
append(mStr_ConnectionState[value]);
}
- template<typename T = const am_Availability_e> void append(const am_Availability_e value)
+ template<typename T = const am_Availability_e>
+ void append(const am_Availability_e value)
{
if (static_cast<std::size_t>(value) >= mStr_Availability.size())
{
@@ -289,10 +304,12 @@ public:
append(static_cast<uint16_t>(value));
return;
}
+
append(mStr_Availability[value]);
}
- template<typename T = const am_InterruptState_e> void append(const am_InterruptState_e value)
+ template<typename T = const am_InterruptState_e>
+ void append(const am_InterruptState_e value)
{
if (static_cast<std::size_t>(value) >= mStr_Interrupt.size())
{
@@ -300,10 +317,12 @@ public:
append(static_cast<uint16_t>(value));
return;
}
+
append(mStr_Interrupt[value]);
}
- template<typename T = const am_Handle_e> void append(const am_Handle_e value)
+ template<typename T = const am_Handle_e>
+ void append(const am_Handle_e value)
{
if (static_cast<std::size_t>(value) >= mStr_Handle.size())
{
@@ -311,16 +330,19 @@ public:
append(static_cast<uint16_t>(value));
return;
}
+
append(mStr_Handle[value]);
}
-
- template<typename T = const am_Handle_s> void append(const am_Handle_s value)
+
+ template<typename T = const am_Handle_s>
+ void append(const am_Handle_s value)
{
- append (value.handleType);
- append (value.handle);
+ append(value.handleType);
+ append(value.handle);
}
- template<typename T = const am_NotificationStatus_e> void append(const am_NotificationStatus_e value)
+ template<typename T = const am_NotificationStatus_e>
+ void append(const am_NotificationStatus_e value)
{
if (static_cast<std::size_t>(value) >= mStr_NotificationStatus.size())
{
@@ -328,11 +350,13 @@ public:
append(static_cast<uint16_t>(value));
return;
}
+
append(mStr_NotificationStatus[value]);
}
// Template to print unknown pointer types with their address
- template<typename T> void append(T* value)
+ template<typename T>
+ void append(T *value)
{
std::ostringstream ss;
ss << "0x" << std::hex << (uint64_t)value;
@@ -340,7 +364,8 @@ public:
}
// Template to print unknown types
- template<typename T> void append(T value)
+ template<typename T>
+ void append(T value)
{
std::ostringstream ss;
ss << std::dec << value;
@@ -349,7 +374,8 @@ public:
// Template parameter pack to generate recursive code
void append(void) {}
- template<typename T, typename... TArgs> void append(T value, TArgs... args)
+ template<typename T, typename... TArgs>
+ void append(T value, TArgs... args)
{
this->append(value);
this->append(args...);
@@ -359,19 +385,20 @@ private:
/**
* private contructor
*/
- CAmDltWrapper(const char *appid, const char * description, const bool debugEnabled = true, const logDestination logDest = logDestination::DAEMON, const std::string Filename="",bool onlyError=false); //is private because of singleton pattern
- bool initNoDlt(DltLogLevelType loglevel, DltContext* context);
+ CAmDltWrapper(const char *appid, const char *description, const bool debugEnabled = true, const logDestination logDest = logDestination::DAEMON, const std::string Filename = "", bool onlyError = false); // is private because of singleton pattern
+ bool initNoDlt(DltLogLevelType loglevel, DltContext *context);
std::string now();
- DltContext mDltContext; //!< the default context
- DltContextData mDltContextData; //!< contextdata
- NoDltContextData mNoDltContextData; //!<contextdata for std out logging
- std::map<DltContext*,std::string> mMapContext; //!< a Map for all registered context
- bool mDebugEnabled; //!< debug Enabled or not
- logDestination mlogDestination; //!< The log destination
- std::ofstream mFilename; //!< Filename for logging
- bool mOnlyError; //!< Only if Log Level is above Error
- bool mLogOn; //!< Used to keep track if currently logging is on
- static CAmDltWrapper* mpDLTWrapper; //!< pointer to the wrapper instance
+
+ DltContext mDltContext; //!< the default context
+ DltContextData mDltContextData; //!< contextdata
+ NoDltContextData mNoDltContextData; //!< contextdata for std out logging
+ std::map<DltContext *, std::string> mMapContext; //!< a Map for all registered context
+ bool mDebugEnabled; //!< debug Enabled or not
+ logDestination mlogDestination; //!< The log destination
+ std::ofstream mFilename; //!< Filename for logging
+ bool mOnlyError; //!< Only if Log Level is above Error
+ bool mLogOn; //!< Used to keep track if currently logging is on
+ static CAmDltWrapper *mpDLTWrapper; //!< pointer to the wrapper instance
static pthread_mutex_t mMutex;
};
@@ -384,17 +411,19 @@ private:
* @param ...
*/
template<typename T, typename... TArgs>
-void log(DltContext* const context, DltLogLevelType loglevel, T value, TArgs... args)
+void log(DltContext *const context, DltLogLevelType loglevel, T value, TArgs... args)
{
- CAmDltWrapper* inst(CAmDltWrapper::instance());
+ CAmDltWrapper *inst(CAmDltWrapper::instance());
if (!inst->getEnabled())
{
return;
}
+
if (!inst->init(loglevel, context))
{
return;
}
+
inst->append(value);
inst->append(args...);
inst->send();
@@ -430,7 +459,7 @@ void logInfo(T value, TArgs... args)
template<typename T, typename... TArgs>
void logError(T value, TArgs... args)
{
- log(NULL, DLT_LOG_ERROR,value,args...);
+ log(NULL, DLT_LOG_ERROR, value, args...);
}
/**
@@ -441,7 +470,7 @@ void logError(T value, TArgs... args)
template<typename T, typename... TArgs>
void logWarning(T value, TArgs... args)
{
- log(NULL, DLT_LOG_WARN,value,args...);
+ log(NULL, DLT_LOG_WARN, value, args...);
}
/**
@@ -452,7 +481,7 @@ void logWarning(T value, TArgs... args)
template<typename T, typename... TArgs>
void logVerbose(T value, TArgs... args)
{
- log(NULL, DLT_LOG_VERBOSE,value,args...);
+ log(NULL, DLT_LOG_VERBOSE, value, args...);
}
}
diff --git a/AudioManagerUtilities/include/CAmSerializer.h b/AudioManagerUtilities/include/CAmSerializer.h
index fbac255..ad0b2b1 100644
--- a/AudioManagerUtilities/include/CAmSerializer.h
+++ b/AudioManagerUtilities/include/CAmSerializer.h
@@ -29,34 +29,36 @@
/*!
* \brief Helper structures used within std::bind for automatically identification of all placeholders.
*/
-template<std::size_t ... Is>
+template<std::size_t... Is>
struct indices
{
};
-template<std::size_t N, std::size_t ... Is>
-struct build_indices: build_indices<N - 1, N - 1, Is...>
+template<std::size_t N, std::size_t... Is>
+struct build_indices : build_indices<N - 1, N - 1, Is...>
{
};
-template<std::size_t ... Is>
+template<std::size_t... Is>
struct build_indices<0, Is...> : indices<Is...>
{
};
-template<int I> struct placeholder
+template<int I>
+struct placeholder
{
};
namespace std
{
- template<int I>
- struct is_placeholder<::placeholder<I>> : std::integral_constant<int, I>
- {
- };
+template<int I>
+struct is_placeholder<::placeholder<I> > : std::integral_constant<int, I>
+{
+};
+
}
-#if defined(__GNUC__)
+#if defined (__GNUC__)
# define DEPRECATED(MSG) __attribute__ ((__deprecated__((#MSG))))
#else
# define DEPRECATED(MSG)
@@ -64,1154 +66,1195 @@ namespace std
namespace am
{
+/**
+ * magic class that does the serialization of functions calls
+ * The constructor must be called within the main threadcontext, after that using the
+ * overloaded template function call will serialize all calls and call them within the
+ * main thread context.\n
+ * More details can be found here: \ref util
+ * \warning asynchronous calls may be used in the mainthread context, but if you want to use synchronous calls make sure that you use one
+ * instance of this class per thread otherwise you could be lost in never returning calls.\n
+ * Examples of the usage can be found in IAmCommandReceiverShadow of the ControlPlugin or IAmRoutingReceiverShadow of the
+ * PluginRoutingInterfaceAsync.
+ *
+ */
+
+/**
+ * \defgroup Deprecated Obsolete class!
+ * @{
+ */
+
+namespace V1
+{
+class CAmSerializer
+{
+private:
+
/**
- * magic class that does the serialization of functions calls
- * The constructor must be called within the main threadcontext, after that using the
- * overloaded template function call will serialize all calls and call them within the
- * main thread context.\n
- * More details can be found here: \ref util
- * \warning asynchronous calls may be used in the mainthread context, but if you want to use synchronous calls make sure that you use one
- * instance of this class per thread otherwise you could be lost in never returning calls.\n
- * Examples of the usage can be found in IAmCommandReceiverShadow of the ControlPlugin or IAmRoutingReceiverShadow of the
- * PluginRoutingInterfaceAsync.
- *
+ * Prototype for a delegate
*/
+ class CAmDelegate
+ {
+ public:
+
+ typedef enum
+ : bool
+ {
+ SyncCallType = false, AsyncCallType = true
+ } CallType;
+
+ virtual ~CAmDelegate()
+ {
+ }
+
+ virtual CallType call(int *pipe) = 0;
+
+ };
/**
- * \defgroup Deprecated Obsolete class!
- * @{
+ * Prototype for a delegate with variadic template arguments in conjunction with the following class.
*/
+ template<class Class, typename Method, typename Tuple, bool Done, int Total, int... N>
+ class CAmDelegateAsyncImpl : public CAmDelegate
+ {
+ Class mInstance;
+ Method mMethod;
+ Tuple mArguments;
+ public:
+ friend class CAmSerializer;
+ static void call(Class instance, Method method, Tuple &&arguments)
+ {
+ CAmDelegateAsyncImpl<Class, Method, Tuple, Total == 1 + sizeof ... (N), Total, N..., sizeof ... (N)>::call(instance, method, std::forward<Tuple>(arguments));
+ }
+
+ CAmDelegateAsyncImpl(Class instance, Method method, Tuple &&arguments)
+ {
+ mInstance = instance;
+ mMethod = method;
+ mArguments = std::move(arguments);
+ }
+
+ CallType call(int *pipe)
+ {
+ (void)pipe;
+ call(mInstance, mMethod, std::forward<Tuple>(mArguments));
+ return (AsyncCallType);
+ }
+
+ };
- namespace V1
+ /**
+ * Prototype for a delegate with variadic template arguments.
+ */
+ template<class Class, typename Method, typename Tuple, int Total, int... N>
+ class CAmDelegateAsyncImpl<Class, Method, Tuple, true, Total, N...> : public CAmDelegate
{
- class CAmSerializer
+ Class mInstance;
+ Method mMethod;
+ Tuple mArguments;
+ public:
+ friend class CAmSerializer;
+ static void call(Class instance, Method method, Tuple &&t)
{
- private:
+ (*instance.*method)(std::get<N>(std::forward<Tuple>(t)) ...);
+ }
- /**
- * Prototype for a delegate
- */
- class CAmDelegate
- {
- public:
-
- typedef enum
- :bool
- {
- SyncCallType = false, AsyncCallType = true
- } CallType;
-
- virtual ~CAmDelegate()
- {
- }
- ;
- virtual CallType call(int* pipe)=0;
-
- };
-
- /**
- * Prototype for a delegate with variadic template arguments in conjunction with the following class.
- */
- template<class Class, typename Method, typename Tuple, bool Done, int Total, int ... N>
- class CAmDelegateAsyncImpl: public CAmDelegate
- {
- Class mInstance;
- Method mMethod;
- Tuple mArguments;
- public:
- friend class CAmSerializer;
- static void call(Class instance, Method method, Tuple && arguments)
- {
- CAmDelegateAsyncImpl<Class, Method, Tuple, Total == 1 + sizeof...(N), Total, N..., sizeof...(N)>::call(instance, method, std::forward<Tuple>(arguments));
- }
-
- CAmDelegateAsyncImpl(Class instance, Method method, Tuple && arguments)
- {
- mInstance = instance;
- mMethod = method;
- mArguments = std::move(arguments);
- }
-
- CallType call(int* pipe)
- {
- (void) pipe;
- call(mInstance, mMethod, std::forward<Tuple>(mArguments));
- return (AsyncCallType);
- }
- ;
- };
-
- /**
- * Prototype for a delegate with variadic template arguments.
- */
- template<class Class, typename Method, typename Tuple, int Total, int ... N>
- class CAmDelegateAsyncImpl<Class, Method, Tuple, true, Total, N...> : public CAmDelegate
- {
- Class mInstance;
- Method mMethod;
- Tuple mArguments;
- public:
- friend class CAmSerializer;
- static void call(Class instance, Method method, Tuple && t)
- {
- (*instance.*method)(std::get<N>(std::forward<Tuple>(t))...);
- }
-
- CAmDelegateAsyncImpl(Class instance, Method method, Tuple && arguments)
- {
- mInstance = instance;
- mMethod = method;
- mArguments = std::move(arguments);
- }
-
- CallType call(int* pipe)
- {
- (void) pipe;
- call(mInstance, mMethod, std::forward<Tuple>(mArguments));
- return (AsyncCallType);
- }
- ;
- };
-
- /**
- * Prototype for a delegate with variadic template arguments in conjunction with the following class.
- */
- template<class Class, typename Method, typename Return, typename Tuple, bool Done, int Total, int ... N>
- class CAmDelegateSyncImpl: public CAmDelegate
- {
- Class mInstance;
- Method mMethod;
- Tuple mArguments;
- Return mReturn;
- public:
- friend class CAmSerializer;
- static void call(Class instance, Method method, Return & result, Tuple && arguments)
- {
- CAmDelegateSyncImpl<Class, Method, Return, Tuple, Total == 1 + sizeof...(N), Total, N..., sizeof...(N)>::call(instance, method, result, std::forward<Tuple>(arguments));
- }
-
- CAmDelegateSyncImpl(Class instance, Method method, Tuple && arguments)
- {
- mInstance = instance;
- mMethod = method;
- mArguments = std::move(arguments);
- }
-
- CallType call(int* pipe)
- {
- call(mInstance, mMethod, mReturn, std::forward<Tuple>(mArguments));
- ssize_t result(-1);
- result = write(pipe[1], this, sizeof(this));
- if (result == -1)
- logError("CAmSerializer: Problem writing into pipe! Error No:", errno);
- return (SyncCallType);
- }
- ;
- };
-
- /**
- * Prototype for a delegate with variadic template arguments.
- */
- template<class Class, typename Method, typename Return, typename Tuple, int Total, int ... N>
- class CAmDelegateSyncImpl<Class, Method, Return, Tuple, true, Total, N...> : public CAmDelegate
- {
- Class mInstance;
- Method mMethod;
- Tuple mArguments;
- Return mReturn;
- public:
- friend class CAmSerializer;
- static void call(Class instance, Method method, Return & result, Tuple && t)
- {
- result = (*instance.*method)(std::get<N>(t)...);
- }
-
- CAmDelegateSyncImpl(Class instance, Method method, Tuple && arguments)
- {
- mInstance = instance;
- mMethod = method;
- mArguments = std::move(arguments);
- }
-
- CallType call(int* pipe)
- {
- call(mInstance, mMethod, mReturn, std::forward<Tuple>(mArguments));
- ssize_t result(-1);
- result = write(pipe[1], this, sizeof(this));
- if (result == -1)
- logError("CAmSerializer: Problem writing into pipe! Error No:", errno);
- return (SyncCallType);
- }
- ;
- };
-
- typedef CAmDelegate* CAmDelegagePtr; //!< pointer to a delegate
-
- public:
- /**
- * instantiates a async delegate with given arguments and sends the delegate pointer over the pipe
- */
- template<typename Class, typename Method, typename Tuple>
- void doAsyncCall(Class intsance, Method method, Tuple & arguments)
- {
- typedef typename std::decay<Tuple>::type ttype;
- typedef CAmDelegateAsyncImpl<Class, Method, Tuple, 0 == std::tuple_size<ttype>::value, std::tuple_size<ttype>::value> AsyncDelegate;
- AsyncDelegate *pImp = new AsyncDelegate(intsance, method, std::forward<Tuple>(arguments));
- send(pImp);
- //Do not delete the pointer. It will be deleted automatically later.
- }
+ CAmDelegateAsyncImpl(Class instance, Method method, Tuple &&arguments)
+ {
+ mInstance = instance;
+ mMethod = method;
+ mArguments = std::move(arguments);
+ }
- /**
- * instantiates a sync delegate with given arguments and sends the delegate pointer over the pipe
- */
- template<typename Class, typename Method, typename Return, typename Tuple>
- void doSyncCall(Class intsance, Method method, Return & result, Tuple & arguments)
- {
- typedef typename std::decay<Tuple>::type ttype;
- typedef CAmDelegateSyncImpl<Class, Method, Return, Tuple, 0 == std::tuple_size<ttype>::value, std::tuple_size<ttype>::value> SyncDelegate;
- SyncDelegate *pImp = new SyncDelegate(intsance, method, std::forward<Tuple>(arguments));
- send(pImp);
- int numReads;
- SyncDelegate *p = NULL;
- if ((numReads = read(mReturnPipe[0], &p, sizeof(p))) == -1)
- {
- logError("CAmSerializer::doSyncCall could not read pipe!");
- throw std::runtime_error("CAmSerializer Could not read pipe!");
- }
- result = std::move(pImp->mReturn);
- arguments = std::move(pImp->mArguments);
- //Delete the pointer.
- delete pImp;
- }
- private:
+ CallType call(int *pipe)
+ {
+ (void)pipe;
+ call(mInstance, mMethod, std::forward<Tuple>(mArguments));
+ return (AsyncCallType);
+ }
- /**
- * rings the line of the pipe and adds the delegate pointer to the queue
- * @param p delegate pointer
- */
- inline void send(CAmDelegagePtr p)
- {
- if (write(mPipe[1], &p, sizeof(p)) == -1)
- {
- throw std::runtime_error("could not write to pipe !");
- }
- }
+ };
- int mPipe[2]; //!< the pipe
- int mReturnPipe[2]; //!< pipe handling returns
- sh_pollHandle_t mHandle;
- CAmSocketHandler* mpSocketHandler;
- std::deque<CAmDelegagePtr> mListDelegatePoiters; //!< intermediate queue to store the pipe results
+ /**
+ * Prototype for a delegate with variadic template arguments in conjunction with the following class.
+ */
+ template<class Class, typename Method, typename Return, typename Tuple, bool Done, int Total, int... N>
+ class CAmDelegateSyncImpl : public CAmDelegate
+ {
+ Class mInstance;
+ Method mMethod;
+ Tuple mArguments;
+ Return mReturn;
+ public:
+ friend class CAmSerializer;
+ static void call(Class instance, Method method, Return &result, Tuple &&arguments)
+ {
+ CAmDelegateSyncImpl<Class, Method, Return, Tuple, Total == 1 + sizeof ... (N), Total, N..., sizeof ... (N)>::call(instance, method, result, std::forward<Tuple>(arguments));
+ }
- public:
+ CAmDelegateSyncImpl(Class instance, Method method, Tuple &&arguments)
+ {
+ mInstance = instance;
+ mMethod = method;
+ mArguments = std::move(arguments);
+ }
- /**
- * get the size of delegate pointers
- */
- int getListDelegatePoiters()
+ CallType call(int *pipe)
+ {
+ call(mInstance, mMethod, mReturn, std::forward<Tuple>(mArguments));
+ ssize_t result(-1);
+ result = write(pipe[1], this, sizeof(this));
+ if (result == -1)
{
- return mListDelegatePoiters.size();
+ logError("CAmSerializer: Problem writing into pipe! Error No:", errno);
}
- /**
- * calls a function with variadic arguments threadsafe
- * @param instance the instance of the class that shall be called
- * @param function the function that shall be called as member function pointer.
- * @param output variable.
- * @tparam TClass the type of the Class to be called
- * @tparam TRet the type of the result
- * @tparam TArgs argument list
- * \section ex Example:
- * @code
- * class MyGreatClass
- * {
- * public:
- * int AGreatMethod(int x);
- * }
- * CAmSerializer serial(&Sockethandler);
- * MyGreatClass anInstance;
- * int result;
- * serial.syncCall<MyGreatClass, int, int>(&anInstance,&MyGreatClass::AGreatMethod, result, 100);
- * @endcode
- */
- template<class TClass, class TRet, class ... TArgs>
- void syncCall(TClass* instance, TRet (TClass::*method)(TArgs ...), TRet & result, TArgs & ... arguments)
- {
- auto t = std::make_tuple(arguments...);
- doSyncCall(instance, method, result, t);
- std::tie(arguments...) = t;
- }
+ return (SyncCallType);
+ }
- /**
- * calls a function with variadic arguments threadsafe
- * @param instance the instance of the class that shall be called
- * @param function the function that shall be called as member function pointer.
- * @tparam TClass the type of the Class to be called
- * @tparam TRet the type of the result
- * @tparam TArgs argument list
- * \section ex Example:
- * @code
- * class MyGreatClass
- * {
- * public:
- * int AGreatMethod(int x);
- * }
- * CAmSerializer serial(&Sockethandler);
- * MyGreatClass anInstance;
- * serial.asyncCall<MyGreatClass, void, int>(&anInstance,&MyGreatClass::AGreatMethod, 100);
- * @endcode
- */
- template<class TClass, class TRet, class ... TArgs>
- void asyncCall(TClass* instance, TRet (TClass::*method)(TArgs ...), TArgs & ... arguments)
- {
- auto t = std::make_tuple(arguments...);
- doAsyncCall(instance, method, t);
- }
+ };
- /**
- * calls a function with no arguments threadsafe
- * @param instance the instance of the class that shall be called
- * @param function the function that shall be called as memberfunction pointer.
- * @tparam TClass1 the type of the Class to be called
- * \section ex Example:
- * @code
- * class myClass
- * {
- * public:
- * void myfunction();
- * }
- * CAmSerializer serial(&Sockethandler);
- * myClass instanceMyClass;
- * serial<CommandSender>(&instanceMyClass,&myClass::myfunction);
- * @endcode
- */
- template<class TClass>
- void asyncCall(TClass* instance, void (TClass::*function)())
- {
- auto t = std::make_tuple();
- doAsyncCall(instance, function, t);
- }
+ /**
+ * Prototype for a delegate with variadic template arguments.
+ */
+ template<class Class, typename Method, typename Return, typename Tuple, int Total, int... N>
+ class CAmDelegateSyncImpl<Class, Method, Return, Tuple, true, Total, N...> : public CAmDelegate
+ {
+ Class mInstance;
+ Method mMethod;
+ Tuple mArguments;
+ Return mReturn;
+ public:
+ friend class CAmSerializer;
+ static void call(Class instance, Method method, Return &result, Tuple &&t)
+ {
+ result = (*instance.*method)(std::get<N>(t) ...);
+ }
- /**
- * calls a function with one arguments asynchronously threadsafe
- * @param instance the instance of the class that shall be called
- * @param function the function that shall be called as memberfunction pointer.
- * @param argument the argument
- * @tparam TClass1 the type of the Class to be called
- * @tparam Targ the type of the argument to be called
- * \section ex Example:
- * @code
- * class myClass
- * {
- * public:
- * void myfunction(int k);
- * }
- * CAmSerializer serial(&Sockethandler);
- * myClass instanceMyClass;
- * serial<CommandSender,int>(&instanceMyClass,&myClass::myfunction,k);
- * @endcode
- *
- */
- template<class TClass1, class Targ>
- void asyncCall(TClass1* instance, void (TClass1::*function)(Targ), Targ argument)
- {
- auto t = std::make_tuple(argument);
- doAsyncCall(instance, function, t);
- }
+ CAmDelegateSyncImpl(Class instance, Method method, Tuple &&arguments)
+ {
+ mInstance = instance;
+ mMethod = method;
+ mArguments = std::move(arguments);
+ }
- /**
- * calls a function with one argument called by reference asynchronously threadsafe
- * @param instance the instance of the class that shall be called
- * @param function the function that shall be called as memberfunction pointer.
- * @param argument the argument
- * @tparam TClass1 the type of the Class to be called
- * @tparam Targ the type of the argument to be called
- * \section ex Example:
- * @code
- * class myClass
- * {
- * public:
- * void myfunction(int k);
- * }
- * CAmSerializer serial(&Sockethandler);
- * myClass instanceMyClass;
- * serial<CommandSender,int>(&instanceMyClass,&myClass::myfunction,k);
- * @endcode
- *
- */
- template<class TClass1, class Targ>
- void asyncCall(TClass1* instance, void (TClass1::*function)(Targ&), Targ& argument)
+ CallType call(int *pipe)
+ {
+ call(mInstance, mMethod, mReturn, std::forward<Tuple>(mArguments));
+ ssize_t result(-1);
+ result = write(pipe[1], this, sizeof(this));
+ if (result == -1)
{
- auto t = std::make_tuple(argument);
- doAsyncCall(instance, function, t);
+ logError("CAmSerializer: Problem writing into pipe! Error No:", errno);
}
- /**
- * calls a function with two arguments asynchronously threadsafe. for more see asyncCall with one argument
- * @param instance pointer to the instance of the class
- * @param function memberfunction poitner
- * @param argument the first argument
- * @param argument1 the second argument
- * @tparam TClass1 the type of the Class to be called
- * @tparam Targ the type of the argument to be called
- * @tparam Targ1 the type of the first argument to be called
- */
- template<class TClass1, class Targ, class Targ1>
- void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1 argument1), Targ argument, Targ1 argument1)
- {
- auto t = std::make_tuple(argument, argument1);
- doAsyncCall(instance, function, t);
- }
+ return (SyncCallType);
+ }
- /**
- * calls a function with two arguments asynchronously threadsafe, first argument is a reference. for more see asyncCall with one argument
- * @param instance pointer to the instance of the class
- * @param function memberfunction poitner
- * @param argument the first argument
- * @param argument1 the second argument
- * @tparam TClass1 the type of the Class to be called
- * @tparam Targ the type of the argument to be called
- * @tparam Targ1 the type of the first argument to be called
- */
- template<class TClass1, class Targ, class Targ1>
- void asyncCall(TClass1* instance, void (TClass1::*function)(Targ& argument, Targ1 argument1), Targ& argument, Targ1 argument1)
- {
- auto t = std::make_tuple(argument, argument1);
- doAsyncCall(instance, function, t);
- }
+ };
- /**
- * calls a function with two arguments asynchronously threadsafe, second argument is a reference. for more see asyncCall with one argument
- * @param instance pointer to the instance of the class
- * @param function memberfunction poitner
- * @param argument the first argument
- * @param argument1 the second argument
- * @tparam TClass1 the type of the Class to be called
- * @tparam Targ the type of the argument to be called
- * @tparam Targ1 the type of the first argument to be called
- */
- template<class TClass1, class Targ, class Targ1>
- void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1& argument1), Targ argument, Targ1& argument1)
- {
- auto t = std::make_tuple(argument, argument1);
- doAsyncCall(instance, function, t);
- }
+ typedef CAmDelegate *CAmDelegagePtr; //!< pointer to a delegate
- /**
- * calls a function with two arguments asynchronously threadsafe, both arguments are references. for more see asyncCall with one argument
- * @param instance pointer to the instance of the class
- * @param function memberfunction poitner
- * @param argument the first argument
- * @param argument1 the second argument
- * @tparam TClass1 the type of the Class to be called
- * @tparam Targ the type of the argument to be called
- * @tparam Targ1 the type of the first argument to be called
- */
- template<class TClass1, class Targ, class Targ1>
- void asyncCall(TClass1* instance, void (TClass1::*function)(Targ& argument, Targ1& argument1), Targ& argument, Targ1& argument1)
- {
- auto t = std::make_tuple(argument, argument1);
- doAsyncCall(instance, function, t);
- }
+public:
+ /**
+ * instantiates a async delegate with given arguments and sends the delegate pointer over the pipe
+ */
+ template<typename Class, typename Method, typename Tuple>
+ void doAsyncCall(Class intsance, Method method, Tuple &arguments)
+ {
+ typedef typename std::decay<Tuple>::type ttype;
+ typedef CAmDelegateAsyncImpl<Class, Method, Tuple, 0 == std::tuple_size<ttype>::value, std::tuple_size<ttype>::value> AsyncDelegate;
+ AsyncDelegate *pImp = new AsyncDelegate(intsance, method, std::forward<Tuple>(arguments));
+ send(pImp);
+ // Do not delete the pointer. It will be deleted automatically later.
+ }
- /**
- * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
- */
- template<class TClass1, class Targ, class Targ1, class Targ2>
- void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1 argument1, Targ2 argument2), Targ argument, Targ1 argument1, Targ2 argument2)
- {
- auto t = std::make_tuple(argument, argument1, argument2);
- doAsyncCall(instance, function, t);
- }
+ /**
+ * instantiates a sync delegate with given arguments and sends the delegate pointer over the pipe
+ */
+ template<typename Class, typename Method, typename Return, typename Tuple>
+ void doSyncCall(Class intsance, Method method, Return &result, Tuple &arguments)
+ {
+ typedef typename std::decay<Tuple>::type ttype;
+ typedef CAmDelegateSyncImpl<Class, Method, Return, Tuple, 0 == std::tuple_size<ttype>::value, std::tuple_size<ttype>::value> SyncDelegate;
+ SyncDelegate *pImp = new SyncDelegate(intsance, method, std::forward<Tuple>(arguments));
+ send(pImp);
+ int numReads;
+ SyncDelegate *p = NULL;
+ if ((numReads = read(mReturnPipe[0], &p, sizeof(p))) == -1)
+ {
+ logError("CAmSerializer::doSyncCall could not read pipe!");
+ throw std::runtime_error("CAmSerializer Could not read pipe!");
+ }
- /**
- * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
- */
- template<class TClass1, class Targ, class Targ1, class Targ2>
- void asyncCall(TClass1* instance, void (TClass1::*function)(Targ& argument, Targ1 argument1, Targ2 argument2), Targ& argument, Targ1 argument1, Targ2 argument2)
- {
- auto t = std::make_tuple(argument, argument1, argument2);
- doAsyncCall(instance, function, t);
- }
+ result = std::move(pImp->mReturn);
+ arguments = std::move(pImp->mArguments);
+ // Delete the pointer.
+ delete pImp;
+ }
- /**
- * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
- */
- template<class TClass1, class Targ, class Targ1, class Targ2>
- void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1& argument1, Targ2 argument2), Targ argument, Targ1& argument1, Targ2 argument2)
- {
- auto t = std::make_tuple(argument, argument1, argument2);
- doAsyncCall(instance, function, t);
- }
+private:
- /**
- * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
- */
- template<class TClass1, class Targ, class Targ1, class Targ2>
- void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1 argument1, Targ2& argument2), Targ argument, Targ1 argument1, Targ2& argument2)
- {
- auto t = std::make_tuple(argument, argument1, argument2);
- doAsyncCall(instance, function, t);
- }
+ /**
+ * rings the line of the pipe and adds the delegate pointer to the queue
+ * @param p delegate pointer
+ */
+ inline void send(CAmDelegagePtr p)
+ {
+ if (write(mPipe[1], &p, sizeof(p)) == -1)
+ {
+ throw std::runtime_error("could not write to pipe !");
+ }
+ }
- /**
- * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
- */
- template<class TClass1, class Targ, class Targ1, class Targ2>
- void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1& argument1, Targ2& argument2), Targ argument, Targ1& argument1, Targ2& argument2)
- {
- auto t = std::make_tuple(argument, argument1, argument2);
- doAsyncCall(instance, function, t);
- }
+ int mPipe[2]; //!< the pipe
+ int mReturnPipe[2]; //!< pipe handling returns
+ sh_pollHandle_t mHandle;
+ CAmSocketHandler *mpSocketHandler;
+ std::deque<CAmDelegagePtr> mListDelegatePoiters; //!< intermediate queue to store the pipe results
- /**
- * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
- */
- template<class TClass1, class Targ, class Targ1, class Targ2>
- void asyncCall(TClass1* instance, void (TClass1::*function)(Targ& argument, Targ1& argument1, Targ2& argument2), Targ& argument, Targ1& argument1, Targ2& argument2)
- {
- auto t = std::make_tuple(argument, argument1, argument2);
- doAsyncCall(instance, function, t);
- }
+public:
- /**
- * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
- */
- template<class TClass1, class Targ, class Targ1, class Targ2>
- void asyncCall(TClass1* instance, void (TClass1::*function)(Targ& argument, Targ1& argument1, Targ2 argument2), Targ& argument, Targ1& argument1, Targ2 argument2)
- {
- auto t = std::make_tuple(argument, argument1, argument2);
- doAsyncCall(instance, function, t);
- }
+ /**
+ * get the size of delegate pointers
+ */
+ int getListDelegatePoiters()
+ {
+ return mListDelegatePoiters.size();
+ }
- /**
- * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
- */
- template<class TClass1, class Targ, class Targ1, class Targ2>
- void asyncCall(TClass1* instance, void (TClass1::*function)(Targ& argument, Targ1 argument1, Targ2& argument2), Targ& argument, Targ1 argument1, Targ2& argument2)
- {
- auto t = std::make_tuple(argument, argument1, argument2);
- doAsyncCall(instance, function, t);
- }
+ /**
+ * calls a function with variadic arguments threadsafe
+ * @param instance the instance of the class that shall be called
+ * @param function the function that shall be called as member function pointer.
+ * @param output variable.
+ * @tparam TClass the type of the Class to be called
+ * @tparam TRet the type of the result
+ * @tparam TArgs argument list
+ * \section ex Example:
+ * @code
+ * class MyGreatClass
+ * {
+ * public:
+ * int AGreatMethod(int x);
+ * }
+ * CAmSerializer serial(&Sockethandler);
+ * MyGreatClass anInstance;
+ * int result;
+ * serial.syncCall<MyGreatClass, int, int>(&anInstance,&MyGreatClass::AGreatMethod, result, 100);
+ * @endcode
+ */
+ template<class TClass, class TRet, class... TArgs>
+ void syncCall(TClass *instance, TRet (TClass::*method)(TArgs...), TRet &result, TArgs & ... arguments)
+ {
+ auto t = std::make_tuple(arguments...);
+ doSyncCall(instance, method, result, t);
+ std::tie(arguments...) = t;
+ }
- /**
- * calls a function with four arguments asynchronously threadsafe. for more see other asycCall
- */
- template<class TClass1, class Targ, class Targ1, class Targ2, class Targ3>
- void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1 argument1, Targ2 argument2, Targ3 argument3), Targ argument, Targ1 argument1, Targ2 argument2, Targ3 argument3)
- {
- auto t = std::make_tuple(argument, argument1, argument2, argument3);
- doAsyncCall(instance, function, t);
- }
+ /**
+ * calls a function with variadic arguments threadsafe
+ * @param instance the instance of the class that shall be called
+ * @param function the function that shall be called as member function pointer.
+ * @tparam TClass the type of the Class to be called
+ * @tparam TRet the type of the result
+ * @tparam TArgs argument list
+ * \section ex Example:
+ * @code
+ * class MyGreatClass
+ * {
+ * public:
+ * int AGreatMethod(int x);
+ * }
+ * CAmSerializer serial(&Sockethandler);
+ * MyGreatClass anInstance;
+ * serial.asyncCall<MyGreatClass, void, int>(&anInstance,&MyGreatClass::AGreatMethod, 100);
+ * @endcode
+ */
+ template<class TClass, class TRet, class... TArgs>
+ void asyncCall(TClass *instance, TRet (TClass::*method)(TArgs...), TArgs & ... arguments)
+ {
+ auto t = std::make_tuple(arguments...);
+ doAsyncCall(instance, method, t);
+ }
- /**
- * calls a synchronous function with no arguments threadsafe
- * @param instance the instance of the class that shall be called
- * @param function the function that shall be called as memberfunction pointer.
- * @param retVal the return parameter, no const allowed !
- * @tparam TClass1 the type of the class to be called
- * @tparam TretVal the type of the return parameter
- * \section ex Example:
- * @code
- * class myClass
- * {
- * public:
- * am_Error_e myfunction();
- * }
- * CAmSerializer serial(&Sockethandler);
- * myClass instanceMyClass;
- * am_Error_e error;
- * serial<CommandSender,am_Error_e>(&instanceMyClass,&myClass::myfunction, error);
- * @endcode
- * All arguments given to synchronous functions must be non-const since the results of the operations will be written back to the arguments.
- *
- */
- template<class TClass1, class TretVal>
- void syncCall(TClass1* instance, TretVal (TClass1::*function)(), TretVal& retVal)
- {
- auto t = std::make_tuple();
- doSyncCall(instance, function, retVal, t);
- }
+ /**
+ * calls a function with no arguments threadsafe
+ * @param instance the instance of the class that shall be called
+ * @param function the function that shall be called as memberfunction pointer.
+ * @tparam TClass1 the type of the Class to be called
+ * \section ex Example:
+ * @code
+ * class myClass
+ * {
+ * public:
+ * void myfunction();
+ * }
+ * CAmSerializer serial(&Sockethandler);
+ * myClass instanceMyClass;
+ * serial<CommandSender>(&instanceMyClass,&myClass::myfunction);
+ * @endcode
+ */
+ template<class TClass>
+ void asyncCall(TClass *instance, void (TClass::*function)())
+ {
+ auto t = std::make_tuple();
+ doAsyncCall(instance, function, t);
+ }
- /**
- * calls a function with one argument synchronous threadsafe
- * @param instance the instance of the class that shall be called
- * @param function the function that shall be called as memberfunction pointer.
- * @param retVal the return parameter, no const allowed !
- * @param argument the argument, no const allowed !
- * @tparam TClass1 the type of the class to be called
- * @tparam TretVal the type of the return parameter
- * @tparam TargCall the type of the argument like in the function to be called. here all references and const must be
- * respected!
- * @tparam Targ the type of the argument, here no const and no references allowed !
- * \section ex Example:
- * @code
- * class myClass
- * {
- * public:
- * am_Error_e myfunction(int k);
- * }
- * CAmSerializer serial(&Sockethandler);
- * myClass instanceMyClass;
- * am_Error_e error;
- * int l;
- * serial<CommandSender,am_Error_e,int>(&instanceMyClass,&myClass::myfunction,error,l);
- * @endcode
- * All arguments given to synchronous functions must be non-const since the results of the operations will be written back to the arguments.
- */
- template<class TClass1, class TretVal, class TargCall, class Targ>
- void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall), TretVal& retVal, Targ& argument)
- {
- auto t = std::make_tuple(argument);
- doSyncCall(instance, function, retVal, t);
- std::tie(argument) = t;
- }
+ /**
+ * calls a function with one arguments asynchronously threadsafe
+ * @param instance the instance of the class that shall be called
+ * @param function the function that shall be called as memberfunction pointer.
+ * @param argument the argument
+ * @tparam TClass1 the type of the Class to be called
+ * @tparam Targ the type of the argument to be called
+ * \section ex Example:
+ * @code
+ * class myClass
+ * {
+ * public:
+ * void myfunction(int k);
+ * }
+ * CAmSerializer serial(&Sockethandler);
+ * myClass instanceMyClass;
+ * serial<CommandSender,int>(&instanceMyClass,&myClass::myfunction,k);
+ * @endcode
+ *
+ */
+ template<class TClass1, class Targ>
+ void asyncCall(TClass1 *instance, void (TClass1::*function)(Targ), Targ argument)
+ {
+ auto t = std::make_tuple(argument);
+ doAsyncCall(instance, function, t);
+ }
- /**
- * calls a function with one argument synchronous threadsafe for const functions. For more see syncCall with one argument
- */
- template<class TClass1, class TretVal, class TargCall, class Targ>
- void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall) const, TretVal& retVal, Targ& argument)
- {
- auto t = std::make_tuple(argument);
- doSyncCall(instance, function, retVal, t);
- std::tie(argument) = t;
- }
+ /**
+ * calls a function with one argument called by reference asynchronously threadsafe
+ * @param instance the instance of the class that shall be called
+ * @param function the function that shall be called as memberfunction pointer.
+ * @param argument the argument
+ * @tparam TClass1 the type of the Class to be called
+ * @tparam Targ the type of the argument to be called
+ * \section ex Example:
+ * @code
+ * class myClass
+ * {
+ * public:
+ * void myfunction(int k);
+ * }
+ * CAmSerializer serial(&Sockethandler);
+ * myClass instanceMyClass;
+ * serial<CommandSender,int>(&instanceMyClass,&myClass::myfunction,k);
+ * @endcode
+ *
+ */
+ template<class TClass1, class Targ>
+ void asyncCall(TClass1 *instance, void (TClass1::*function)(Targ &), Targ &argument)
+ {
+ auto t = std::make_tuple(argument);
+ doAsyncCall(instance, function, t);
+ }
- /**
- * calls a function with two arguments synchronously threadsafe. For more see syncCall with one argument
- */
- template<class TClass1, class TretVal, class TargCall, class Targ1Call, class Targ, class Targ1>
- void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall, Targ1Call), TretVal& retVal, Targ& argument, Targ1& argument1)
- {
- auto t = std::make_tuple(argument, argument1);
- doSyncCall(instance, function, retVal, t);
- std::tie(argument, argument1) = t;
- }
- /**
- * calls a function with two arguments synchronously threadsafe const. For more see syncCall with one argument
- */
- template<class TClass1, class TretVal, class TargCall, class Targ1Call, class Targ, class Targ1>
- void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall, Targ1Call) const, TretVal& retVal, Targ& argument, Targ1& argument1)
- {
- auto t = std::make_tuple(argument, argument1);
- doSyncCall(instance, function, retVal, t);
- std::tie(argument, argument1) = t;
- }
+ /**
+ * calls a function with two arguments asynchronously threadsafe. for more see asyncCall with one argument
+ * @param instance pointer to the instance of the class
+ * @param function memberfunction poitner
+ * @param argument the first argument
+ * @param argument1 the second argument
+ * @tparam TClass1 the type of the Class to be called
+ * @tparam Targ the type of the argument to be called
+ * @tparam Targ1 the type of the first argument to be called
+ */
+ template<class TClass1, class Targ, class Targ1>
+ void asyncCall(TClass1 *instance, void (TClass1::*function)(Targ argument, Targ1 argument1), Targ argument, Targ1 argument1)
+ {
+ auto t = std::make_tuple(argument, argument1);
+ doAsyncCall(instance, function, t);
+ }
- /**
- * calls a function with three arguments synchronously threadsafe. for more see syncCall with one argument
- */
- template<class TClass1, class TretVal, class TargCall, class TargCall1, class TargCall2, class Targ, class Targ1, class Targ2>
- void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall, TargCall1, TargCall2), TretVal& retVal, Targ& argument, Targ1& argument1, Targ2& argument2)
- {
- auto t = std::make_tuple(argument, argument1, argument2);
- doSyncCall(instance, function, retVal, t);
- std::tie(argument, argument1, argument2) = t;
- }
+ /**
+ * calls a function with two arguments asynchronously threadsafe, first argument is a reference. for more see asyncCall with one argument
+ * @param instance pointer to the instance of the class
+ * @param function memberfunction poitner
+ * @param argument the first argument
+ * @param argument1 the second argument
+ * @tparam TClass1 the type of the Class to be called
+ * @tparam Targ the type of the argument to be called
+ * @tparam Targ1 the type of the first argument to be called
+ */
+ template<class TClass1, class Targ, class Targ1>
+ void asyncCall(TClass1 *instance, void (TClass1::*function)(Targ & argument, Targ1 argument1), Targ &argument, Targ1 argument1)
+ {
+ auto t = std::make_tuple(argument, argument1);
+ doAsyncCall(instance, function, t);
+ }
- /**
- * calls a const function with three arguments synchronously threadsafe. for more see syncCall with one argument
- */
- template<class TClass1, class TretVal, class TargCall, class TargCall1, class TargCall2, class Targ, class Targ1, class Targ2>
- void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall, TargCall1, TargCall2) const, TretVal& retVal, Targ& argument, Targ1& argument1, Targ2& argument2)
- {
- auto t = std::make_tuple(argument, argument1, argument2);
- doSyncCall(instance, function, retVal, t);
- std::tie(argument, argument1, argument2) = t;
- }
+ /**
+ * calls a function with two arguments asynchronously threadsafe, second argument is a reference. for more see asyncCall with one argument
+ * @param instance pointer to the instance of the class
+ * @param function memberfunction poitner
+ * @param argument the first argument
+ * @param argument1 the second argument
+ * @tparam TClass1 the type of the Class to be called
+ * @tparam Targ the type of the argument to be called
+ * @tparam Targ1 the type of the first argument to be called
+ */
+ template<class TClass1, class Targ, class Targ1>
+ void asyncCall(TClass1 *instance, void (TClass1::*function)(Targ argument, Targ1 & argument1), Targ argument, Targ1 &argument1)
+ {
+ auto t = std::make_tuple(argument, argument1);
+ doAsyncCall(instance, function, t);
+ }
- /**
- * calls a function with four arguments synchronously threadsafe. for more see syncCall with one argument
- */
- template<class TClass1, class TretVal, class TargCall, class TargCall1, class TargCall2, class TargCall3, class Targ, class Targ1, class Targ2, class Targ3>
- void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall, TargCall1, TargCall2, TargCall3), TretVal& retVal, Targ& argument, Targ1& argument1, Targ2& argument2, Targ3& argument3)
- {
- auto t = std::make_tuple(argument, argument1, argument2, argument3);
- doSyncCall(instance, function, retVal, t);
- std::tie(argument, argument1, argument2, argument3) = t;
- }
+ /**
+ * calls a function with two arguments asynchronously threadsafe, both arguments are references. for more see asyncCall with one argument
+ * @param instance pointer to the instance of the class
+ * @param function memberfunction poitner
+ * @param argument the first argument
+ * @param argument1 the second argument
+ * @tparam TClass1 the type of the Class to be called
+ * @tparam Targ the type of the argument to be called
+ * @tparam Targ1 the type of the first argument to be called
+ */
+ template<class TClass1, class Targ, class Targ1>
+ void asyncCall(TClass1 *instance, void (TClass1::*function)(Targ & argument, Targ1 & argument1), Targ &argument, Targ1 &argument1)
+ {
+ auto t = std::make_tuple(argument, argument1);
+ doAsyncCall(instance, function, t);
+ }
- /**
- * calls a function with five arguments synchronously threadsafe. for more see syncCall with one argument
- */
- template<class TClass1, class TretVal, class TargCall, class TargCall1, class TargCall2, class TargCall3, class TargCall4, class Targ, class Targ1, class Targ2, class Targ3, class Targ4>
- void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall, TargCall1, TargCall2, TargCall3, TargCall4), TretVal& retVal, Targ& argument, Targ1& argument1, Targ2& argument2, Targ3& argument3, Targ4& argument4)
- {
- auto t = std::make_tuple(argument, argument1, argument2, argument3, argument4);
- doSyncCall(instance, function, retVal, t);
- std::tie(argument, argument1, argument2, argument3, argument4) = t;
- }
+ /**
+ * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
+ */
+ template<class TClass1, class Targ, class Targ1, class Targ2>
+ void asyncCall(TClass1 *instance, void (TClass1::*function)(Targ argument, Targ1 argument1, Targ2 argument2), Targ argument, Targ1 argument1, Targ2 argument2)
+ {
+ auto t = std::make_tuple(argument, argument1, argument2);
+ doAsyncCall(instance, function, t);
+ }
- /**
- * calls a function with six arguments synchronously threadsafe. for more see syncCall with one argument
- */
- template<class TClass1, class TretVal, class TargCall, class TargCall1, class TargCall2, class TargCall3, class TargCall4, class TargCall5, class Targ, class Targ1, class Targ2, class Targ3, class Targ4, class Targ5>
- void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall, TargCall1, TargCall2, TargCall3, TargCall4, TargCall5), TretVal& retVal, Targ& argument, Targ1& argument1, Targ2& argument2, Targ3& argument3,
- Targ4& argument4, Targ5& argument5)
- {
- auto t = std::make_tuple(argument, argument1, argument2, argument3, argument4, argument5);
- doSyncCall(instance, function, retVal, t);
- std::tie(argument, argument1, argument2, argument3, argument4, argument5) = t;
- }
+ /**
+ * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
+ */
+ template<class TClass1, class Targ, class Targ1, class Targ2>
+ void asyncCall(TClass1 *instance, void (TClass1::*function)(Targ & argument, Targ1 argument1, Targ2 argument2), Targ &argument, Targ1 argument1, Targ2 argument2)
+ {
+ auto t = std::make_tuple(argument, argument1, argument2);
+ doAsyncCall(instance, function, t);
+ }
- /**
- * receiver callback for sockethandling, for more, see CAmSocketHandler
- */
- void receiverCallback(const pollfd pollfd, const sh_pollHandle_t handle, void* userData)
- {
- (void) handle;
- (void) userData;
- int numReads;
- CAmDelegagePtr listPointers[3];
- if ((numReads = read(pollfd.fd, &listPointers, sizeof(listPointers))) == -1)
- {
- logError("CAmSerializer::receiverCallback could not read pipe!");
- throw std::runtime_error("CAmSerializer Could not read pipe!");
- }
- mListDelegatePoiters.assign(listPointers, listPointers + (numReads / sizeof(CAmDelegagePtr)));
- }
+ /**
+ * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
+ */
+ template<class TClass1, class Targ, class Targ1, class Targ2>
+ void asyncCall(TClass1 *instance, void (TClass1::*function)(Targ argument, Targ1 & argument1, Targ2 argument2), Targ argument, Targ1 &argument1, Targ2 argument2)
+ {
+ auto t = std::make_tuple(argument, argument1, argument2);
+ doAsyncCall(instance, function, t);
+ }
- /**
- * checker callback for sockethandling, for more, see CAmSocketHandler
- */
- bool checkerCallback(const sh_pollHandle_t handle, void* userData)
- {
- (void) handle;
- (void) userData;
- if (mListDelegatePoiters.empty())
- return (false);
- return (true);
- }
+ /**
+ * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
+ */
+ template<class TClass1, class Targ, class Targ1, class Targ2>
+ void asyncCall(TClass1 *instance, void (TClass1::*function)(Targ argument, Targ1 argument1, Targ2 & argument2), Targ argument, Targ1 argument1, Targ2 &argument2)
+ {
+ auto t = std::make_tuple(argument, argument1, argument2);
+ doAsyncCall(instance, function, t);
+ }
- /**
- * dispatcher callback for sockethandling, for more, see CAmSocketHandler
- */
- bool dispatcherCallback(const sh_pollHandle_t handle, void* userData)
- {
- (void) handle;
- (void) userData;
- CAmDelegagePtr delegatePoiter = mListDelegatePoiters.front();
- mListDelegatePoiters.pop_front();
- if (delegatePoiter->call(mReturnPipe))
- delete delegatePoiter;
- if (mListDelegatePoiters.empty())
- return (false);
- return (true);
- }
+ /**
+ * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
+ */
+ template<class TClass1, class Targ, class Targ1, class Targ2>
+ void asyncCall(TClass1 *instance, void (TClass1::*function)(Targ argument, Targ1 & argument1, Targ2 & argument2), Targ argument, Targ1 &argument1, Targ2 &argument2)
+ {
+ auto t = std::make_tuple(argument, argument1, argument2);
+ doAsyncCall(instance, function, t);
+ }
- TAmShPollFired<CAmSerializer> receiverCallbackT;
- TAmShPollDispatch<CAmSerializer> dispatcherCallbackT;
- TAmShPollCheck<CAmSerializer> checkerCallbackT;
-
- /**
- * The constructor must be called in the mainthread context !
- * @param iSocketHandler pointer to the CAmSocketHandler
- */
- CAmSerializer(CAmSocketHandler *iSocketHandler) :
- mPipe(),
- mReturnPipe(),
- mHandle(),
- mpSocketHandler(iSocketHandler),
- mListDelegatePoiters(),
- receiverCallbackT(this, &CAmSerializer::receiverCallback),
- dispatcherCallbackT(this, &CAmSerializer::dispatcherCallback),
- checkerCallbackT(this, &CAmSerializer::checkerCallback)
- {
- assert(NULL!=iSocketHandler);
-
- if (pipe(mPipe) == -1)
- {
- logError("CAmSerializer could not create pipe!");
- throw std::runtime_error("CAmSerializer Could not open pipe!");
- }
-
- if (pipe(mReturnPipe) == -1)
- {
- logError("CAmSerializer could not create mReturnPipe!");
- throw std::runtime_error("CAmSerializer Could not open mReturnPipe!");
- }
-
- short event = 0;
- event |= POLLIN;
- mpSocketHandler->addFDPoll(mPipe[0], event, NULL, &receiverCallbackT, &checkerCallbackT, &dispatcherCallbackT, NULL, mHandle);
- }
+ /**
+ * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
+ */
+ template<class TClass1, class Targ, class Targ1, class Targ2>
+ void asyncCall(TClass1 *instance, void (TClass1::*function)(Targ & argument, Targ1 & argument1, Targ2 & argument2), Targ &argument, Targ1 &argument1, Targ2 &argument2)
+ {
+ auto t = std::make_tuple(argument, argument1, argument2);
+ doAsyncCall(instance, function, t);
+ }
- ~CAmSerializer()
- {
- mpSocketHandler->removeFDPoll(mHandle);
- close(mPipe[0]);
- close(mPipe[1]);
- close(mReturnPipe[0]);
- close(mReturnPipe[1]);
- }
- };
+ /**
+ * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
+ */
+ template<class TClass1, class Targ, class Targ1, class Targ2>
+ void asyncCall(TClass1 *instance, void (TClass1::*function)(Targ & argument, Targ1 & argument1, Targ2 argument2), Targ &argument, Targ1 &argument1, Targ2 argument2)
+ {
+ auto t = std::make_tuple(argument, argument1, argument2);
+ doAsyncCall(instance, function, t);
+ }
+
+ /**
+ * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
+ */
+ template<class TClass1, class Targ, class Targ1, class Targ2>
+ void asyncCall(TClass1 *instance, void (TClass1::*function)(Targ & argument, Targ1 argument1, Targ2 & argument2), Targ &argument, Targ1 argument1, Targ2 &argument2)
+ {
+ auto t = std::make_tuple(argument, argument1, argument2);
+ doAsyncCall(instance, function, t);
+ }
+
+ /**
+ * calls a function with four arguments asynchronously threadsafe. for more see other asycCall
+ */
+ template<class TClass1, class Targ, class Targ1, class Targ2, class Targ3>
+ void asyncCall(TClass1 *instance, void (TClass1::*function)(Targ argument, Targ1 argument1, Targ2 argument2, Targ3 argument3), Targ argument, Targ1 argument1, Targ2 argument2, Targ3 argument3)
+ {
+ auto t = std::make_tuple(argument, argument1, argument2, argument3);
+ doAsyncCall(instance, function, t);
+ }
- } /* namespace V1 */
+ /**
+ * calls a synchronous function with no arguments threadsafe
+ * @param instance the instance of the class that shall be called
+ * @param function the function that shall be called as memberfunction pointer.
+ * @param retVal the return parameter, no const allowed !
+ * @tparam TClass1 the type of the class to be called
+ * @tparam TretVal the type of the return parameter
+ * \section ex Example:
+ * @code
+ * class myClass
+ * {
+ * public:
+ * am_Error_e myfunction();
+ * }
+ * CAmSerializer serial(&Sockethandler);
+ * myClass instanceMyClass;
+ * am_Error_e error;
+ * serial<CommandSender,am_Error_e>(&instanceMyClass,&myClass::myfunction, error);
+ * @endcode
+ * All arguments given to synchronous functions must be non-const since the results of the operations will be written back to the arguments.
+ *
+ */
+ template<class TClass1, class TretVal>
+ void syncCall(TClass1 *instance, TretVal (TClass1::*function)(), TretVal &retVal)
+ {
+ auto t = std::make_tuple();
+ doSyncCall(instance, function, retVal, t);
+ }
+
+ /**
+ * calls a function with one argument synchronous threadsafe
+ * @param instance the instance of the class that shall be called
+ * @param function the function that shall be called as memberfunction pointer.
+ * @param retVal the return parameter, no const allowed !
+ * @param argument the argument, no const allowed !
+ * @tparam TClass1 the type of the class to be called
+ * @tparam TretVal the type of the return parameter
+ * @tparam TargCall the type of the argument like in the function to be called. here all references and const must be
+ * respected!
+ * @tparam Targ the type of the argument, here no const and no references allowed !
+ * \section ex Example:
+ * @code
+ * class myClass
+ * {
+ * public:
+ * am_Error_e myfunction(int k);
+ * }
+ * CAmSerializer serial(&Sockethandler);
+ * myClass instanceMyClass;
+ * am_Error_e error;
+ * int l;
+ * serial<CommandSender,am_Error_e,int>(&instanceMyClass,&myClass::myfunction,error,l);
+ * @endcode
+ * All arguments given to synchronous functions must be non-const since the results of the operations will be written back to the arguments.
+ */
+ template<class TClass1, class TretVal, class TargCall, class Targ>
+ void syncCall(TClass1 *instance, TretVal (TClass1::*function)(TargCall), TretVal &retVal, Targ &argument)
+ {
+ auto t = std::make_tuple(argument);
+ doSyncCall(instance, function, retVal, t);
+ std::tie(argument) = t;
+ }
+
+ /**
+ * calls a function with one argument synchronous threadsafe for const functions. For more see syncCall with one argument
+ */
+ template<class TClass1, class TretVal, class TargCall, class Targ>
+ void syncCall(TClass1 *instance, TretVal (TClass1::*function)(TargCall) const, TretVal &retVal, Targ &argument)
+ {
+ auto t = std::make_tuple(argument);
+ doSyncCall(instance, function, retVal, t);
+ std::tie(argument) = t;
+ }
+
+ /**
+ * calls a function with two arguments synchronously threadsafe. For more see syncCall with one argument
+ */
+ template<class TClass1, class TretVal, class TargCall, class Targ1Call, class Targ, class Targ1>
+ void syncCall(TClass1 *instance, TretVal (TClass1::*function)(TargCall, Targ1Call), TretVal &retVal, Targ &argument, Targ1 &argument1)
+ {
+ auto t = std::make_tuple(argument, argument1);
+ doSyncCall(instance, function, retVal, t);
+ std::tie(argument, argument1) = t;
+ }
+
+ /**
+ * calls a function with two arguments synchronously threadsafe const. For more see syncCall with one argument
+ */
+ template<class TClass1, class TretVal, class TargCall, class Targ1Call, class Targ, class Targ1>
+ void syncCall(TClass1 *instance, TretVal (TClass1::*function)(TargCall, Targ1Call) const, TretVal &retVal, Targ &argument, Targ1 &argument1)
+ {
+ auto t = std::make_tuple(argument, argument1);
+ doSyncCall(instance, function, retVal, t);
+ std::tie(argument, argument1) = t;
+ }
+
+ /**
+ * calls a function with three arguments synchronously threadsafe. for more see syncCall with one argument
+ */
+ template<class TClass1, class TretVal, class TargCall, class TargCall1, class TargCall2, class Targ, class Targ1, class Targ2>
+ void syncCall(TClass1 *instance, TretVal (TClass1::*function)(TargCall, TargCall1, TargCall2), TretVal &retVal, Targ &argument, Targ1 &argument1, Targ2 &argument2)
+ {
+ auto t = std::make_tuple(argument, argument1, argument2);
+ doSyncCall(instance, function, retVal, t);
+ std::tie(argument, argument1, argument2) = t;
+ }
+
+ /**
+ * calls a const function with three arguments synchronously threadsafe. for more see syncCall with one argument
+ */
+ template<class TClass1, class TretVal, class TargCall, class TargCall1, class TargCall2, class Targ, class Targ1, class Targ2>
+ void syncCall(TClass1 *instance, TretVal (TClass1::*function)(TargCall, TargCall1, TargCall2) const, TretVal &retVal, Targ &argument, Targ1 &argument1, Targ2 &argument2)
+ {
+ auto t = std::make_tuple(argument, argument1, argument2);
+ doSyncCall(instance, function, retVal, t);
+ std::tie(argument, argument1, argument2) = t;
+ }
- /**@}*/
+ /**
+ * calls a function with four arguments synchronously threadsafe. for more see syncCall with one argument
+ */
+ template<class TClass1, class TretVal, class TargCall, class TargCall1, class TargCall2, class TargCall3, class Targ, class Targ1, class Targ2, class Targ3>
+ void syncCall(TClass1 *instance, TretVal (TClass1::*function)(TargCall, TargCall1, TargCall2, TargCall3), TretVal &retVal, Targ &argument, Targ1 &argument1, Targ2 &argument2, Targ3 &argument3)
+ {
+ auto t = std::make_tuple(argument, argument1, argument2, argument3);
+ doSyncCall(instance, function, retVal, t);
+ std::tie(argument, argument1, argument2, argument3) = t;
+ }
- namespace V2
+ /**
+ * calls a function with five arguments synchronously threadsafe. for more see syncCall with one argument
+ */
+ template<class TClass1, class TretVal, class TargCall, class TargCall1, class TargCall2, class TargCall3, class TargCall4, class Targ, class Targ1, class Targ2, class Targ3, class Targ4>
+ void syncCall(TClass1 *instance, TretVal (TClass1::*function)(TargCall, TargCall1, TargCall2, TargCall3, TargCall4), TretVal &retVal, Targ &argument, Targ1 &argument1, Targ2 &argument2, Targ3 &argument3, Targ4 &argument4)
+ {
+ auto t = std::make_tuple(argument, argument1, argument2, argument3, argument4);
+ doSyncCall(instance, function, retVal, t);
+ std::tie(argument, argument1, argument2, argument3, argument4) = t;
+ }
+
+ /**
+ * calls a function with six arguments synchronously threadsafe. for more see syncCall with one argument
+ */
+ template<class TClass1, class TretVal, class TargCall, class TargCall1, class TargCall2, class TargCall3, class TargCall4, class TargCall5, class Targ, class Targ1, class Targ2, class Targ3, class Targ4, class Targ5>
+ void syncCall(TClass1 *instance, TretVal (TClass1::*function)(TargCall, TargCall1, TargCall2, TargCall3, TargCall4, TargCall5), TretVal &retVal, Targ &argument, Targ1 &argument1, Targ2 &argument2, Targ3 &argument3,
+ Targ4 &argument4, Targ5 &argument5)
{
- class CAmSerializer
+ auto t = std::make_tuple(argument, argument1, argument2, argument3, argument4, argument5);
+ doSyncCall(instance, function, retVal, t);
+ std::tie(argument, argument1, argument2, argument3, argument4, argument5) = t;
+ }
+
+ /**
+ * receiver callback for sockethandling, for more, see CAmSocketHandler
+ */
+ void receiverCallback(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
+ {
+ (void)handle;
+ (void)userData;
+ int numReads;
+ CAmDelegagePtr listPointers[3];
+ if ((numReads = read(pollfd.fd, &listPointers, sizeof(listPointers))) == -1)
{
- /**
- * Prototype for a delegate
- */
- class CAmDelegate
- {
- public:
- typedef enum
- :bool
- {
- SyncCallType = false, AsyncCallType = true
- } CallType;
-
- virtual ~CAmDelegate()
- {
- }
- ;
- virtual CallType call(int* pipe)=0;
- };
-
- /**
- * Prototype for a delegate with variadic template arguments.
- */
- template<class TInvocation>
- class CAmDelegateAsyncImpl: public CAmDelegate
- {
- TInvocation mInvocation;
- public:
- friend class CAmSerializer;
- CAmDelegateAsyncImpl(TInvocation && invocation) :
- mInvocation(std::move(invocation))
- {
- }
-
- CallType call(int* pipe)
- {
- (void) pipe;
- mInvocation();
- return (AsyncCallType);
- }
- ;
- };
-
- template<class TInvocation, class TRet>
- class CAmDelegateSyncImpl: public CAmDelegate
- {
- TInvocation mInvocation;
- TRet & mReturn;
- public:
- friend class CAmSerializer;
- CAmDelegateSyncImpl(TInvocation && invocation, TRet && ret) :
- mInvocation(std::move(invocation)), mReturn(ret)
- {
- }
-
- CallType call(int* pipe)
- {
- mReturn = mInvocation();
- ssize_t result(-1);
- result = write(pipe[1], this, sizeof(this));
- if (result == -1)
- logError("CAmSerializer: Problem writing into pipe! Error No:", errno);
- return (SyncCallType);
- }
- ;
- };
-
- template<class TInvocation>
- class CAmDelegateSyncVoidImpl: public CAmDelegate
- {
- TInvocation mInvocation;
- public:
- friend class CAmSerializer;
- CAmDelegateSyncVoidImpl(TInvocation && invocation) :
- mInvocation(std::move(invocation))
- {
- }
-
- CallType call(int* pipe)
- {
- mInvocation();
- ssize_t result(-1);
- result = write(pipe[1], this, sizeof(this));
- if (result == -1)
- logError("CAmSerializer: Problem writing into pipe! Error No:", errno);
- return (SyncCallType);
- }
- ;
- };
-
- typedef CAmDelegate* CAmDelegagePtr; //!< pointer to a delegate
-
- void sendSync(CAmDelegagePtr pDelegate)
- {
- send(pDelegate);
- int numReads;
- CAmDelegagePtr *p = NULL;
- if ((numReads = read(mReturnPipe[0], &p, sizeof(p))) == -1)
- {
- logError("CAmSerializer::doSyncCall could not read pipe!");
- throw std::runtime_error("CAmSerializer Could not read pipe!");
- }
- }
+ logError("CAmSerializer::receiverCallback could not read pipe!");
+ throw std::runtime_error("CAmSerializer Could not read pipe!");
+ }
- /**
- * rings the line of the pipe and adds the delegate pointer to the queue
- * @param p delegate pointer
- */
- inline void send(CAmDelegagePtr p)
- {
- if (write(mPipe[1], &p, sizeof(p)) == -1)
- {
- throw std::runtime_error("could not write to pipe !");
- }
- }
+ mListDelegatePoiters.assign(listPointers, listPointers + (numReads / sizeof(CAmDelegagePtr)));
+ }
- int mPipe[2]; //!< the pipe
- int mReturnPipe[2]; //!< pipe handling returns
- sh_pollHandle_t mHandle;
- CAmSocketHandler* mpSocketHandler;
- std::deque<CAmDelegagePtr> mListDelegatePointers; //!< intermediate queue to store the pipe results
+ /**
+ * checker callback for sockethandling, for more, see CAmSocketHandler
+ */
+ bool checkerCallback(const sh_pollHandle_t handle, void *userData)
+ {
+ (void)handle;
+ (void)userData;
+ if (mListDelegatePoiters.empty())
+ {
+ return (false);
+ }
- public:
+ return (true);
+ }
- /**
- * get the size of delegate pointers
- */
- size_t getListDelegatePointers()
- {
- return mListDelegatePointers.size();
- }
+ /**
+ * dispatcher callback for sockethandling, for more, see CAmSocketHandler
+ */
+ bool dispatcherCallback(const sh_pollHandle_t handle, void *userData)
+ {
+ (void)handle;
+ (void)userData;
+ CAmDelegagePtr delegatePoiter = mListDelegatePoiters.front();
+ mListDelegatePoiters.pop_front();
+ if (delegatePoiter->call(mReturnPipe))
+ {
+ delete delegatePoiter;
+ }
- /**
- * calls a function with variadic arguments threadsafe
- * @param invocation is a type is produced by std::bind
- * \section ex Example:
- * @code
- * CAmSerializer serial(&Sockethandler);
- * serial.asyncInvocation(std::bind([]()->bool{return true;}));
- * @endcode
- */
- template<class TFunc>
- void asyncInvocation(TFunc invocation)
- {
- static_assert(std::is_bind_expression<TFunc>::value,"The type is not produced by std::bind");
- typedef CAmDelegateAsyncImpl<TFunc> AsyncDelegate;
- AsyncDelegate *pImp = new AsyncDelegate(std::forward<TFunc>(invocation));
- send(pImp);
- //Do not delete the pointer. It will be deleted automatically later.
- }
+ if (mListDelegatePoiters.empty())
+ {
+ return (false);
+ }
- /**
- * calls a function with variadic arguments threadsafe
- * @param instance the instance of the class that shall be called
- * @param function the function that shall be called as member function pointer.
- * @tparam TClass the type of the Class to be called
- * @tparam TRet the type of the result
- * @tparam TArgs argument list
- * \section ex Example:
- * @code
- * class AClass
- * {
- * public:
- * void instanceMethod(int x);
- * }
- * CAmSerializer serial(&Sockethandler);
- * AClass anInstance;
- * serial.asyncCall(&anInstance,&AClass::instanceMethod, 100);
- * @endcode
- */
- template<class TClass, class TMeth, class TRet, class ... TArgs>
- void asyncCall(TClass* instance, TMeth method, TArgs && ... arguments)
- {
- auto invocation = std::bind(method, instance, std::forward<TArgs>(arguments)...);
- asyncInvocation(invocation);
- }
+ return (true);
+ }
- template<class TClass, class TMeth, class ... TArgs>
- void asyncCall(TClass* instance, TMeth method, TArgs && ... arguments)
- {
- auto invocation = std::bind(method, instance, std::forward<TArgs>(arguments)...);
- asyncInvocation(invocation);
- }
+ TAmShPollFired<CAmSerializer> receiverCallbackT;
+ TAmShPollDispatch<CAmSerializer> dispatcherCallbackT;
+ TAmShPollCheck<CAmSerializer> checkerCallbackT;
- /**
- * calls a function with variadic arguments threadsafe
- * @param invocation is a type is produced by std::bind
- * @param result from type TRet
- * \section ex Example:
- * @code
- * CAmSerializer serial(&Sockethandler);
- * bool result;
- * serial.syncCall(std::bind([]()->bool{return true;}), result);
- * @endcode
- */
- template<class TFunc, class TRet>
- void syncInvocation(TFunc invocation, TRet && result)
- {
- static_assert(std::is_bind_expression<TFunc>::value,"The type is not produced by std::bind");
+ /**
+ * The constructor must be called in the mainthread context !
+ * @param iSocketHandler pointer to the CAmSocketHandler
+ */
+ CAmSerializer(CAmSocketHandler *iSocketHandler)
+ : mPipe()
+ , mReturnPipe()
+ , mHandle()
+ , mpSocketHandler(iSocketHandler)
+ , mListDelegatePoiters()
+ , receiverCallbackT(this, &CAmSerializer::receiverCallback)
+ , dispatcherCallbackT(this, &CAmSerializer::dispatcherCallback)
+ , checkerCallbackT(this, &CAmSerializer::checkerCallback)
+ {
+ assert(NULL != iSocketHandler);
- typedef CAmDelegateSyncImpl<TFunc, TRet> SyncDelegate;
+ if (pipe(mPipe) == -1)
+ {
+ logError("CAmSerializer could not create pipe!");
+ throw std::runtime_error("CAmSerializer Could not open pipe!");
+ }
- SyncDelegate *pImp = new SyncDelegate(std::forward<TFunc>(invocation), std::forward<TRet>(result));
- sendSync(pImp);
- //Delete the pointer.
- delete pImp;
- }
+ if (pipe(mReturnPipe) == -1)
+ {
+ logError("CAmSerializer could not create mReturnPipe!");
+ throw std::runtime_error("CAmSerializer Could not open mReturnPipe!");
+ }
- /**
- * calls a function with variadic arguments threadsafe
- * @param invocation is a type produced by std::bind
- * \section ex Example:
- * @code
- * CAmSerializer serial(&Sockethandler);
- * serial.syncCall(std::bind([]()->bool{return true;}));
- * @endcode
- */
- template<class TFunc>
- void syncInvocation(TFunc invocation)
- {
- static_assert(std::is_bind_expression<TFunc>::value,"The type is not produced by std::bind");
+ short event = 0;
+ event |= POLLIN;
+ mpSocketHandler->addFDPoll(mPipe[0], event, NULL, &receiverCallbackT, &checkerCallbackT, &dispatcherCallbackT, NULL, mHandle);
+ }
- typedef CAmDelegateSyncVoidImpl<TFunc> SyncDelegate;
+ ~CAmSerializer()
+ {
+ mpSocketHandler->removeFDPoll(mHandle);
+ close(mPipe[0]);
+ close(mPipe[1]);
+ close(mReturnPipe[0]);
+ close(mReturnPipe[1]);
+ }
- SyncDelegate *pImp = new SyncDelegate(std::forward<TFunc>(invocation));
- sendSync(pImp);
- //Delete the pointer.
- delete pImp;
- }
- /**
- * calls a function with variadic arguments threadsafe
- * @param instance the instance of the class that shall be called
- * @param function the function that shall be called as member function pointer.
- * @param output variable.
- * @tparam TClass the type of the Class to be called
- * @tparam TRet the type of the result
- * @tparam TArgs argument list
- * \section ex Example:
- * @code
- * class AClass
- * {
- * public:
- * int instanceMethod(int x);
- * }
- * CAmSerializer serial(&Sockethandler);
- * AClass anInstance;
- * int result;
- * serial.syncCall(&anInstance,&AClass::instanceMethod, result, 100);
- * @endcode
- */
- template<class TClass, class TMeth, class TRet, class ... TArgs>
- void syncCall(TClass* instance, TMeth method, TRet & result, TArgs && ... arguments)
- {
- auto invocation = std::bind(method, instance, std::ref(arguments)...);
- syncInvocation(invocation, result);
- }
+};
- template<class TClass, class TMeth, class ... TArgs>
- void syncCall(TClass* instance, TMeth method, TArgs && ... arguments)
- {
- auto invocation = std::bind(method, instance, std::ref(arguments)...);
- syncInvocation(invocation);
- }
+} /* namespace V1 */
- /**
- * receiver callback for sockethandling, for more, see CAmSocketHandler
- */
- void receiverCallback(const pollfd pollfd, const sh_pollHandle_t handle, void* userData)
- {
- (void) handle;
- (void) userData;
- int numReads;
- CAmDelegagePtr listPointers[3];
- if ((numReads = read(pollfd.fd, &listPointers, sizeof(listPointers))) == -1)
- {
- logError("CAmSerializer::receiverCallback could not read pipe!");
- throw std::runtime_error("CAmSerializer Could not read pipe!");
- }
- mListDelegatePointers.assign(listPointers, listPointers + (numReads / sizeof(CAmDelegagePtr)));
- }
+/**@}*/
- /**
- * checker callback for sockethandling, for more, see CAmSocketHandler
- */
- bool checkerCallback(const sh_pollHandle_t handle, void* userData)
- {
- (void) handle;
- (void) userData;
- if (mListDelegatePointers.empty())
- return (false);
- return (true);
- }
+namespace V2
+{
+class CAmSerializer
+{
+ /**
+ * Prototype for a delegate
+ */
+ class CAmDelegate
+ {
+ public:
+ typedef enum
+ : bool
+ {
+ SyncCallType = false, AsyncCallType = true
+ } CallType;
- /**
- * dispatcher callback for sockethandling, for more, see CAmSocketHandler
- */
- bool dispatcherCallback(const sh_pollHandle_t handle, void* userData)
- {
- (void) handle;
- (void) userData;
- CAmDelegagePtr delegatePoiter = mListDelegatePointers.front();
- mListDelegatePointers.pop_front();
- if (delegatePoiter->call(mReturnPipe))
- delete delegatePoiter;
- if (mListDelegatePointers.empty())
- return (false);
- return (true);
- }
+ virtual ~CAmDelegate()
+ {
+ }
+
+ virtual CallType call(int *pipe) = 0;
+
+ };
+
+ /**
+ * Prototype for a delegate with variadic template arguments.
+ */
+ template<class TInvocation>
+ class CAmDelegateAsyncImpl : public CAmDelegate
+ {
+ TInvocation mInvocation;
+ public:
+ friend class CAmSerializer;
+ CAmDelegateAsyncImpl(TInvocation &&invocation)
+ : mInvocation(std::move(invocation))
+ {
+ }
+
+ CallType call(int *pipe)
+ {
+ (void)pipe;
+ mInvocation();
+ return (AsyncCallType);
+ }
+
+ };
- TAmShPollFired<CAmSerializer> receiverCallbackT;
- TAmShPollDispatch<CAmSerializer> dispatcherCallbackT;
- TAmShPollCheck<CAmSerializer> checkerCallbackT;
-
- /**
- * The constructor must be called in the mainthread context !
- * @param iSocketHandler pointer to the CAmSocketHandler
- */
- CAmSerializer(CAmSocketHandler *iSocketHandler) :
- mPipe(),
- mReturnPipe(),
- mHandle(),
- mpSocketHandler(iSocketHandler),
- mListDelegatePointers(),
- receiverCallbackT(this, &CAmSerializer::receiverCallback),
- dispatcherCallbackT(this, &CAmSerializer::dispatcherCallback),
- checkerCallbackT(this, &CAmSerializer::checkerCallback)
+ template<class TInvocation, class TRet>
+ class CAmDelegateSyncImpl : public CAmDelegate
+ {
+ TInvocation mInvocation;
+ TRet &mReturn;
+ public:
+ friend class CAmSerializer;
+ CAmDelegateSyncImpl(TInvocation &&invocation, TRet &&ret)
+ : mInvocation(std::move(invocation))
+ , mReturn(ret)
+ {
+ }
+
+ CallType call(int *pipe)
+ {
+ mReturn = mInvocation();
+ ssize_t result(-1);
+ result = write(pipe[1], this, sizeof(this));
+ if (result == -1)
{
- assert(NULL!=iSocketHandler);
-
- if (pipe(mPipe) == -1)
- {
- logError("CAmSerializer could not create pipe!");
- throw std::runtime_error("CAmSerializer Could not open pipe!");
- }
-
- if (pipe(mReturnPipe) == -1)
- {
- logError("CAmSerializer could not create mReturnPipe!");
- throw std::runtime_error("CAmSerializer Could not open mReturnPipe!");
- }
-
- short event = 0;
- event |= POLLIN;
- mpSocketHandler->addFDPoll(mPipe[0], event, NULL, &receiverCallbackT, &checkerCallbackT, &dispatcherCallbackT, NULL, mHandle);
+ logError("CAmSerializer: Problem writing into pipe! Error No:", errno);
}
- ~CAmSerializer()
+ return (SyncCallType);
+ }
+
+ };
+
+ template<class TInvocation>
+ class CAmDelegateSyncVoidImpl : public CAmDelegate
+ {
+ TInvocation mInvocation;
+ public:
+ friend class CAmSerializer;
+ CAmDelegateSyncVoidImpl(TInvocation &&invocation)
+ : mInvocation(std::move(invocation))
+ {
+ }
+
+ CallType call(int *pipe)
+ {
+ mInvocation();
+ ssize_t result(-1);
+ result = write(pipe[1], this, sizeof(this));
+ if (result == -1)
{
- mpSocketHandler->removeFDPoll(mHandle);
- close(mPipe[0]);
- close(mPipe[1]);
- close(mReturnPipe[0]);
- close(mReturnPipe[1]);
+ logError("CAmSerializer: Problem writing into pipe! Error No:", errno);
}
- };
- } /* namespace V2 */
- typedef V1::CAmSerializer CAmSerializer DEPRECATED("You should use V2::CAmSerializer instead!");
+ return (SyncCallType);
+ }
+
+ };
+
+ typedef CAmDelegate *CAmDelegagePtr; //!< pointer to a delegate
+
+ void sendSync(CAmDelegagePtr pDelegate)
+ {
+ send(pDelegate);
+ int numReads;
+ CAmDelegagePtr *p = NULL;
+ if ((numReads = read(mReturnPipe[0], &p, sizeof(p))) == -1)
+ {
+ logError("CAmSerializer::doSyncCall could not read pipe!");
+ throw std::runtime_error("CAmSerializer Could not read pipe!");
+ }
+ }
+
+ /**
+ * rings the line of the pipe and adds the delegate pointer to the queue
+ * @param p delegate pointer
+ */
+ inline void send(CAmDelegagePtr p)
+ {
+ if (write(mPipe[1], &p, sizeof(p)) == -1)
+ {
+ throw std::runtime_error("could not write to pipe !");
+ }
+ }
+
+ int mPipe[2]; //!< the pipe
+ int mReturnPipe[2]; //!< pipe handling returns
+ sh_pollHandle_t mHandle;
+ CAmSocketHandler *mpSocketHandler;
+ std::deque<CAmDelegagePtr> mListDelegatePointers; //!< intermediate queue to store the pipe results
+
+public:
+
+ /**
+ * get the size of delegate pointers
+ */
+ size_t getListDelegatePointers()
+ {
+ return mListDelegatePointers.size();
+ }
+
+ /**
+ * calls a function with variadic arguments threadsafe
+ * @param invocation is a type is produced by std::bind
+ * \section ex Example:
+ * @code
+ * CAmSerializer serial(&Sockethandler);
+ * serial.asyncInvocation(std::bind([]()->bool{return true;}));
+ * @endcode
+ */
+ template<class TFunc>
+ void asyncInvocation(TFunc invocation)
+ {
+ static_assert(std::is_bind_expression<TFunc>::value, "The type is not produced by std::bind");
+ typedef CAmDelegateAsyncImpl<TFunc> AsyncDelegate;
+ AsyncDelegate *pImp = new AsyncDelegate(std::forward<TFunc>(invocation));
+ send(pImp);
+ // Do not delete the pointer. It will be deleted automatically later.
+ }
+
+ /**
+ * calls a function with variadic arguments threadsafe
+ * @param instance the instance of the class that shall be called
+ * @param function the function that shall be called as member function pointer.
+ * @tparam TClass the type of the Class to be called
+ * @tparam TRet the type of the result
+ * @tparam TArgs argument list
+ * \section ex Example:
+ * @code
+ * class AClass
+ * {
+ * public:
+ * void instanceMethod(int x);
+ * }
+ * CAmSerializer serial(&Sockethandler);
+ * AClass anInstance;
+ * serial.asyncCall(&anInstance,&AClass::instanceMethod, 100);
+ * @endcode
+ */
+ template<class TClass, class TMeth, class TRet, class... TArgs>
+ void asyncCall(TClass *instance, TMeth method, TArgs && ... arguments)
+ {
+ auto invocation = std::bind(method, instance, std::forward<TArgs>(arguments) ...);
+ asyncInvocation(invocation);
+ }
+
+ template<class TClass, class TMeth, class... TArgs>
+ void asyncCall(TClass *instance, TMeth method, TArgs && ... arguments)
+ {
+ auto invocation = std::bind(method, instance, std::forward<TArgs>(arguments) ...);
+ asyncInvocation(invocation);
+ }
+
+ /**
+ * calls a function with variadic arguments threadsafe
+ * @param invocation is a type is produced by std::bind
+ * @param result from type TRet
+ * \section ex Example:
+ * @code
+ * CAmSerializer serial(&Sockethandler);
+ * bool result;
+ * serial.syncCall(std::bind([]()->bool{return true;}), result);
+ * @endcode
+ */
+ template<class TFunc, class TRet>
+ void syncInvocation(TFunc invocation, TRet &&result)
+ {
+ static_assert(std::is_bind_expression<TFunc>::value, "The type is not produced by std::bind");
+
+ typedef CAmDelegateSyncImpl<TFunc, TRet> SyncDelegate;
+
+ SyncDelegate *pImp = new SyncDelegate(std::forward<TFunc>(invocation), std::forward<TRet>(result));
+ sendSync(pImp);
+ // Delete the pointer.
+ delete pImp;
+ }
+
+ /**
+ * calls a function with variadic arguments threadsafe
+ * @param invocation is a type produced by std::bind
+ * \section ex Example:
+ * @code
+ * CAmSerializer serial(&Sockethandler);
+ * serial.syncCall(std::bind([]()->bool{return true;}));
+ * @endcode
+ */
+ template<class TFunc>
+ void syncInvocation(TFunc invocation)
+ {
+ static_assert(std::is_bind_expression<TFunc>::value, "The type is not produced by std::bind");
+
+ typedef CAmDelegateSyncVoidImpl<TFunc> SyncDelegate;
+
+ SyncDelegate *pImp = new SyncDelegate(std::forward<TFunc>(invocation));
+ sendSync(pImp);
+ // Delete the pointer.
+ delete pImp;
+ }
+
+ /**
+ * calls a function with variadic arguments threadsafe
+ * @param instance the instance of the class that shall be called
+ * @param function the function that shall be called as member function pointer.
+ * @param output variable.
+ * @tparam TClass the type of the Class to be called
+ * @tparam TRet the type of the result
+ * @tparam TArgs argument list
+ * \section ex Example:
+ * @code
+ * class AClass
+ * {
+ * public:
+ * int instanceMethod(int x);
+ * }
+ * CAmSerializer serial(&Sockethandler);
+ * AClass anInstance;
+ * int result;
+ * serial.syncCall(&anInstance,&AClass::instanceMethod, result, 100);
+ * @endcode
+ */
+ template<class TClass, class TMeth, class TRet, class... TArgs>
+ void syncCall(TClass *instance, TMeth method, TRet &result, TArgs && ... arguments)
+ {
+ auto invocation = std::bind(method, instance, std::ref(arguments) ...);
+ syncInvocation(invocation, result);
+ }
+
+ template<class TClass, class TMeth, class... TArgs>
+ void syncCall(TClass *instance, TMeth method, TArgs && ... arguments)
+ {
+ auto invocation = std::bind(method, instance, std::ref(arguments) ...);
+ syncInvocation(invocation);
+ }
+
+ /**
+ * receiver callback for sockethandling, for more, see CAmSocketHandler
+ */
+ void receiverCallback(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
+ {
+ (void)handle;
+ (void)userData;
+ int numReads;
+ CAmDelegagePtr listPointers[3];
+ if ((numReads = read(pollfd.fd, &listPointers, sizeof(listPointers))) == -1)
+ {
+ logError("CAmSerializer::receiverCallback could not read pipe!");
+ throw std::runtime_error("CAmSerializer Could not read pipe!");
+ }
+
+ mListDelegatePointers.assign(listPointers, listPointers + (numReads / sizeof(CAmDelegagePtr)));
+ }
+
+ /**
+ * checker callback for sockethandling, for more, see CAmSocketHandler
+ */
+ bool checkerCallback(const sh_pollHandle_t handle, void *userData)
+ {
+ (void)handle;
+ (void)userData;
+ if (mListDelegatePointers.empty())
+ {
+ return (false);
+ }
+
+ return (true);
+ }
+
+ /**
+ * dispatcher callback for sockethandling, for more, see CAmSocketHandler
+ */
+ bool dispatcherCallback(const sh_pollHandle_t handle, void *userData)
+ {
+ (void)handle;
+ (void)userData;
+ CAmDelegagePtr delegatePoiter = mListDelegatePointers.front();
+ mListDelegatePointers.pop_front();
+ if (delegatePoiter->call(mReturnPipe))
+ {
+ delete delegatePoiter;
+ }
+
+ if (mListDelegatePointers.empty())
+ {
+ return (false);
+ }
+
+ return (true);
+ }
+
+ TAmShPollFired<CAmSerializer> receiverCallbackT;
+ TAmShPollDispatch<CAmSerializer> dispatcherCallbackT;
+ TAmShPollCheck<CAmSerializer> checkerCallbackT;
+
+ /**
+ * The constructor must be called in the mainthread context !
+ * @param iSocketHandler pointer to the CAmSocketHandler
+ */
+ CAmSerializer(CAmSocketHandler *iSocketHandler)
+ : mPipe()
+ , mReturnPipe()
+ , mHandle()
+ , mpSocketHandler(iSocketHandler)
+ , mListDelegatePointers()
+ , receiverCallbackT(this, &CAmSerializer::receiverCallback)
+ , dispatcherCallbackT(this, &CAmSerializer::dispatcherCallback)
+ , checkerCallbackT(this, &CAmSerializer::checkerCallback)
+ {
+ assert(NULL != iSocketHandler);
+
+ if (pipe(mPipe) == -1)
+ {
+ logError("CAmSerializer could not create pipe!");
+ throw std::runtime_error("CAmSerializer Could not open pipe!");
+ }
+
+ if (pipe(mReturnPipe) == -1)
+ {
+ logError("CAmSerializer could not create mReturnPipe!");
+ throw std::runtime_error("CAmSerializer Could not open mReturnPipe!");
+ }
+
+ short event = 0;
+ event |= POLLIN;
+ mpSocketHandler->addFDPoll(mPipe[0], event, NULL, &receiverCallbackT, &checkerCallbackT, &dispatcherCallbackT, NULL, mHandle);
+ }
+
+ ~CAmSerializer()
+ {
+ mpSocketHandler->removeFDPoll(mHandle);
+ close(mPipe[0]);
+ close(mPipe[1]);
+ close(mReturnPipe[0]);
+ close(mReturnPipe[1]);
+ }
+
+};
+
+} /* namespace V2 */
+
+typedef V1::CAmSerializer CAmSerializer DEPRECATED ("You should use V2::CAmSerializer instead!");
} /* namespace am */
#endif /* CAMSERIALIZER_H_ */
diff --git a/AudioManagerUtilities/include/CAmSocketHandler.h b/AudioManagerUtilities/include/CAmSocketHandler.h
index 04d19c3..ffd9e71 100644
--- a/AudioManagerUtilities/include/CAmSocketHandler.h
+++ b/AudioManagerUtilities/include/CAmSocketHandler.h
@@ -33,189 +33,205 @@
#ifdef WITH_TIMERFD
-#include <stdio.h>
-#include <string>
-#include <stdexcept>
-#include <unistd.h>
-#include <fcntl.h>
+# include <stdio.h>
+# include <string>
+# include <stdexcept>
+# include <unistd.h>
+# include <fcntl.h>
-#endif
+#endif // ifdef WITH_TIMERFD
namespace am
{
-#define MAX_NS 1000000000L
+#define MAX_NS 1000000000L
#define MAX_TIMERHANDLE UINT16_MAX
-#define MAX_POLLHANDLE UINT16_MAX
+#define MAX_POLLHANDLE UINT16_MAX
-typedef uint16_t sh_pollHandle_t; //!<this is a handle for a filedescriptor to be used with the SocketHandler
-typedef sh_pollHandle_t sh_timerHandle_t; //!<this is a handle for a timer to be used with the SocketHandler
+typedef uint16_t sh_pollHandle_t; //!< this is a handle for a filedescriptor to be used with the SocketHandler
+typedef sh_pollHandle_t sh_timerHandle_t; //!< this is a handle for a timer to be used with the SocketHandler
/**
- * prototype for poll prepared callback
- */
+ * prototype for poll prepared callback
+ */
class IAmShPollPrepare
{
public:
- virtual void Call(const sh_pollHandle_t handle, void* userData) = 0;
+ virtual void Call(const sh_pollHandle_t handle, void *userData) = 0;
+
virtual ~IAmShPollPrepare() {}
};
/**
- * prototype for poll fired callback
- */
+ * prototype for poll fired callback
+ */
class IAmShPollFired
{
public:
- virtual void Call(const pollfd pollfd, const sh_pollHandle_t handle, void* userData) = 0;
- virtual ~ IAmShPollFired() {}
+ virtual void Call(const pollfd pollfd, const sh_pollHandle_t handle, void *userData) = 0;
+
+ virtual ~IAmShPollFired() {}
};
/**
- * prototype for poll check callback
- */
+ * prototype for poll check callback
+ */
class IAmShPollCheck
{
public:
- virtual bool Call(const sh_pollHandle_t handle, void* userData) = 0;
- virtual ~ IAmShPollCheck() {}
+ virtual bool Call(const sh_pollHandle_t handle, void *userData) = 0;
+
+ virtual ~IAmShPollCheck() {}
};
/**
- * prototype for dispatch callback
- */
+ * prototype for dispatch callback
+ */
class IAmShPollDispatch
{
public:
- virtual bool Call(const sh_pollHandle_t handle, void* userData) = 0;
- virtual ~ IAmShPollDispatch() {}
+ virtual bool Call(const sh_pollHandle_t handle, void *userData) = 0;
+
+ virtual ~IAmShPollDispatch() {}
};
/**
- * prototype for the timer callback
- */
+ * prototype for the timer callback
+ */
class IAmShTimerCallBack
{
public:
- IAmShTimerCallBack(){};
- virtual void Call(const sh_timerHandle_t handle, void* userData) = 0;
+ IAmShTimerCallBack(){}
+ virtual void Call(const sh_timerHandle_t handle, void *userData) = 0;
+
virtual ~IAmShTimerCallBack(){}
};
/**make private, not public
- * template for a callback
- */
-template<class TClass> class TAmShPollFired: public IAmShPollFired
+ * template for a callback
+ */
+template<class TClass>
+class TAmShPollFired : public IAmShPollFired
{
private:
- TClass* mInstance;
- void (TClass::*mFunction)(const pollfd pollfd, const sh_pollHandle_t handle, void* userData);
+ TClass *mInstance;
+ void (TClass::*mFunction)(const pollfd pollfd, const sh_pollHandle_t handle, void *userData);
public:
- TAmShPollFired(TClass* instance, void (TClass::*function)(const pollfd pollfd, const sh_pollHandle_t handle, void* userData)) :
- mInstance(instance),
- mFunction(function)
+ TAmShPollFired(TClass *instance, void (TClass::*function)(const pollfd pollfd, const sh_pollHandle_t handle, void *userData))
+ : mInstance(instance)
+ , mFunction(function)
{}
- virtual void Call(const pollfd pollfd, const sh_pollHandle_t handle, void* userData)
+ virtual void Call(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
{
(*mInstance.*mFunction)(pollfd, handle, userData);
}
+
};
/**
- * template for a callback
- */
-template<class TClass> class TAmShPollCheck: public IAmShPollCheck
+ * template for a callback
+ */
+template<class TClass>
+class TAmShPollCheck : public IAmShPollCheck
{
private:
- TClass* mInstance;
- bool (TClass::*mFunction)(const sh_pollHandle_t handle, void* userData);
+ TClass *mInstance;
+ bool (TClass::*mFunction)(const sh_pollHandle_t handle, void *userData);
public:
- TAmShPollCheck(TClass* instance, bool (TClass::*function)(const sh_pollHandle_t handle, void* userData)) :
- mInstance(instance),
- mFunction(function)
+ TAmShPollCheck(TClass *instance, bool (TClass::*function)(const sh_pollHandle_t handle, void *userData))
+ : mInstance(instance)
+ , mFunction(function)
{}
- virtual bool Call(const sh_pollHandle_t handle, void* userData)
+ virtual bool Call(const sh_pollHandle_t handle, void *userData)
{
return ((*mInstance.*mFunction)(handle, userData));
}
+
};
/**
- * template for a callback
- */
-template<class TClass> class TAmShPollDispatch: public IAmShPollDispatch
+ * template for a callback
+ */
+template<class TClass>
+class TAmShPollDispatch : public IAmShPollDispatch
{
private:
- TClass* mInstance;
- bool (TClass::*mFunction)(const sh_pollHandle_t handle, void* userData);
+ TClass *mInstance;
+ bool (TClass::*mFunction)(const sh_pollHandle_t handle, void *userData);
public:
- TAmShPollDispatch(TClass* instance, bool (TClass::*function)(const sh_pollHandle_t handle, void* userData)) :
- mInstance(instance),
- mFunction(function)
+ TAmShPollDispatch(TClass *instance, bool (TClass::*function)(const sh_pollHandle_t handle, void *userData))
+ : mInstance(instance)
+ , mFunction(function)
{}
- virtual bool Call(const sh_pollHandle_t handle, void* userData)
+ virtual bool Call(const sh_pollHandle_t handle, void *userData)
{
return ((*mInstance.*mFunction)(handle, userData));
}
+
};
/**
- * template to create the functor for a class
- */
-template<class TClass> class TAmShTimerCallBack: public IAmShTimerCallBack
+ * template to create the functor for a class
+ */
+template<class TClass>
+class TAmShTimerCallBack : public IAmShTimerCallBack
{
private:
- TClass* mInstance;
- void (TClass::*mFunction)(sh_timerHandle_t handle, void* userData);
+ TClass *mInstance;
+ void (TClass::*mFunction)(sh_timerHandle_t handle, void *userData);
public:
- TAmShTimerCallBack(TClass* instance, void (TClass::*function)(sh_timerHandle_t handle, void* userData)) :
- IAmShTimerCallBack(), mInstance(instance),
- mFunction(function)
+ TAmShTimerCallBack(TClass *instance, void (TClass::*function)(sh_timerHandle_t handle, void *userData))
+ : IAmShTimerCallBack()
+ , mInstance(instance)
+ , mFunction(function)
{}
- virtual void Call(sh_timerHandle_t handle, void* userData)
+ virtual void Call(sh_timerHandle_t handle, void *userData)
{
(*mInstance.*mFunction)(handle, userData);
}
+
};
/**
- * template for a callback
- */
+ * template for a callback
+ */
-template<class TClass> class TAmShPollPrepare: public IAmShPollPrepare
+template<class TClass>
+class TAmShPollPrepare : public IAmShPollPrepare
{
private:
- TClass* mInstance;
- void (TClass::*mFunction)(const sh_pollHandle_t handle, void* userData);
+ TClass *mInstance;
+ void (TClass::*mFunction)(const sh_pollHandle_t handle, void *userData);
public:
- TAmShPollPrepare(TClass* instance, void (TClass::*function)(const sh_pollHandle_t handle, void* userData)) :
- mInstance(instance),
- mFunction(function)
+ TAmShPollPrepare(TClass *instance, void (TClass::*function)(const sh_pollHandle_t handle, void *userData))
+ : mInstance(instance)
+ , mFunction(function)
{}
- virtual void Call(const sh_pollHandle_t handle, void* userData)
+ virtual void Call(const sh_pollHandle_t handle, void *userData)
{
(*mInstance.*mFunction)(handle, userData);
}
+
};
/**
- * The am::CAmSocketHandler implements a mainloop for the AudioManager. Plugins and different parts of the AudioManager add their filedescriptors to the handler
- * to get called on communication of the filedescriptors.\n
- * More information can be found here : \ref mainl
- */
+ * The am::CAmSocketHandler implements a mainloop for the AudioManager. Plugins and different parts of the AudioManager add their filedescriptors to the handler
+ * to get called on communication of the filedescriptors.\n
+ * More information can be found here : \ref mainl
+ */
class CAmSocketHandler
{
- typedef enum:uint8_t
+ typedef enum : uint8_t
{
ADD = 0u, // new, uninitialized element which needs to be added to ppoll array
UPDATE = 1u, // update of event information therefore update ppoll array
@@ -224,49 +240,60 @@ class CAmSocketHandler
INVALID = 4u // uninit element requested to be removed from internal map only
} poll_states_e;
- struct sh_poll_s //!<struct that holds information about polls
+ struct sh_poll_s //!< struct that holds information about polls
{
- sh_pollHandle_t handle; //!<handle to uniquely adress a filedesriptor
- pollfd pollfdValue; //!<the array for polling the filedescriptors
- std::function<void(const sh_pollHandle_t handle, void* userData)> prepareCB; //preperation callback
- std::function<void(const pollfd pollfd, const sh_pollHandle_t handle, void* userData)> firedCB; //fired callback
- std::function<bool(const sh_pollHandle_t handle, void* userData)> checkCB; //check callback
- std::function<bool(const sh_pollHandle_t handle, void* userData)> dispatchCB; //dispatch callback
- void* userData;
+ sh_pollHandle_t handle; //!< handle to uniquely adress a filedesriptor
+ pollfd pollfdValue; //!< the array for polling the filedescriptors
+ std::function<void(const sh_pollHandle_t handle, void *userData)> prepareCB; // preperation callback
+ std::function<void(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)> firedCB; // fired callback
+ std::function<bool(const sh_pollHandle_t handle, void *userData)> checkCB; // check callback
+ std::function<bool(const sh_pollHandle_t handle, void *userData)> dispatchCB; // dispatch callback
+ void *userData;
poll_states_e state;
- sh_poll_s() :
- handle(0), pollfdValue(), prepareCB(), firedCB(), checkCB(), dispatchCB(), userData(0), state(ADD)
+ sh_poll_s()
+ : handle(0)
+ , pollfdValue()
+ , prepareCB()
+ , firedCB()
+ , checkCB()
+ , dispatchCB()
+ , userData(0)
+ , state(ADD)
{}
};
- struct sh_timer_s //!<struct that holds information of timers
+ struct sh_timer_s //!< struct that holds information of timers
{
- sh_timerHandle_t handle; //!<the handle of the timer
-#ifdef WITH_TIMERFD
+ sh_timerHandle_t handle; //!< the handle of the timer
+#ifdef WITH_TIMERFD
int fd;
- itimerspec countdown; //!<the countdown, this value is decreased every time the timer is up
+ itimerspec countdown; //!< the countdown, this value is decreased every time the timer is up
#else
- timespec countdown; //!<the countdown, this value is decreased every time the timer is up
-#endif
- std::function<void(const sh_timerHandle_t handle, void* userData)> callback; //timer callback
- void* userData;
- sh_timer_s() :
- handle(0)
+ timespec countdown; //!< the countdown, this value is decreased every time the timer is up
+#endif
+ std::function<void(const sh_timerHandle_t handle, void *userData)> callback; // timer callback
+ void *userData;
+ sh_timer_s()
+ : handle(0)
#ifdef WITH_TIMERFD
- , fd(-1)
+ , fd(-1)
#endif
- , countdown(), callback(), userData(0)
+ , countdown()
+ , callback()
+ , userData(0)
{}
};
struct sh_signal_s
{
- sh_pollHandle_t handle; //!<handle to uniquely adress a filedesriptor
- std::function<void(const sh_pollHandle_t handle, const signalfd_siginfo & info, void* userData)> callback;
- void* userData;
- sh_signal_s() :
- handle(0), callback(), userData(0)
+ sh_pollHandle_t handle; //!< handle to uniquely adress a filedesriptor
+ std::function<void(const sh_pollHandle_t handle, const signalfd_siginfo &info, void *userData)> callback;
+ void *userData;
+ sh_signal_s()
+ : handle(0)
+ , callback()
+ , userData(0)
{}
};
@@ -275,17 +302,19 @@ class CAmSocketHandler
std::set<sh_pollHandle_t> pollHandles;
uint16_t limit;
uint16_t lastUsedID;
- sh_identifier_s(const uint16_t pollLimit = UINT16_MAX) :
- pollHandles(), limit(pollLimit), lastUsedID(0)
+ sh_identifier_s(const uint16_t pollLimit = UINT16_MAX)
+ : pollHandles()
+ , limit(pollLimit)
+ , lastUsedID(0)
{}
};
- typedef std::reverse_iterator<sh_timer_s> rListTimerIter; //!<typedef for reverseiterator on timer lists
- typedef std::vector<pollfd> VectorPollfd_t; //!<vector of filedescriptors
- typedef std::map<int, sh_poll_s> MapShPoll_t; //!<list for the callbacks
- typedef std::vector<sh_signal_s> VectorSignalHandlers_t; //!<list for the callbacks
+ typedef std::reverse_iterator<sh_timer_s> rListTimerIter; //!< typedef for reverseiterator on timer lists
+ typedef std::vector<pollfd> VectorPollfd_t; //!< vector of filedescriptors
+ typedef std::map<int, sh_poll_s> MapShPoll_t; //!< list for the callbacks
+ typedef std::vector<sh_signal_s> VectorSignalHandlers_t; //!< list for the callbacks
- typedef enum:uint8_t
+ typedef enum : uint8_t
{
NO_ERROR = 0u, // OK
FD_ERROR = 1u, // Invalid file descriptor
@@ -293,53 +322,55 @@ class CAmSocketHandler
} internal_codes_e;
typedef uint8_t internal_codes_t;
- int mEventFd;
- int mSignalFd;
- bool mDispatchDone; //this starts / stops the mainloop
- MapShPoll_t mMapShPoll; //!<list that holds all information for the ppoll
+ int mEventFd;
+ int mSignalFd;
+ bool mDispatchDone; // this starts / stops the mainloop
+ MapShPoll_t mMapShPoll; //!< list that holds all information for the ppoll
- sh_identifier_s mSetPollKeys; //!A set of all used ppoll keys
- sh_identifier_s mSetTimerKeys; //!A set of all used timer keys
- std::list<sh_timer_s> mListTimer; //!<list of all timers
+ sh_identifier_s mSetPollKeys; //! A set of all used ppoll keys
+ sh_identifier_s mSetTimerKeys; //! A set of all used timer keys
+ std::list<sh_timer_s> mListTimer; //!< list of all timers
#ifndef WITH_TIMERFD
- std::list<sh_timer_s> mListActiveTimer; //!<list of all currently active timers
+ std::list<sh_timer_s> mListActiveTimer; //!< list of all currently active timers
#endif
- sh_identifier_s mSetSignalhandlerKeys; //!A set of all used signal handler keys
+ sh_identifier_s mSetSignalhandlerKeys; //! A set of all used signal handler keys
VectorSignalHandlers_t mSignalHandlers;
- internal_codes_t mInternalCodes;
+ internal_codes_t mInternalCodes;
#ifndef WITH_TIMERFD
- timespec mStartTime; //!<here the actual time is saved for timecorrection
+ timespec mStartTime; //!< here the actual time is saved for timecorrection
#endif
private:
bool fdIsValid(const int fd) const;
- void wakeupWorker(const std::string & func, const uint64_t value = 1u);
+ void wakeupWorker(const std::string &func, const uint64_t value = 1u);
+
+ timespec *insertTime(timespec &buffertime);
- timespec* insertTime(timespec& buffertime);
-#ifdef WITH_TIMERFD
- am_Error_e createTimeFD(const itimerspec & timeouts, int & fd);
-#else
+#ifdef WITH_TIMERFD
+ am_Error_e createTimeFD(const itimerspec &timeouts, int &fd);
+
+#else
void timerUp();
void timerCorrection();
/**
- * compares countdown values
- * @param a
- * @param b
- * @return true if b greater a
- */
- inline static bool compareCountdown(const sh_timer_s& a, const sh_timer_s& b)
+ * compares countdown values
+ * @param a
+ * @param b
+ * @return true if b greater a
+ */
+ inline static bool compareCountdown(const sh_timer_s &a, const sh_timer_s &b)
{
return ((a.countdown.tv_sec == b.countdown.tv_sec) ? (a.countdown.tv_nsec < b.countdown.tv_nsec) : (a.countdown.tv_sec < b.countdown.tv_sec));
}
/**
- * Subtracts b from a
- * @param a
- * @param b
- * @return subtracted value
- */
- inline static timespec timespecSub(const timespec& a, const timespec& b)
+ * Subtracts b from a
+ * @param a
+ * @param b
+ * @return subtracted value
+ */
+ inline static timespec timespecSub(const timespec &a, const timespec &b)
{
timespec result;
@@ -360,136 +391,149 @@ private:
result.tv_nsec = a.tv_nsec - b.tv_nsec;
}
}
+
return (result);
}
/**
- * adds timespec values
- * @param a
- * @param b
- * @return the added values
- */
- inline timespec timespecAdd(const timespec& a, const timespec& b)
+ * adds timespec values
+ * @param a
+ * @param b
+ * @return the added values
+ */
+ inline timespec timespecAdd(const timespec &a, const timespec &b)
{
timespec result;
- result.tv_sec = a.tv_sec + b.tv_sec;
+ result.tv_sec = a.tv_sec + b.tv_sec;
result.tv_nsec = a.tv_nsec + b.tv_nsec;
if (result.tv_nsec >= MAX_NS)
{
result.tv_sec++;
result.tv_nsec = result.tv_nsec - MAX_NS;
}
+
return (result);
}
/**
- * comapares timespec values
- * @param a
- * @param b
- * @return
- */
- inline int timespecCompare(const timespec& a, const timespec& b)
+ * comapares timespec values
+ * @param a
+ * @param b
+ * @return
+ */
+ inline int timespecCompare(const timespec &a, const timespec &b)
{
- //less
+ // less
if (a.tv_sec < b.tv_sec)
- return (-1);
- //greater
+ {
+ return (-1);
+ }
+ // greater
else if (a.tv_sec > b.tv_sec)
- return (1);
- //less
+ {
+ return (1);
+ }
+ // less
else if (a.tv_nsec < b.tv_nsec)
- return (-1);
- //greater
+ {
+ return (-1);
+ }
+ // greater
else if (a.tv_nsec > b.tv_nsec)
- return (1);
- //equal
+ {
+ return (1);
+ }
+
+ // equal
return (0);
}
-#endif
+#endif // ifdef WITH_TIMERFD
/**
- * functor to prepare all fire events
- * @param a
- * @return
- */
- inline static void prepare(sh_poll_s& row);
+ * functor to prepare all fire events
+ * @param a
+ * @return
+ */
+ inline static void prepare(sh_poll_s &row);
/**
- * functor to return all fired events
- * @param a
- * @return
- */
- inline static void fire(const sh_poll_s& a);
+ * functor to return all fired events
+ * @param a
+ * @return
+ */
+ inline static void fire(const sh_poll_s &a);
/**
- * functor to help find the items that do not need dispatching
- * @param a
- * @return
- */
- inline static bool noDispatching(const sh_poll_s* a);
+ * functor to help find the items that do not need dispatching
+ * @param a
+ * @return
+ */
+ inline static bool noDispatching(const sh_poll_s *a);
/**
- * checks if dispatching is already finished
- * @param a
- * @return
- */
- inline static bool dispatchingFinished(const sh_poll_s* a);
+ * checks if dispatching is already finished
+ * @param a
+ * @return
+ */
+ inline static bool dispatchingFinished(const sh_poll_s *a);
/**
- * timer fire callback
- * @param a
- * @return
- */
- inline static void callTimer(sh_timer_s& a);
+ * timer fire callback
+ * @param a
+ * @return
+ */
+ inline static void callTimer(sh_timer_s &a);
/**
- * next handle id
- * @param std::set handles
- * @return handle
- */
- bool nextHandle(sh_identifier_s & handle);
+ * next handle id
+ * @param std::set handles
+ * @return handle
+ */
+ bool nextHandle(sh_identifier_s &handle);
public:
CAmSocketHandler();
~CAmSocketHandler();
-
- /**
+
+ /**
* install the signal fd
*/
- am_Error_e listenToSignals(const std::vector<uint8_t> & listSignals);
-
- am_Error_e addFDPoll(const int fd, const short event, std::function<void(const sh_pollHandle_t handle, void* userData)> prepare, std::function<void(const pollfd pollfd, const sh_pollHandle_t handle, void* userData)> fired,
- std::function<bool(const sh_pollHandle_t handle, void* userData)> check, std::function<bool(const sh_pollHandle_t handle, void* userData)> dispatch, void* userData, sh_pollHandle_t& handle);
+ am_Error_e listenToSignals(const std::vector<uint8_t> &listSignals);
+
+ am_Error_e addFDPoll(const int fd, const short event, std::function<void(const sh_pollHandle_t handle, void *userData)> prepare, std::function<void(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)> fired,
+ std::function<bool(const sh_pollHandle_t handle, void *userData)> check, std::function<bool(const sh_pollHandle_t handle, void *userData)> dispatch, void *userData, sh_pollHandle_t &handle);
- am_Error_e addFDPoll(const int fd, const short event, IAmShPollPrepare *prepare, IAmShPollFired *fired, IAmShPollCheck *check, IAmShPollDispatch *dispatch, void* userData, sh_pollHandle_t& handle);
+ am_Error_e addFDPoll(const int fd, const short event, IAmShPollPrepare *prepare, IAmShPollFired *fired, IAmShPollCheck *check, IAmShPollDispatch *dispatch, void *userData, sh_pollHandle_t &handle);
am_Error_e removeFDPoll(const sh_pollHandle_t handle);
am_Error_e updateEventFlags(const sh_pollHandle_t handle, const short events);
- am_Error_e addSignalHandler(std::function<void(const sh_pollHandle_t handle, const signalfd_siginfo & info, void* userData)> callback, sh_pollHandle_t& handle, void * userData);
+ am_Error_e addSignalHandler(std::function<void(const sh_pollHandle_t handle, const signalfd_siginfo &info, void *userData)> callback, sh_pollHandle_t &handle, void *userData);
am_Error_e removeSignalHandler(const sh_pollHandle_t handle);
- am_Error_e addTimer(const timespec & timeouts, IAmShTimerCallBack* callback, sh_timerHandle_t& handle, void * userData,
+
+ am_Error_e addTimer(const timespec &timeouts, IAmShTimerCallBack *callback, sh_timerHandle_t & handle, void *userData,
#ifndef WITH_TIMERFD
- const bool __attribute__((__unused__)) repeats = false
+ const bool __attribute__((__unused__)) repeats = false
#else
- const bool repeats = false
+ const bool repeats = false
#endif
- );
- am_Error_e addTimer(const timespec & timeouts, std::function<void(const sh_timerHandle_t handle, void* userData)> callback, sh_timerHandle_t& handle, void* userData,
+ );
+ am_Error_e addTimer(const timespec &timeouts, std::function<void(const sh_timerHandle_t handle, void *userData)> callback, sh_timerHandle_t & handle, void *userData,
#ifndef WITH_TIMERFD
- const bool __attribute__((__unused__)) repeats = false
+ const bool __attribute__((__unused__)) repeats = false
#else
- const bool repeats = false
+ const bool repeats = false
#endif
- );
+ );
am_Error_e removeTimer(const sh_timerHandle_t handle);
am_Error_e restartTimer(const sh_timerHandle_t handle);
- am_Error_e updateTimer(const sh_timerHandle_t handle, const timespec & timeouts);
+ am_Error_e updateTimer(const sh_timerHandle_t handle, const timespec &timeouts);
am_Error_e stopTimer(const sh_timerHandle_t handle);
void start_listenting();
void stop_listening();
void exit_mainloop();
-
+
bool fatalErrorOccurred();
+
};
} /* namespace am */
diff --git a/AudioManagerUtilities/include/CAmWatchdog.h b/AudioManagerUtilities/include/CAmWatchdog.h
index 4449c75..bbd2c00 100755..100644
--- a/AudioManagerUtilities/include/CAmWatchdog.h
+++ b/AudioManagerUtilities/include/CAmWatchdog.h
@@ -35,15 +35,16 @@ namespace am
class CAmWatchdog
{
public:
- CAmWatchdog(CAmSocketHandler* CAmSocketHandler);
+ CAmWatchdog(CAmSocketHandler *CAmSocketHandler);
virtual ~CAmWatchdog();
- void startWatchdog(); //!< starts the watchdog by sending ready to systemD
- void timerCallback(sh_timerHandle_t handle, void * userData); //!< the watchdog timer callback
+ void startWatchdog(); //!< starts the watchdog by sending ready to systemD
+ void timerCallback(sh_timerHandle_t handle, void *userData); //!< the watchdog timer callback
+
TAmShTimerCallBack<CAmWatchdog> TimerCallback;
private:
- CAmSocketHandler* mpCAmSocketHandler; //!< pointer to the sockethandler
- sh_timerHandle_t mHandle; //!< handle of the timer
+ CAmSocketHandler *mpCAmSocketHandler; //!< pointer to the sockethandler
+ sh_timerHandle_t mHandle; //!< handle of the timer
};
} /* namespace am */
diff --git a/AudioManagerUtilities/include/TAmPluginTemplate.h b/AudioManagerUtilities/include/TAmPluginTemplate.h
index 95523f1..b030123 100644
--- a/AudioManagerUtilities/include/TAmPluginTemplate.h
+++ b/AudioManagerUtilities/include/TAmPluginTemplate.h
@@ -37,24 +37,25 @@ namespace am
* @param libraryHandle the handle to the library that gets returned
* @return returns the pointer to the class to be loaded
*/
-template<class T> T* getCreateFunction(const std::string& libname, void*& libraryHandle)
+template<class T>
+T *getCreateFunction(const std::string &libname, void * &libraryHandle)
{
- logInfo("getCreateFunction : Trying to load library with name: ",libname);
+ logInfo("getCreateFunction : Trying to load library with name: ", libname);
// cut off directories
- char* fileWithPath = const_cast<char*>(libname.c_str());
- std::string libFileName = basename(fileWithPath);
+ char *fileWithPath = const_cast<char *>(libname.c_str());
+ std::string libFileName = basename(fileWithPath);
// cut off "lib" in front and cut off .so end"
std::string createFunctionName = libFileName.substr(3, libFileName.length() - 6) + "Factory";
// open library
dlerror(); // Clear any existing error
- libraryHandle = dlopen(libname.c_str(), RTLD_LAZY );
- const char* dlopen_error = dlerror();
+ libraryHandle = dlopen(libname.c_str(), RTLD_LAZY);
+ const char *dlopen_error = dlerror();
if (!libraryHandle || dlopen_error)
{
- logError("getCreateFunction : dlopen failed",dlopen_error);
+ logError("getCreateFunction : dlopen failed", dlopen_error);
return (0);
}
@@ -63,8 +64,8 @@ template<class T> T* getCreateFunction(const std::string& libname, void*& librar
union
{
- void* voidPointer;
- T* typedPointer;
+ void *voidPointer;
+ T *typedPointer;
} functionPointer;
// Note: direct cast is not allowed by ISO C++. e.g.
@@ -72,17 +73,18 @@ template<class T> T* getCreateFunction(const std::string& libname, void*& librar
// compiler warning: "forbids casting between pointer-to-function and pointer-to-object"
functionPointer.voidPointer = dlsym(libraryHandle, createFunctionName.c_str());
- T* createFunction = functionPointer.typedPointer;
+ T *createFunction = functionPointer.typedPointer;
- const char* dlsym_error = dlerror();
+ const char *dlsym_error = dlerror();
if (!createFunction || dlsym_error)
{
- logError("getCreateFunction: Failed to load shared lib entry point",dlsym_error);
+ logError("getCreateFunction: Failed to load shared lib entry point", dlsym_error);
}
else
{
logInfo("getCreateFunction : loaded successfully plugin", createFunctionName);
}
+
return (createFunction);
}
@@ -91,13 +93,14 @@ template<class T> T* getCreateFunction(const std::string& libname, void*& librar
* @param libname the full path to the library to be loaded
*
*/
-template<class T> T* getDestroyFunction(const std::string& libname,void* libraryHandle)
+template<class T>
+T *getDestroyFunction(const std::string &libname, void *libraryHandle)
{
- logInfo("destroy : Trying to destroy : ",libname);
+ logInfo("destroy : Trying to destroy : ", libname);
// cut off directories
- char* fileWithPath = const_cast<char*>(libname.c_str());
- std::string libFileName = basename(fileWithPath);
+ char *fileWithPath = const_cast<char *>(libname.c_str());
+ std::string libFileName = basename(fileWithPath);
// cut off "lib" in front and cut off .so end"
std::string destroyFunctionName = "destroy" + libFileName.substr(3, libFileName.length() - 6);
@@ -106,23 +109,24 @@ template<class T> T* getDestroyFunction(const std::string& libname,void* library
dlerror(); // Clear any existing error
union
{
- void* voidPointer;
- T* typedPointer;
+ void *voidPointer;
+ T *typedPointer;
} functionPointer;
functionPointer.voidPointer = dlsym(libraryHandle, destroyFunctionName.c_str());
- T* destroyFunction = functionPointer.typedPointer;
+ T *destroyFunction = functionPointer.typedPointer;
- const char* dlsym_error = dlerror();
+ const char *dlsym_error = dlerror();
if (!destroyFunction || dlsym_error)
{
logError("getDestroyFunction: Failed to load shared lib entry point function name=",
- destroyFunctionName, "error=",dlsym_error);
+ destroyFunctionName, "error=", dlsym_error);
}
else
{
logInfo("getDestroyFunction: loaded successfully plugin", destroyFunctionName);
}
+
return (destroyFunction);
}
diff --git a/AudioManagerUtilities/src/CAmCommandLineSingleton.cpp b/AudioManagerUtilities/src/CAmCommandLineSingleton.cpp
index 1170c31..493b842 100644
--- a/AudioManagerUtilities/src/CAmCommandLineSingleton.cpp
+++ b/AudioManagerUtilities/src/CAmCommandLineSingleton.cpp
@@ -19,41 +19,46 @@
namespace am {
-static TCLAP::CmdLine* pSingleCmdLine = NULL;
+static TCLAP::CmdLine *pSingleCmdLine = NULL;
-CAmCommandLineSingleton::CAmCommandLineSingleton() {
- // TODO Auto-generated constructor stub
+CAmCommandLineSingleton::CAmCommandLineSingleton()
+{
+ // TODO Auto-generated constructor stub
}
-TCLAP::CmdLine* CAmCommandLineSingleton::instanciateOnce(const std::string& message,
- const char delimiter,
- const std::string& version,
- bool helpAndVersion)
+TCLAP::CmdLine *CAmCommandLineSingleton::instanciateOnce(const std::string &message,
+ const char delimiter,
+ const std::string &version,
+ bool helpAndVersion)
{
- if(NULL==pSingleCmdLine)
- {
- pSingleCmdLine = new TCLAP::CmdLine(message,delimiter,version,helpAndVersion);
- }
- return pSingleCmdLine;
+ if (NULL == pSingleCmdLine)
+ {
+ pSingleCmdLine = new TCLAP::CmdLine(message, delimiter, version, helpAndVersion);
+ }
+
+ return pSingleCmdLine;
}
-TCLAP::CmdLine* CAmCommandLineSingleton::instance()
+TCLAP::CmdLine *CAmCommandLineSingleton::instance()
{
- assert(NULL!=pSingleCmdLine);
- return pSingleCmdLine;
+ assert(NULL != pSingleCmdLine);
+ return pSingleCmdLine;
}
void CAmCommandLineSingleton::deleteInstance()
{
- if (pSingleCmdLine)
- delete pSingleCmdLine;
-
- pSingleCmdLine=NULL;
+ if (pSingleCmdLine)
+ {
+ delete pSingleCmdLine;
+ }
+
+ pSingleCmdLine = NULL;
}
-CAmCommandLineSingleton::~CAmCommandLineSingleton() {
- // TODO Auto-generated destructor stub
+CAmCommandLineSingleton::~CAmCommandLineSingleton()
+{
+ // TODO Auto-generated destructor stub
}
} /* namespace am */
diff --git a/AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp b/AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp
index f9cefa6..e22dcd6 100644
--- a/AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp
+++ b/AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp
@@ -30,115 +30,133 @@
#include "CAmDltWrapper.h"
#include "CAmCommonAPIWrapper.h"
-
namespace am
{
-static CAmCommonAPIWrapper* pSingleCommonAPIInstance = NULL;
+static CAmCommonAPIWrapper *pSingleCommonAPIInstance = NULL;
+
+CAmCommonAPIWrapper::CAmCommonAPIWrapper(CAmSocketHandler *socketHandler, const std::string &applicationName)
+ : pCommonPrepareCallback(this, &CAmCommonAPIWrapper::commonPrepareCallback)
+ , pCommonDispatchCallback(this, &CAmCommonAPIWrapper::commonDispatchCallback)
+ , pCommonFireCallback(this, &CAmCommonAPIWrapper::commonFireCallback)
+ , pCommonCheckCallback(this, &CAmCommonAPIWrapper::commonCheckCallback)
+ , pCommonTimerCallback(this, &CAmCommonAPIWrapper::commonTimerCallback)
+ , mpSocketHandler(socketHandler)
+ , mWatchToCheck(NULL)
+{
+ assert(NULL != socketHandler);
+// Get the runtime
+ mRuntime = CommonAPI::Runtime::get();
+ assert(NULL != mRuntime);
+ // Create the context
+ if (applicationName.size())
+ {
+ mContext = std::make_shared<CommonAPI::MainLoopContext>(applicationName);
+ }
+ else
+ {
+ mContext = std::make_shared<CommonAPI::MainLoopContext>();
+ }
-CAmCommonAPIWrapper::CAmCommonAPIWrapper(CAmSocketHandler* socketHandler, const std::string & applicationName):
- pCommonPrepareCallback(this,&CAmCommonAPIWrapper::commonPrepareCallback),
- pCommonDispatchCallback(this, &CAmCommonAPIWrapper::commonDispatchCallback),
- pCommonFireCallback(this, &CAmCommonAPIWrapper::commonFireCallback),
- pCommonCheckCallback(this, &CAmCommonAPIWrapper::commonCheckCallback),
- pCommonTimerCallback(this, &CAmCommonAPIWrapper::commonTimerCallback),
- mpSocketHandler(socketHandler),
- mWatchToCheck(NULL)
-{
- assert(NULL!=socketHandler);
-//Get the runtime
- mRuntime = CommonAPI::Runtime::get();
- assert(NULL!=mRuntime);
-
- //Create the context
- if(applicationName.size())
- mContext = std::make_shared<CommonAPI::MainLoopContext>(applicationName);
- else
- mContext = std::make_shared<CommonAPI::MainLoopContext>();
- assert(NULL!=mContext);
- logInfo(__func__,"CommonAPI main loop context with name '", mContext->getName(), "' has been created!");
-
-//Make subscriptions
- mDispatchSourceListenerSubscription = mContext->subscribeForDispatchSources(
- std::bind(&CAmCommonAPIWrapper::registerDispatchSource, this, std::placeholders::_1, std::placeholders::_2),
- std::bind(&CAmCommonAPIWrapper::deregisterDispatchSource, this, std::placeholders::_1));
- mWatchListenerSubscription = mContext->subscribeForWatches(
- std::bind(&CAmCommonAPIWrapper::registerWatch, this, std::placeholders::_1, std::placeholders::_2),
- std::bind(&CAmCommonAPIWrapper::deregisterWatch, this, std::placeholders::_1));
- mTimeoutSourceListenerSubscription = mContext->subscribeForTimeouts(
- std::bind(&CAmCommonAPIWrapper::registerTimeout, this, std::placeholders::_1, std::placeholders::_2),
- std::bind(&CAmCommonAPIWrapper::deregisterTimeout, this, std::placeholders::_1));
+ assert(NULL != mContext);
+ logInfo(__func__, "CommonAPI main loop context with name '", mContext->getName(), "' has been created!");
+
+// Make subscriptions
+ mDispatchSourceListenerSubscription = mContext->subscribeForDispatchSources(
+ std::bind(&CAmCommonAPIWrapper::registerDispatchSource, this, std::placeholders::_1, std::placeholders::_2),
+ std::bind(&CAmCommonAPIWrapper::deregisterDispatchSource, this, std::placeholders::_1));
+ mWatchListenerSubscription = mContext->subscribeForWatches(
+ std::bind(&CAmCommonAPIWrapper::registerWatch, this, std::placeholders::_1, std::placeholders::_2),
+ std::bind(&CAmCommonAPIWrapper::deregisterWatch, this, std::placeholders::_1));
+ mTimeoutSourceListenerSubscription = mContext->subscribeForTimeouts(
+ std::bind(&CAmCommonAPIWrapper::registerTimeout, this, std::placeholders::_1, std::placeholders::_2),
+ std::bind(&CAmCommonAPIWrapper::deregisterTimeout, this, std::placeholders::_1));
}
CAmCommonAPIWrapper::~CAmCommonAPIWrapper()
{
- mContext->unsubscribeForDispatchSources(mDispatchSourceListenerSubscription);
- mContext->unsubscribeForWatches(mWatchListenerSubscription);
- mContext->unsubscribeForTimeouts(mTimeoutSourceListenerSubscription);
- mContext.reset();
- mpSocketHandler = NULL;
- mWatchToCheck = NULL;
+ mContext->unsubscribeForDispatchSources(mDispatchSourceListenerSubscription);
+ mContext->unsubscribeForWatches(mWatchListenerSubscription);
+ mContext->unsubscribeForTimeouts(mTimeoutSourceListenerSubscription);
+ mContext.reset();
+ mpSocketHandler = NULL;
+ mWatchToCheck = NULL;
}
-CAmCommonAPIWrapper* CAmCommonAPIWrapper::instantiateOnce(CAmSocketHandler* socketHandler, const std::string & applicationName)
+CAmCommonAPIWrapper *CAmCommonAPIWrapper::instantiateOnce(CAmSocketHandler *socketHandler, const std::string &applicationName)
{
- if(NULL==pSingleCommonAPIInstance)
- {
- if(NULL==socketHandler)
- throw std::runtime_error(std::string("Expected a valid socket handler. The socket handler pointer must not be NULL."));
- else
- pSingleCommonAPIInstance = new CAmCommonAPIWrapper(socketHandler, applicationName);
- }
- else
- throw std::logic_error(std::string("The singleton instance has been already instantiated. This method should be called only once."));
- return pSingleCommonAPIInstance;
+ if (NULL == pSingleCommonAPIInstance)
+ {
+ if (NULL == socketHandler)
+ {
+ throw std::runtime_error(std::string("Expected a valid socket handler. The socket handler pointer must not be NULL."));
+ }
+ else
+ {
+ pSingleCommonAPIInstance = new CAmCommonAPIWrapper(socketHandler, applicationName);
+ }
+ }
+ else
+ {
+ throw std::logic_error(std::string("The singleton instance has been already instantiated. This method should be called only once."));
+ }
+
+ return pSingleCommonAPIInstance;
}
void CAmCommonAPIWrapper::deleteInstance()
{
- try
- {
- if (pSingleCommonAPIInstance!=NULL)
- delete pSingleCommonAPIInstance;
-
- pSingleCommonAPIInstance=NULL;
- }
- catch(...)
- {
- logError(__func__,"error while deleting CAPIWrapper instance");
- }
+ try
+ {
+ if (pSingleCommonAPIInstance != NULL)
+ {
+ delete pSingleCommonAPIInstance;
+ }
+
+ pSingleCommonAPIInstance = NULL;
+ }
+ catch (...)
+ {
+ logError(__func__, "error while deleting CAPIWrapper instance");
+ }
}
-CAmCommonAPIWrapper* CAmCommonAPIWrapper::getInstance()
+CAmCommonAPIWrapper *CAmCommonAPIWrapper::getInstance()
{
- assert(NULL!=pSingleCommonAPIInstance);
- return pSingleCommonAPIInstance;
+ assert(NULL != pSingleCommonAPIInstance);
+ return pSingleCommonAPIInstance;
}
bool CAmCommonAPIWrapper::commonDispatchCallback(const sh_pollHandle_t handle, void *userData)
{
- (void) handle;
- (void) userData;
+ (void)handle;
+ (void)userData;
- std::list<CommonAPI::DispatchSource*>::iterator iterator(mSourcesToDispatch.begin());
- for(;iterator!=mSourcesToDispatch.end();)
+ std::list<CommonAPI::DispatchSource *>::iterator iterator(mSourcesToDispatch.begin());
+ for (; iterator != mSourcesToDispatch.end();)
{
- CommonAPI::DispatchSource* source = *iterator;
- if (!source->dispatch()) {
- iterator=mSourcesToDispatch.erase(iterator);
+ CommonAPI::DispatchSource *source = *iterator;
+ if (!source->dispatch())
+ {
+ iterator = mSourcesToDispatch.erase(iterator);
}
else
+ {
iterator++;
+ }
}
+
if (!mSourcesToDispatch.empty())
+ {
return (true);
+ }
return false;
}
bool CAmCommonAPIWrapper::commonCheckCallback(const sh_pollHandle_t, void *)
{
- std::vector<CommonAPI::DispatchSource*> vecDispatch=mWatchToCheck->getDependentDispatchSources();
+ std::vector<CommonAPI::DispatchSource *> vecDispatch = mWatchToCheck->getDependentDispatchSources();
mSourcesToDispatch.insert(mSourcesToDispatch.end(), vecDispatch.begin(), vecDispatch.end());
return (mWatchToCheck || !mSourcesToDispatch.empty());
@@ -146,54 +164,59 @@ bool CAmCommonAPIWrapper::commonCheckCallback(const sh_pollHandle_t, void *)
void CAmCommonAPIWrapper::commonFireCallback(const pollfd pollfd, const sh_pollHandle_t, void *)
{
- mWatchToCheck=NULL;
+ mWatchToCheck = NULL;
try
{
- mWatchToCheck=mMapWatches.at(pollfd.fd);
+ mWatchToCheck = mMapWatches.at(pollfd.fd);
}
- catch (const std::out_of_range& error) {
- logInfo(__PRETTY_FUNCTION__,error.what());
- return;
+ catch (const std::out_of_range &error)
+ {
+ logInfo(__PRETTY_FUNCTION__, error.what());
+ return;
}
mWatchToCheck->dispatch(pollfd.revents);
}
-void CAmCommonAPIWrapper::commonPrepareCallback(const sh_pollHandle_t, void*)
+void CAmCommonAPIWrapper::commonPrepareCallback(const sh_pollHandle_t, void *)
{
for (auto dispatchSourceIterator = mRegisteredDispatchSources.begin();
- dispatchSourceIterator != mRegisteredDispatchSources.end();
- dispatchSourceIterator++)
+ dispatchSourceIterator != mRegisteredDispatchSources.end();
+ dispatchSourceIterator++)
{
int64_t dispatchTimeout(CommonAPI::TIMEOUT_INFINITE);
- if(dispatchSourceIterator->second->prepare(dispatchTimeout))
+ if (dispatchSourceIterator->second->prepare(dispatchTimeout))
{
- while (dispatchSourceIterator->second->dispatch());
+ while (dispatchSourceIterator->second->dispatch())
+ {
+ }
}
}
}
-void CAmCommonAPIWrapper::registerDispatchSource(CommonAPI::DispatchSource* dispatchSource, const CommonAPI::DispatchPriority dispatchPriority)
+void CAmCommonAPIWrapper::registerDispatchSource(CommonAPI::DispatchSource *dispatchSource, const CommonAPI::DispatchPriority dispatchPriority)
{
mRegisteredDispatchSources.insert({dispatchPriority, dispatchSource});
}
-void CAmCommonAPIWrapper::deregisterDispatchSource(CommonAPI::DispatchSource* dispatchSource)
+void CAmCommonAPIWrapper::deregisterDispatchSource(CommonAPI::DispatchSource *dispatchSource)
{
- for(auto dispatchSourceIterator = mRegisteredDispatchSources.begin();
- dispatchSourceIterator != mRegisteredDispatchSources.end();
- dispatchSourceIterator++) {
+ for (auto dispatchSourceIterator = mRegisteredDispatchSources.begin();
+ dispatchSourceIterator != mRegisteredDispatchSources.end();
+ dispatchSourceIterator++)
+ {
- if(dispatchSourceIterator->second == dispatchSource) {
+ if (dispatchSourceIterator->second == dispatchSource)
+ {
mRegisteredDispatchSources.erase(dispatchSourceIterator);
break;
}
}
}
-void CAmCommonAPIWrapper::deregisterWatch(CommonAPI::Watch* watch)
+void CAmCommonAPIWrapper::deregisterWatch(CommonAPI::Watch *watch)
{
- for(std::map<int,CommonAPI::Watch*>::iterator iter(mMapWatches.begin());iter!=mMapWatches.end();iter++)
+ for (std::map<int, CommonAPI::Watch *>::iterator iter(mMapWatches.begin()); iter != mMapWatches.end(); iter++)
{
if (iter->second == watch)
{
@@ -203,82 +226,84 @@ void CAmCommonAPIWrapper::deregisterWatch(CommonAPI::Watch* watch)
}
}
-void CAmCommonAPIWrapper::registerTimeout(CommonAPI::Timeout* timeout, const CommonAPI::DispatchPriority)
+void CAmCommonAPIWrapper::registerTimeout(CommonAPI::Timeout *timeout, const CommonAPI::DispatchPriority)
{
timespec pollTimeout;
- int64_t localTimeout = timeout->getTimeoutInterval();
-
- if(CommonAPI::TIMEOUT_INFINITE==localTimeout)//dispatch never
+ int64_t localTimeout = timeout->getTimeoutInterval();
+
+ if (CommonAPI::TIMEOUT_INFINITE == localTimeout)// dispatch never
{
- pollTimeout.tv_sec = localTimeout;
+ pollTimeout.tv_sec = localTimeout;
pollTimeout.tv_nsec = 0;
}
- else if(CommonAPI::TIMEOUT_NONE==localTimeout)//dispatch immediately
+ else if (CommonAPI::TIMEOUT_NONE == localTimeout)// dispatch immediately
{
- pollTimeout.tv_sec = 0;
- pollTimeout.tv_nsec = 1000000;
+ pollTimeout.tv_sec = 0;
+ pollTimeout.tv_nsec = 1000000;
}
- else
+ else
{
- pollTimeout.tv_sec = localTimeout / 1000;
- pollTimeout.tv_nsec = (localTimeout % 1000) * 1000000;
+ pollTimeout.tv_sec = localTimeout / 1000;
+ pollTimeout.tv_nsec = (localTimeout % 1000) * 1000000;
}
- //prepare handle and callback. new is eval, but there is no other choice because we need the pointer!
+ // prepare handle and callback. new is eval, but there is no other choice because we need the pointer!
sh_timerHandle_t handle;
- //add the timer to the pollLoop
+ // add the timer to the pollLoop
am_Error_e error = mpSocketHandler->addTimer(pollTimeout, &pCommonTimerCallback, handle, timeout);
if (error != am_Error_e::E_OK || handle == 0)
{
- logError(__func__,"adding timer failed");
+ logError(__func__, "adding timer failed");
}
else
{
- timerHandles myHandle({handle,timeout});
- mpListTimerhandles.push_back(myHandle);
+ timerHandles myHandle({handle, timeout});
+ mpListTimerhandles.push_back(myHandle);
}
}
-void CAmCommonAPIWrapper::deregisterTimeout(CommonAPI::Timeout* timeout)
+void CAmCommonAPIWrapper::deregisterTimeout(CommonAPI::Timeout *timeout)
{
- for( std::vector<timerHandles>::iterator iter(mpListTimerhandles.begin());iter!=mpListTimerhandles.end();iter++)
+ for ( std::vector<timerHandles>::iterator iter(mpListTimerhandles.begin()); iter != mpListTimerhandles.end(); iter++)
{
- if(iter->timeout==timeout)
+ if (iter->timeout == timeout)
{
mpSocketHandler->removeTimer(iter->handle);
}
}
}
-void CAmCommonAPIWrapper::registerWatch(CommonAPI::Watch* watch, const CommonAPI::DispatchPriority)
+void CAmCommonAPIWrapper::registerWatch(CommonAPI::Watch *watch, const CommonAPI::DispatchPriority)
{
logInfo(__PRETTY_FUNCTION__);
- pollfd pollfd_ (watch->getAssociatedFileDescriptor());
- sh_pollHandle_t handle (0);
+ pollfd pollfd_(watch->getAssociatedFileDescriptor());
+ sh_pollHandle_t handle(0);
am_Error_e error = mpSocketHandler->addFDPoll(pollfd_.fd, pollfd_.events, &pCommonPrepareCallback, &pCommonFireCallback, &pCommonCheckCallback, &pCommonDispatchCallback, watch, handle);
- //if everything is alright, add the watch and the handle to our map so we know this relationship
+ // if everything is alright, add the watch and the handle to our map so we know this relationship
if (error != am_Error_e::E_OK || handle == 0)
{
- logError(__func__,"entering watch failed");
+ logError(__func__, "entering watch failed");
}
else
- mMapWatches.insert(std::make_pair(pollfd_.fd,watch));
+ {
+ mMapWatches.insert(std::make_pair(pollfd_.fd, watch));
+ }
}
void CAmCommonAPIWrapper::commonTimerCallback(sh_timerHandle_t handle, void *)
{
- for( std::vector<timerHandles>::iterator iter(mpListTimerhandles.begin());iter!=mpListTimerhandles.end();iter++)
+ for ( std::vector<timerHandles>::iterator iter(mpListTimerhandles.begin()); iter != mpListTimerhandles.end(); iter++)
{
- if(iter->handle==handle)
+ if (iter->handle == handle)
{
iter->timeout->dispatch();
}
}
}
-CAmCommonAPIWrapper* (*getCAPI)() = CAmCommonAPIWrapper::getInstance;
+CAmCommonAPIWrapper *(*getCAPI)() = CAmCommonAPIWrapper::getInstance;
}
diff --git a/AudioManagerUtilities/src/CAmDbusWrapper.cpp b/AudioManagerUtilities/src/CAmDbusWrapper.cpp
index 1881526..504bf38 100644
--- a/AudioManagerUtilities/src/CAmDbusWrapper.cpp
+++ b/AudioManagerUtilities/src/CAmDbusWrapper.cpp
@@ -38,36 +38,38 @@ namespace am
/**
* introspectio header
*/
-#define ROOT_INTROSPECT_XML \
-DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
-"<node>" \
-"<interface name='org.AudioManager.freedesktop.DBus.Introspectable'>" \
-"<method name='Introspect'>" \
-" <arg name='xml_data' type='s' direction='out'/>" \
-"</method>" \
-"</interface>" \
-
-CAmDbusWrapper* CAmDbusWrapper::mpReference = NULL;
-
-CAmDbusWrapper::CAmDbusWrapper(CAmSocketHandler* socketHandler, DBusBusType type, const std::string& prefix, const std::string& objectPath) :
- pDbusPrepareCallback(this,&CAmDbusWrapper::dbusPrepareCallback),
- pDbusDispatchCallback(this, &CAmDbusWrapper::dbusDispatchCallback),
- pDbusFireCallback(this, &CAmDbusWrapper::dbusFireCallback),
- pDbusCheckCallback(this, &CAmDbusWrapper::dbusCheckCallback),
- pDbusTimerCallback(this, &CAmDbusWrapper::dbusTimerCallback),
- mpDbusConnection(0),
- mDBusError(),
- mListNodes(),
- mpListTimerhandles(),
- mpSocketHandler(socketHandler),
- mDbusType(type)
+#define ROOT_INTROSPECT_XML \
+ DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
+ "<node>" \
+ "<interface name='org.AudioManager.freedesktop.DBus.Introspectable'>" \
+ "<method name='Introspect'>" \
+ " <arg name='xml_data' type='s' direction='out'/>" \
+ "</method>" \
+ "</interface>" \
+
+CAmDbusWrapper *CAmDbusWrapper::mpReference = NULL;
+
+CAmDbusWrapper::CAmDbusWrapper(CAmSocketHandler *socketHandler, DBusBusType type, const std::string &prefix, const std::string &objectPath)
+ : pDbusPrepareCallback(this, &CAmDbusWrapper::dbusPrepareCallback)
+ , pDbusDispatchCallback(this, &CAmDbusWrapper::dbusDispatchCallback)
+ , pDbusFireCallback(this, &CAmDbusWrapper::dbusFireCallback)
+ , pDbusCheckCallback(this, &CAmDbusWrapper::dbusCheckCallback)
+ , pDbusTimerCallback(this, &CAmDbusWrapper::dbusTimerCallback)
+ , mpDbusConnection(0)
+ , mDBusError()
+ , mListNodes()
+ , mpListTimerhandles()
+ , mpSocketHandler(socketHandler)
+ , mDbusType(type)
{
- assert(mpSocketHandler!=0);
+ assert(mpSocketHandler != 0);
dbus_error_init(&mDBusError);
if (!dbus_threads_init_default())
+ {
logError("CAmDbusWrapper::CAmDbusWrapper threads init call failed");
+ }
logInfo("DBusWrapper::DBusWrapper Opening DBus connection of:", prefix, objectPath);
mpDbusConnection = dbus_bus_get(mDbusType, &mDBusError);
@@ -76,6 +78,7 @@ CAmDbusWrapper::CAmDbusWrapper(CAmSocketHandler* socketHandler, DBusBusType type
logError("DBusWrapper::DBusWrapper Error while getting the DBus");
dbus_error_free(&mDBusError);
}
+
if (NULL == mpDbusConnection)
{
logError("DBusWrapper::DBusWrapper DBus Connection is null");
@@ -85,21 +88,21 @@ CAmDbusWrapper::CAmDbusWrapper(CAmSocketHandler* socketHandler, DBusBusType type
logInfo("DBusWrapper::DBusWrapper DBus Connection is", mpDbusConnection);
}
- //then we need to adopt the dbus to our mainloop:
- //first, we are old enought to live longer then the connection:
+ // then we need to adopt the dbus to our mainloop:
+ // first, we are old enought to live longer then the connection:
dbus_connection_set_exit_on_disconnect(mpDbusConnection, FALSE);
- //we do not need the manual dispatching, since it is not allowed to call from a different thread. So leave it uncommented:
- //dbus_connection_set_dispatch_status_function
+ // we do not need the manual dispatching, since it is not allowed to call from a different thread. So leave it uncommented:
+ // dbus_connection_set_dispatch_status_function
- //add watch functions:
+ // add watch functions:
dbus_bool_t watch = dbus_connection_set_watch_functions(mpDbusConnection, addWatch, removeWatch, toogleWatch, this, NULL);
if (!watch)
{
logError("DBusWrapper::DBusWrapper Registering of watch functions failed");
}
- //add timer functions:
+ // add timer functions:
dbus_bool_t timer = dbus_connection_set_timeout_functions(mpDbusConnection, addTimeout, removeTimeout, toggleTimeout, this, NULL);
if (!timer)
{
@@ -112,35 +115,35 @@ CAmDbusWrapper::CAmDbusWrapper(CAmSocketHandler* socketHandler, DBusBusType type
return;
}
- //register callback for Introspectio
+ // register callback for Introspectio
mObjectPathVTable.message_function = CAmDbusWrapper::cbRootIntrospection;
dbus_connection_register_object_path(mpDbusConnection, objectPath.c_str(), &mObjectPathVTable, this);
int ret = dbus_bus_request_name(mpDbusConnection, prefix.c_str(), DBUS_NAME_FLAG_DO_NOT_QUEUE, &mDBusError);
if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER == ret)
{
- logInfo("DBusWrapper::DBusWrapper We own", prefix);
+ logInfo("DBusWrapper::DBusWrapper We own", prefix);
}
else
{
std::ostringstream sserror("DBusWrapper::DBusWrapper ");
switch (ret)
{
- case -1:
- sserror << "Couldn't acquire name " << prefix << ". DBus message: " << mDBusError.message;
- dbus_error_free(&mDBusError);
- break;
- case DBUS_REQUEST_NAME_REPLY_IN_QUEUE:
- sserror << "We are queued for " << prefix;
- break;
- case DBUS_REQUEST_NAME_REPLY_EXISTS:
- sserror << ":-( " << prefix << " already exists!";
- break;
- case DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER:
- sserror << "Eh? We already own " << prefix;
- break;
- default:
- sserror << "Unknown result = " << ret;
- break;
+ case -1:
+ sserror << "Couldn't acquire name " << prefix << ". DBus message: " << mDBusError.message;
+ dbus_error_free(&mDBusError);
+ break;
+ case DBUS_REQUEST_NAME_REPLY_IN_QUEUE:
+ sserror << "We are queued for " << prefix;
+ break;
+ case DBUS_REQUEST_NAME_REPLY_EXISTS:
+ sserror << ":-( " << prefix << " already exists!";
+ break;
+ case DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER:
+ sserror << "Eh? We already own " << prefix;
+ break;
+ default:
+ sserror << "Unknown result = " << ret;
+ break;
}
logError(sserror.str());
@@ -150,12 +153,12 @@ CAmDbusWrapper::CAmDbusWrapper(CAmSocketHandler* socketHandler, DBusBusType type
CAmDbusWrapper::~CAmDbusWrapper()
{
- //close the connection again
+ // close the connection again
logInfo("DBusWrapper::~DBusWrapper Closing DBus connection");
dbus_connection_unref(mpDbusConnection);
- //clean up all timerhandles we created but did not delete before
- std::vector<sh_timerHandle_t*>::iterator it = mpListTimerhandles.begin();
+ // clean up all timerhandles we created but did not delete before
+ std::vector<sh_timerHandle_t *>::iterator it = mpListTimerhandles.begin();
for (; it != mpListTimerhandles.end(); ++it)
{
delete *it;
@@ -170,7 +173,7 @@ CAmDbusWrapper::~CAmDbusWrapper()
* @param userdata pointer to the class that will handle the callback
* @param prefix before the path which is optional
*/
-void CAmDbusWrapper::registerCallback(const DBusObjectPathVTable* vtable, const std::string& path, void* userdata, const std::string& prefix)
+void CAmDbusWrapper::registerCallback(const DBusObjectPathVTable *vtable, const std::string &path, void *userdata, const std::string &prefix)
{
logInfo("DBusWrapper::registerCallback register callback:", path);
@@ -182,16 +185,17 @@ void CAmDbusWrapper::registerCallback(const DBusObjectPathVTable* vtable, const
logError("DBusWrapper::registerCallack error: ", mDBusError.message);
dbus_error_free(&mDBusError);
}
+
mListNodes.push_back(path);
}
/**
-* register signal watch callback to matching rule
-* @param handler pointer to the callback function
-* @param rule signal watch rule like "type='signal',interface='org.genivi.audiomanager.something'"
-* @param userdata userdata
-*/
-void CAmDbusWrapper::registerSignalWatch(DBusHandleMessageFunction handler, const std::string& rule, void* userdata)
+ * register signal watch callback to matching rule
+ * @param handler pointer to the callback function
+ * @param rule signal watch rule like "type='signal',interface='org.genivi.audiomanager.something'"
+ * @param userdata userdata
+ */
+void CAmDbusWrapper::registerSignalWatch(DBusHandleMessageFunction handler, const std::string &rule, void *userdata)
{
logInfo("DBusWrapper::registerSignalWatch register callback:", rule);
dbus_error_init(&mDBusError);
@@ -205,6 +209,7 @@ void CAmDbusWrapper::registerSignalWatch(DBusHandleMessageFunction handler, cons
dbus_error_free(&mDBusError);
}
}
+
/**
* internal callback for the root introspection
* @param conn
@@ -214,28 +219,29 @@ void CAmDbusWrapper::registerSignalWatch(DBusHandleMessageFunction handler, cons
*/
DBusHandlerResult CAmDbusWrapper::cbRootIntrospection(DBusConnection *conn, DBusMessage *msg, void *reference)
{
- //logInfo("DBusWrapper::~cbRootIntrospection called:");
+ // logInfo("DBusWrapper::~cbRootIntrospection called:");
- mpReference = (CAmDbusWrapper*) reference;
+ mpReference = (CAmDbusWrapper *)reference;
std::vector<std::string> nodesList = mpReference->mListNodes;
- DBusMessage * reply;
- DBusMessageIter args;
- dbus_uint32_t serial = 0;
+ DBusMessage *reply;
+ DBusMessageIter args;
+ dbus_uint32_t serial = 0;
if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
{
std::vector<std::string>::iterator nodeIter = nodesList.begin();
- const char *xml = ROOT_INTROSPECT_XML;
- std::stringstream introspect;
+ const char *xml = ROOT_INTROSPECT_XML;
+ std::stringstream introspect;
introspect << std::string(xml);
for (; nodeIter != nodesList.end(); ++nodeIter)
{
introspect << "<node name='" << nodeIter->c_str() << "'/>";
}
+
introspect << "</node>";
reply = dbus_message_new_method_return(msg);
- std::string s = introspect.str();
- const char* string = s.c_str();
+ std::string s = introspect.str();
+ const char *string = s.c_str();
// add the arguments to the reply
dbus_message_iter_init_append(reply, &args);
@@ -249,6 +255,7 @@ DBusHandlerResult CAmDbusWrapper::cbRootIntrospection(DBusConnection *conn, DBus
{
logError("DBusWrapper::~cbRootIntrospection DBUS Out Of Memory!");
}
+
dbus_connection_flush(conn);
// free the reply
dbus_message_unref(reply);
@@ -265,58 +272,65 @@ DBusHandlerResult CAmDbusWrapper::cbRootIntrospection(DBusConnection *conn, DBus
* returns the dbus connection
* @param connection pointer to the connection
*/
-void CAmDbusWrapper::getDBusConnection(DBusConnection *& connection) const
+void CAmDbusWrapper::getDBusConnection(DBusConnection * &connection) const
{
connection = mpDbusConnection;
}
dbus_bool_t CAmDbusWrapper::addWatch(DBusWatch *watch, void *userData)
{
- mpReference = (CAmDbusWrapper*) userData;
- assert(mpReference!=0);
+ mpReference = (CAmDbusWrapper *)userData;
+ assert(mpReference != 0);
return (mpReference->addWatchDelegate(watch, userData));
}
-dbus_bool_t CAmDbusWrapper::addWatchDelegate(DBusWatch * watch, void* userData)
+dbus_bool_t CAmDbusWrapper::addWatchDelegate(DBusWatch *watch, void *userData)
{
- (void) userData;
- int16_t event = 0;
+ (void)userData;
+ int16_t event = 0;
sh_pollHandle_t handle = 0;
- uint flags = dbus_watch_get_flags(watch);
+ uint flags = dbus_watch_get_flags(watch);
/* no watch flags for disabled watches */
if (dbus_watch_get_enabled(watch))
{
if (flags & DBUS_WATCH_READABLE)
+ {
event |= POLLIN;
+ }
+
if (flags & DBUS_WATCH_WRITABLE)
+ {
event |= POLLOUT;
+ }
logInfo("DBusWrapper::addWatchDelegate entered new watch, fd=", dbus_watch_get_unix_fd(watch), "event flag=", event);
am_Error_e error = mpSocketHandler->addFDPoll(dbus_watch_get_unix_fd(watch), event, &pDbusPrepareCallback, &pDbusFireCallback, &pDbusCheckCallback, &pDbusDispatchCallback, watch, handle);
- //if everything is alright, add the watch and the handle to our map so we know this relationship
+ // if everything is alright, add the watch and the handle to our map so we know this relationship
if (error == E_OK && handle != 0)
{
mMapHandleWatch.insert(std::make_pair(watch, handle));
return (true);
}
+
logError("DBusWrapper::addWatchDelegate entering watch failed");
}
+
return (true);
}
void CAmDbusWrapper::removeWatch(DBusWatch *watch, void *userData)
{
- mpReference = (CAmDbusWrapper*) userData;
- assert(mpReference!=0);
+ mpReference = (CAmDbusWrapper *)userData;
+ assert(mpReference != 0);
mpReference->removeWatchDelegate(watch, userData);
}
void CAmDbusWrapper::removeWatchDelegate(DBusWatch *watch, void *userData)
{
- (void) userData;
- std::map<DBusWatch*, sh_pollHandle_t>::iterator iterator = mMapHandleWatch.begin();
+ (void)userData;
+ std::map<DBusWatch *, sh_pollHandle_t>::iterator iterator = mMapHandleWatch.begin();
iterator = mMapHandleWatch.find(watch);
if (iterator != mMapHandleWatch.end())
{
@@ -332,14 +346,14 @@ void CAmDbusWrapper::removeWatchDelegate(DBusWatch *watch, void *userData)
void CAmDbusWrapper::toogleWatch(DBusWatch *watch, void *userData)
{
- mpReference = (CAmDbusWrapper*) userData;
- assert(mpReference!=0);
+ mpReference = (CAmDbusWrapper *)userData;
+ assert(mpReference != 0);
mpReference->toogleWatchDelegate(watch, userData);
}
void CAmDbusWrapper::toogleWatchDelegate(DBusWatch *watch, void *userData)
{
- (void) userData;
+ (void)userData;
int16_t event = 0;
dbus_watch_get_unix_fd(watch);
uint flags = dbus_watch_get_flags(watch);
@@ -347,65 +361,75 @@ void CAmDbusWrapper::toogleWatchDelegate(DBusWatch *watch, void *userData)
if (dbus_watch_get_enabled(watch))
{
if (flags & DBUS_WATCH_READABLE)
+ {
event |= POLLIN;
+ }
+
if (flags & DBUS_WATCH_WRITABLE)
+ {
event |= POLLOUT;
+ }
}
- std::map<DBusWatch*, sh_pollHandle_t>::iterator iterator = mMapHandleWatch.begin();
+
+ std::map<DBusWatch *, sh_pollHandle_t>::iterator iterator = mMapHandleWatch.begin();
iterator = mMapHandleWatch.find(watch);
if (iterator != mMapHandleWatch.end())
+ {
mpSocketHandler->updateEventFlags(iterator->second, event);
+ }
}
-dbus_bool_t CAmDbusWrapper::addTimeout(DBusTimeout *timeout, void* userData)
+dbus_bool_t CAmDbusWrapper::addTimeout(DBusTimeout *timeout, void *userData)
{
- mpReference = (CAmDbusWrapper*) userData;
- assert(mpReference!=0);
+ mpReference = (CAmDbusWrapper *)userData;
+ assert(mpReference != 0);
return (mpReference->addTimeoutDelegate(timeout, userData));
}
-dbus_bool_t CAmDbusWrapper::addTimeoutDelegate(DBusTimeout *timeout, void* userData)
+dbus_bool_t CAmDbusWrapper::addTimeoutDelegate(DBusTimeout *timeout, void *userData)
{
(void)userData;
if (!dbus_timeout_get_enabled(timeout))
+ {
return (false);
+ }
- //calculate the timeout in timeval
+ // calculate the timeout in timeval
timespec pollTimeout;
- int localTimeout = dbus_timeout_get_interval(timeout);
- pollTimeout.tv_sec = localTimeout / 1000;
+ int localTimeout = dbus_timeout_get_interval(timeout);
+ pollTimeout.tv_sec = localTimeout / 1000;
pollTimeout.tv_nsec = (localTimeout % 1000) * 1000000;
- //prepare handle and callback. new is eval, but there is no other choice because we need the pointer!
- sh_timerHandle_t* handle = new sh_timerHandle_t;
+ // prepare handle and callback. new is eval, but there is no other choice because we need the pointer!
+ sh_timerHandle_t *handle = new sh_timerHandle_t;
mpListTimerhandles.push_back(handle);
- //add the timer to the pollLoop
+ // add the timer to the pollLoop
mpSocketHandler->addTimer(pollTimeout, &pDbusTimerCallback, *handle, timeout);
- //save the handle with dbus context
+ // save the handle with dbus context
dbus_timeout_set_data(timeout, handle, NULL);
return (true);
}
-void CAmDbusWrapper::removeTimeout(DBusTimeout *timeout, void* userData)
+void CAmDbusWrapper::removeTimeout(DBusTimeout *timeout, void *userData)
{
- mpReference = (CAmDbusWrapper*) userData;
- assert(mpReference!=0);
+ mpReference = (CAmDbusWrapper *)userData;
+ assert(mpReference != 0);
mpReference->removeTimeoutDelegate(timeout, userData);
}
-void CAmDbusWrapper::removeTimeoutDelegate(DBusTimeout *timeout, void* userData)
+void CAmDbusWrapper::removeTimeoutDelegate(DBusTimeout *timeout, void *userData)
{
- (void) userData;
- //get the pointer to the handle and remove the timer
- sh_timerHandle_t* handle = (sh_timerHandle_t*) dbus_timeout_get_data(timeout);
+ (void)userData;
+ // get the pointer to the handle and remove the timer
+ sh_timerHandle_t *handle = (sh_timerHandle_t *)dbus_timeout_get_data(timeout);
mpSocketHandler->removeTimer(*handle);
- //now go throught the timerlist and remove the pointer, free memory
- std::vector<sh_timerHandle_t*>::iterator it = mpListTimerhandles.begin();
+ // now go throught the timerlist and remove the pointer, free memory
+ std::vector<sh_timerHandle_t *>::iterator it = mpListTimerhandles.begin();
for (; it != mpListTimerhandles.end(); ++it)
{
if (*it == handle)
@@ -414,92 +438,111 @@ void CAmDbusWrapper::removeTimeoutDelegate(DBusTimeout *timeout, void* userData)
break;
}
}
+
delete handle;
- }
+}
-void CAmDbusWrapper::toggleTimeout(DBusTimeout *timeout, void* userData)
+void CAmDbusWrapper::toggleTimeout(DBusTimeout *timeout, void *userData)
{
- mpReference = (CAmDbusWrapper*) userData;
- assert(mpReference!=0);
+ mpReference = (CAmDbusWrapper *)userData;
+ assert(mpReference != 0);
mpReference->toggleTimeoutDelegate(timeout, userData);
}
bool am::CAmDbusWrapper::dbusDispatchCallback(const sh_pollHandle_t handle, void *userData)
{
- (void) handle;
- (void) userData;
+ (void)handle;
+ (void)userData;
bool returnVal = true;
dbus_connection_ref(mpDbusConnection);
if (dbus_connection_dispatch(mpDbusConnection) == DBUS_DISPATCH_COMPLETE)
+ {
returnVal = false;
+ }
+
dbus_connection_unref(mpDbusConnection);
- //logInfo("DBusWrapper::dbusDispatchCallback was called");
+ // logInfo("DBusWrapper::dbusDispatchCallback was called");
return (returnVal);
}
bool am::CAmDbusWrapper::dbusCheckCallback(const sh_pollHandle_t handle, void *userData)
{
- (void) handle;
- (void) userData;
+ (void)handle;
+ (void)userData;
bool returnVal = false;
dbus_connection_ref(mpDbusConnection);
if (dbus_connection_get_dispatch_status(mpDbusConnection) == DBUS_DISPATCH_DATA_REMAINS)
+ {
returnVal = true;
+ }
+
dbus_connection_unref(mpDbusConnection);
- //logInfo("DBusWrapper::dbusCheckCallback was called");
+ // logInfo("DBusWrapper::dbusCheckCallback was called");
return (returnVal);
}
void am::CAmDbusWrapper::dbusFireCallback(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
{
- (void) handle;
- (void) userData;
- assert(userData!=NULL);
+ (void)handle;
+ (void)userData;
+ assert(userData != NULL);
uint flags = 0;
if (pollfd.revents & POLLIN)
+ {
flags |= DBUS_WATCH_READABLE;
+ }
+
if (pollfd.revents & POLLOUT)
+ {
flags |= DBUS_WATCH_WRITABLE;
+ }
+
if (pollfd.revents & POLLHUP)
+ {
flags |= DBUS_WATCH_HANGUP;
+ }
+
if (pollfd.revents & POLLERR)
+ {
flags |= DBUS_WATCH_ERROR;
+ }
- DBusWatch *watch = (DBusWatch*) userData;
+ DBusWatch *watch = (DBusWatch *)userData;
dbus_connection_ref(mpDbusConnection);
dbus_watch_handle(watch, flags);
dbus_connection_unref(mpDbusConnection);
- //logInfo("DBusWrapper::dbusFireCallback was called");
+ // logInfo("DBusWrapper::dbusFireCallback was called");
}
-void CAmDbusWrapper::dbusPrepareCallback(const sh_pollHandle_t handle, void* userData)
+void CAmDbusWrapper::dbusPrepareCallback(const sh_pollHandle_t handle, void *userData)
{
- (void) handle;
- (void) userData;
+ (void)handle;
+ (void)userData;
dbus_connection_ref(mpDbusConnection);
while (dbus_connection_get_dispatch_status(mpDbusConnection) == DBUS_DISPATCH_DATA_REMAINS)
{
- dbus_connection_dispatch(mpDbusConnection);
- //logInfo("prepare was neccessary!");
+ dbus_connection_dispatch(mpDbusConnection);
+ // logInfo("prepare was neccessary!");
}
+
dbus_connection_unref(mpDbusConnection);
}
-void CAmDbusWrapper::toggleTimeoutDelegate(DBusTimeout *timeout, void* userData)
+void CAmDbusWrapper::toggleTimeoutDelegate(DBusTimeout *timeout, void *userData)
{
- (void) userData;
- //get the pointer to the handle and remove the timer
- sh_timerHandle_t* handle = (sh_timerHandle_t*) dbus_timeout_get_data(timeout);
+ (void)userData;
+ // get the pointer to the handle and remove the timer
+ sh_timerHandle_t *handle = (sh_timerHandle_t *)dbus_timeout_get_data(timeout);
- //stop or restart?
+ // stop or restart?
if (dbus_timeout_get_enabled(timeout))
{
- //calculate the timeout in timeval
+ // calculate the timeout in timeval
timespec pollTimeout;
- int localTimeout = dbus_timeout_get_interval(timeout);
- pollTimeout.tv_sec = localTimeout / 1000;
+ int localTimeout = dbus_timeout_get_interval(timeout);
+ pollTimeout.tv_sec = localTimeout / 1000;
pollTimeout.tv_nsec = (localTimeout % 1000) * 1000000;
mpSocketHandler->updateTimer(*handle, pollTimeout);
}
@@ -511,20 +554,22 @@ void CAmDbusWrapper::toggleTimeoutDelegate(DBusTimeout *timeout, void* userData)
void CAmDbusWrapper::dbusTimerCallback(sh_timerHandle_t handle, void *userData)
{
- assert(userData!=NULL);
- for (auto && timerHandle : mpListTimerhandles)
+ assert(userData != NULL);
+ for (auto &&timerHandle : mpListTimerhandles)
{
if (*timerHandle == handle)
{
- if (dbus_timeout_get_enabled((DBusTimeout*) userData))
+ if (dbus_timeout_get_enabled((DBusTimeout *)userData))
{
mpSocketHandler->restartTimer(handle);
}
- dbus_timeout_handle((DBusTimeout*) userData);
+
+ dbus_timeout_handle((DBusTimeout *)userData);
return;
}
}
+
logWarning("CAmDbusWrapper::dbusTimerCallback Unknown timer handle");
}
-}
+}
diff --git a/AudioManagerUtilities/src/CAmDltWrapper.cpp b/AudioManagerUtilities/src/CAmDltWrapper.cpp
index 44ec614..fff4a57 100644
--- a/AudioManagerUtilities/src/CAmDltWrapper.cpp
+++ b/AudioManagerUtilities/src/CAmDltWrapper.cpp
@@ -22,7 +22,6 @@
*
*/
-
#include <string>
#include <iostream>
#include <string.h>
@@ -34,668 +33,781 @@
namespace am
{
-CAmDltWrapper* CAmDltWrapper::mpDLTWrapper = NULL;
-pthread_mutex_t CAmDltWrapper::mMutex = PTHREAD_MUTEX_INITIALIZER;
-
-const std::vector<const char*> CAmDltWrapper::mStr_error =
-{
- "E_OK",
- "E_UNKNOWN",
- "E_OUT_OF_RANGE",
- "E_NOT_USED",
- "E_DATABASE_ERROR",
- "E_ALREADY_EXISTS",
- "E_NO_CHANGE",
- "E_NOT_POSSIBLE",
- "E_NON_EXISTENT",
- "E_ABORTED",
- "E_WRONG_FORMAT",
- "E_COMMUNICATION",
- "E_MAX"
-};
+CAmDltWrapper *CAmDltWrapper::mpDLTWrapper = NULL;
+pthread_mutex_t CAmDltWrapper::mMutex = PTHREAD_MUTEX_INITIALIZER;
-const std::vector<const char*> CAmDltWrapper::mStr_sourceState =
+const std::vector<const char *> CAmDltWrapper::mStr_error =
{
- "SS_UNKNNOWN",
- "SS_ON",
- "SS_OFF",
- "SS_PAUSED",
- "SS_MAX"
+ "E_OK",
+ "E_UNKNOWN",
+ "E_OUT_OF_RANGE",
+ "E_NOT_USED",
+ "E_DATABASE_ERROR",
+ "E_ALREADY_EXISTS",
+ "E_NO_CHANGE",
+ "E_NOT_POSSIBLE",
+ "E_NON_EXISTENT",
+ "E_ABORTED",
+ "E_WRONG_FORMAT",
+ "E_COMMUNICATION",
+ "E_MAX"
};
-const std::vector<const char*> CAmDltWrapper::mStr_MuteState =
+const std::vector<const char *> CAmDltWrapper::mStr_sourceState =
{
- "MS_UNKNOWN" ,
- "MS_MUTED" ,
- "MS_UNMUTED" ,
- "MS_MAX"
+ "SS_UNKNNOWN",
+ "SS_ON",
+ "SS_OFF",
+ "SS_PAUSED",
+ "SS_MAX"
};
-const std::vector<const char*> CAmDltWrapper::mStr_DomainState =
+const std::vector<const char *> CAmDltWrapper::mStr_MuteState =
{
- "DS_UNKNOWN",
- "DS_CONTROLLED",
- "DS_INDEPENDENT_STARTUP",
- "DS_INDEPENDENT_RUNDOWN",
- "DS_MAX"
+ "MS_UNKNOWN",
+ "MS_MUTED",
+ "MS_UNMUTED",
+ "MS_MAX"
};
-const std::vector<const char*> CAmDltWrapper::mStr_ConnectionState =
+const std::vector<const char *> CAmDltWrapper::mStr_DomainState =
{
- "CS_UNKNOWN",
- "CS_CONNECTING",
- "CS_CONNECTED",
- "CS_DISCONNECTING",
- "CS_DISCONNECTED",
- "CS_SUSPENDED",
- "CS_MAX"
+ "DS_UNKNOWN",
+ "DS_CONTROLLED",
+ "DS_INDEPENDENT_STARTUP",
+ "DS_INDEPENDENT_RUNDOWN",
+ "DS_MAX"
};
-const std::vector<const char*> CAmDltWrapper::mStr_Availability =
+const std::vector<const char *> CAmDltWrapper::mStr_ConnectionState =
{
- "A_UNKNOWN",
- "A_AVAILABLE",
- "A_UNAVAILABLE",
- "A_MAX"
+ "CS_UNKNOWN",
+ "CS_CONNECTING",
+ "CS_CONNECTED",
+ "CS_DISCONNECTING",
+ "CS_DISCONNECTED",
+ "CS_SUSPENDED",
+ "CS_MAX"
};
-const std::vector<const char*> CAmDltWrapper::mStr_Interrupt =
+const std::vector<const char *> CAmDltWrapper::mStr_Availability =
{
- "IS_UNKNOWN",
- "IS_OFF",
- "IS_INTERRUPTED",
- "IS_MAX"
+ "A_UNKNOWN",
+ "A_AVAILABLE",
+ "A_UNAVAILABLE",
+ "A_MAX"
};
-const std::vector<const char*> CAmDltWrapper::mStr_Handle =
-{
- "H_UNKNOWN",
- "H_CONNECT",
- "H_DISCONNECT",
- "H_SETSOURCESTATE",
- "H_SETSINKVOLUME",
- "H_SETSOURCEVOLUME",
- "H_SETSINKSOUNDPROPERTY",
- "H_SETSOURCESOUNDPROPERTY",
- "H_SETSINKSOUNDPROPERTIES",
- "H_SETSOURCESOUNDPROPERTIES",
- "H_CROSSFADE",
- "H_SETVOLUMES",
- "H_SETSINKNOTIFICATION",
- "H_SETSOURCENOTIFICATION",
- "H_MAX"
+const std::vector<const char *> CAmDltWrapper::mStr_Interrupt =
+{
+ "IS_UNKNOWN",
+ "IS_OFF",
+ "IS_INTERRUPTED",
+ "IS_MAX"
};
-const std::vector<const char*> CAmDltWrapper::mStr_NotificationStatus =
+const std::vector<const char *> CAmDltWrapper::mStr_Handle =
{
- "NS_UNKNOWN",
- "NS_OFF",
- "NS_PERIODIC",
- "NS_MINIMUM",
- "NS_MAXIMUM",
- "NS_CHANGE",
- "NS_MAX"
+ "H_UNKNOWN",
+ "H_CONNECT",
+ "H_DISCONNECT",
+ "H_SETSOURCESTATE",
+ "H_SETSINKVOLUME",
+ "H_SETSOURCEVOLUME",
+ "H_SETSINKSOUNDPROPERTY",
+ "H_SETSOURCESOUNDPROPERTY",
+ "H_SETSINKSOUNDPROPERTIES",
+ "H_SETSOURCESOUNDPROPERTIES",
+ "H_CROSSFADE",
+ "H_SETVOLUMES",
+ "H_SETSINKNOTIFICATION",
+ "H_SETSOURCENOTIFICATION",
+ "H_MAX"
};
-
+const std::vector<const char *> CAmDltWrapper::mStr_NotificationStatus =
+{
+ "NS_UNKNOWN",
+ "NS_OFF",
+ "NS_PERIODIC",
+ "NS_MINIMUM",
+ "NS_MAXIMUM",
+ "NS_CHANGE",
+ "NS_MAX"
+};
std::string CAmDltWrapper::now()
{
- std::time_t t(std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()));
- struct tm * timeinfo(localtime(&t));
- char buffer[80];
- std::strftime(buffer,80,"%D %T ",timeinfo);
- return (std::string(buffer));
+ std::time_t t(std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()));
+ struct tm *timeinfo(localtime(&t));
+ char buffer[80];
+ std::strftime(buffer, 80, "%D %T ", timeinfo);
+ return (std::string(buffer));
}
-CAmDltWrapper* CAmDltWrapper::instanctiateOnce(const char *appid, const char * description, const bool debugEnabled, const logDestination logDest, const std::string Filename,bool onlyError)
+CAmDltWrapper *CAmDltWrapper::instanctiateOnce(const char *appid, const char *description, const bool debugEnabled, const logDestination logDest, const std::string Filename, bool onlyError)
{
- if (!mpDLTWrapper)
- {
- mpDLTWrapper = new CAmDltWrapper(appid,description,debugEnabled,logDest,Filename,onlyError);
- }
- return (mpDLTWrapper);
+ if (!mpDLTWrapper)
+ {
+ mpDLTWrapper = new CAmDltWrapper(appid, description, debugEnabled, logDest, Filename, onlyError);
+ }
+
+ return (mpDLTWrapper);
}
-CAmDltWrapper* CAmDltWrapper::instance()
+CAmDltWrapper *CAmDltWrapper::instance()
{
- if (!mpDLTWrapper)
- {
- // an application seems not to use our CAmDltWrapper class therefore create default
- std::ostringstream description;
- description << "PID=" << getpid() << " _=" << getenv("_");
- mpDLTWrapper = new CAmDltWrapper("AMDL", description.str().c_str());
- std::cerr << "Application doesn't call CAmDltWrapper::instanciateOnce!!!" << std::endl;
- std::cerr << "-> CAmDltWrapper::instance registers DLT application [ AMDL | " << description.str() << " ]" << std::endl;
- }
- return mpDLTWrapper;
+ if (!mpDLTWrapper)
+ {
+ // an application seems not to use our CAmDltWrapper class therefore create default
+ std::ostringstream description;
+ description << "PID=" << getpid() << " _=" << getenv("_");
+ mpDLTWrapper = new CAmDltWrapper("AMDL", description.str().c_str());
+ std::cerr << "Application doesn't call CAmDltWrapper::instanciateOnce!!!" << std::endl;
+ std::cerr << "-> CAmDltWrapper::instance registers DLT application [ AMDL | " << description.str() << " ]" << std::endl;
+ }
+
+ return mpDLTWrapper;
}
bool CAmDltWrapper::getEnabled()
{
- return (mDebugEnabled);
-}
-
-bool CAmDltWrapper::initNoDlt(DltLogLevelType loglevel, DltContext* context)
-{
- if (mlogDestination==logDestination::COMMAND_LINE)
- {
- if (!context)
- {
- switch (loglevel)
- {
- case DLT_LOG_OFF :
- case DLT_LOG_FATAL :
- case DLT_LOG_ERROR :
- mNoDltContextData.buffer << "\033[0;31m"<<"[DEF] [Erro] \033[0m";
- mLogOn=true;
- break;
- case DLT_LOG_WARN :
- if (!mOnlyError)
- {
- mNoDltContextData.buffer << "\033[0;33m"<<"[DEF] [Warn] \033[0m";
- }
- else
- mLogOn=false;
- break;
- case DLT_LOG_INFO :
- if (!mOnlyError)
- {
- mNoDltContextData.buffer << "\033[0;36m"<<"[DEF] [Info] \033[0m";
- }
- else
- mLogOn=false;
- break;
- default:
- if (!mOnlyError)
- {
- mNoDltContextData.buffer << "\033[0;32m"<<"[DEF] [Defa] \033[0m";
- }
- else
- mLogOn=false;
- }
- }
- else
- {
- std::string con(mMapContext.at(context));
- switch (loglevel)
- {
- case DLT_LOG_OFF :
- case DLT_LOG_FATAL :
- case DLT_LOG_ERROR :
- mNoDltContextData.buffer << "\033[0;31m["<<con<<"] [Erro] \033[0m";
- mLogOn=true;
- break;
- case DLT_LOG_WARN :
- if (!mOnlyError)
- {
- mNoDltContextData.buffer << "\033[0;33m["<<con<<"] [Warn] \033[0m";
- }
- else
- mLogOn=false;
- break;
- case DLT_LOG_INFO :
- if (!mOnlyError)
- {
- mNoDltContextData.buffer << "\033[0;36m["<<con<<"] [Info] \033[0m";
- }
- else
- mLogOn=false;
-
- break;
- default:
- if (!mOnlyError)
- {
- mNoDltContextData.buffer << "\033[0;32m["<<con<<"] [Defa] \033[0m";
- }
- else
- mLogOn=false;
- }
- }
- return true;
- }
- else
- {
- if (!context)
- {
- switch (loglevel)
- {
- case DLT_LOG_OFF :
- case DLT_LOG_FATAL :
- case DLT_LOG_ERROR :
- mNoDltContextData.buffer <<"[DEF] [Erro] ";
- mLogOn=true;
- break;
- case DLT_LOG_WARN :
- if (!mOnlyError)
- {
- mNoDltContextData.buffer <<"[DEF] [Warn] ";
- }
- else
- mLogOn=false;
- break;
- case DLT_LOG_INFO :
- if (!mOnlyError)
- {
- mNoDltContextData.buffer <<"[DEF] [Info] ";
- }
- else
- mLogOn=false;
- break;
- default:
- if (!mOnlyError)
- {
- mNoDltContextData.buffer <<"[DEF] [Defa] ";
- }
- else
- mLogOn=false;
-
- }
- }
- else
- {
- std::string con(mMapContext.at(context));
- switch (loglevel)
- {
- case DLT_LOG_OFF :
- case DLT_LOG_FATAL :
- case DLT_LOG_ERROR :
- mNoDltContextData.buffer << "["<<con<<"] [Erro] ";
- mLogOn=true;
- break;
- case DLT_LOG_WARN :
- if (!mOnlyError)
- {
- mNoDltContextData.buffer << "["<<con<<"] [Warn] ";
- }
- else
- mLogOn=false;
- break;
- case DLT_LOG_INFO :
- if (!mOnlyError)
- {
- mNoDltContextData.buffer << "["<<con<<"] [Info] ";
- }
- else
- mLogOn=false;
-
- break;
- default:
- if (!mOnlyError)
- {
- mNoDltContextData.buffer << "["<<con<<"] [Defa] ";
- }
- else
- mLogOn=false;
- }
- }
- return true;
- }
-}
-
-#ifdef WITH_DLT
-
- CAmDltWrapper::CAmDltWrapper(const char *appid, const char * description, const bool debugEnabled, const logDestination logDest, const std::string Filename,bool onlyError) :
- mDebugEnabled(debugEnabled), //
- mlogDestination(logDest), //
- mFilename(NULL), //
- mOnlyError(onlyError), //
- mLogOn(true)
- {
- if (mDebugEnabled && mlogDestination==logDestination::DAEMON)
- {
- dlt_register_app(appid, description);
- //register a default context
- dlt_register_context(&mDltContext, "DEF", "Default Context registered by DLTWrapper Class");
- }
- else if (mDebugEnabled)
- {
- if (mlogDestination==logDestination::COMMAND_LINE)
- std::cout << "\033[0;36m[DLT] Registering AppID " << appid << " , " << description << "\033[0m"<< std::endl;
- else
- {
- mFilename.open(Filename, std::ofstream::out | std::ofstream::trunc);
- if (!mFilename.is_open())
- {
- throw std::runtime_error("Cannot open file for logging");
- }
- mFilename << now() << "[DLT] Registering AppID " << appid << " , " << description << std::endl;
- }
- }
- }
-
- CAmDltWrapper::~CAmDltWrapper()
- {
- if (mpDLTWrapper && mDebugEnabled && mlogDestination==logDestination::DAEMON)
- {
- mpDLTWrapper->unregisterContext(mDltContext);
- delete mpDLTWrapper;
- }
- else if (mpDLTWrapper && mDebugEnabled && mlogDestination==logDestination::COMMAND_LINE)
- {
- mFilename.close();
- }
- }
-
- void CAmDltWrapper::unregisterContext(DltContext & handle)
- {
- if (mDebugEnabled && mlogDestination==logDestination::DAEMON)
- {
- dlt_unregister_context(&handle);
- }
- }
-
- void CAmDltWrapper::deinit()
- {
- if (mDebugEnabled)
- {
- unregisterContext(mDltContext);
- }
- }
-
- void CAmDltWrapper::registerContext(DltContext& handle, const char *contextid, const char *description)
- {
- if (mDebugEnabled && mlogDestination==logDestination::DAEMON)
- {
- dlt_register_context(&handle, contextid, description);
- }
- else if (mDebugEnabled)
- {
- mMapContext.emplace(&handle,std::string(contextid));
-
- if (mlogDestination==logDestination::COMMAND_LINE)
- std::cout << "\033[0;36m[DLT] Registering Context " << contextid << " , " << description << "\033[0m"<< std::endl;
- else
- mFilename << now() << "[DLT] Registering Context " << contextid << " , " << description << std::endl;
- }
- }
-
- void CAmDltWrapper::registerContext(DltContext& handle, const char *contextid, const char * description,const DltLogLevelType level, const DltTraceStatusType status)
- {
- if (mDebugEnabled && mlogDestination==logDestination::DAEMON)
- {
- dlt_register_context_ll_ts(&handle, contextid, description, level, status);
- }
- else if (mDebugEnabled)
- {
- mMapContext.emplace(&handle,std::string(contextid));
-
- if (mlogDestination==logDestination::COMMAND_LINE)
- std::cout << "\033[0;36m[DLT] Registering Context " << contextid << " , " << description << "\033[0m"<< std::endl;
- else
- mFilename << now() << " [DLT] Registering Context " << contextid << " , " << description << std::endl;
- }
- }
-
- bool CAmDltWrapper::init(DltLogLevelType loglevel, DltContext* context)
- {
- pthread_mutex_lock(&mMutex);
- if (mlogDestination==logDestination::DAEMON)
- {
- if (!context)
- context = &mDltContext;
-
- if(dlt_user_log_write_start(context, &mDltContextData, loglevel) <= 0)
- {
- pthread_mutex_unlock(&mMutex);
- return false;
- }
- }
- else
- {
- initNoDlt(loglevel,context);
- }
- return true;
- }
-
- void CAmDltWrapper::send()
- {
- if (mlogDestination==logDestination::DAEMON)
- {
- dlt_user_log_write_finish(&mDltContextData);
- }
- else
- {
- if (mlogDestination==logDestination::COMMAND_LINE && mLogOn)
- std::cout << mNoDltContextData.buffer.str().c_str() << std::endl;
- else if (mLogOn)
- mFilename << now() << mNoDltContextData.buffer.str().c_str() << std::endl;
-
- mNoDltContextData.buffer.str("");
- mNoDltContextData.buffer.clear();
- }
- pthread_mutex_unlock(&mMutex);
- }
-
- void CAmDltWrapper::append(const int8_t value)
- {
- if (mlogDestination==logDestination::DAEMON)
- dlt_user_log_write_int8(&mDltContextData, value);
- else
- appendNoDLT(value);
- }
-
- void CAmDltWrapper::append(const uint8_t value)
- {
- if (mlogDestination==logDestination::DAEMON)
- dlt_user_log_write_uint8(&mDltContextData, value);
- else
- appendNoDLT(value);
- }
-
- void CAmDltWrapper::append(const int16_t value)
- {
- if (mlogDestination==logDestination::DAEMON)
- dlt_user_log_write_int16(&mDltContextData, value);
- else
- appendNoDLT(value);
- }
-
- void CAmDltWrapper::append(const uint16_t value)
- {
- if (mlogDestination==logDestination::DAEMON)
- dlt_user_log_write_uint16(&mDltContextData, value);
- else
- appendNoDLT(value);
- }
-
- void CAmDltWrapper::append(const int32_t value)
- {
- if (mlogDestination==logDestination::DAEMON)
- dlt_user_log_write_int32(&mDltContextData, value);
- else
- appendNoDLT(value);
- }
-
- void CAmDltWrapper::append(const uint32_t value)
- {
- if (mlogDestination==logDestination::DAEMON)
- dlt_user_log_write_uint32(&mDltContextData, value);
- else
- appendNoDLT(value);
- }
-
- void CAmDltWrapper::append(const std::string& value)
- {
- append(value.c_str());
- }
-
- void CAmDltWrapper::append(const bool value)
- {
- if (mlogDestination==logDestination::DAEMON)
- dlt_user_log_write_bool(&mDltContextData, static_cast<uint8_t>(value));
- else
- appendNoDLT(value);
- }
-
- void CAmDltWrapper::append(const int64_t value)
- {
- if (mlogDestination==logDestination::DAEMON)
- dlt_user_log_write_int64(&mDltContextData, value);
- else
- appendNoDLT(value);
- }
-
- void CAmDltWrapper::append(const uint64_t value)
- {
- if (mlogDestination==logDestination::DAEMON)
- dlt_user_log_write_uint64(&mDltContextData, value);
- else
- appendNoDLT(value);
- }
-
- void CAmDltWrapper::append(const std::vector<uint8_t> & data)
- {
- if (mlogDestination==logDestination::DAEMON)
- dlt_user_log_write_raw(&mDltContextData,(void*)data.data(),data.size());
- else
- mNoDltContextData.buffer << data.data();
- }
-}
-
-#else //------------------------------------------------------------------------------------------------- no DLT !
-
- CAmDltWrapper::CAmDltWrapper(const char *appid, const char * description, const bool debugEnabled, const logDestination logDest, const std::string Filename,bool onlyError) :
- mDebugEnabled(debugEnabled), //
- mlogDestination(logDest), //
- mFilename(NULL), //
- mOnlyError(onlyError), //
- mLogOn(true)
- {
- if (logDest==logDestination::DAEMON)
- {
- std::cout << "\033[0;31m[DLT] Cannot Use Daemon Logging, active in CMAKE! Using CommandLine\033[0m"<< std::endl;
- mlogDestination=logDestination::COMMAND_LINE;
- }
- if (mDebugEnabled)
- {
- if (mlogDestination==logDestination::COMMAND_LINE)
- std::cout << "\033[0;36m[DLT] Registering AppID " << appid << " , " << description << "\033[0m"<< std::endl;
- else
- {
- mFilename.open(Filename, std::ofstream::out | std::ofstream::trunc);
- if (!mFilename.is_open())
- {
- throw std::runtime_error("Cannot open file for logging");
- }
- mFilename << now() << "[DLT] Registering AppID " << appid << " , " << description << std::endl;
- }
- }
- }
-
- CAmDltWrapper::~CAmDltWrapper()
- {
- if (mpDLTWrapper && mDebugEnabled && mlogDestination==logDestination::COMMAND_LINE)
- {
- mFilename.close();
- }
- }
-
- void CAmDltWrapper::unregisterContext(DltContext & handle)
- {}
-
- void CAmDltWrapper::deinit()
- {}
-
- void CAmDltWrapper::registerContext(DltContext& handle, const char *contextid, const char *description)
- {
- if (mDebugEnabled)
- {
- mMapContext.emplace(&handle,std::string(contextid));
-
- if (mlogDestination==logDestination::COMMAND_LINE)
- std::cout << "\033[0;36m[DLT] Registering Context " << contextid << " , " << description << "\033[0m"<< std::endl;
- else
- mFilename << now() << "[DLT] Registering Context " << contextid << " , " << description << std::endl;
- }
- }
-
- void CAmDltWrapper::registerContext(DltContext& handle, const char *contextid, const char * description,const DltLogLevelType level, const DltTraceStatusType status)
- {
- if (mDebugEnabled)
- {
- mMapContext.emplace(&handle,std::string(contextid));
-
- if (mlogDestination==logDestination::COMMAND_LINE)
- std::cout << "\033[0;36m[DLT] Registering Context " << contextid << " , " << description << "\033[0m"<< std::endl;
- else
- mFilename << now() << " [DLT] Registering Context " << contextid << " , " << description << std::endl;
- }
- }
-
- bool CAmDltWrapper::init(DltLogLevelType loglevel, DltContext* context)
- {
- pthread_mutex_lock(&mMutex);
- return initNoDlt(loglevel,context);
- }
-
- void CAmDltWrapper::send()
- {
- if (mlogDestination==logDestination::COMMAND_LINE && mLogOn)
- std::cout << mNoDltContextData.buffer.str().c_str() << std::endl;
- else if (mLogOn)
- mFilename << now() << mNoDltContextData.buffer.str().c_str() << std::endl;
-
- mNoDltContextData.buffer.str("");
- mNoDltContextData.buffer.clear();
- pthread_mutex_unlock(&mMutex);
- }
-
- void CAmDltWrapper::append(const int8_t value)
- {
- appendNoDLT(value);
- }
-
- void CAmDltWrapper::append(const uint8_t value)
- {
- appendNoDLT(value);
- }
-
- void CAmDltWrapper::append(const int16_t value)
- {
- appendNoDLT(value);
- }
-
- void CAmDltWrapper::append(const uint16_t value)
- {
- appendNoDLT(value);
- }
-
- void CAmDltWrapper::append(const int32_t value)
- {
- appendNoDLT(value);
- }
-
- void CAmDltWrapper::append(const uint32_t value)
- {
- appendNoDLT(value);
- }
-
- void CAmDltWrapper::append(const std::string& value)
- {
- append(value.c_str());
- }
-
- void CAmDltWrapper::append(const bool value)
- {
- appendNoDLT(value);
- }
-
- void CAmDltWrapper::append(const int64_t value)
- {
- appendNoDLT(value);
- }
-
- void CAmDltWrapper::append(const uint64_t value)
- {
- appendNoDLT(value);
- }
-
- void CAmDltWrapper::append(const std::vector<uint8_t> & data)
- {
- mNoDltContextData.buffer << data.data();
- }
-}
-#endif //WITH_DLT
+ return (mDebugEnabled);
+}
+
+bool CAmDltWrapper::initNoDlt(DltLogLevelType loglevel, DltContext *context)
+{
+ if (mlogDestination == logDestination::COMMAND_LINE)
+ {
+ if (!context)
+ {
+ switch (loglevel)
+ {
+ case DLT_LOG_OFF:
+ case DLT_LOG_FATAL:
+ case DLT_LOG_ERROR:
+ mNoDltContextData.buffer << "\033[0;31m" << "[DEF] [Erro] \033[0m";
+ mLogOn = true;
+ break;
+ case DLT_LOG_WARN:
+ if (!mOnlyError)
+ {
+ mNoDltContextData.buffer << "\033[0;33m" << "[DEF] [Warn] \033[0m";
+ }
+ else
+ {
+ mLogOn = false;
+ }
+
+ break;
+ case DLT_LOG_INFO:
+ if (!mOnlyError)
+ {
+ mNoDltContextData.buffer << "\033[0;36m" << "[DEF] [Info] \033[0m";
+ }
+ else
+ {
+ mLogOn = false;
+ }
+
+ break;
+ default:
+ if (!mOnlyError)
+ {
+ mNoDltContextData.buffer << "\033[0;32m" << "[DEF] [Defa] \033[0m";
+ }
+ else
+ {
+ mLogOn = false;
+ }
+ }
+ }
+ else
+ {
+ std::string con(mMapContext.at(context));
+ switch (loglevel)
+ {
+ case DLT_LOG_OFF:
+ case DLT_LOG_FATAL:
+ case DLT_LOG_ERROR:
+ mNoDltContextData.buffer << "\033[0;31m[" << con << "] [Erro] \033[0m";
+ mLogOn = true;
+ break;
+ case DLT_LOG_WARN:
+ if (!mOnlyError)
+ {
+ mNoDltContextData.buffer << "\033[0;33m[" << con << "] [Warn] \033[0m";
+ }
+ else
+ {
+ mLogOn = false;
+ }
+
+ break;
+ case DLT_LOG_INFO:
+ if (!mOnlyError)
+ {
+ mNoDltContextData.buffer << "\033[0;36m[" << con << "] [Info] \033[0m";
+ }
+ else
+ {
+ mLogOn = false;
+ }
+
+ break;
+ default:
+ if (!mOnlyError)
+ {
+ mNoDltContextData.buffer << "\033[0;32m[" << con << "] [Defa] \033[0m";
+ }
+ else
+ {
+ mLogOn = false;
+ }
+ }
+ }
+
+ return true;
+ }
+ else
+ {
+ if (!context)
+ {
+ switch (loglevel)
+ {
+ case DLT_LOG_OFF:
+ case DLT_LOG_FATAL:
+ case DLT_LOG_ERROR:
+ mNoDltContextData.buffer << "[DEF] [Erro] ";
+ mLogOn = true;
+ break;
+ case DLT_LOG_WARN:
+ if (!mOnlyError)
+ {
+ mNoDltContextData.buffer << "[DEF] [Warn] ";
+ }
+ else
+ {
+ mLogOn = false;
+ }
+
+ break;
+ case DLT_LOG_INFO:
+ if (!mOnlyError)
+ {
+ mNoDltContextData.buffer << "[DEF] [Info] ";
+ }
+ else
+ {
+ mLogOn = false;
+ }
+
+ break;
+ default:
+ if (!mOnlyError)
+ {
+ mNoDltContextData.buffer << "[DEF] [Defa] ";
+ }
+ else
+ {
+ mLogOn = false;
+ }
+ }
+ }
+ else
+ {
+ std::string con(mMapContext.at(context));
+ switch (loglevel)
+ {
+ case DLT_LOG_OFF:
+ case DLT_LOG_FATAL:
+ case DLT_LOG_ERROR:
+ mNoDltContextData.buffer << "[" << con << "] [Erro] ";
+ mLogOn = true;
+ break;
+ case DLT_LOG_WARN:
+ if (!mOnlyError)
+ {
+ mNoDltContextData.buffer << "[" << con << "] [Warn] ";
+ }
+ else
+ {
+ mLogOn = false;
+ }
+
+ break;
+ case DLT_LOG_INFO:
+ if (!mOnlyError)
+ {
+ mNoDltContextData.buffer << "[" << con << "] [Info] ";
+ }
+ else
+ {
+ mLogOn = false;
+ }
+
+ break;
+ default:
+ if (!mOnlyError)
+ {
+ mNoDltContextData.buffer << "[" << con << "] [Defa] ";
+ }
+ else
+ {
+ mLogOn = false;
+ }
+ }
+ }
+
+ return true;
+ }
+}
+
+#ifdef WITH_DLT
+CAmDltWrapper::CAmDltWrapper(const char *appid, const char *description, const bool debugEnabled, const logDestination logDest, const std::string Filename, bool onlyError)
+ : mDebugEnabled(debugEnabled)
+ , //
+ mlogDestination(logDest)
+ , //
+ mFilename(NULL)
+ , //
+ mOnlyError(onlyError)
+ , //
+ mLogOn(true)
+{
+ if (mDebugEnabled && mlogDestination == logDestination::DAEMON)
+ {
+ dlt_register_app(appid, description);
+ // register a default context
+ dlt_register_context(&mDltContext, "DEF", "Default Context registered by DLTWrapper Class");
+ }
+ else if (mDebugEnabled)
+ {
+ if (mlogDestination == logDestination::COMMAND_LINE)
+ {
+ std::cout << "\033[0;36m[DLT] Registering AppID " << appid << " , " << description << "\033[0m" << std::endl;
+ }
+ else
+ {
+ mFilename.open(Filename, std::ofstream::out | std::ofstream::trunc);
+ if (!mFilename.is_open())
+ {
+ throw std::runtime_error("Cannot open file for logging");
+ }
+
+ mFilename << now() << "[DLT] Registering AppID " << appid << " , " << description << std::endl;
+ }
+ }
+}
+
+CAmDltWrapper::~CAmDltWrapper()
+{
+ if (mpDLTWrapper && mDebugEnabled && mlogDestination == logDestination::DAEMON)
+ {
+ mpDLTWrapper->unregisterContext(mDltContext);
+ delete mpDLTWrapper;
+ }
+ else if (mpDLTWrapper && mDebugEnabled && mlogDestination == logDestination::COMMAND_LINE)
+ {
+ mFilename.close();
+ }
+}
+
+void CAmDltWrapper::unregisterContext(DltContext &handle)
+{
+ if (mDebugEnabled && mlogDestination == logDestination::DAEMON)
+ {
+ dlt_unregister_context(&handle);
+ }
+}
+
+void CAmDltWrapper::deinit()
+{
+ if (mDebugEnabled)
+ {
+ unregisterContext(mDltContext);
+ }
+}
+
+void CAmDltWrapper::registerContext(DltContext &handle, const char *contextid, const char *description)
+{
+ if (mDebugEnabled && mlogDestination == logDestination::DAEMON)
+ {
+ dlt_register_context(&handle, contextid, description);
+ }
+ else if (mDebugEnabled)
+ {
+ mMapContext.emplace(&handle, std::string(contextid));
+
+ if (mlogDestination == logDestination::COMMAND_LINE)
+ {
+ std::cout << "\033[0;36m[DLT] Registering Context " << contextid << " , " << description << "\033[0m" << std::endl;
+ }
+ else
+ {
+ mFilename << now() << "[DLT] Registering Context " << contextid << " , " << description << std::endl;
+ }
+ }
+}
+
+void CAmDltWrapper::registerContext(DltContext &handle, const char *contextid, const char *description, const DltLogLevelType level, const DltTraceStatusType status)
+{
+ if (mDebugEnabled && mlogDestination == logDestination::DAEMON)
+ {
+ dlt_register_context_ll_ts(&handle, contextid, description, level, status);
+ }
+ else if (mDebugEnabled)
+ {
+ mMapContext.emplace(&handle, std::string(contextid));
+
+ if (mlogDestination == logDestination::COMMAND_LINE)
+ {
+ std::cout << "\033[0;36m[DLT] Registering Context " << contextid << " , " << description << "\033[0m" << std::endl;
+ }
+ else
+ {
+ mFilename << now() << " [DLT] Registering Context " << contextid << " , " << description << std::endl;
+ }
+ }
+}
+
+bool CAmDltWrapper::init(DltLogLevelType loglevel, DltContext *context)
+{
+ pthread_mutex_lock(&mMutex);
+ if (mlogDestination == logDestination::DAEMON)
+ {
+ if (!context)
+ {
+ context = &mDltContext;
+ }
+
+ if (dlt_user_log_write_start(context, &mDltContextData, loglevel) <= 0)
+ {
+ pthread_mutex_unlock(&mMutex);
+ return false;
+ }
+ }
+ else
+ {
+ initNoDlt(loglevel, context);
+ }
+
+ return true;
+}
+
+void CAmDltWrapper::send()
+{
+ if (mlogDestination == logDestination::DAEMON)
+ {
+ dlt_user_log_write_finish(&mDltContextData);
+ }
+ else
+ {
+ if (mlogDestination == logDestination::COMMAND_LINE && mLogOn)
+ {
+ std::cout << mNoDltContextData.buffer.str().c_str() << std::endl;
+ }
+ else if (mLogOn)
+ {
+ mFilename << now() << mNoDltContextData.buffer.str().c_str() << std::endl;
+ }
+
+ mNoDltContextData.buffer.str("");
+ mNoDltContextData.buffer.clear();
+ }
+
+ pthread_mutex_unlock(&mMutex);
+}
+
+void CAmDltWrapper::append(const int8_t value)
+{
+ if (mlogDestination == logDestination::DAEMON)
+ {
+ dlt_user_log_write_int8(&mDltContextData, value);
+ }
+ else
+ {
+ appendNoDLT(value);
+ }
+}
+
+void CAmDltWrapper::append(const uint8_t value)
+{
+ if (mlogDestination == logDestination::DAEMON)
+ {
+ dlt_user_log_write_uint8(&mDltContextData, value);
+ }
+ else
+ {
+ appendNoDLT(value);
+ }
+}
+
+void CAmDltWrapper::append(const int16_t value)
+{
+ if (mlogDestination == logDestination::DAEMON)
+ {
+ dlt_user_log_write_int16(&mDltContextData, value);
+ }
+ else
+ {
+ appendNoDLT(value);
+ }
+}
+
+void CAmDltWrapper::append(const uint16_t value)
+{
+ if (mlogDestination == logDestination::DAEMON)
+ {
+ dlt_user_log_write_uint16(&mDltContextData, value);
+ }
+ else
+ {
+ appendNoDLT(value);
+ }
+}
+
+void CAmDltWrapper::append(const int32_t value)
+{
+ if (mlogDestination == logDestination::DAEMON)
+ {
+ dlt_user_log_write_int32(&mDltContextData, value);
+ }
+ else
+ {
+ appendNoDLT(value);
+ }
+}
+
+void CAmDltWrapper::append(const uint32_t value)
+{
+ if (mlogDestination == logDestination::DAEMON)
+ {
+ dlt_user_log_write_uint32(&mDltContextData, value);
+ }
+ else
+ {
+ appendNoDLT(value);
+ }
+}
+
+void CAmDltWrapper::append(const std::string &value)
+{
+ append(value.c_str());
+}
+
+void CAmDltWrapper::append(const bool value)
+{
+ if (mlogDestination == logDestination::DAEMON)
+ {
+ dlt_user_log_write_bool(&mDltContextData, static_cast<uint8_t>(value));
+ }
+ else
+ {
+ appendNoDLT(value);
+ }
+}
+
+void CAmDltWrapper::append(const int64_t value)
+{
+ if (mlogDestination == logDestination::DAEMON)
+ {
+ dlt_user_log_write_int64(&mDltContextData, value);
+ }
+ else
+ {
+ appendNoDLT(value);
+ }
+}
+
+void CAmDltWrapper::append(const uint64_t value)
+{
+ if (mlogDestination == logDestination::DAEMON)
+ {
+ dlt_user_log_write_uint64(&mDltContextData, value);
+ }
+ else
+ {
+ appendNoDLT(value);
+ }
+}
+
+void CAmDltWrapper::append(const std::vector<uint8_t> &data)
+{
+ if (mlogDestination == logDestination::DAEMON)
+ {
+ dlt_user_log_write_raw(&mDltContextData, (void *)data.data(), data.size());
+ }
+ else
+ {
+ mNoDltContextData.buffer << data.data();
+ }
+}
+
+}
+#else // ------------------------------------------------------------------------------------------------- no DLT !
+CAmDltWrapper::CAmDltWrapper(const char *appid, const char *description, const bool debugEnabled, const logDestination logDest, const std::string Filename, bool onlyError)
+ : mDebugEnabled(debugEnabled)
+ , //
+ mlogDestination(logDest)
+ , //
+ mFilename(NULL)
+ , //
+ mOnlyError(onlyError)
+ , //
+ mLogOn(true)
+{
+ if (logDest == logDestination::DAEMON)
+ {
+ std::cout << "\033[0;31m[DLT] Cannot Use Daemon Logging, active in CMAKE! Using CommandLine\033[0m" << std::endl;
+ mlogDestination = logDestination::COMMAND_LINE;
+ }
+
+ if (mDebugEnabled)
+ {
+ if (mlogDestination == logDestination::COMMAND_LINE)
+ {
+ std::cout << "\033[0;36m[DLT] Registering AppID " << appid << " , " << description << "\033[0m" << std::endl;
+ }
+ else
+ {
+ mFilename.open(Filename, std::ofstream::out | std::ofstream::trunc);
+ if (!mFilename.is_open())
+ {
+ throw std::runtime_error("Cannot open file for logging");
+ }
+
+ mFilename << now() << "[DLT] Registering AppID " << appid << " , " << description << std::endl;
+ }
+ }
+}
+
+CAmDltWrapper::~CAmDltWrapper()
+{
+ if (mpDLTWrapper && mDebugEnabled && mlogDestination == logDestination::COMMAND_LINE)
+ {
+ mFilename.close();
+ }
+}
+
+void CAmDltWrapper::unregisterContext(DltContext &handle)
+{
+}
+
+void CAmDltWrapper::deinit()
+{
+}
+
+void CAmDltWrapper::registerContext(DltContext &handle, const char *contextid, const char *description)
+{
+ if (mDebugEnabled)
+ {
+ mMapContext.emplace(&handle, std::string(contextid));
+
+ if (mlogDestination == logDestination::COMMAND_LINE)
+ {
+ std::cout << "\033[0;36m[DLT] Registering Context " << contextid << " , " << description << "\033[0m" << std::endl;
+ }
+ else
+ {
+ mFilename << now() << "[DLT] Registering Context " << contextid << " , " << description << std::endl;
+ }
+ }
+}
+
+void CAmDltWrapper::registerContext(DltContext &handle, const char *contextid, const char *description, const DltLogLevelType level, const DltTraceStatusType status)
+{
+ if (mDebugEnabled)
+ {
+ mMapContext.emplace(&handle, std::string(contextid));
+
+ if (mlogDestination == logDestination::COMMAND_LINE)
+ {
+ std::cout << "\033[0;36m[DLT] Registering Context " << contextid << " , " << description << "\033[0m" << std::endl;
+ }
+ else
+ {
+ mFilename << now() << " [DLT] Registering Context " << contextid << " , " << description << std::endl;
+ }
+ }
+}
+
+bool CAmDltWrapper::init(DltLogLevelType loglevel, DltContext *context)
+{
+ pthread_mutex_lock(&mMutex);
+ return initNoDlt(loglevel, context);
+}
+
+void CAmDltWrapper::send()
+{
+ if (mlogDestination == logDestination::COMMAND_LINE && mLogOn)
+ {
+ std::cout << mNoDltContextData.buffer.str().c_str() << std::endl;
+ }
+ else if (mLogOn)
+ {
+ mFilename << now() << mNoDltContextData.buffer.str().c_str() << std::endl;
+ }
+
+ mNoDltContextData.buffer.str("");
+ mNoDltContextData.buffer.clear();
+ pthread_mutex_unlock(&mMutex);
+}
+void CAmDltWrapper::append(const int8_t value)
+{
+ appendNoDLT(value);
+}
+void CAmDltWrapper::append(const uint8_t value)
+{
+ appendNoDLT(value);
+}
+
+void CAmDltWrapper::append(const int16_t value)
+{
+ appendNoDLT(value);
+}
+
+void CAmDltWrapper::append(const uint16_t value)
+{
+ appendNoDLT(value);
+}
+
+void CAmDltWrapper::append(const int32_t value)
+{
+ appendNoDLT(value);
+}
+
+void CAmDltWrapper::append(const uint32_t value)
+{
+ appendNoDLT(value);
+}
+
+void CAmDltWrapper::append(const std::string &value)
+{
+ append(value.c_str());
+}
+
+void CAmDltWrapper::append(const bool value)
+{
+ appendNoDLT(value);
+}
+
+void CAmDltWrapper::append(const int64_t value)
+{
+ appendNoDLT(value);
+}
+
+void CAmDltWrapper::append(const uint64_t value)
+{
+ appendNoDLT(value);
+}
+
+void CAmDltWrapper::append(const std::vector<uint8_t> &data)
+{
+ mNoDltContextData.buffer << data.data();
+}
+
+}
+#endif // WITH_DLT
diff --git a/AudioManagerUtilities/src/CAmSocketHandler.cpp b/AudioManagerUtilities/src/CAmSocketHandler.cpp
index 9d9196a..8f0cdb0 100644
--- a/AudioManagerUtilities/src/CAmSocketHandler.cpp
+++ b/AudioManagerUtilities/src/CAmSocketHandler.cpp
@@ -37,66 +37,71 @@
#include "CAmSocketHandler.h"
#ifdef WITH_TIMERFD
-#include <sys/timerfd.h>
+# include <sys/timerfd.h>
#endif
-#define END_EVENT (UINT64_MAX >> 1)
+#define END_EVENT (UINT64_MAX >> 1)
namespace am
{
-CAmSocketHandler::CAmSocketHandler() :
- mEventFd(-1),
- mSignalFd(-1),
- mDispatchDone(true),
- mSetPollKeys(MAX_POLLHANDLE),
- mMapShPoll(),
- mSetTimerKeys(MAX_TIMERHANDLE),
- mListTimer(),
+CAmSocketHandler::CAmSocketHandler()
+ : mEventFd(-1)
+ , mSignalFd(-1)
+ , mDispatchDone(true)
+ , mSetPollKeys(MAX_POLLHANDLE)
+ , mMapShPoll()
+ , mSetTimerKeys(MAX_TIMERHANDLE)
+ , mListTimer()
+ ,
#ifndef WITH_TIMERFD
- mListActiveTimer(),
+ mListActiveTimer()
+ ,
#endif
- mSetSignalhandlerKeys(MAX_POLLHANDLE),
- mSignalHandlers(),
- mInternalCodes(internal_codes_e::NO_ERROR)
+ mSetSignalhandlerKeys(MAX_POLLHANDLE)
+ , mSignalHandlers()
+ , mInternalCodes(internal_codes_e::NO_ERROR)
#ifndef WITH_TIMERFD
- ,mStartTime()
+ , mStartTime()
#endif
{
- auto actionPoll = [this](const pollfd pollfd, const sh_pollHandle_t, void*)
- {
- /* We have a valid signal, read the info from the fd */
- uint64_t events;
- ssize_t bytes = read(pollfd.fd, &events, sizeof(events));
- if (bytes == sizeof(events))
- {
- if (events >= END_EVENT)
- {
- for (auto & elem : mMapShPoll)
- {
- if (elem.second.state == poll_states_e::UPDATE ||
- elem.second.state == poll_states_e::VALID)
- {
- elem.second.state = poll_states_e::ADD;
- }
- }
- mDispatchDone = true;
- }
- return;
- }
-
- // ppoll on EAGAIN
- if ((bytes == -1) && (errno == EAGAIN))
- return;
-
- //Failed to read from event fd...
- std::ostringstream msg;
- msg << "Failed to read from event fd: " << pollfd.fd << " errno: " << std::strerror(errno);
- throw std::runtime_error(msg.str());
- };
-
- //add the pipe to the poll - nothing needs to be processed here we just need the pipe to trigger the ppoll
+ auto actionPoll = [this](const pollfd pollfd, const sh_pollHandle_t, void *){
+ /* We have a valid signal, read the info from the fd */
+ uint64_t events;
+ ssize_t bytes = read(pollfd.fd, &events, sizeof(events));
+ if (bytes == sizeof(events))
+ {
+ if (events >= END_EVENT)
+ {
+ for (auto &elem : mMapShPoll)
+ {
+ if (elem.second.state == poll_states_e::UPDATE ||
+ elem.second.state == poll_states_e::VALID)
+ {
+ elem.second.state = poll_states_e::ADD;
+ }
+ }
+
+ mDispatchDone = true;
+ }
+
+ return;
+ }
+
+ // ppoll on EAGAIN
+ if ((bytes == -1) && (errno == EAGAIN))
+ {
+ return;
+ }
+
+ // Failed to read from event fd...
+ std::ostringstream msg;
+ msg << "Failed to read from event fd: " << pollfd.fd << " errno: " << std::strerror(errno);
+ throw std::runtime_error(msg.str());
+ };
+
+ // add the pipe to the poll - nothing needs to be processed here we just need the pipe to trigger the ppoll
sh_pollHandle_t handle;
mEventFd = eventfd(1, EFD_NONBLOCK | EFD_CLOEXEC);
if (addFDPoll(mEventFd, POLLIN, NULL, actionPoll, NULL, NULL, NULL, handle) != E_OK)
@@ -107,26 +112,26 @@ CAmSocketHandler::CAmSocketHandler() :
CAmSocketHandler::~CAmSocketHandler()
{
- for (const auto& it : mMapShPoll)
+ for (const auto &it : mMapShPoll)
{
close(it.second.pollfdValue.fd);
}
}
-//todo: maybe have some: give me more time returned?
+// todo: maybe have some: give me more time returned?
/**
- * start the block listening for filedescriptors. This is the mainloop.
- */
+ * start the block listening for filedescriptors. This is the mainloop.
+ */
void CAmSocketHandler::start_listenting()
{
mDispatchDone = false;
-#ifndef WITH_TIMERFD
+#ifndef WITH_TIMERFD
clock_gettime(CLOCK_MONOTONIC, &mStartTime);
-#endif
+#endif
timespec buffertime;
- VectorPollfd_t fdPollingArray; //!<the polling array for ppoll
+ VectorPollfd_t fdPollingArray; //!< the polling array for ppoll
while (!mDispatchDone)
{
@@ -138,35 +143,35 @@ void CAmSocketHandler::start_listenting()
for (auto it = mMapShPoll.begin(); it != mMapShPoll.end(); )
{
// NOTE: The order of the switch/case statement reflects the state flow
- auto& elem = it->second;
+ auto &elem = it->second;
switch (elem.state)
{
- case poll_states_e::ADD:
- elem.state = poll_states_e::UPDATE;
- fdPollIt = fdPollingArray.emplace(fdPollIt);
- break;
-
- case poll_states_e::UPDATE:
- elem.state = poll_states_e::VALID;
- CAmSocketHandler::prepare(elem);
- *fdPollIt = elem.pollfdValue;
- break;
-
- case poll_states_e::VALID:
- // check for multi-thread access
- assert(fdPollIt != fdPollingArray.end());
- ++fdPollIt;
- ++it;
- break;
-
- case poll_states_e::REMOVE:
- elem.state = poll_states_e::INVALID;
- fdPollIt = fdPollingArray.erase(fdPollIt);
- break;
-
- case poll_states_e::INVALID:
- it = mMapShPoll.erase(it);
- break;
+ case poll_states_e::ADD:
+ elem.state = poll_states_e::UPDATE;
+ fdPollIt = fdPollingArray.emplace(fdPollIt);
+ break;
+
+ case poll_states_e::UPDATE:
+ elem.state = poll_states_e::VALID;
+ CAmSocketHandler::prepare(elem);
+ *fdPollIt = elem.pollfdValue;
+ break;
+
+ case poll_states_e::VALID:
+ // check for multi-thread access
+ assert(fdPollIt != fdPollingArray.end());
+ ++fdPollIt;
+ ++it;
+ break;
+
+ case poll_states_e::REMOVE:
+ elem.state = poll_states_e::INVALID;
+ fdPollIt = fdPollingArray.erase(fdPollIt);
+ break;
+
+ case poll_states_e::INVALID:
+ it = mMapShPoll.erase(it);
+ break;
}
}
@@ -186,16 +191,20 @@ void CAmSocketHandler::start_listenting()
if (pollStatus > 0)
{
// stage 0+1, call firedCB
- std::list<sh_poll_s*> listPoll;
- for (auto& it : fdPollingArray)
+ std::list<sh_poll_s *> listPoll;
+ for (auto &it : fdPollingArray)
{
it.revents &= it.events;
if (it.revents == 0)
+ {
continue;
+ }
- sh_poll_s& pollObj = mMapShPoll.at(it.fd);
+ sh_poll_s &pollObj = mMapShPoll.at(it.fd);
if (pollObj.state != poll_states_e::VALID)
+ {
continue;
+ }
// ensure to copy the revents fired in fdPollingArray
pollObj.pollfdValue.revents = it.revents;
@@ -203,11 +212,11 @@ void CAmSocketHandler::start_listenting()
CAmSocketHandler::fire(pollObj);
it.revents = 0;
}
-
- //stage 2, lets ask around if some dispatching is necessary, the ones who need stay on the list
+
+ // stage 2, lets ask around if some dispatching is necessary, the ones who need stay on the list
listPoll.remove_if(CAmSocketHandler::noDispatching);
- //stage 3, the ones left need to dispatch, we do this as long as there is something to dispatch..
+ // stage 3, the ones left need to dispatch, we do this as long as there is something to dispatch..
do
{
listPoll.remove_if(CAmSocketHandler::dispatchingFinished);
@@ -218,11 +227,11 @@ void CAmSocketHandler::start_listenting()
logError("SocketHandler::start_listenting ppoll returned with error", errno);
throw std::runtime_error(std::string("SocketHandler::start_listenting ppoll returned with error."));
}
- else //Timerevent
+ else // Timerevent
{
#ifndef WITH_TIMERFD
- //this was a timer event, we need to take care about the timers
- //find out the timedifference to starttime
+ // this was a timer event, we need to take care about the timers
+ // find out the timedifference to starttime
timerUp();
#endif
}
@@ -230,36 +239,39 @@ void CAmSocketHandler::start_listenting()
}
/**
- * exits the loop
- */
+ * exits the loop
+ */
void CAmSocketHandler::stop_listening()
{
- //fire the ending event
+ // fire the ending event
if (mDispatchDone)
+ {
return;
+ }
wakeupWorker("stop_listening", END_EVENT);
#ifndef WITH_TIMERFD
- //this is for all running timers only - we need to handle the additional offset here
+ // this is for all running timers only - we need to handle the additional offset here
if (!mListActiveTimer.empty())
{
timespec currentTime, correctionTime;
clock_gettime(CLOCK_MONOTONIC, &currentTime);
correctionTime = timespecSub(currentTime, mStartTime);
- std::for_each(mListActiveTimer.begin(), mListActiveTimer.end(), [&correctionTime](sh_timer_s& t)
- { t.countdown = timespecSub(t.countdown, correctionTime);});
+ std::for_each(mListActiveTimer.begin(), mListActiveTimer.end(), [&correctionTime](sh_timer_s &t){
+ t.countdown = timespecSub(t.countdown, correctionTime);
+ });
}
-#endif
+#endif // ifndef WITH_TIMERFD
}
void CAmSocketHandler::exit_mainloop()
{
- //end the while loop
+ // end the while loop
stop_listening();
}
-void CAmSocketHandler::wakeupWorker(const std::string & func, const uint64_t value)
+void CAmSocketHandler::wakeupWorker(const std::string &func, const uint64_t value)
{
if (write(mEventFd, &value, sizeof(value)) < 0)
{
@@ -270,27 +282,27 @@ void CAmSocketHandler::wakeupWorker(const std::string & func, const uint64_t val
}
}
-bool CAmSocketHandler::fatalErrorOccurred()
+bool CAmSocketHandler::fatalErrorOccurred()
{
return (mInternalCodes != internal_codes_e::NO_ERROR);
}
/**
- * Adds a signal handler filedescriptor to the polling loop
- *
- */
-am_Error_e CAmSocketHandler::listenToSignals(const std::vector<uint8_t> & listSignals)
+ * Adds a signal handler filedescriptor to the polling loop
+ *
+ */
+am_Error_e CAmSocketHandler::listenToSignals(const std::vector<uint8_t> &listSignals)
{
- int fdErr;
- uint8_t addedSignals = 0;
+ int fdErr;
+ uint8_t addedSignals = 0;
sigset_t sigset;
-
- if(0==listSignals.size())
+
+ if (0 == listSignals.size())
{
logWarning("Empty signal list!");
return (E_NOT_POSSIBLE);
}
-
+
/* Create a sigset of all the signals that we're interested in */
fdErr = sigemptyset(&sigset);
if (fdErr != 0)
@@ -298,17 +310,21 @@ am_Error_e CAmSocketHandler::listenToSignals(const std::vector<uint8_t> & listSi
logError("Could not create sigset!");
return (E_NOT_POSSIBLE);
}
-
- for(uint8_t itSignal : listSignals)
+
+ for (uint8_t itSignal : listSignals)
{
fdErr = sigaddset(&sigset, itSignal);
if (fdErr != 0)
+ {
logWarning("Could not add", itSignal);
+ }
else
- addedSignals++;
+ {
+ addedSignals++;
+ }
}
-
- if(0==addedSignals)
+
+ if (0 == addedSignals)
{
logWarning("None of the signals were added!");
return (E_NOT_POSSIBLE);
@@ -332,32 +348,36 @@ am_Error_e CAmSocketHandler::listenToSignals(const std::vector<uint8_t> & listSi
return (E_NOT_POSSIBLE);
}
- auto actionPoll = [this](const pollfd pollfd, const sh_pollHandle_t, void*)
- {
- /* We have a valid signal, read the info from the fd */
- struct signalfd_siginfo info;
- ssize_t bytes = read(pollfd.fd, &info, sizeof(info));
- if (bytes == sizeof(info))
- {
- /* Notify all listeners */
- for(const auto& it: mSignalHandlers)
- it.callback(it.handle, info, it.userData);
- return;
- }
-
- // ppoll on EAGAIN
- if ((bytes == -1) && (errno == EAGAIN))
- return;
-
- //Failed to read from fd...
- std::ostringstream msg;
- msg << "Failed to read from signal fd: " << pollfd.fd << " errno: " << std::strerror(errno);
- throw std::runtime_error(msg.str());
- };
+ auto actionPoll = [this](const pollfd pollfd, const sh_pollHandle_t, void *){
+ /* We have a valid signal, read the info from the fd */
+ struct signalfd_siginfo info;
+ ssize_t bytes = read(pollfd.fd, &info, sizeof(info));
+ if (bytes == sizeof(info))
+ {
+ /* Notify all listeners */
+ for (const auto &it: mSignalHandlers)
+ {
+ it.callback(it.handle, info, it.userData);
+ }
+
+ return;
+ }
+
+ // ppoll on EAGAIN
+ if ((bytes == -1) && (errno == EAGAIN))
+ {
+ return;
+ }
+
+ // Failed to read from fd...
+ std::ostringstream msg;
+ msg << "Failed to read from signal fd: " << pollfd.fd << " errno: " << std::strerror(errno);
+ throw std::runtime_error(msg.str());
+ };
/* We're going to add the signal fd through addFDPoll. At this point we don't have any signal listeners. */
sh_pollHandle_t handle;
return addFDPoll(mSignalFd, POLLIN | POLLERR | POLLHUP, NULL, actionPoll, NULL, NULL, NULL, handle);
- }
+ }
else
{
if (signalfd(mSignalFd, &sigset, 0) == -1)
@@ -365,39 +385,41 @@ am_Error_e CAmSocketHandler::listenToSignals(const std::vector<uint8_t> & listSi
logError("Could not update signal fd!", std::strerror(errno));
return (E_NOT_POSSIBLE);
}
+
return E_OK;
}
}
/**
- * Adds a filedescriptor to the polling loop
- * @param fd the filedescriptor
- * @param event the event flags
- * @param prepare a std::function that is called before the loop is entered
- * @param fired a std::function that is called when the filedescriptor needs to be read
- * @param check a std::function that is called to check if further actions are neccessary
- * @param dispatch a std::function that is called to dispatch the received data
- * @param userData a pointer to userdata that is always passed around
- * @param handle the handle of this poll
- * @return E_OK if the descriptor was added
- * E_NON_EXISTENT if the fd is not valid
- * E_ALREADY_EXISTS if the fd is already known
- * E_NOT_POSSIBLE if the maximum handle threshold is reached
- */
-
+ * Adds a filedescriptor to the polling loop
+ * @param fd the filedescriptor
+ * @param event the event flags
+ * @param prepare a std::function that is called before the loop is entered
+ * @param fired a std::function that is called when the filedescriptor needs to be read
+ * @param check a std::function that is called to check if further actions are neccessary
+ * @param dispatch a std::function that is called to dispatch the received data
+ * @param userData a pointer to userdata that is always passed around
+ * @param handle the handle of this poll
+ * @return E_OK if the descriptor was added
+ * E_NON_EXISTENT if the fd is not valid
+ * E_ALREADY_EXISTS if the fd is already known
+ * E_NOT_POSSIBLE if the maximum handle threshold is reached
+ */
am_Error_e CAmSocketHandler::addFDPoll(const int fd,
- const short event,
- std::function<void(const sh_pollHandle_t handle, void* userData)> prepare,
- std::function<void(const pollfd pollfd, const sh_pollHandle_t handle, void* userData)> fired,
- std::function<bool(const sh_pollHandle_t handle, void* userData)> check,
- std::function<bool(const sh_pollHandle_t handle, void* userData)> dispatch,
- void* userData,
- sh_pollHandle_t& handle)
+ const short event,
+ std::function<void(const sh_pollHandle_t handle, void *userData)> prepare,
+ std::function<void(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)> fired,
+ std::function<bool(const sh_pollHandle_t handle, void *userData)> check,
+ std::function<bool(const sh_pollHandle_t handle, void *userData)> dispatch,
+ void *userData,
+ sh_pollHandle_t &handle)
{
sh_poll_s pollData;
if (!fdIsValid(fd))
+ {
return E_NON_EXISTENT;
+ }
const auto elem = mMapShPoll.find(fd);
if (elem != mMapShPoll.end())
@@ -405,38 +427,38 @@ am_Error_e CAmSocketHandler::addFDPoll(const int fd,
// The fd was already in map therefore we need to trigger an update instead
switch (elem->second.state)
{
- case poll_states_e::REMOVE:
- pollData.state = poll_states_e::UPDATE;
- break;
+ case poll_states_e::REMOVE:
+ pollData.state = poll_states_e::UPDATE;
+ break;
- case poll_states_e::INVALID:
- pollData.state = poll_states_e::ADD;
- break;
+ case poll_states_e::INVALID:
+ pollData.state = poll_states_e::ADD;
+ break;
- default:
- logError("CAmSocketHandler::addFDPoll fd", fd, "already registered!");
- return E_ALREADY_EXISTS;
+ default:
+ logError("CAmSocketHandler::addFDPoll fd", fd, "already registered!");
+ return E_ALREADY_EXISTS;
}
}
- //create a new handle for the poll
+ // create a new handle for the poll
if (!nextHandle(mSetPollKeys))
{
logError("CAmSocketHandler::addFDPoll Max handle count reached!");
return (E_NOT_POSSIBLE);
}
- pollData.pollfdValue.fd = fd;
- pollData.handle = mSetPollKeys.lastUsedID;
- pollData.pollfdValue.events = event;
+ pollData.pollfdValue.fd = fd;
+ pollData.handle = mSetPollKeys.lastUsedID;
+ pollData.pollfdValue.events = event;
pollData.pollfdValue.revents = 0;
- pollData.prepareCB = prepare;
- pollData.firedCB = fired;
- pollData.checkCB = check;
- pollData.dispatchCB = dispatch;
- pollData.userData = userData;
+ pollData.prepareCB = prepare;
+ pollData.firedCB = fired;
+ pollData.checkCB = check;
+ pollData.dispatchCB = dispatch;
+ pollData.userData = userData;
- //add new data to the list
+ // add new data to the list
mMapShPoll[fd] = pollData;
wakeupWorker("addFDPoll");
@@ -446,49 +468,60 @@ am_Error_e CAmSocketHandler::addFDPoll(const int fd,
}
/**
- * Adds a filedescriptor to the polling loop
- * @param fd the filedescriptor
- * @param event the event flags
- * @param prepare a callback that is called before the loop is entered
- * @param fired a callback that is called when the filedescriptor needs to be read
- * @param check a callback that is called to check if further actions are neccessary
- * @param dispatch a callback that is called to dispatch the received data
- * @param userData a pointer to userdata that is always passed around
- * @param handle the handle of this poll
- * @return E_OK if the descriptor was added
- * E_NON_EXISTENT if the fd is not valid
- * E_ALREADY_EXISTS if the fd is already known
- * E_NOT_POSSIBLE if the maximum handle threshold is reached
- */
-am::am_Error_e CAmSocketHandler::addFDPoll(const int fd, const short event, IAmShPollPrepare *prepare, IAmShPollFired *fired, IAmShPollCheck *check, IAmShPollDispatch *dispatch, void *userData, sh_pollHandle_t & handle)
+ * Adds a filedescriptor to the polling loop
+ * @param fd the filedescriptor
+ * @param event the event flags
+ * @param prepare a callback that is called before the loop is entered
+ * @param fired a callback that is called when the filedescriptor needs to be read
+ * @param check a callback that is called to check if further actions are neccessary
+ * @param dispatch a callback that is called to dispatch the received data
+ * @param userData a pointer to userdata that is always passed around
+ * @param handle the handle of this poll
+ * @return E_OK if the descriptor was added
+ * E_NON_EXISTENT if the fd is not valid
+ * E_ALREADY_EXISTS if the fd is already known
+ * E_NOT_POSSIBLE if the maximum handle threshold is reached
+ */
+am::am_Error_e CAmSocketHandler::addFDPoll(const int fd, const short event, IAmShPollPrepare *prepare, IAmShPollFired *fired, IAmShPollCheck *check, IAmShPollDispatch *dispatch, void *userData, sh_pollHandle_t &handle)
{
- std::function<void(const sh_pollHandle_t, void*)> prepareCB; //preperation callback
- std::function<void(const pollfd, const sh_pollHandle_t, void*)> firedCB; //fired callback
- std::function<bool(const sh_pollHandle_t, void*)> checkCB; //check callback
- std::function<bool(const sh_pollHandle_t, void*)> dispatchCB; //check callback
+ std::function<void(const sh_pollHandle_t, void *)> prepareCB; // preperation callback
+ std::function<void(const pollfd, const sh_pollHandle_t, void *)> firedCB; // fired callback
+ std::function<bool(const sh_pollHandle_t, void *)> checkCB; // check callback
+ std::function<bool(const sh_pollHandle_t, void *)> dispatchCB; // check callback
if (prepare)
+ {
prepareCB = std::bind(&IAmShPollPrepare::Call, prepare, std::placeholders::_1, std::placeholders::_2);
+ }
+
if (fired)
+ {
firedCB = std::bind(&IAmShPollFired::Call, fired, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3);
+ }
+
if (check)
+ {
checkCB = std::bind(&IAmShPollCheck::Call, check, std::placeholders::_1, std::placeholders::_2);
+ }
+
if (dispatch)
+ {
dispatchCB = std::bind(&IAmShPollDispatch::Call, dispatch, std::placeholders::_1, std::placeholders::_2);
+ }
return addFDPoll(fd, event, prepareCB, firedCB, checkCB, dispatchCB, userData, handle);
}
/**
- * removes a filedescriptor from the poll loop
- * @param handle
- * @param [rmv] default RMV_ONLY_FDPOLL
- * @return
- */
+ * removes a filedescriptor from the poll loop
+ * @param handle
+ * @param [rmv] default RMV_ONLY_FDPOLL
+ * @return
+ */
am_Error_e CAmSocketHandler::removeFDPoll(const sh_pollHandle_t handle)
{
- for (auto& it : mMapShPoll)
+ for (auto &it : mMapShPoll)
{
if (it.second.handle == handle)
{
@@ -498,18 +531,19 @@ am_Error_e CAmSocketHandler::removeFDPoll(const sh_pollHandle_t handle)
return E_OK;
}
}
+
logWarning("CAmSocketHandler::removeFDPoll handle unknown", handle);
return E_UNKNOWN;
}
/**
- * Adds a callback for any signals
- * @param callback
- * @param handle the handle of this poll
- * @param userData a pointer to userdata that is always passed around
- * @return E_OK if the descriptor was added, E_NON_EXISTENT if the fd is not valid
- */
-am_Error_e CAmSocketHandler::addSignalHandler(std::function<void(const sh_pollHandle_t handle, const signalfd_siginfo & info, void* userData)> callback, sh_pollHandle_t& handle, void * userData)
+ * Adds a callback for any signals
+ * @param callback
+ * @param handle the handle of this poll
+ * @param userData a pointer to userdata that is always passed around
+ * @return E_OK if the descriptor was added, E_NON_EXISTENT if the fd is not valid
+ */
+am_Error_e CAmSocketHandler::addSignalHandler(std::function<void(const sh_pollHandle_t handle, const signalfd_siginfo &info, void *userData)> callback, sh_pollHandle_t &handle, void *userData)
{
if (!nextHandle(mSetSignalhandlerKeys))
{
@@ -519,7 +553,7 @@ am_Error_e CAmSocketHandler::addSignalHandler(std::function<void(const sh_pollHa
mSignalHandlers.emplace_back();
mSignalHandlers.back().callback = callback;
- mSignalHandlers.back().handle = mSetSignalhandlerKeys.lastUsedID;
+ mSignalHandlers.back().handle = mSetSignalhandlerKeys.lastUsedID;
mSignalHandlers.back().userData = userData;
handle = mSetSignalhandlerKeys.lastUsedID;
@@ -527,10 +561,10 @@ am_Error_e CAmSocketHandler::addSignalHandler(std::function<void(const sh_pollHa
}
/**
- * removes a signal handler from the list
- * @param handle is signal handler id
- * @return E_OK in case of success, E_UNKNOWN if the handler was not found.
- */
+ * removes a signal handler from the list
+ * @param handle is signal handler id
+ * @return E_OK in case of success, E_UNKNOWN if the handler was not found.
+ */
am_Error_e CAmSocketHandler::removeSignalHandler(const sh_pollHandle_t handle)
{
VectorSignalHandlers_t::iterator it(mSignalHandlers.begin());
@@ -543,37 +577,37 @@ am_Error_e CAmSocketHandler::removeSignalHandler(const sh_pollHandle_t handle)
return (E_OK);
}
}
+
return (E_UNKNOWN);
}
/**
- * adds a timer to the list of timers. The callback will be fired when the timer is up.
- * This is not a high precise timer, it is very coarse. It is meant to be used for timeouts when waiting
- * for an answer via a filedescriptor.
- * One time timer. If you need again a timer, you need to add a new timer in the callback of the old one.
- * @param timeouts timeouts time until the callback is fired
- * @param callback callback the callback
- * @param handle handle the handle that is created for the timer is returned. Can be used to remove the timer
- * @param userData pointer always passed with the call
- * @return E_OK in case of success
- */
-
-am_Error_e CAmSocketHandler::addTimer(const timespec & timeouts, IAmShTimerCallBack* callback, sh_timerHandle_t& handle, void * userData, const bool repeats)
+ * adds a timer to the list of timers. The callback will be fired when the timer is up.
+ * This is not a high precise timer, it is very coarse. It is meant to be used for timeouts when waiting
+ * for an answer via a filedescriptor.
+ * One time timer. If you need again a timer, you need to add a new timer in the callback of the old one.
+ * @param timeouts timeouts time until the callback is fired
+ * @param callback callback the callback
+ * @param handle handle the handle that is created for the timer is returned. Can be used to remove the timer
+ * @param userData pointer always passed with the call
+ * @return E_OK in case of success
+ */
+am_Error_e CAmSocketHandler::addTimer(const timespec &timeouts, IAmShTimerCallBack *callback, sh_timerHandle_t &handle, void *userData, const bool repeats)
{
- assert(callback!=NULL);
+ assert(callback != NULL);
- std::function<void(const sh_timerHandle_t handle, void* userData)> callbackFunc;
+ std::function<void(const sh_timerHandle_t handle, void *userData)> callbackFunc;
callbackFunc = std::bind(&IAmShTimerCallBack::Call, callback, std::placeholders::_1, std::placeholders::_2);
return addTimer(timeouts, callbackFunc, handle, userData, repeats);
}
-am_Error_e CAmSocketHandler::addTimer(const timespec & timeouts, std::function<void(const sh_timerHandle_t handle, void* userData)> callback, sh_timerHandle_t& handle, void * userData, const bool repeats)
+am_Error_e CAmSocketHandler::addTimer(const timespec &timeouts, std::function<void(const sh_timerHandle_t handle, void *userData)> callback, sh_timerHandle_t &handle, void *userData, const bool repeats)
{
assert(!((timeouts.tv_sec == 0) && (timeouts.tv_nsec == 0)));
-#ifndef WITH_TIMERFD
- //create a new handle for the timer
+#ifndef WITH_TIMERFD
+ // create a new handle for the timer
if (!nextHandle(mSetTimerKeys))
{
logError("CAmSocketHandler::addTimer Could not create new timers, too many open!");
@@ -581,69 +615,78 @@ am_Error_e CAmSocketHandler::addTimer(const timespec & timeouts, std::function<v
}
mListTimer.emplace_back();
- sh_timer_s & timerItem = mListTimer.back();
+ sh_timer_s &timerItem = mListTimer.back();
- //create a new handle for the timer
+ // create a new handle for the timer
handle = mSetTimerKeys.lastUsedID;
timerItem.countdown = timeouts;
- timerItem.callback = callback;
- timerItem.userData = userData;
+ timerItem.callback = callback;
+ timerItem.userData = userData;
timerItem.handle = handle;
- //we add here the time difference between startTime and currenttime, because this time will be substracted later on in timecorrection
+ // we add here the time difference between startTime and currenttime, because this time will be substracted later on in timecorrection
timespec currentTime;
clock_gettime(CLOCK_MONOTONIC, &currentTime);
- if (!mDispatchDone)//the mainloop is started
- timerItem.countdown = timespecAdd(timeouts, timespecSub(currentTime, mStartTime));
+ if (!mDispatchDone)// the mainloop is started
+ {
+ timerItem.countdown = timespecAdd(timeouts, timespecSub(currentTime, mStartTime));
+ }
+
mListActiveTimer.push_back(timerItem);
mListActiveTimer.sort(compareCountdown);
return (E_OK);
-
-#else
+#else // ifndef WITH_TIMERFD
sh_timer_s timerItem;
timerItem.countdown.it_value = timeouts;
if (repeats)
+ {
timerItem.countdown.it_interval = timeouts;
+ }
else
{
timespec zero;
- zero.tv_sec = 0;
- zero.tv_nsec = 0;
+ zero.tv_sec = 0;
+ zero.tv_nsec = 0;
timerItem.countdown.it_interval = zero;
}
- timerItem.fd = -1;
+ timerItem.fd = -1;
timerItem.userData = userData;
am_Error_e err = createTimeFD(timerItem.countdown, timerItem.fd);
if (err != E_OK)
+ {
return err;
+ }
- auto actionPoll = [this](const pollfd pollfd, const sh_pollHandle_t handle, void* userData)
- {
- uint64_t expCnt;
- ssize_t bytes = read(pollfd.fd, &expCnt, sizeof(expCnt));
- if (bytes == sizeof(expCnt))
- return;
+ auto actionPoll = [this](const pollfd pollfd, const sh_pollHandle_t handle, void *userData){
+ uint64_t expCnt;
+ ssize_t bytes = read(pollfd.fd, &expCnt, sizeof(expCnt));
+ if (bytes == sizeof(expCnt))
+ {
+ return;
+ }
- // ppoll has to be called again in following case
- if ((bytes == -1) && (errno == EAGAIN))
- return;
+ // ppoll has to be called again in following case
+ if ((bytes == -1) && (errno == EAGAIN))
+ {
+ return;
+ }
- // failed to read data from timer_fd...
- std::ostringstream msg;
- msg << "Failed to read from timer fd: " << pollfd.fd << " errno: " << std::strerror(errno);
- throw std::runtime_error(msg.str());
- };
+ // failed to read data from timer_fd...
+ std::ostringstream msg;
+ msg << "Failed to read from timer fd: " << pollfd.fd << " errno: " << std::strerror(errno);
+ throw std::runtime_error(msg.str());
+ };
err = addFDPoll(timerItem.fd, POLLIN | POLLERR, NULL, actionPoll,
- [callback](const sh_pollHandle_t handle, void* userData)->bool {
- callback(handle, userData);
- return false;
- },
- NULL, userData, handle);
+ [callback](const sh_pollHandle_t handle, void *userData) -> bool {
+ callback(handle, userData);
+ return false;
+ },
+ NULL, userData, handle);
if (err == E_OK)
{
@@ -654,24 +697,25 @@ am_Error_e CAmSocketHandler::addTimer(const timespec & timeouts, std::function<v
// E_NOT_POSSIBLE is the only case were we need to close the timer
if (err == E_NOT_POSSIBLE)
+ {
close(timerItem.fd);
-
+ }
return err;
-#endif
+#endif // ifndef WITH_TIMERFD
}
/**
- * removes a timer from the list of timers
- * @param handle the handle to the timer
- * @return E_OK in case of success, E_UNKNOWN if timer was not found.
- */
+ * removes a timer from the list of timers
+ * @param handle the handle to the timer
+ * @return E_OK in case of success, E_UNKNOWN if timer was not found.
+ */
am_Error_e CAmSocketHandler::removeTimer(const sh_timerHandle_t handle)
{
assert(handle != 0);
- //stop the current timer
-#ifdef WITH_TIMERFD
+ // stop the current timer
+#ifdef WITH_TIMERFD
std::list<sh_timer_s>::iterator it(mListTimer.begin());
while (it != mListTimer.end())
{
@@ -682,11 +726,12 @@ am_Error_e CAmSocketHandler::removeTimer(const sh_timerHandle_t handle)
mListTimer.erase(it);
return err;
}
+
++it;
}
- return (E_NON_EXISTENT);
-#else
+ return (E_NON_EXISTENT);
+#else // ifdef WITH_TIMERFD
stopTimer(handle);
std::list<sh_timer_s>::iterator it(mListTimer.begin());
while (it != mListTimer.end())
@@ -697,39 +742,50 @@ am_Error_e CAmSocketHandler::removeTimer(const sh_timerHandle_t handle)
mSetTimerKeys.pollHandles.erase(handle);
return (E_OK);
}
+
++it;
}
return (E_UNKNOWN);
-#endif
+#endif // ifdef WITH_TIMERFD
}
/**
- * restarts a timer and updates with a new interva
- * @param handle handle to the timer
- * @param timeouts new timout time
- * @return E_OK on success, E_NON_EXISTENT if the handle was not found
- */
-am_Error_e CAmSocketHandler::updateTimer(const sh_timerHandle_t handle, const timespec & timeouts)
+ * restarts a timer and updates with a new interva
+ * @param handle handle to the timer
+ * @param timeouts new timout time
+ * @return E_OK on success, E_NON_EXISTENT if the handle was not found
+ */
+am_Error_e CAmSocketHandler::updateTimer(const sh_timerHandle_t handle, const timespec &timeouts)
{
#ifdef WITH_TIMERFD
std::list<sh_timer_s>::iterator it = mListTimer.begin();
for (; it != mListTimer.end(); ++it)
{
if (it->handle == handle)
+ {
break;
+ }
}
+
if (it == mListTimer.end())
+ {
return (E_NON_EXISTENT);
+ }
if (it->countdown.it_interval.tv_nsec != 0 || it->countdown.it_interval.tv_sec != 0)
+ {
it->countdown.it_interval = timeouts;
+ }
+
it->countdown.it_value = timeouts;
if (!fdIsValid(it->fd))
{
am_Error_e err = createTimeFD(it->countdown, it->fd);
if (err != E_OK)
+ {
return err;
+ }
}
else
{
@@ -739,60 +795,66 @@ am_Error_e CAmSocketHandler::updateTimer(const sh_timerHandle_t handle, const ti
return E_NOT_POSSIBLE;
}
}
-#else
-
- //update the mList ....
- sh_timer_s timerItem;
+#else // ifdef WITH_TIMERFD
+ // update the mList ....
+ sh_timer_s timerItem;
std::list<sh_timer_s>::iterator it(mListTimer.begin()), activeIt(mListActiveTimer.begin());
- bool found(false);
+ bool found(false);
for (; it != mListTimer.end(); ++it)
{
if (it->handle == handle)
{
it->countdown = timeouts;
- timerItem = *it;
- found = true;
+ timerItem = *it;
+ found = true;
break;
}
}
+
if (!found)
- return (E_NON_EXISTENT);
+ {
+ return (E_NON_EXISTENT);
+ }
found = false;
- //we add here the time difference between startTime and currenttime, because this time will be substracted later on in timecorrection
+ // we add here the time difference between startTime and currenttime, because this time will be substracted later on in timecorrection
timespec currentTime, timeoutsCorrected;
- currentTime.tv_nsec=timeoutsCorrected.tv_nsec=0;
- currentTime.tv_sec=timeoutsCorrected.tv_sec=0;
+ currentTime.tv_nsec = timeoutsCorrected.tv_nsec = 0;
+ currentTime.tv_sec = timeoutsCorrected.tv_sec = 0;
clock_gettime(CLOCK_MONOTONIC, &currentTime);
- if (!mDispatchDone)//the mainloop is started
- timeoutsCorrected = timespecAdd(timeouts, timespecSub(currentTime, mStartTime));
+ if (!mDispatchDone)// the mainloop is started
+ {
+ timeoutsCorrected = timespecAdd(timeouts, timespecSub(currentTime, mStartTime));
+ }
for (; activeIt != mListActiveTimer.end(); ++activeIt)
{
if (activeIt->handle == handle)
{
activeIt->countdown = timeoutsCorrected;
- found = true;
+ found = true;
break;
}
}
if (!found)
- timerItem.countdown = timeoutsCorrected;
+ {
+ timerItem.countdown = timeoutsCorrected;
+ }
+
mListActiveTimer.push_back(timerItem);
mListActiveTimer.sort(compareCountdown);
-
-#endif
+#endif // ifdef WITH_TIMERFD
return (E_OK);
}
/**
- * restarts a timer with the original value
- * @param handle
- * @return E_OK on success, E_NON_EXISTENT if the handle was not found
- */
+ * restarts a timer with the original value
+ * @param handle
+ * @return E_OK on success, E_NON_EXISTENT if the handle was not found
+ */
am_Error_e CAmSocketHandler::restartTimer(const sh_timerHandle_t handle)
{
#ifdef WITH_TIMERFD
@@ -800,16 +862,23 @@ am_Error_e CAmSocketHandler::restartTimer(const sh_timerHandle_t handle)
for (; it != mListTimer.end(); ++it)
{
if (it->handle == handle)
+ {
break;
+ }
}
+
if (it == mListTimer.end())
+ {
return (E_NON_EXISTENT);
+ }
if (!fdIsValid(it->fd))
{
am_Error_e err = createTimeFD(it->countdown, it->fd);
if (err != E_OK)
+ {
return err;
+ }
}
else
{
@@ -819,32 +888,34 @@ am_Error_e CAmSocketHandler::restartTimer(const sh_timerHandle_t handle)
return E_NOT_POSSIBLE;
}
}
-#else
-
- sh_timer_s timerItem; //!<the original timer value
- //find the original value
+#else // ifdef WITH_TIMERFD
+ sh_timer_s timerItem; //!< the original timer value
+ // find the original value
std::list<sh_timer_s>::iterator it(mListTimer.begin()), activeIt(mListActiveTimer.begin());
- bool found(false);
+ bool found(false);
for (; it != mListTimer.end(); ++it)
{
if (it->handle == handle)
{
timerItem = *it;
- found = true;
+ found = true;
break;
}
}
+
if (!found)
- return (E_NON_EXISTENT);
+ {
+ return (E_NON_EXISTENT);
+ }
found = false;
- //we add here the time difference between startTime and currenttime, because this time will be substracted later on in timecorrection
+ // we add here the time difference between startTime and currenttime, because this time will be substracted later on in timecorrection
timespec currentTime, timeoutsCorrected;
clock_gettime(CLOCK_MONOTONIC, &currentTime);
- if (!mDispatchDone)//the mainloop is started
+ if (!mDispatchDone)// the mainloop is started
{
- timeoutsCorrected = timespecAdd(timerItem.countdown, timespecSub(currentTime, mStartTime));
+ timeoutsCorrected = timespecAdd(timerItem.countdown, timespecSub(currentTime, mStartTime));
timerItem.countdown = timeoutsCorrected;
}
@@ -853,35 +924,38 @@ am_Error_e CAmSocketHandler::restartTimer(const sh_timerHandle_t handle)
if (activeIt->handle == handle)
{
activeIt->countdown = timerItem.countdown;
- found = true;
+ found = true;
break;
}
}
if (!found)
- mListActiveTimer.push_back(timerItem);
-
+ {
+ mListActiveTimer.push_back(timerItem);
+ }
mListActiveTimer.sort(compareCountdown);
-#endif
+#endif // ifdef WITH_TIMERFD
return (E_OK);
}
/**
- * stops a timer
- * @param handle
- * @return E_OK on success, E_NON_EXISTENT if the handle was not found
- */
+ * stops a timer
+ * @param handle
+ * @return E_OK on success, E_NON_EXISTENT if the handle was not found
+ */
am_Error_e CAmSocketHandler::stopTimer(const sh_timerHandle_t handle)
{
#ifdef WITH_TIMERFD
for (auto elem : mListTimer)
{
if (elem.handle != handle)
+ {
continue;
+ }
itimerspec countdown = elem.countdown;
countdown.it_value.tv_nsec = 0;
- countdown.it_value.tv_sec = 0;
+ countdown.it_value.tv_sec = 0;
if (timerfd_settime(elem.fd, 0, &countdown, NULL) < 0)
{
@@ -891,8 +965,8 @@ am_Error_e CAmSocketHandler::stopTimer(const sh_timerHandle_t handle)
return E_OK;
}
-#else
- //go through the list and remove the timer with the handle
+#else // ifdef WITH_TIMERFD
+ // go through the list and remove the timer with the handle
std::list<sh_timer_s>::iterator it(mListActiveTimer.begin());
while (it != mListActiveTimer.end())
{
@@ -901,53 +975,57 @@ am_Error_e CAmSocketHandler::stopTimer(const sh_timerHandle_t handle)
mListActiveTimer.erase(it);
return E_OK;
}
+
++it;
}
-#endif
+#endif // ifdef WITH_TIMERFD
return E_NON_EXISTENT;
}
/**
- * updates the eventFlags of a poll
- * @param handle
- * @param events
- * @return @return E_OK on succsess, E_NON_EXISTENT if fd was not found
- */
+ * updates the eventFlags of a poll
+ * @param handle
+ * @param events
+ * @return @return E_OK on succsess, E_NON_EXISTENT if fd was not found
+ */
am_Error_e CAmSocketHandler::updateEventFlags(const sh_pollHandle_t handle, const short events)
{
- for (auto& it : mMapShPoll)
+ for (auto &it : mMapShPoll)
{
- auto& elem = it.second;
+ auto &elem = it.second;
if (elem.handle != handle)
+ {
continue;
+ }
switch (elem.state)
{
- case poll_states_e::ADD:
- elem.pollfdValue.events = events;
- return (E_OK);
+ case poll_states_e::ADD:
+ elem.pollfdValue.events = events;
+ return (E_OK);
- case poll_states_e::UPDATE:
- case poll_states_e::VALID:
- elem.state = poll_states_e::UPDATE;
- elem.pollfdValue.revents = 0;
- elem.pollfdValue.events = events;
- return (E_OK);
+ case poll_states_e::UPDATE:
+ case poll_states_e::VALID:
+ elem.state = poll_states_e::UPDATE;
+ elem.pollfdValue.revents = 0;
+ elem.pollfdValue.events = events;
+ return (E_OK);
- default:
- // This issue should never happen!
- return (E_DATABASE_ERROR);
+ default:
+ // This issue should never happen!
+ return (E_DATABASE_ERROR);
}
}
+
return (E_UNKNOWN);
}
/**
- * checks if a filedescriptor is validCAmShSubstractTime
- * @param fd the filedescriptor
- * @return true if the fd is valid
- */
+ * checks if a filedescriptor is validCAmShSubstractTime
+ * @param fd the filedescriptor
+ * @return true if the fd is valid
+ */
bool CAmSocketHandler::fdIsValid(const int fd) const
{
return (fcntl(fd, F_GETFL) != -1 || errno != EBADF);
@@ -955,148 +1033,158 @@ bool CAmSocketHandler::fdIsValid(const int fd) const
#ifndef WITH_TIMERFD
/**
- * timer is up.
- */
+ * timer is up.
+ */
void CAmSocketHandler::timerUp()
{
- //find out the timedifference to starttime
+ // find out the timedifference to starttime
static timespec currentTime, diffTime;
clock_gettime(CLOCK_MONOTONIC, &currentTime);
diffTime = timespecSub(currentTime, mStartTime);
- static auto countdownUp = [&](const sh_timer_s& row)->bool
- {
- timespec sub = timespecSub(row.countdown, diffTime);
- if (sub.tv_nsec == 0 && sub.tv_sec == 0)
- return (true);
- return (false);
- };
+ static auto countdownUp = [&](const sh_timer_s &row) -> bool {
+ timespec sub = timespecSub(row.countdown, diffTime);
+ if (sub.tv_nsec == 0 && sub.tv_sec == 0)
+ {
+ return (true);
+ }
+
+ return (false);
+ };
- //now we need to substract the diffTime from all timers and see if they are up
+ // now we need to substract the diffTime from all timers and see if they are up
std::list<sh_timer_s>::reverse_iterator overflowIter = std::find_if(mListActiveTimer.rbegin(), mListActiveTimer.rend(), countdownUp);
- //copy all fired timers into a list
+ // copy all fired timers into a list
std::vector<sh_timer_s> tempList(overflowIter, mListActiveTimer.rend());
- //erase all fired timers
+ // erase all fired timers
std::list<sh_timer_s>::iterator it(overflowIter.base());
mListActiveTimer.erase(mListActiveTimer.begin(), it);
- //call the callbacks for the timers
+ // call the callbacks for the timers
std::for_each(tempList.begin(), tempList.end(), CAmSocketHandler::callTimer);
}
/**
- * correct timers and fire the ones who are up
- */
+ * correct timers and fire the ones who are up
+ */
void CAmSocketHandler::timerCorrection()
{
- //get the current time and calculate the correction value
+ // get the current time and calculate the correction value
static timespec currentTime, correctionTime;
clock_gettime(CLOCK_MONOTONIC, &currentTime);
correctionTime = timespecSub(currentTime, mStartTime);
- mStartTime = currentTime;
+ mStartTime = currentTime;
- static auto countdownZero = [](const sh_timer_s& row)->bool
- {
- if (row.countdown.tv_nsec == 0 && row.countdown.tv_sec == 0)
- return (true);
- return (false);
- };
+ static auto countdownZero = [](const sh_timer_s &row) -> bool {
+ if (row.countdown.tv_nsec == 0 && row.countdown.tv_sec == 0)
+ {
+ return (true);
+ }
- static auto substractTime = [&](sh_timer_s& t)
- {
- t.countdown = timespecSub(t.countdown, correctionTime);
- };
+ return (false);
+ };
+
+ static auto substractTime = [&](sh_timer_s &t){
+ t.countdown = timespecSub(t.countdown, correctionTime);
+ };
if (!mListActiveTimer.empty())
{
- //subtract the correction value from all items in the list
+ // subtract the correction value from all items in the list
std::for_each(mListActiveTimer.begin(), mListActiveTimer.end(), substractTime);
- //find the last occurrence of zero -> timer overflowed
+ // find the last occurrence of zero -> timer overflowed
std::list<sh_timer_s>::reverse_iterator overflowIter = std::find_if(mListActiveTimer.rbegin(), mListActiveTimer.rend(), countdownZero);
- //only if a timer overflowed
+ // only if a timer overflowed
if (overflowIter != mListActiveTimer.rend())
{
- //copy all timers that need to be called to a new list
+ // copy all timers that need to be called to a new list
std::vector<sh_timer_s> tempList(overflowIter, mListActiveTimer.rend());
- //erase all fired timers
+ // erase all fired timers
std::list<sh_timer_s>::iterator it(overflowIter.base());
mListActiveTimer.erase(mListActiveTimer.begin(), it);
- //call the callbacks for the timers
+ // call the callbacks for the timers
std::for_each(tempList.begin(), tempList.end(), CAmSocketHandler::callTimer);
}
}
}
-#endif
+#endif // ifndef WITH_TIMERFD
/**
- * prepare for poll
- */
-void CAmSocketHandler::prepare(am::CAmSocketHandler::sh_poll_s& row)
+ * prepare for poll
+ */
+void CAmSocketHandler::prepare(am::CAmSocketHandler::sh_poll_s &row)
{
if (!row.prepareCB)
+ {
return;
+ }
try
{
row.prepareCB(row.handle, row.userData);
}
- catch (std::exception& e)
+ catch (std::exception &e)
{
logError("CAmSocketHandler::prepare Exception caught", e.what());
}
}
/**
- * fire callback
- */
-void CAmSocketHandler::fire(const sh_poll_s& a)
+ * fire callback
+ */
+void CAmSocketHandler::fire(const sh_poll_s &a)
{
try
{
a.firedCB(a.pollfdValue, a.handle, a.userData);
}
- catch (std::exception& e)
+ catch (std::exception &e)
{
logError("CAmSocketHandler::fire Exception caught", e.what());
}
}
/**
- * should disptach
- */
-bool CAmSocketHandler::noDispatching(const sh_poll_s* a)
+ * should disptach
+ */
+bool CAmSocketHandler::noDispatching(const sh_poll_s *a)
{
- //remove from list of there is no checkCB
+ // remove from list of there is no checkCB
if (nullptr == a->checkCB || a->state != poll_states_e::VALID)
+ {
return (true);
+ }
+
return (!a->checkCB(a->handle, a->userData));
}
/**
- * disptach
- */
-bool CAmSocketHandler::dispatchingFinished(const sh_poll_s* a)
+ * disptach
+ */
+bool CAmSocketHandler::dispatchingFinished(const sh_poll_s *a)
{
- //remove from list of there is no dispatchCB
+ // remove from list of there is no dispatchCB
if (nullptr == a->dispatchCB || a->state != poll_states_e::VALID)
+ {
return (true);
+ }
return (!a->dispatchCB(a->handle, a->userData));
}
/**
- * is used to set the pointer for the ppoll command
- * @param buffertime
- * @return
- */
-inline timespec* CAmSocketHandler::insertTime(timespec& buffertime)
+ * is used to set the pointer for the ppoll command
+ * @param buffertime
+ * @return
+ */
+inline timespec *CAmSocketHandler::insertTime(timespec &buffertime)
{
#ifndef WITH_TIMERFD
if (!mListActiveTimer.empty())
@@ -1105,19 +1193,19 @@ inline timespec* CAmSocketHandler::insertTime(timespec& buffertime)
return (&buffertime);
}
else
-#endif
+#endif // ifndef WITH_TIMERFD
{
return (NULL);
}
}
-#ifdef WITH_TIMERFD
-am_Error_e CAmSocketHandler::createTimeFD(const itimerspec & timeouts, int & fd)
+#ifdef WITH_TIMERFD
+am_Error_e CAmSocketHandler::createTimeFD(const itimerspec &timeouts, int &fd)
{
fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
if (fd < 0)
{
- logError("CAmSocketHandler::createTimeFD Failed with", static_cast<const char*>(std::strerror(errno)));
+ logError("CAmSocketHandler::createTimeFD Failed with", static_cast<const char *>(std::strerror(errno)));
return E_NOT_POSSIBLE;
}
@@ -1128,25 +1216,26 @@ am_Error_e CAmSocketHandler::createTimeFD(const itimerspec & timeouts, int & fd)
fd = -1;
return E_NOT_POSSIBLE;
}
+
return E_OK;
}
-#endif
+#endif // ifdef WITH_TIMERFD
-void CAmSocketHandler::callTimer(sh_timer_s& a)
+void CAmSocketHandler::callTimer(sh_timer_s &a)
{
try
{
a.callback(a.handle, a.userData);
}
- catch (std::exception& e)
+ catch (std::exception &e)
{
logError("CAmSocketHandler::callTimer() Exception caught", e.what());
}
}
-bool CAmSocketHandler::nextHandle(sh_identifier_s & handle)
+bool CAmSocketHandler::nextHandle(sh_identifier_s &handle)
{
- //create a new handle for the poll
+ // create a new handle for the poll
const sh_pollHandle_t lastHandle(handle.lastUsedID);
do
{
@@ -1155,11 +1244,11 @@ bool CAmSocketHandler::nextHandle(sh_identifier_s & handle)
{
handle.lastUsedID = 1;
}
+
if (handle.lastUsedID == lastHandle)
{
return (false);
}
-
} while (handle.pollHandles.find(handle.lastUsedID) != handle.pollHandles.end());
handle.pollHandles.insert(handle.lastUsedID);
@@ -1168,4 +1257,3 @@ bool CAmSocketHandler::nextHandle(sh_identifier_s & handle)
}
}
-
diff --git a/AudioManagerUtilities/src/CAmWatchdog.cpp b/AudioManagerUtilities/src/CAmWatchdog.cpp
index 2161630..3bac79c 100755..100644
--- a/AudioManagerUtilities/src/CAmWatchdog.cpp
+++ b/AudioManagerUtilities/src/CAmWatchdog.cpp
@@ -32,40 +32,40 @@
namespace am
{
-CAmWatchdog::CAmWatchdog(CAmSocketHandler* CAmSocketHandler) :
- TimerCallback(this, &CAmWatchdog::timerCallback),
- mpCAmSocketHandler(CAmSocketHandler),
- mHandle(0)
+CAmWatchdog::CAmWatchdog(CAmSocketHandler *CAmSocketHandler)
+ : TimerCallback(this, &CAmWatchdog::timerCallback)
+ , mpCAmSocketHandler(CAmSocketHandler)
+ , mHandle(0)
{
assert(mpCAmSocketHandler);
-
- //first retrieve the timeout interval
+ // first retrieve the timeout interval
int watchdogTimeout = 0;
- char* wusec=getenv("WATCHDOG_USEC");
+ char *wusec = getenv("WATCHDOG_USEC");
if (wusec)
- watchdogTimeout=atoi(wusec);
+ {
+ watchdogTimeout = atoi(wusec);
+ }
if (watchdogTimeout > 0)
{
timespec timeout;
- //calculate the half cycle as the right interval to trigger the watchdog.
- timeout.tv_sec = (watchdogTimeout / 2) / 1000000;
+ // calculate the half cycle as the right interval to trigger the watchdog.
+ timeout.tv_sec = (watchdogTimeout / 2) / 1000000;
timeout.tv_nsec = ((watchdogTimeout / 2) % 1000000) * 1000;
logInfo("CAmWatchdog::CAmWatchdog setting watchdog timeout:", watchdogTimeout, "us. Notification set to:",
- (int)timeout.tv_sec, "sec and", (int)timeout.tv_nsec, "ns");
+ (int)timeout.tv_sec, "sec and", (int)timeout.tv_nsec, "ns");
- //add the timer here
+ // add the timer here
if (mpCAmSocketHandler->addTimer(timeout, &TimerCallback, mHandle, NULL))
{
logError("CAmWatchdog::CAmWatchdog failed to add timer");
throw std::runtime_error("CAmWatchdog::CAmWatchdog failed to add timer");
}
}
-
else
{
logInfo("CAmWatchdog::CAmWatchdog watchdog timeout was ", watchdogTimeout, " museconds, no watchdog active");
@@ -74,14 +74,16 @@ CAmWatchdog::CAmWatchdog(CAmSocketHandler* CAmSocketHandler) :
CAmWatchdog::~CAmWatchdog()
{
- //remove the timer again.
- if (mHandle!=0)
- mpCAmSocketHandler->removeTimer(mHandle);
+ // remove the timer again.
+ if (mHandle != 0)
+ {
+ mpCAmSocketHandler->removeTimer(mHandle);
+ }
}
-void CAmWatchdog::timerCallback(sh_timerHandle_t handle, void* userData)
+void CAmWatchdog::timerCallback(sh_timerHandle_t handle, void *userData)
{
- (void) userData;
+ (void)userData;
int error(sd_notify(0, "WATCHDOG=1"));
if (error < 0)
{
@@ -100,6 +102,7 @@ void CAmWatchdog::startWatchdog()
logError("CAmWatchdog::startWatchdog could not start watchdog, error ", error);
throw std::runtime_error("CAmWatchdog::startWatchdog could not start watchdog");
}
+
logInfo("READY=1 was sent to systemd");
}
diff --git a/Foo/uncrustify_files.cfg b/Foo/uncrustify_files.cfg
index 07e08a2..c422173 100644
--- a/Foo/uncrustify_files.cfg
+++ b/Foo/uncrustify_files.cfg
@@ -1,9 +1,6 @@
./AudioManagerUtilities/src/CAmCommonAPIWrapper.cpp
-./AudioManagerUtilities/src/CAmLogWrapper.cpp
-./AudioManagerUtilities/src/CAmLoggerFile.cpp
-./AudioManagerUtilities/src/CAmLoggerStdOut.cpp
+./AudioManagerUtilities/src/CAmDltWrapper.cpp
./AudioManagerUtilities/src/CAmSocketHandler.cpp
-./AudioManagerUtilities/src/CAmLoggerDlt.cpp
./AudioManagerUtilities/src/CAmDbusWrapper.cpp
./AudioManagerUtilities/src/CAmCommandLineSingleton.cpp
./AudioManagerUtilities/src/CAmWatchdog.cpp
@@ -18,17 +15,12 @@
./AudioManagerCore/src/CAmDatabaseHandlerMap.cpp
./AudioManagerDaemon/src/main.cpp
./AudioManagerUtilities/include/CAmCommonAPIWrapper.h
-./AudioManagerUtilities/include/CAmLoggerDlt.h
./AudioManagerUtilities/include/CAmDbusWrapper.h
-./AudioManagerUtilities/include/CAmTimeUtility.h
./AudioManagerUtilities/include/CAmSerializer.h
-./AudioManagerUtilities/include/CAmLogWrapper.h
+./AudioManagerUtilities/include/CAmDltWrapper.h
./AudioManagerUtilities/include/CAmWatchdog.h
./AudioManagerUtilities/include/TAmPluginTemplate.h
-./AudioManagerUtilities/include/IAmLogger.h
-./AudioManagerUtilities/include/CAmLoggerFile.h
./AudioManagerUtilities/include/CAmCommandLineSingleton.h
-./AudioManagerUtilities/include/CAmLoggerStdOut.h
./AudioManagerUtilities/include/CAmSocketHandler.h
./AudioManagerCore/include/CAmLog.h
./AudioManagerCore/include/IAmDatabaseHandler.h