diff options
author | Aleksander Donchev <aleksander.donchev@partner.bmw.de> | 2013-07-10 14:05:44 +0200 |
---|---|---|
committer | Aleksander Donchev <aleksander.donchev@partner.bmw.de> | 2013-07-10 14:59:18 +0200 |
commit | 7b4ad13452dac45128209d54ebc2e1e83ecd5beb (patch) | |
tree | d487e0da36ff4b79887e1996591806bbe43d3708 | |
parent | 9dfa70416411055a86a9fd7eba828c65bea48325 (diff) | |
download | audiomanager-7b4ad13452dac45128209d54ebc2e1e83ecd5beb.tar.gz |
Created an abstract interface for the database handlers.
Renamed CAmDatabaseHandler to CAmDatabaseHandlerSQLite and CAmMapHandler to CAmDatabaseHandlerMap.
Changed std::map to std::unordered_map.
Added to the cmake configuration a definition, which defines the capacity of the source and sink maps.
Signed-off-by: Christian Linke <christian.linke@bmw.de>
34 files changed, 757 insertions, 410 deletions
diff --git a/AudioManagerDaemon/CMakeLists.txt b/AudioManagerDaemon/CMakeLists.txt index 11019fe..f917fd5 100644 --- a/AudioManagerDaemon/CMakeLists.txt +++ b/AudioManagerDaemon/CMakeLists.txt @@ -57,7 +57,12 @@ SET(AUDIOMAN_SRCS_CXX src/CAmSocketHandler.cpp src/CAmDltWrapper.cpp ) - + +# Preallocation variable for the map. +IF(NOT WITH_DATABASE_STORAGE ) + set (AM_MAP_CAPACITY 10) + add_definitions( -DAM_MAP_CAPACITY=${AM_MAP_CAPACITY} ) +ENDIF(NOT WITH_DATABASE_STORAGE) IF(WITH_TELNET) SET (AUDIOMAN_SRCS_CXX @@ -98,12 +103,12 @@ ENDIF(WITH_NSM) IF(WITH_DATABASE_STORAGE) SET (AUDIOMAN_SRCS_CXX ${AUDIOMAN_SRCS_CXX} - src/CAmDatabaseHandler.cpp + src/CAmDatabaseHandlerSQLite.cpp ) ELSE(WITH_DATABASE_STORAGE) SET (AUDIOMAN_SRCS_CXX ${AUDIOMAN_SRCS_CXX} - src/CAmMapHandler.cpp + src/CAmDatabaseHandlerMap.cpp ) ENDIF(WITH_DATABASE_STORAGE) diff --git a/AudioManagerDaemon/include/CAmCommandReceiver.h b/AudioManagerDaemon/include/CAmCommandReceiver.h index 56f26d1..8e9f0fd 100644 --- a/AudioManagerDaemon/include/CAmCommandReceiver.h +++ b/AudioManagerDaemon/include/CAmCommandReceiver.h @@ -27,7 +27,7 @@ namespace am { -class CAmDatabaseHandlerInterface; +class IAmDatabaseHandler; class CAmControlSender; class CAmDbusWrapper; class CAmSocketHandler; @@ -38,8 +38,8 @@ class CAmSocketHandler; class CAmCommandReceiver: public IAmCommandReceive { public: - CAmCommandReceiver(CAmDatabaseHandlerInterface* iDatabaseHandler, CAmControlSender* iControlSender, CAmSocketHandler* iSocketHandler); - CAmCommandReceiver(CAmDatabaseHandlerInterface* 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 disconnect(const am_mainConnectionID_t mainConnectionID); @@ -75,7 +75,7 @@ public: void waitOnRundown(bool rundown); //!< tells the ComandReceiver to start waiting for all handles to be confirmed private: - CAmDatabaseHandlerInterface* mDatabaseHandler; //!< pointer to the databasehandler + 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 diff --git a/AudioManagerDaemon/include/CAmControlReceiver.h b/AudioManagerDaemon/include/CAmControlReceiver.h index ca0c3f5..56c4be8 100644 --- a/AudioManagerDaemon/include/CAmControlReceiver.h +++ b/AudioManagerDaemon/include/CAmControlReceiver.h @@ -28,7 +28,7 @@ namespace am { class CAmSocketHandler; -class CAmDatabaseHandlerInterface; +class IAmDatabaseHandler; class CAmRoutingSender; class CAmCommandSender; class CAmRouter; @@ -40,8 +40,8 @@ class CAmNodeStateCommunicator; class CAmControlReceiver: public IAmControlReceive { public: - CAmControlReceiver(CAmDatabaseHandlerInterface *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter, CAmNodeStateCommunicator* iNodeStateCommunicator); - CAmControlReceiver(CAmDatabaseHandlerInterface *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter); + CAmControlReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter, CAmNodeStateCommunicator* iNodeStateCommunicator); + 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_ConnectionFormat_e format, const am_sourceID_t sourceID, const am_sinkID_t sinkID); @@ -137,7 +137,7 @@ public: NsmErrorStatus_e sendLifecycleRequestCompleteNSM(const uint32_t RequestId, const NsmErrorStatus_e status) ; private: - CAmDatabaseHandlerInterface* mDatabaseHandler; //!< pointer tto the databasehandler + 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 diff --git a/AudioManagerDaemon/include/CAmDatabaseHandlerMap.h b/AudioManagerDaemon/include/CAmDatabaseHandlerMap.h new file mode 100644 index 0000000..87f46b5 --- /dev/null +++ b/AudioManagerDaemon/include/CAmDatabaseHandlerMap.h @@ -0,0 +1,341 @@ +/** + * Copyright (C) 2012, BMW AG + * + * This file is part of GENIVI Project AudioManager. + * + * Contributions are licensed to the GENIVI Alliance under one or more + * Contribution License Agreements. + * + * \copyright + * This Source Code Form is subject to the terms of the + * Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with + * this file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * +* \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013 + * + * \file CAmDatabaseHandlerMap.h + * For further information see http://www.genivi.org/. + * + */ + +#ifndef MAPHANDLER_H_ +#define MAPHANDLER_H_ + +#include "IAmDatabaseHandler.h" +#include <stdint.h> +#include <limits.h> +#include <sstream> +#include <iostream> +#include <unordered_map> + + + +namespace am +{ +#ifndef AM_MAP_CAPACITY + #ifdef WITH_DATABASE_STORAGE + #define AM_MAP_CAPACITY @AM_MAP_CAPACITY@ + #else + #define AM_MAP_CAPACITY 0 + #endif +#endif +#define AM_MAP std::unordered_map + +//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 +{ + CAmDatabaseObserver *mpDatabaseObserver; //!< pointer to the Observer + bool mFirstStaticSink; //!< bool for dynamic range handling + bool mFirstStaticSource; //!< bool for dynamic range handling + bool mFirstStaticGateway; //!< 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 + ListConnectionFormat mListConnectionFormat; //!< list of connection formats + +public: + CAmDatabaseHandlerMap(); + virtual ~CAmDatabaseHandlerMap(); + 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 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 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 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); + am_Error_e changeSinkVolume(const am_sinkID_t sinkID, const am_volume_t volume); + am_Error_e changeSourceVolume(const am_sourceID_t sourceID, const am_volume_t volume); + am_Error_e changeCrossFaderHotSink(const am_crossfaderID_t crossfaderID, const am_HotSink_e hotsink); + 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); + am_Error_e removeGatewayDB(const am_gatewayID_t gatewayID); + am_Error_e removeCrossfaderDB(const am_crossfaderID_t crossfaderID); + 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 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 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 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_SoundPropertyType_e propertyType, int16_t& value) const; + am_Error_e getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_SoundPropertyType_e propertyType, int16_t& value) 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 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>& 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 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_ConnectionFormat_e> & listConnectionFormats) const; + am_Error_e getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector<am_ConnectionFormat_e> & 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 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 getRoutingTree(bool onlyfree, CAmRoutingTree& tree, std::vector<CAmRoutingTreeItem*>& flatTree); + 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_ConnectionFormat_e>& 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_ConnectionFormat_e>& 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_ConnectionFormat_e>& listSourceConnectionFormats, const std::vector<am_ConnectionFormat_e>& 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 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 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 existDomain(const am_domainID_t domainID) const; + bool existGateway(const am_gatewayID_t gatewayID) const; + bool existSinkClass(const am_sinkClass_t sinkClassID) const; + bool existSourceClass(const am_sourceClass_t sourceClassID) const; + void registerObserver(CAmDatabaseObserver *iObserver); + bool sourceVisible(const am_sourceID_t sourceID) const; + bool sinkVisible(const am_sinkID_t sinkID) const; + + void dump( std::ostream & output ); + /** + * The following structures extend the base structures with the field 'reserved'. + */ + +#define AM_TYPEDEF_SUBCLASS_BEGIN(Subclass, Class) \ + typedef struct Subclass : public Class\ + {\ + Subclass & operator=(const Subclass & anObject) \ + {\ + if (this != &anObject)\ + {\ + Class::operator=(anObject);\ + }\ + return *this;\ + };\ + Subclass & operator=(const Class & anObject)\ + {\ + if (this != &anObject)\ + Class::operator=(anObject);\ + return *this;\ + };\ + void getDescription (std::string & outString) const;\ + +#define AM_TYPEDEF_SUBCLASS_RESERVED_FLAG_BEGIN(Subclass, Class) \ + typedef struct Subclass : public Class\ + {\ + bool reserved;\ + Subclass():Class(), reserved(false)\ + {};\ + Subclass & operator=(const Subclass & anObject)\ + {\ + if (this != &anObject)\ + {\ + Class::operator=(anObject);\ + reserved = anObject.reserved;\ + }\ + return *this;\ + };\ + Subclass & operator=(const Class & anObject)\ + {\ + if (this != &anObject)\ + Class::operator=(anObject);\ + return *this;\ + };\ + void getDescription (std::string & outString) const;\ + +#define AM_TYPEDEF_SUBCLASS_END(Typedef) } Typedef; \ + + AM_TYPEDEF_SUBCLASS_RESERVED_FLAG_BEGIN(am_Domain_Database_s,am_Domain_s) + AM_TYPEDEF_SUBCLASS_END(CAmDomain) + + AM_TYPEDEF_SUBCLASS_RESERVED_FLAG_BEGIN(am_Sink_Database_s,am_Sink_s) + void getSinkType(am_SinkType_s & sinkType) const;\ + AM_TYPEDEF_SUBCLASS_END(CAmSink) + + AM_TYPEDEF_SUBCLASS_RESERVED_FLAG_BEGIN(am_Source_Database_s,am_Source_s) + void getSourceType(am_SourceType_s & sourceType) const;\ + AM_TYPEDEF_SUBCLASS_END(CAmSource) + + AM_TYPEDEF_SUBCLASS_RESERVED_FLAG_BEGIN(am_Connection_Database_s,am_Connection_s) + AM_TYPEDEF_SUBCLASS_END(CAmConnection) + + /** + * The following structures extend the base structures with print capabilities. + */ + AM_TYPEDEF_SUBCLASS_BEGIN(am_MainConnection_Database_s, am_MainConnection_s) + void getMainConnectionType(am_MainConnectionType_s & connectionType) const;\ + AM_TYPEDEF_SUBCLASS_END(CAmMainConnection) + + AM_TYPEDEF_SUBCLASS_BEGIN(am_SourceClass_Database_s, am_SourceClass_s) + AM_TYPEDEF_SUBCLASS_END(CAmSourceClass) + + AM_TYPEDEF_SUBCLASS_BEGIN(am_SinkClass_Database_s, am_SinkClass_s) + AM_TYPEDEF_SUBCLASS_END(CAmSinkClass) + + AM_TYPEDEF_SUBCLASS_BEGIN(am_Gateway_Database_s, am_Gateway_s) + AM_TYPEDEF_SUBCLASS_END(CAmGateway) + + AM_TYPEDEF_SUBCLASS_BEGIN(am_Crossfader_Database_s, am_Crossfader_s) + AM_TYPEDEF_SUBCLASS_END(CAmCrossfader) + + private: + + typedef AM_MAP<am_domainID_t, CAmDomain> CAmMapDomain; + typedef AM_MAP<am_sourceClass_t, CAmSourceClass> CAmMapSourceClass; + typedef AM_MAP<am_sinkClass_t, CAmSinkClass> CAmMapSinkClass; + typedef AM_MAP<am_sinkID_t, CAmSink> CAmMapSink; + typedef AM_MAP<am_sourceID_t, CAmSource> CAmMapSource; + typedef AM_MAP<am_gatewayID_t, CAmGateway> CAmMapGateway; + typedef AM_MAP<am_crossfaderID_t, CAmCrossfader> CAmMapCrossfader; + typedef AM_MAP<am_connectionID_t, CAmConnection> CAmMapConnection; + typedef AM_MAP<am_mainConnectionID_t, CAmMainConnection> CAmMapMainConnection; + typedef std::vector<am_SystemProperty_s> CAmVectorSystemProperties; + typedef struct CAmMappedData + { + int16_t mCurrentDomainID; + int16_t mCurrentSourceClassesID; + int16_t mCurrentSinkClassesID; + int16_t mCurrentSinkID; + int16_t mCurrentSourceID; + int16_t mCurrentGatewayID; + int16_t mCurrentCrossfaderID; + int16_t mCurrentConnectionID; + int16_t mCurrentMainConnectionID; + int16_t mDefaultIDLimit; + + CAmVectorSystemProperties mSystemProperties; + CAmMapDomain mDomainMap; + CAmMapSourceClass mSourceClassesMap; + CAmMapSinkClass mSinkClassesMap; + CAmMapSink mSinkMap; + CAmMapSource mSourceMap; + CAmMapGateway mGatewayMap; + CAmMapCrossfader mCrossfaderMap; + CAmMapConnection mConnectionMap; + CAmMapMainConnection mMainConnectionMap; + + CAmMappedData(): //For Domain, MainConnections, Connections we don't have static IDs. + mCurrentDomainID(1), mCurrentSourceClassesID(DYNAMIC_ID_BOUNDARY), mCurrentSinkClassesID(DYNAMIC_ID_BOUNDARY), + mCurrentSinkID(DYNAMIC_ID_BOUNDARY), mCurrentSourceID(DYNAMIC_ID_BOUNDARY), mCurrentGatewayID(DYNAMIC_ID_BOUNDARY), + mCurrentCrossfaderID(DYNAMIC_ID_BOUNDARY), mCurrentConnectionID(1), mCurrentMainConnectionID(1), + mDefaultIDLimit(SHRT_MAX), + + mSystemProperties(), + mDomainMap(),mSourceClassesMap(), mSinkClassesMap(), mSinkMap(AM_MAP_CAPACITY), mSourceMap(AM_MAP_CAPACITY), + mGatewayMap(), mCrossfaderMap(), mConnectionMap(), mMainConnectionMap() + {}; + + bool increaseID(int16_t * resultID, int16_t * sourceID, + int16_t const desiredStaticID, int16_t const preferedStaticIDBoundary ); + template <class TPrintObject> void print (const TPrintObject & t, std::ostream & output) const + { + std::string description(""); + t.getDescription( description ); + output << description; + } + template <typename TPrintMapKey,class TPrintMapObject> void printMap (const AM_MAP<TPrintMapKey, TPrintMapObject> & t, std::ostream & output) const + { + typename AM_MAP<TPrintMapKey, TPrintMapObject>::const_iterator iter = t.begin(); + for(; iter!=t.end(); iter++) + print(iter->second, output); + } + } CAmMappedData; + + CAmMappedData mMappedData; + + 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 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); +}; + +} + +#endif /* MAPHANDLER_H_ */ diff --git a/AudioManagerDaemon/include/CAmDatabaseHandlerSQLite.h b/AudioManagerDaemon/include/CAmDatabaseHandlerSQLite.h index 1adc4d6..dc845fd 100644 --- a/AudioManagerDaemon/include/CAmDatabaseHandlerSQLite.h +++ b/AudioManagerDaemon/include/CAmDatabaseHandlerSQLite.h @@ -14,7 +14,7 @@ * * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012 * - * \file CAmDatabaseHandler.h + * \file CAmDatabaseHandlerSQLite.h * For further information see http://www.genivi.org/. * */ @@ -22,7 +22,7 @@ #ifndef DATABASEHANDLER_H_ #define DATABASEHANDLER_H_ -#include "CAmDatabaseHandlerInterface.h" +#include "IAmDatabaseHandler.h" #include <map> #include <sqlite3.h> @@ -44,20 +44,28 @@ class CAmRoutingTreeItem; /** * This class handles and abstracts the database */ -class CAmDatabaseHandler : public CAmDatabaseHandlerInterface +class CAmDatabaseHandlerSQLite : public IAmDatabaseHandler { private: am_timeSync_t calculateMainConnectionDelay(const am_mainConnectionID_t mainConnectionID) const; //!< calculates a new main connection delay + + CAmDatabaseObserver *mpDatabaseObserver; //!< pointer to the Observer + bool mFirstStaticSink; //!< bool for dynamic range handling + bool mFirstStaticSource; //!< bool for dynamic range handling + bool mFirstStaticGateway; //!< 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 + ListConnectionFormat mListConnectionFormat; //!< list of connection formats + sqlite3 *mpDatabase; //!< pointer to the database + std::string mPath; //!< path to the database bool sqQuery(const std::string& query); //!< queries the database bool openDatabase(); //!< opens the database void createTables(); //!< creates all tables from the static table - sqlite3 *mpDatabase; //!< pointer to the database - std::string mPath; //!< path to the database - public: - CAmDatabaseHandler(); - CAmDatabaseHandler(std::string databasePath); - ~CAmDatabaseHandler(); + CAmDatabaseHandlerSQLite(); + CAmDatabaseHandlerSQLite(std::string databasePath); + virtual ~CAmDatabaseHandlerSQLite(); 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); @@ -169,6 +177,7 @@ public: void registerObserver(CAmDatabaseObserver *iObserver); bool sourceVisible(const am_sourceID_t sourceID) const; bool sinkVisible(const am_sinkID_t sinkID) const; + void dump( std::ostream & output) { output << __FUNCTION__ << " not implemented!"; }; }; } diff --git a/AudioManagerDaemon/include/CAmRouter.h b/AudioManagerDaemon/include/CAmRouter.h index ca04d6a..275f075 100644 --- a/AudioManagerDaemon/include/CAmRouter.h +++ b/AudioManagerDaemon/include/CAmRouter.h @@ -27,7 +27,7 @@ namespace am { -class CAmDatabaseHandlerInterface; +class IAmDatabaseHandler; class CAmControlSender; /** @@ -36,7 +36,7 @@ class CAmControlSender; class CAmRouter { public: - CAmRouter(CAmDatabaseHandlerInterface* iDatabaseHandler, CAmControlSender* iSender); + CAmRouter(IAmDatabaseHandler* iDatabaseHandler, CAmControlSender* iSender); ~CAmRouter(); am_Error_e getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s>& returnList); @@ -44,7 +44,7 @@ private: am_Error_e findBestWay(am_sinkID_t sinkID, am_sourceID_t sourceID, std::vector<am_RoutingElement_s>& listRoute, std::vector<am_RoutingElement_s>::iterator routeIterator, std::vector<am_gatewayID_t>::iterator gatewayIterator); void listPossibleConnectionFormats(const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_ConnectionFormat_e>& listFormats) const; void listRestrictedOutputFormatsGateways(const am_gatewayID_t gatewayID, const am_ConnectionFormat_e sinkConnectionFormat, std::vector<am_ConnectionFormat_e>& listFormats) const; - CAmDatabaseHandlerInterface* mpDatabaseHandler; //!< pointer to database handler + IAmDatabaseHandler* mpDatabaseHandler; //!< pointer to database handler CAmControlSender* mpControlSender; //!< pointer the controlsender - is used to retrieve information for the optimal route }; diff --git a/AudioManagerDaemon/include/CAmRoutingReceiver.h b/AudioManagerDaemon/include/CAmRoutingReceiver.h index 4d1493a..b83ae2c 100644 --- a/AudioManagerDaemon/include/CAmRoutingReceiver.h +++ b/AudioManagerDaemon/include/CAmRoutingReceiver.h @@ -29,7 +29,7 @@ namespace am class CAmSocketHandler; class CAmDbusWrapper; -class CAmDatabaseHandlerInterface; +class IAmDatabaseHandler; class CAmRoutingSender; class CAmControlSender; @@ -39,8 +39,8 @@ class CAmControlSender; class CAmRoutingReceiver: public IAmRoutingReceive { public: - CAmRoutingReceiver(CAmDatabaseHandlerInterface *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler); - CAmRoutingReceiver(CAmDatabaseHandlerInterface *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler, CAmDbusWrapper *iDBusWrapper); + CAmRoutingReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler); + CAmRoutingReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler, CAmDbusWrapper *iDBusWrapper); ~CAmRoutingReceiver(); void ackConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error); void ackDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error); @@ -97,7 +97,7 @@ public: void waitOnRundown(bool rundown); //!< tells the RoutingReceiver to start waiting for all handles to be confirmed private: - CAmDatabaseHandlerInterface *mpDatabaseHandler; //!< pointer to the databaseHandler + IAmDatabaseHandler *mpDatabaseHandler; //!< pointer to the databaseHandler CAmRoutingSender *mpRoutingSender; //!< pointer to the routingSender CAmControlSender *mpControlSender; //!< pointer to the controlSender CAmSocketHandler *mpSocketHandler; //!< pointer to sockethandler diff --git a/AudioManagerDaemon/include/CAmTelnetMenuHelper.h b/AudioManagerDaemon/include/CAmTelnetMenuHelper.h index b73bf56..9476751 100644 --- a/AudioManagerDaemon/include/CAmTelnetMenuHelper.h +++ b/AudioManagerDaemon/include/CAmTelnetMenuHelper.h @@ -38,7 +38,7 @@ namespace am { class CAmTelnetServer; -class CAmDatabaseHandlerInterface; +class IAmDatabaseHandler; class CAmCommandSender; class CAmRoutingSender; class CAmControlSender; @@ -61,7 +61,7 @@ public: eRootState = 0, eListState, eInfoState, eGetState, eSetState }; - CAmTelnetMenuHelper(CAmSocketHandler *iSocketHandler, CAmCommandSender *iCommandSender, CAmCommandReceiver *iCommandReceiver, CAmRoutingSender *iRoutingSender, CAmRoutingReceiver *iRoutingReceiver, CAmControlSender *iControlSender, CAmControlReceiver *iControlReceiver, CAmDatabaseHandlerInterface *iDatabasehandler, CAmRouter *iRouter, CAmTelnetServer *iTelnetServer); + CAmTelnetMenuHelper(CAmSocketHandler *iSocketHandler, CAmCommandSender *iCommandSender, CAmCommandReceiver *iCommandReceiver, CAmRoutingSender *iRoutingSender, CAmRoutingReceiver *iRoutingReceiver, CAmControlSender *iControlSender, CAmControlReceiver *iControlReceiver, IAmDatabaseHandler *iDatabasehandler, CAmRouter *iRouter, CAmTelnetServer *iTelnetServer); ~CAmTelnetMenuHelper(); @@ -186,7 +186,7 @@ private: CAmRoutingReceiver *mpRoutingReceiver; CAmControlSender *mpControlSender; CAmControlReceiver *mpControlReceiver; - CAmDatabaseHandlerInterface *mpDatabasehandler; + IAmDatabaseHandler *mpDatabasehandler; CAmRouter *mpRouter; tCommandMap mRootCommands; diff --git a/AudioManagerDaemon/include/CAmTelnetServer.h b/AudioManagerDaemon/include/CAmTelnetServer.h index 8e590ee..4275cce 100644 --- a/AudioManagerDaemon/include/CAmTelnetServer.h +++ b/AudioManagerDaemon/include/CAmTelnetServer.h @@ -31,7 +31,7 @@ namespace am { -class CAmDatabaseHandlerInterface; +class IAmDatabaseHandler; class CAmCommandSender; class CAmRoutingSender; class CAmControlSender; @@ -50,7 +50,7 @@ class CAmTelnetMenuHelper; class CAmTelnetServer { public: - CAmTelnetServer(CAmSocketHandler *iSocketHandler, CAmCommandSender *iCommandSender, CAmCommandReceiver *iCommandReceiver, CAmRoutingSender *iRoutingSender, CAmRoutingReceiver *iRoutingReceiver, CAmControlSender *iControlSender, CAmControlReceiver *iControlReceiver, CAmDatabaseHandlerInterface *iDatabasehandler, CAmRouter *iRouter, unsigned int servPort, unsigned int maxConnections); + CAmTelnetServer(CAmSocketHandler *iSocketHandler, CAmCommandSender *iCommandSender, CAmCommandReceiver *iCommandReceiver, CAmRoutingSender *iRoutingSender, CAmRoutingReceiver *iRoutingReceiver, CAmControlSender *iControlSender, CAmControlReceiver *iControlReceiver, IAmDatabaseHandler *iDatabasehandler, CAmRouter *iRouter, unsigned int servPort, unsigned int maxConnections); ~CAmTelnetServer(); void connectSocket(const pollfd pfd, const sh_pollHandle_t handle, void* userData); void disconnectClient(int filedescriptor); @@ -82,7 +82,7 @@ private: CAmRoutingReceiver *mpRoutingReceiver; CAmControlSender *mpControlSender; CAmControlReceiver *mpControlReceiver; - CAmDatabaseHandlerInterface *mpDatabasehandler; + IAmDatabaseHandler *mpDatabasehandler; CAmRouter *mpRouter; sh_pollHandle_t mConnecthandle; std::queue<std::string> mListMessages; diff --git a/AudioManagerDaemon/include/IAmDatabaseHandler.h b/AudioManagerDaemon/include/IAmDatabaseHandler.h index de50511..57053ef 100644 --- a/AudioManagerDaemon/include/IAmDatabaseHandler.h +++ b/AudioManagerDaemon/include/IAmDatabaseHandler.h @@ -50,30 +50,13 @@ typedef std::map<am_gatewayID_t, std::vector<bool> > ListConnectionFormat; //!< * This class handles and abstracts the database */ -class CAmDatabaseHandlerInterface +class IAmDatabaseHandler { protected: virtual am_timeSync_t calculateMainConnectionDelay(const am_mainConnectionID_t mainConnectionID) const = 0; //!< calculates a new main connection delay - CAmDatabaseObserver *mpDatabaseObserver; //!< pointer to the Observer - bool mFirstStaticSink; //!< bool for dynamic range handling - bool mFirstStaticSource; //!< bool for dynamic range handling - bool mFirstStaticGateway; //!< 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 - ListConnectionFormat mListConnectionFormat; //!< list of connection formats - public: - CAmDatabaseHandlerInterface(): mpDatabaseObserver(NULL), // - mFirstStaticSink(true), // - mFirstStaticSource(true), // - mFirstStaticGateway(true), // - mFirstStaticSinkClass(true), // - mFirstStaticSourceClass(true), // - mFirstStaticCrossfader(true), // - mListConnectionFormat() - {}; - virtual ~CAmDatabaseHandlerInterface() {}; +// IAmDatabaseHandler(); +// virtual ~IAmDatabaseHandler(); 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; @@ -187,7 +170,7 @@ public: virtual bool sourceVisible(const am_sourceID_t sourceID) const = 0; virtual bool sinkVisible(const am_sinkID_t sinkID) const = 0; - virtual void dump( std::ostream & output) { output << __FUNCTION__ << " not implemented!"; }; + virtual void dump( std::ostream & output) = 0 ; }; } diff --git a/AudioManagerDaemon/src/CAmCommandReceiver.cpp b/AudioManagerDaemon/src/CAmCommandReceiver.cpp index 491cf6e..066fb81 100644 --- a/AudioManagerDaemon/src/CAmCommandReceiver.cpp +++ b/AudioManagerDaemon/src/CAmCommandReceiver.cpp @@ -22,7 +22,7 @@ #include "CAmCommandReceiver.h" #include <cassert> #include <algorithm> -#include "CAmDatabaseHandlerInterface.h" +#include "IAmDatabaseHandler.h" #include "CAmControlSender.h" #include "shared/CAmDltWrapper.h" #include "shared/CAmSocketHandler.h" @@ -30,7 +30,7 @@ namespace am { -CAmCommandReceiver::CAmCommandReceiver(CAmDatabaseHandlerInterface *iDatabaseHandler, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler) : +CAmCommandReceiver::CAmCommandReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler) : mDatabaseHandler(iDatabaseHandler), // mControlSender(iControlSender), // mDBusWrapper(NULL), // @@ -49,7 +49,7 @@ CAmCommandReceiver::CAmCommandReceiver(CAmDatabaseHandlerInterface *iDatabaseHan assert(mControlSender!=NULL); } -CAmCommandReceiver::CAmCommandReceiver(CAmDatabaseHandlerInterface *iDatabaseHandler, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler, CAmDbusWrapper *iDBusWrapper) : +CAmCommandReceiver::CAmCommandReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler, CAmDbusWrapper *iDBusWrapper) : mDatabaseHandler(iDatabaseHandler), // mControlSender(iControlSender), // mDBusWrapper(iDBusWrapper), // diff --git a/AudioManagerDaemon/src/CAmControlReceiver.cpp b/AudioManagerDaemon/src/CAmControlReceiver.cpp index 99aa988..54346f1 100644 --- a/AudioManagerDaemon/src/CAmControlReceiver.cpp +++ b/AudioManagerDaemon/src/CAmControlReceiver.cpp @@ -24,7 +24,7 @@ #include <stdlib.h> #include <stdexcept> #include "config.h" -#include "CAmDatabaseHandlerInterface.h" +#include "IAmDatabaseHandler.h" #include "CAmRoutingSender.h" #include "CAmCommandSender.h" #include "CAmRouter.h" @@ -38,7 +38,7 @@ namespace am { -CAmControlReceiver::CAmControlReceiver(CAmDatabaseHandlerInterface *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter, CAmNodeStateCommunicator* iNodeStateCommunicator) : +CAmControlReceiver::CAmControlReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter, CAmNodeStateCommunicator* iNodeStateCommunicator) : mDatabaseHandler(iDatabaseHandler), // mRoutingSender(iRoutingSender), // mCommandSender(iCommandSender), // @@ -54,7 +54,7 @@ CAmControlReceiver::CAmControlReceiver(CAmDatabaseHandlerInterface *iDatabaseHan assert(iNodeStateCommunicator!=NULL); } -CAmControlReceiver::CAmControlReceiver(CAmDatabaseHandlerInterface *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter) : +CAmControlReceiver::CAmControlReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmCommandSender *iCommandSender, CAmSocketHandler *iSocketHandler, CAmRouter* iRouter) : mDatabaseHandler(iDatabaseHandler), // mRoutingSender(iRoutingSender), // mCommandSender(iCommandSender), // diff --git a/AudioManagerDaemon/src/CAmDatabaseHandlerMap.cpp b/AudioManagerDaemon/src/CAmDatabaseHandlerMap.cpp index 66b801e..b1c1768 100644 --- a/AudioManagerDaemon/src/CAmDatabaseHandlerMap.cpp +++ b/AudioManagerDaemon/src/CAmDatabaseHandlerMap.cpp @@ -14,12 +14,12 @@ * * \author Aleksandar Donchev, aleksander.donchev@partner.bmw.de BMW 2013 * - * \file CAmMapHandler.cpp + * \file CAmDatabaseHandlerMap.cpp * For further information see http://www.genivi.org/. * */ -#include "CAmMapHandler.h" +#include "CAmDatabaseHandlerMap.h" #include <iostream> #include <cassert> #include <stdexcept> @@ -78,12 +78,12 @@ TMapObjectType const * findFirstObjectMatchingCriteria(const AM_MAP<TMapKeyType, bool compareSinkObjectByName(const void *anObject, const void *aValue, void *) { - return (anObject && aValue)?((const std::string *)aValue)->compare(((const CAmMapHandler::am_Sink_Database_s *)anObject)->name)==0:false; + return (anObject && aValue)?((const std::string *)aValue)->compare(((const CAmDatabaseHandlerMap::am_Sink_Database_s *)anObject)->name)==0:false; } bool compareSourceObjectByName(const void *anObject, const void *aValue, void *) { - return (anObject && aValue)?((const std::string *)aValue)->compare(((const CAmMapHandler::am_Source_Database_s *)anObject)->name)==0:false; + return (anObject && aValue)?((const std::string *)aValue)->compare(((const CAmDatabaseHandlerMap::am_Source_Database_s *)anObject)->name)==0:false; } bool compareSinkClassObjectByName(const void *anObject, const void *aValue, void *) @@ -106,7 +106,7 @@ bool compareSinkObjectByNameAndFlag(const void *anObject, const void *aValue, vo if(anObject && aValue) { bool flag = (contextOrNull!=NULL)?*((bool*)contextOrNull):true; - return flag==((const CAmMapHandler::am_Sink_Database_s *)anObject)->reserved && + return flag==((const CAmDatabaseHandlerMap::am_Sink_Database_s *)anObject)->reserved && ((const std::string *)aValue)->compare(((const am_Sink_s *)anObject)->name)==0; } return false; @@ -116,10 +116,10 @@ bool compareConnectionObjectsWithObject(const void *anObject, const void *aValue { if(anObject && aValue) { - return 0==((const CAmMapHandler::am_Connection_Database_s *)anObject)->reserved && - ((const CAmMapHandler::am_Connection_Database_s *)aValue)->sinkID == ((const CAmMapHandler::am_Connection_Database_s *)anObject)->sinkID && - ((const CAmMapHandler::am_Connection_Database_s *)aValue)->sourceID == ((const CAmMapHandler::am_Connection_Database_s *)anObject)->sourceID && - ((const CAmMapHandler::am_Connection_Database_s *)aValue)->connectionFormat == ((const CAmMapHandler::am_Connection_Database_s *)anObject)->connectionFormat; + return 0==((const CAmDatabaseHandlerMap::am_Connection_Database_s *)anObject)->reserved && + ((const CAmDatabaseHandlerMap::am_Connection_Database_s *)aValue)->sinkID == ((const CAmDatabaseHandlerMap::am_Connection_Database_s *)anObject)->sinkID && + ((const CAmDatabaseHandlerMap::am_Connection_Database_s *)aValue)->sourceID == ((const CAmDatabaseHandlerMap::am_Connection_Database_s *)anObject)->sourceID && + ((const CAmDatabaseHandlerMap::am_Connection_Database_s *)aValue)->connectionFormat == ((const CAmDatabaseHandlerMap::am_Connection_Database_s *)anObject)->connectionFormat; } return false; } @@ -129,15 +129,15 @@ bool compareSourceObjectsByNameAndFlag(const void *anObject, const void *aValue, if(anObject && aValue) { bool flag = (contextOrNull!=NULL)?*((bool*)contextOrNull):true; - return flag==((const CAmMapHandler::am_Source_Database_s *)anObject)->reserved && - ((const std::string *)aValue)->compare(((const CAmMapHandler::am_Source_Database_s *)anObject)->name)==0; + return flag==((const CAmDatabaseHandlerMap::am_Source_Database_s *)anObject)->reserved && + ((const std::string *)aValue)->compare(((const CAmDatabaseHandlerMap::am_Source_Database_s *)anObject)->name)==0; } return false; } /* Domain */ -void CAmMapHandler::CAmDomain::getDescription (std::string & outString) const +void CAmDatabaseHandlerMap::CAmDomain::getDescription (std::string & outString) const { std::ostringstream fmt; fmt << "Domain(" << name.c_str() << ") id(" << domainID << ")" << std::endl << @@ -153,7 +153,7 @@ void CAmMapHandler::CAmDomain::getDescription (std::string & outString) const /* Source */ -void CAmMapHandler::CAmSource::getSourceType(am_SourceType_s & sourceType) const +void CAmDatabaseHandlerMap::CAmSource::getSourceType(am_SourceType_s & sourceType) const { sourceType.name = name; sourceType.sourceClassID = sourceClassID; @@ -161,7 +161,7 @@ void CAmMapHandler::CAmSource::getSourceType(am_SourceType_s & sourceType) const sourceType.sourceID = sourceID; } -void CAmMapHandler::CAmSource::getDescription (std::string & outString) const +void CAmDatabaseHandlerMap::CAmSource::getDescription (std::string & outString) const { std::ostringstream fmt; fmt << "Source(" << name.c_str() << ") id(" << sourceID << ")" << std::endl << @@ -199,7 +199,7 @@ void CAmMapHandler::CAmSource::getDescription (std::string & outString) const /* Sink */ -void CAmMapHandler::CAmSink::getDescription (std::string & outString) const +void CAmDatabaseHandlerMap::CAmSink::getDescription (std::string & outString) const { std::ostringstream fmt; fmt << "Sink(" << name.c_str() << ") id(" << sinkID << ")" << std::endl << @@ -235,7 +235,7 @@ void CAmMapHandler::CAmSink::getDescription (std::string & outString) const outString = fmt.str(); } -void CAmMapHandler::CAmSink::getSinkType(am_SinkType_s & sinkType) const +void CAmDatabaseHandlerMap::CAmSink::getSinkType(am_SinkType_s & sinkType) const { sinkType.name = name; sinkType.sinkID = sinkID; @@ -247,7 +247,7 @@ void CAmMapHandler::CAmSink::getSinkType(am_SinkType_s & sinkType) const /* Connection */ -void CAmMapHandler::CAmConnection::getDescription (std::string & outString) const +void CAmDatabaseHandlerMap::CAmConnection::getDescription (std::string & outString) const { std::ostringstream fmt; fmt << "Connection id(" << connectionID << ") " << std::endl << @@ -261,7 +261,7 @@ void CAmMapHandler::CAmConnection::getDescription (std::string & outString) cons /* Main Connection */ -void CAmMapHandler::CAmMainConnection::getDescription (std::string & outString) const +void CAmDatabaseHandlerMap::CAmMainConnection::getDescription (std::string & outString) const { std::ostringstream fmt; fmt << "MainConnection id(" << mainConnectionID << ") " << std::endl << @@ -277,7 +277,7 @@ void CAmMapHandler::CAmMainConnection::getDescription (std::string & outString) outString = fmt.str(); } -void CAmMapHandler::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; @@ -288,7 +288,7 @@ void CAmMapHandler::am_MainConnection_Database_s::getMainConnectionType(am_MainC /* Source Class */ -void CAmMapHandler::CAmSourceClass::getDescription (std::string & outString) const +void CAmDatabaseHandlerMap::CAmSourceClass::getDescription (std::string & outString) const { std::ostringstream fmt; fmt << "Source class(" << name.c_str() << ") id(" << sourceClassID << ")\n" << @@ -302,7 +302,7 @@ void CAmMapHandler::CAmSourceClass::getDescription (std::string & outString) con /* Sink Class */ -void CAmMapHandler::CAmSinkClass::getDescription (std::string & outString) const +void CAmDatabaseHandlerMap::CAmSinkClass::getDescription (std::string & outString) const { std::ostringstream fmt; fmt << "Sink class(" << name.c_str() << ") id(" << sinkClassID << ")\n" << @@ -317,7 +317,7 @@ void CAmMapHandler::CAmSinkClass::getDescription (std::string & outString) const /* Gateway */ -void CAmMapHandler::CAmGateway::getDescription (std::string & outString) const +void CAmDatabaseHandlerMap::CAmGateway::getDescription (std::string & outString) const { std::ostringstream fmt; fmt << "Gateway(" << name.c_str() << ") id(" << gatewayID << ")\n" << @@ -344,7 +344,7 @@ void CAmMapHandler::CAmGateway::getDescription (std::string & outString) const /* Crossfader */ -void CAmMapHandler::CAmCrossfader::getDescription (std::string & outString) const +void CAmDatabaseHandlerMap::CAmCrossfader::getDescription (std::string & outString) const { std::ostringstream fmt; fmt << "Crossfader(" << name.c_str() << ") id(" << crossfaderID << ")\n" << @@ -356,21 +356,7 @@ void CAmMapHandler::CAmCrossfader::getDescription (std::string & outString) cons outString = fmt.str(); } -template <typename TPrintMapKey,class TPrintMapObject> void CAmMapHandler::printMap (const AM_MAP<TPrintMapKey, TPrintMapObject> & t, std::ostream & output) const -{ - typename AM_MAP<TPrintMapKey, TPrintMapObject>::const_iterator iter = t.begin(); - for(; iter!=t.end(); iter++) - print(iter->second, output); -} - -template <class TPrintObject> void CAmMapHandler::print (const TPrintObject & t, std::ostream & output) const -{ - std::string description(""); - t.getDescription( description ); - output << description; -} - -bool CAmMapHandler::CAmMappedData::increaseID(int16_t * resultID, int16_t * sourceID, +bool CAmDatabaseHandlerMap::CAmMappedData::increaseID(int16_t * resultID, int16_t * sourceID, int16_t const desiredStaticID = 0, int16_t const preferedStaticIDBoundary = DYNAMIC_ID_BOUNDARY) { if( desiredStaticID > 0 && desiredStaticID < preferedStaticIDBoundary ) @@ -378,7 +364,7 @@ bool CAmMapHandler::CAmMappedData::increaseID(int16_t * resultID, int16_t * sour *resultID = desiredStaticID; return true; } - else if( *sourceID < mDefaultIDLimit-1 ) //SHRT_MAX or the max limit is reserved and not used!!! + else if( *sourceID < mDefaultIDLimit-1 ) //The last used value is the 'limit' - 1. e.g. SHRT_MAX - 1, SHRT_MAX is reserved. { *resultID = (*sourceID)++; return true; @@ -403,17 +389,26 @@ inline std::string i2s(T const& x) return (o.str()); } -CAmMapHandler::CAmMapHandler():CAmDatabaseHandlerInterface(), mMappedData() +CAmDatabaseHandlerMap::CAmDatabaseHandlerMap():mpDatabaseObserver(NULL), // + mFirstStaticSink(true), // + mFirstStaticSource(true), // + mFirstStaticGateway(true), // + mFirstStaticSinkClass(true), // + mFirstStaticSourceClass(true), // + mFirstStaticCrossfader(true), // + mListConnectionFormat(), // + mMappedData() { logInfo(__PRETTY_FUNCTION__,"Init"); } -CAmMapHandler::~CAmMapHandler() +CAmDatabaseHandlerMap::~CAmDatabaseHandlerMap() { logInfo(__PRETTY_FUNCTION__,"Destroy"); + mpDatabaseObserver = NULL; } -am_Error_e CAmMapHandler::enterDomainDB(const am_Domain_s & domainData, am_domainID_t & domainID) +am_Error_e CAmDatabaseHandlerMap::enterDomainDB(const am_Domain_s & domainData, am_domainID_t & domainID) { assert(domainData.domainID==0); assert(!domainData.name.empty()); @@ -457,7 +452,7 @@ am_Error_e CAmMapHandler::enterDomainDB(const am_Domain_s & domainData, am_domai } } -int16_t CAmMapHandler::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(); @@ -477,7 +472,7 @@ int16_t CAmMapHandler::calculateDelayForRoute(const std::vector<am_connectionID_ return delay; } -am_Error_e CAmMapHandler::enterMainConnectionDB(const am_MainConnection_s & mainConnectionData, am_mainConnectionID_t & connectionID) +am_Error_e CAmDatabaseHandlerMap::enterMainConnectionDB(const am_MainConnection_s & mainConnectionData, am_mainConnectionID_t & connectionID) { assert(mainConnectionData.mainConnectionID==0); assert(mainConnectionData.connectionState>=CS_UNKNOWN && mainConnectionData.connectionState<=CS_MAX); @@ -526,7 +521,7 @@ am_Error_e CAmMapHandler::enterMainConnectionDB(const am_MainConnection_s & main * 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 CAmMapHandler::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) ) @@ -544,7 +539,7 @@ bool CAmMapHandler::insertSinkDB(const am_Sink_s & sinkData, am_sinkID_t & sinkI } } -am_Error_e CAmMapHandler::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t & sinkID) +am_Error_e CAmDatabaseHandlerMap::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t & sinkID) { assert(sinkData.sinkID<DYNAMIC_ID_BOUNDARY); assert(sinkData.domainID!=0); @@ -598,7 +593,7 @@ am_Error_e CAmMapHandler::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t & return (E_OK); } -bool CAmMapHandler::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)) @@ -616,7 +611,7 @@ bool CAmMapHandler::insertCrossfaderDB(const am_Crossfader_s & crossfaderData, a } } -am_Error_e CAmMapHandler::enterCrossfaderDB(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID) +am_Error_e CAmDatabaseHandlerMap::enterCrossfaderDB(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID) { assert(crossfaderData.crossfaderID<DYNAMIC_ID_BOUNDARY); assert(crossfaderData.hotSink>=HS_UNKNOWN && crossfaderData.hotSink<=HS_MAX); @@ -658,7 +653,7 @@ am_Error_e CAmMapHandler::enterCrossfaderDB(const am_Crossfader_s & crossfaderDa return (E_OK); } -bool CAmMapHandler::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)) @@ -676,7 +671,7 @@ bool CAmMapHandler::insertGatewayDB(const am_Gateway_s & gatewayData, am_gateway } } -am_Error_e CAmMapHandler::enterGatewayDB(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID) +am_Error_e CAmDatabaseHandlerMap::enterGatewayDB(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID) { assert(gatewayData.gatewayID<DYNAMIC_ID_BOUNDARY); assert(gatewayData.sinkID!=0); @@ -724,18 +719,18 @@ am_Error_e CAmMapHandler::enterGatewayDB(const am_Gateway_s & gatewayData, am_ga return (E_OK); } -void CAmMapHandler::dump( std::ostream & output ) +void CAmDatabaseHandlerMap::dump( std::ostream & output ) { output << std::endl << "****************** DUMP START ******************" << std::endl; - printMap(mMappedData.mDomainMap, output); - printMap(mMappedData.mSourceMap, output); - printMap(mMappedData.mSinkMap, output); - printMap(mMappedData.mSourceClassesMap, output); - printMap(mMappedData.mSinkClassesMap, output); - printMap(mMappedData.mConnectionMap, output); - printMap(mMappedData.mMainConnectionMap, output); - printMap(mMappedData.mCrossfaderMap, output); - printMap(mMappedData.mGatewayMap, output); + mMappedData.printMap(mMappedData.mDomainMap, output); + mMappedData.printMap(mMappedData.mSourceMap, output); + mMappedData.printMap(mMappedData.mSinkMap, output); + mMappedData.printMap(mMappedData.mSourceClassesMap, output); + mMappedData.printMap(mMappedData.mSinkClassesMap, output); + mMappedData.printMap(mMappedData.mConnectionMap, output); + mMappedData.printMap(mMappedData.mMainConnectionMap, output); + mMappedData.printMap(mMappedData.mCrossfaderMap, output); + mMappedData.printMap(mMappedData.mGatewayMap, output); CAmVectorSystemProperties::const_iterator iter = mMappedData.mSystemProperties.begin(); output << "System properties" << "\n"; for(; iter!=mMappedData.mSystemProperties.end(); iter++) @@ -743,7 +738,7 @@ void CAmMapHandler::dump( std::ostream & output ) output << std::endl << "****************** DUMP END ******************" << std::endl; } -bool CAmMapHandler::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)) @@ -761,7 +756,7 @@ bool CAmMapHandler::insertSourceDB(const am_Source_s & sourceData, am_sourceID_t } } -am_Error_e CAmMapHandler::enterSourceDB(const am_Source_s & sourceData, am_sourceID_t & sourceID) +am_Error_e CAmDatabaseHandlerMap::enterSourceDB(const am_Source_s & sourceData, am_sourceID_t & sourceID) { assert(sourceData.sourceID<DYNAMIC_ID_BOUNDARY); assert(sourceData.domainID!=0); @@ -816,7 +811,7 @@ am_Error_e CAmMapHandler::enterSourceDB(const am_Source_s & sourceData, am_sourc return (E_OK); } -am_Error_e CAmMapHandler::enterConnectionDB(const am_Connection_s& connection, am_connectionID_t& connectionID) +am_Error_e CAmDatabaseHandlerMap::enterConnectionDB(const am_Connection_s& connection, am_connectionID_t& connectionID) { assert(connection.connectionID==0); assert(connection.sinkID!=0); @@ -840,7 +835,7 @@ am_Error_e CAmMapHandler::enterConnectionDB(const am_Connection_s& connection, a return (E_OK); } -bool CAmMapHandler::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)) @@ -858,7 +853,7 @@ bool CAmMapHandler::insertSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkC } } -am_Error_e CAmMapHandler::enterSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID) +am_Error_e CAmDatabaseHandlerMap::enterSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID) { assert(sinkClass.sinkClassID<DYNAMIC_ID_BOUNDARY); assert(!sinkClass.name.empty()); @@ -893,7 +888,7 @@ am_Error_e CAmMapHandler::enterSinkClassDB(const am_SinkClass_s & sinkClass, am_ return (E_OK); } -bool CAmMapHandler::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)) @@ -911,7 +906,7 @@ bool CAmMapHandler::insertSourceClassDB(am_sourceClass_t & sourceClassID, const } } -am_Error_e CAmMapHandler::enterSourceClassDB(am_sourceClass_t & sourceClassID, const am_SourceClass_s & sourceClass) +am_Error_e CAmDatabaseHandlerMap::enterSourceClassDB(am_sourceClass_t & sourceClassID, const am_SourceClass_s & sourceClass) { assert(sourceClass.sourceClassID<DYNAMIC_ID_BOUNDARY); assert(!sourceClass.name.empty()); @@ -948,7 +943,7 @@ am_Error_e CAmMapHandler::enterSourceClassDB(am_sourceClass_t & sourceClassID, c return (E_OK); } -am_Error_e CAmMapHandler::enterSystemProperties(const std::vector<am_SystemProperty_s> & listSystemProperties) +am_Error_e CAmDatabaseHandlerMap::enterSystemProperties(const std::vector<am_SystemProperty_s> & listSystemProperties) { assert(!listSystemProperties.empty()); @@ -958,7 +953,7 @@ am_Error_e CAmMapHandler::enterSystemProperties(const std::vector<am_SystemPrope return (E_OK); } -am_Error_e CAmMapHandler::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) { assert(mainconnectionID!=0); if (!existMainConnection(mainconnectionID)) @@ -978,7 +973,7 @@ am_Error_e CAmMapHandler::changeMainConnectionRouteDB(const am_mainConnectionID_ return (E_OK); } -am_Error_e CAmMapHandler::changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState) +am_Error_e CAmDatabaseHandlerMap::changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState) { assert(mainconnectionID!=0); assert(connectionState>=CS_UNKNOWN && connectionState<=CS_MAX); @@ -995,7 +990,7 @@ am_Error_e CAmMapHandler::changeMainConnectionStateDB(const am_mainConnectionID_ return (E_OK); } -am_Error_e CAmMapHandler::changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID) +am_Error_e CAmDatabaseHandlerMap::changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID) { assert(sinkID!=0); @@ -1014,7 +1009,7 @@ am_Error_e CAmMapHandler::changeSinkMainVolumeDB(const am_mainVolume_t mainVolum return (E_OK); } -am_Error_e CAmMapHandler::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) { assert(sinkID!=0); assert(availability.availability>=A_UNKNOWN && availability.availability<=A_MAX); @@ -1034,7 +1029,7 @@ am_Error_e CAmMapHandler::changeSinkAvailabilityDB(const am_Availability_s & ava return (E_OK); } -am_Error_e CAmMapHandler::changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID) +am_Error_e CAmDatabaseHandlerMap::changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID) { assert(domainID!=0); assert(domainState>=DS_UNKNOWN && domainState<=DS_MAX); @@ -1050,7 +1045,7 @@ am_Error_e CAmMapHandler::changDomainStateDB(const am_DomainState_e domainState, return (E_OK); } -am_Error_e CAmMapHandler::changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID) +am_Error_e CAmDatabaseHandlerMap::changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID) { assert(sinkID!=0); assert(muteState>=MS_UNKNOWN && muteState<=MS_MAX); @@ -1070,7 +1065,7 @@ am_Error_e CAmMapHandler::changeSinkMuteStateDB(const am_MuteState_e muteState, return (E_OK); } -am_Error_e CAmMapHandler::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) { assert(soundProperty.type>=MSP_UNKNOWN && soundProperty.type<=MSP_MAX); assert(sinkID!=0); @@ -1093,7 +1088,7 @@ am_Error_e CAmMapHandler::changeMainSinkSoundPropertyDB(const am_MainSoundProper return (E_OK); } -am_Error_e CAmMapHandler::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) { assert(soundProperty.type>=MSP_UNKNOWN && soundProperty.type<=MSP_MAX); assert(sourceID!=0); @@ -1117,7 +1112,7 @@ am_Error_e CAmMapHandler::changeMainSourceSoundPropertyDB(const am_MainSoundProp return (E_OK); } -am_Error_e CAmMapHandler::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) { assert(sourceID!=0); assert(availability.availability>=A_UNKNOWN && availability.availability<=A_MAX); @@ -1137,7 +1132,7 @@ am_Error_e CAmMapHandler::changeSourceAvailabilityDB(const am_Availability_s & a return (E_OK); } -am_Error_e CAmMapHandler::changeSystemPropertyDB(const am_SystemProperty_s & property) +am_Error_e CAmDatabaseHandlerMap::changeSystemPropertyDB(const am_SystemProperty_s & property) { assert(property.type>=SYP_UNKNOWN && property.type<=SYP_MAX); @@ -1156,7 +1151,7 @@ am_Error_e CAmMapHandler::changeSystemPropertyDB(const am_SystemProperty_s & pro return (E_OK); } -am_Error_e CAmMapHandler::removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID) +am_Error_e CAmDatabaseHandlerMap::removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID) { assert(mainConnectionID!=0); @@ -1176,7 +1171,7 @@ am_Error_e CAmMapHandler::removeMainConnectionDB(const am_mainConnectionID_t mai return (E_OK); } -am_Error_e CAmMapHandler::removeSinkDB(const am_sinkID_t sinkID) +am_Error_e CAmDatabaseHandlerMap::removeSinkDB(const am_sinkID_t sinkID) { assert(sinkID!=0); @@ -1198,7 +1193,7 @@ am_Error_e CAmMapHandler::removeSinkDB(const am_sinkID_t sinkID) return (E_OK); } -am_Error_e CAmMapHandler::removeSourceDB(const am_sourceID_t sourceID) +am_Error_e CAmDatabaseHandlerMap::removeSourceDB(const am_sourceID_t sourceID) { assert(sourceID!=0); @@ -1220,7 +1215,7 @@ am_Error_e CAmMapHandler::removeSourceDB(const am_sourceID_t sourceID) return (E_OK); } -am_Error_e CAmMapHandler::removeGatewayDB(const am_gatewayID_t gatewayID) +am_Error_e CAmDatabaseHandlerMap::removeGatewayDB(const am_gatewayID_t gatewayID) { assert(gatewayID!=0); @@ -1237,7 +1232,7 @@ am_Error_e CAmMapHandler::removeGatewayDB(const am_gatewayID_t gatewayID) return (E_OK); } -am_Error_e CAmMapHandler::removeCrossfaderDB(const am_crossfaderID_t crossfaderID) +am_Error_e CAmDatabaseHandlerMap::removeCrossfaderDB(const am_crossfaderID_t crossfaderID) { assert(crossfaderID!=0); @@ -1253,7 +1248,7 @@ am_Error_e CAmMapHandler::removeCrossfaderDB(const am_crossfaderID_t crossfaderI return (E_OK); } -am_Error_e CAmMapHandler::removeDomainDB(const am_domainID_t domainID) +am_Error_e CAmDatabaseHandlerMap::removeDomainDB(const am_domainID_t domainID) { assert(domainID!=0); @@ -1269,7 +1264,7 @@ am_Error_e CAmMapHandler::removeDomainDB(const am_domainID_t domainID) return (E_OK); } -am_Error_e CAmMapHandler::removeSinkClassDB(const am_sinkClass_t sinkClassID) +am_Error_e CAmDatabaseHandlerMap::removeSinkClassDB(const am_sinkClass_t sinkClassID) { assert(sinkClassID!=0); @@ -1287,7 +1282,7 @@ am_Error_e CAmMapHandler::removeSinkClassDB(const am_sinkClass_t sinkClassID) return (E_OK); } -am_Error_e CAmMapHandler::removeSourceClassDB(const am_sourceClass_t sourceClassID) +am_Error_e CAmDatabaseHandlerMap::removeSourceClassDB(const am_sourceClass_t sourceClassID) { assert(sourceClassID!=0); @@ -1303,7 +1298,7 @@ am_Error_e CAmMapHandler::removeSourceClassDB(const am_sourceClass_t sourceClass return (E_OK); } -am_Error_e CAmMapHandler::removeConnection(const am_connectionID_t connectionID) +am_Error_e CAmDatabaseHandlerMap::removeConnection(const am_connectionID_t connectionID) { assert(connectionID!=0); @@ -1313,7 +1308,7 @@ am_Error_e CAmMapHandler::removeConnection(const am_connectionID_t connectionID) return (E_OK); } -am_Error_e CAmMapHandler::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 { assert(sourceID!=0); @@ -1334,7 +1329,7 @@ am_Error_e CAmMapHandler::getSourceClassInfoDB(const am_sourceID_t sourceID, am_ return (E_OK); } -am_Error_e CAmMapHandler::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 { assert(sinkID!=0); @@ -1349,7 +1344,7 @@ am_Error_e CAmMapHandler::getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s & si return (E_OK); } -am_Error_e CAmMapHandler::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 { assert(sourceID!=0); @@ -1365,7 +1360,7 @@ am_Error_e CAmMapHandler::getSourceInfoDB(const am_sourceID_t sourceID, am_Sourc return (E_OK); } -am_Error_e am::CAmMapHandler::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 { assert(mainConnectionID!=0); if (!existMainConnection(mainConnectionID)) @@ -1378,7 +1373,7 @@ am_Error_e am::CAmMapHandler::getMainConnectionInfoDB(const am_mainConnectionID_ return (E_OK); } -am_Error_e CAmMapHandler::changeSinkClassInfoDB(const am_SinkClass_s& sinkClass) +am_Error_e CAmDatabaseHandlerMap::changeSinkClassInfoDB(const am_SinkClass_s& sinkClass) { assert(sinkClass.sinkClassID!=0); assert(!sinkClass.listClassProperties.empty()); @@ -1393,7 +1388,7 @@ am_Error_e CAmMapHandler::changeSinkClassInfoDB(const am_SinkClass_s& sinkClass) return (E_OK); } -am_Error_e CAmMapHandler::changeSourceClassInfoDB(const am_SourceClass_s& sourceClass) +am_Error_e CAmDatabaseHandlerMap::changeSourceClassInfoDB(const am_SourceClass_s& sourceClass) { assert(sourceClass.sourceClassID!=0); assert(!sourceClass.listClassProperties.empty()); @@ -1408,7 +1403,7 @@ am_Error_e CAmMapHandler::changeSourceClassInfoDB(const am_SourceClass_s& source return (E_OK); } -am_Error_e CAmMapHandler::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 { assert(sinkID!=0); @@ -1429,7 +1424,7 @@ am_Error_e CAmMapHandler::getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkCl return (E_OK); } -am_Error_e CAmMapHandler::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 { assert(gatewayID!=0); if (!existGateway(gatewayID)) @@ -1443,7 +1438,7 @@ am_Error_e CAmMapHandler::getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Ga } -am_Error_e CAmMapHandler::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 { assert(crossfaderID!=0); if (!existcrossFader(crossfaderID)) @@ -1456,7 +1451,7 @@ am_Error_e CAmMapHandler::getCrossfaderInfoDB(const am_crossfaderID_t crossfader return (E_OK); } -am_Error_e CAmMapHandler::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 { assert(domainID!=0); listSinkID.clear(); @@ -1474,7 +1469,7 @@ am_Error_e CAmMapHandler::getListSinksOfDomain(const am_domainID_t domainID, std return (E_OK); } -am_Error_e CAmMapHandler::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 { assert(domainID!=0); listSourceID.clear(); @@ -1492,7 +1487,7 @@ am_Error_e CAmMapHandler::getListSourcesOfDomain(const am_domainID_t domainID, s return (E_OK); } -am_Error_e CAmMapHandler::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 { assert(domainID!=0); listCrossfader.clear(); @@ -1519,7 +1514,7 @@ am_Error_e CAmMapHandler::getListCrossfadersOfDomain(const am_domainID_t domainI } -am_Error_e CAmMapHandler::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 { assert(domainID!=0); listGatewaysID.clear(); @@ -1537,7 +1532,7 @@ am_Error_e CAmMapHandler::getListGatewaysOfDomain(const am_domainID_t domainID, return (E_OK); } -am_Error_e CAmMapHandler::getListMainConnections(std::vector<am_MainConnection_s> & listMainConnections) const +am_Error_e CAmDatabaseHandlerMap::getListMainConnections(std::vector<am_MainConnection_s> & listMainConnections) const { listMainConnections.clear(); @@ -1550,7 +1545,7 @@ am_Error_e CAmMapHandler::getListMainConnections(std::vector<am_MainConnection_s return (E_OK); } -am_Error_e CAmMapHandler::getListDomains(std::vector<am_Domain_s> & listDomains) const +am_Error_e CAmDatabaseHandlerMap::getListDomains(std::vector<am_Domain_s> & listDomains) const { listDomains.clear(); @@ -1564,7 +1559,7 @@ am_Error_e CAmMapHandler::getListDomains(std::vector<am_Domain_s> & listDomains) return (E_OK); } -am_Error_e CAmMapHandler::getListConnections(std::vector<am_Connection_s> & listConnections) const +am_Error_e CAmDatabaseHandlerMap::getListConnections(std::vector<am_Connection_s> & listConnections) const { listConnections.clear(); @@ -1578,7 +1573,7 @@ am_Error_e CAmMapHandler::getListConnections(std::vector<am_Connection_s> & list return (E_OK); } -am_Error_e CAmMapHandler::getListSinks(std::vector<am_Sink_s> & listSinks) const +am_Error_e CAmDatabaseHandlerMap::getListSinks(std::vector<am_Sink_s> & listSinks) const { listSinks.clear(); @@ -1590,7 +1585,7 @@ am_Error_e CAmMapHandler::getListSinks(std::vector<am_Sink_s> & listSinks) const return (E_OK); } -am_Error_e CAmMapHandler::getListSources(std::vector<am_Source_s> & listSources) const +am_Error_e CAmDatabaseHandlerMap::getListSources(std::vector<am_Source_s> & listSources) const { listSources.clear(); @@ -1603,7 +1598,7 @@ am_Error_e CAmMapHandler::getListSources(std::vector<am_Source_s> & listSources) return (E_OK); } -am_Error_e CAmMapHandler::getListSourceClasses(std::vector<am_SourceClass_s> & listSourceClasses) const +am_Error_e CAmDatabaseHandlerMap::getListSourceClasses(std::vector<am_SourceClass_s> & listSourceClasses) const { listSourceClasses.clear(); @@ -1614,7 +1609,7 @@ am_Error_e CAmMapHandler::getListSourceClasses(std::vector<am_SourceClass_s> & l return (E_OK); } -am_Error_e CAmMapHandler::getListCrossfaders(std::vector<am_Crossfader_s> & listCrossfaders) const +am_Error_e CAmDatabaseHandlerMap::getListCrossfaders(std::vector<am_Crossfader_s> & listCrossfaders) const { listCrossfaders.clear(); @@ -1625,7 +1620,7 @@ am_Error_e CAmMapHandler::getListCrossfaders(std::vector<am_Crossfader_s> & list return (E_OK); } -am_Error_e CAmMapHandler::getListGateways(std::vector<am_Gateway_s> & listGateways) const +am_Error_e CAmDatabaseHandlerMap::getListGateways(std::vector<am_Gateway_s> & listGateways) const { listGateways.clear(); @@ -1636,7 +1631,7 @@ am_Error_e CAmMapHandler::getListGateways(std::vector<am_Gateway_s> & listGatewa return (E_OK); } -am_Error_e CAmMapHandler::getListSinkClasses(std::vector<am_SinkClass_s> & listSinkClasses) const +am_Error_e CAmDatabaseHandlerMap::getListSinkClasses(std::vector<am_SinkClass_s> & listSinkClasses) const { listSinkClasses.clear(); @@ -1647,7 +1642,7 @@ am_Error_e CAmMapHandler::getListSinkClasses(std::vector<am_SinkClass_s> & listS return (E_OK); } -am_Error_e CAmMapHandler::getListVisibleMainConnections(std::vector<am_MainConnectionType_s> & listConnections) const +am_Error_e CAmDatabaseHandlerMap::getListVisibleMainConnections(std::vector<am_MainConnectionType_s> & listConnections) const { listConnections.clear(); am_MainConnectionType_s temp; @@ -1659,7 +1654,7 @@ am_Error_e CAmMapHandler::getListVisibleMainConnections(std::vector<am_MainConne return (E_OK); } -am_Error_e CAmMapHandler::getListMainSinks(std::vector<am_SinkType_s> & listMainSinks) const +am_Error_e CAmDatabaseHandlerMap::getListMainSinks(std::vector<am_SinkType_s> & listMainSinks) const { listMainSinks.clear(); am_SinkType_s sinkType; @@ -1674,7 +1669,7 @@ am_Error_e CAmMapHandler::getListMainSinks(std::vector<am_SinkType_s> & listMain return (E_OK); } -am_Error_e CAmMapHandler::getListMainSources(std::vector<am_SourceType_s> & listMainSources) const +am_Error_e CAmDatabaseHandlerMap::getListMainSources(std::vector<am_SourceType_s> & listMainSources) const { listMainSources.clear(); am_SourceType_s temp; @@ -1689,7 +1684,7 @@ am_Error_e CAmMapHandler::getListMainSources(std::vector<am_SourceType_s> & list return (E_OK); } -am_Error_e CAmMapHandler::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 { assert(sinkID!=0); if (!existSink(sinkID)) @@ -1701,7 +1696,7 @@ am_Error_e CAmMapHandler::getListMainSinkSoundProperties(const am_sinkID_t sinkI return (E_OK); } -am_Error_e CAmMapHandler::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 { assert(sourceID!=0); if (!existSource(sourceID)) @@ -1713,13 +1708,13 @@ am_Error_e CAmMapHandler::getListMainSourceSoundProperties(const am_sourceID_t s return (E_OK); } -am_Error_e CAmMapHandler::getListSystemProperties(std::vector<am_SystemProperty_s> & listSystemProperties) const +am_Error_e CAmDatabaseHandlerMap::getListSystemProperties(std::vector<am_SystemProperty_s> & listSystemProperties) const { listSystemProperties = mMappedData.mSystemProperties; return (E_OK); } -am_Error_e am::CAmMapHandler::getListSinkConnectionFormats(const am_sinkID_t sinkID, std::vector<am_ConnectionFormat_e> & listConnectionFormats) const +am_Error_e am::CAmDatabaseHandlerMap::getListSinkConnectionFormats(const am_sinkID_t sinkID, std::vector<am_ConnectionFormat_e> & listConnectionFormats) const { if (!existSink(sinkID)) return E_NON_EXISTENT; @@ -1729,7 +1724,7 @@ am_Error_e am::CAmMapHandler::getListSinkConnectionFormats(const am_sinkID_t sin return (E_OK); } -am_Error_e am::CAmMapHandler::getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector<am_ConnectionFormat_e> & listConnectionFormats) const +am_Error_e am::CAmDatabaseHandlerMap::getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector<am_ConnectionFormat_e> & listConnectionFormats) const { if (!existSource(sourceID)) return E_NON_EXISTENT; @@ -1739,7 +1734,7 @@ am_Error_e am::CAmMapHandler::getListSourceConnectionFormats(const am_sourceID_t return (E_OK); } -am_Error_e am::CAmMapHandler::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 { ListConnectionFormat::const_iterator iter = mListConnectionFormat.begin(); iter = mListConnectionFormat.find(gatewayID); @@ -1754,7 +1749,7 @@ am_Error_e am::CAmMapHandler::getListGatewayConnectionFormats(const am_gatewayID return (E_OK); } -am_Error_e CAmMapHandler::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 { assert(mainConnectionID!=0); if (!existMainConnection(mainConnectionID)) @@ -1770,7 +1765,7 @@ am_Error_e CAmMapHandler::getTimingInformation(const am_mainConnectionID_t mainC return (E_OK); } -am_Error_e CAmMapHandler::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) { assert(connectionID!=0); if (!existMainConnection(connectionID)) @@ -1785,7 +1780,7 @@ am_Error_e CAmMapHandler::changeDelayMainConnection(const am_timeSync_t & delay, * @param mainConnectionID to be checked for * @return true if it exists */ -bool CAmMapHandler::existMainConnection(const am_mainConnectionID_t mainConnectionID) const +bool CAmDatabaseHandlerMap::existMainConnection(const am_mainConnectionID_t mainConnectionID) const { return existsObjectWithKeyInMap(mainConnectionID, mMappedData.mMainConnectionMap); } @@ -1795,7 +1790,7 @@ bool CAmMapHandler::existMainConnection(const am_mainConnectionID_t mainConnecti * @param sourceID to be checked for * @return true if it exists */ -bool CAmMapHandler::existSource(const am_sourceID_t sourceID) const +bool CAmDatabaseHandlerMap::existSource(const am_sourceID_t sourceID) const { am_Source_Database_s const * source = objectWithKeyIfExistsInMap(sourceID, mMappedData.mSourceMap); if( NULL!=source ) @@ -1810,7 +1805,7 @@ bool CAmMapHandler::existSource(const am_sourceID_t sourceID) const * @param name the name * @return true if it exits */ -bool CAmMapHandler::existSourceNameOrID(const am_sourceID_t sourceID, const std::string & name) const +bool CAmDatabaseHandlerMap::existSourceNameOrID(const am_sourceID_t sourceID, const std::string & name) const { bool returnVal = false; CAmMapSource::const_iterator elementIterator = mMappedData.mSourceMap.begin(); @@ -1831,7 +1826,7 @@ bool CAmMapHandler::existSourceNameOrID(const am_sourceID_t sourceID, const std: * @param name the name * @return true if it exits */ -bool CAmMapHandler::existSourceName(const std::string & name) const +bool CAmDatabaseHandlerMap::existSourceName(const std::string & name) const { return existSourceNameOrID(SHRT_MAX, name); } @@ -1841,7 +1836,7 @@ bool CAmMapHandler::existSourceName(const std::string & name) const * @param sinkID to be checked for * @return true if it exists */ -bool CAmMapHandler::existSink(const am_sinkID_t sinkID) const +bool CAmDatabaseHandlerMap::existSink(const am_sinkID_t sinkID) const { bool returnVal = false; CAmMapSink::const_iterator elementIterator = mMappedData.mSinkMap.begin(); @@ -1863,7 +1858,7 @@ bool CAmMapHandler::existSink(const am_sinkID_t sinkID) const * @param name the name * @return true if it exists. */ -bool CAmMapHandler::existSinkNameOrID(const am_sinkID_t sinkID, const std::string & name) const +bool CAmDatabaseHandlerMap::existSinkNameOrID(const am_sinkID_t sinkID, const std::string & name) const { bool returnVal = false; CAmMapSink::const_iterator elementIterator = mMappedData.mSinkMap.begin(); @@ -1885,7 +1880,7 @@ bool CAmMapHandler::existSinkNameOrID(const am_sinkID_t sinkID, const std::strin * @param name the name * @return true if it exists */ -bool CAmMapHandler::existSinkName(const std::string & name) const +bool CAmDatabaseHandlerMap::existSinkName(const std::string & name) const { return existSinkNameOrID(SHRT_MAX, name); } @@ -1895,7 +1890,7 @@ bool CAmMapHandler::existSinkName(const std::string & name) const * @param domainID to be checked for * @return true if it exists */ -bool CAmMapHandler::existDomain(const am_domainID_t domainID) const +bool CAmDatabaseHandlerMap::existDomain(const am_domainID_t domainID) const { am_Domain_Database_s const * source = objectWithKeyIfExistsInMap(domainID, mMappedData.mDomainMap); if( NULL!=source ) @@ -1909,12 +1904,12 @@ bool CAmMapHandler::existDomain(const am_domainID_t domainID) const * @param gatewayID to be checked for * @return true if it exists */ -bool CAmMapHandler::existGateway(const am_gatewayID_t gatewayID) const +bool CAmDatabaseHandlerMap::existGateway(const am_gatewayID_t gatewayID) const { return existsObjectWithKeyInMap(gatewayID, mMappedData.mGatewayMap); } -am_Error_e CAmMapHandler::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 { assert(sourceID!=0); @@ -1927,7 +1922,7 @@ am_Error_e CAmMapHandler::getDomainOfSource(const am_sourceID_t sourceID, am_dom return E_NON_EXISTENT; } -am_Error_e am::CAmMapHandler::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 { assert(sinkID!=0); @@ -1945,7 +1940,7 @@ am_Error_e am::CAmMapHandler::getDomainOfSink(const am_sinkID_t sinkID, am_domai * @param sinkClassID * @return true if it exists */ -bool CAmMapHandler::existSinkClass(const am_sinkClass_t sinkClassID) const +bool CAmDatabaseHandlerMap::existSinkClass(const am_sinkClass_t sinkClassID) const { return existsObjectWithKeyInMap(sinkClassID, mMappedData.mSinkClassesMap); } @@ -1955,12 +1950,12 @@ bool CAmMapHandler::existSinkClass(const am_sinkClass_t sinkClassID) const * @param sourceClassID * @return true if it exists */ -bool CAmMapHandler::existSourceClass(const am_sourceClass_t sourceClassID) const +bool CAmDatabaseHandlerMap::existSourceClass(const am_sourceClass_t sourceClassID) const { return existsObjectWithKeyInMap(sourceClassID, mMappedData.mSourceClassesMap); } -am_Error_e CAmMapHandler::changeConnectionTimingInformation(const am_connectionID_t connectionID, const am_timeSync_t delay) +am_Error_e CAmDatabaseHandlerMap::changeConnectionTimingInformation(const am_connectionID_t connectionID, const am_timeSync_t delay) { assert(connectionID!=0); if(!existConnectionID(connectionID)) @@ -1987,7 +1982,7 @@ am_Error_e CAmMapHandler::changeConnectionTimingInformation(const am_connectionI return (E_OK); } -am_Error_e CAmMapHandler::changeConnectionFinal(const am_connectionID_t connectionID) +am_Error_e CAmDatabaseHandlerMap::changeConnectionFinal(const am_connectionID_t connectionID) { assert(connectionID!=0); am_Connection_Database_s const * connection = objectWithKeyIfExistsInMap(connectionID, mMappedData.mConnectionMap); @@ -1999,7 +1994,7 @@ am_Error_e CAmMapHandler::changeConnectionFinal(const am_connectionID_t connecti return (E_NON_EXISTENT); } -am_timeSync_t CAmMapHandler::calculateMainConnectionDelay(const am_mainConnectionID_t mainConnectionID) const +am_timeSync_t CAmDatabaseHandlerMap::calculateMainConnectionDelay(const am_mainConnectionID_t mainConnectionID) const { assert(mainConnectionID!=0); if (!existMainConnection(mainConnectionID)) @@ -2027,7 +2022,7 @@ am_timeSync_t CAmMapHandler::calculateMainConnectionDelay(const am_mainConnectio * registers the Observer at the Database * @param iObserver pointer to the observer */ -void CAmMapHandler::registerObserver(CAmDatabaseObserver *iObserver) +void CAmDatabaseHandlerMap::registerObserver(CAmDatabaseObserver *iObserver) { assert(iObserver!=NULL); mpDatabaseObserver = iObserver; @@ -2038,7 +2033,7 @@ void CAmMapHandler::registerObserver(CAmDatabaseObserver *iObserver) * @param sourceID the sourceID * @return true if source is visible */ -bool CAmMapHandler::sourceVisible(const am_sourceID_t sourceID) const +bool CAmDatabaseHandlerMap::sourceVisible(const am_sourceID_t sourceID) const { assert(sourceID!=0); if (!existSource(sourceID)) @@ -2052,7 +2047,7 @@ bool CAmMapHandler::sourceVisible(const am_sourceID_t sourceID) const * @param sinkID the sinkID * @return true if source is visible */ -bool CAmMapHandler::sinkVisible(const am_sinkID_t sinkID) const +bool CAmDatabaseHandlerMap::sinkVisible(const am_sinkID_t sinkID) const { am_Sink_Database_s const * source = objectWithKeyIfExistsInMap(sinkID, mMappedData.mSinkMap); if( NULL!=source ) @@ -2069,7 +2064,7 @@ bool CAmMapHandler::sinkVisible(const am_sinkID_t sinkID) const * @param connection the connection to be checked * @return true if connections exists */ -bool CAmMapHandler::existConnection(const am_Connection_s & connection) const +bool CAmDatabaseHandlerMap::existConnection(const am_Connection_s & connection) const { am_Connection_Database_s const * connectionObject = findFirstObjectMatchingCriteria(mMappedData.mConnectionMap, connection, compareConnectionObjectsWithObject); return ( NULL!=connectionObject ); @@ -2080,7 +2075,7 @@ bool CAmMapHandler::existConnection(const am_Connection_s & connection) const * @param connectionID * @return true if connection exits */ -bool CAmMapHandler::existConnectionID(const am_connectionID_t connectionID) const +bool CAmDatabaseHandlerMap::existConnectionID(const am_connectionID_t connectionID) const { am_Connection_Database_s const * connection = objectWithKeyIfExistsInMap(connectionID, mMappedData.mConnectionMap); if( NULL!=connection ) @@ -2095,12 +2090,12 @@ bool CAmMapHandler::existConnectionID(const am_connectionID_t connectionID) cons * @param crossfaderID the ID of the crossfader to be checked * @return true if exists */ -bool CAmMapHandler::existcrossFader(const am_crossfaderID_t crossfaderID) const +bool CAmDatabaseHandlerMap::existcrossFader(const am_crossfaderID_t crossfaderID) const { return existsObjectWithKeyInMap(crossfaderID, mMappedData.mCrossfaderMap); } -am_Error_e CAmMapHandler::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 = objectWithKeyIfExistsInMap(sourceID, mMappedData.mSourceMap); if( NULL!=source ) @@ -2115,7 +2110,7 @@ am_Error_e CAmMapHandler::getSoureState(const am_sourceID_t sourceID, am_SourceS } } -am_Error_e CAmMapHandler::changeSourceState(const am_sourceID_t sourceID, const am_SourceState_e sourceState) +am_Error_e CAmDatabaseHandlerMap::changeSourceState(const am_sourceID_t sourceID, const am_SourceState_e sourceState) { assert(sourceID!=0); assert(sourceState>=SS_UNKNNOWN && sourceState<=SS_MAX); @@ -2127,7 +2122,7 @@ am_Error_e CAmMapHandler::changeSourceState(const am_sourceID_t sourceID, const return (E_NON_EXISTENT); } -am_Error_e CAmMapHandler::getSinkVolume(const am_sinkID_t sinkID, am_volume_t & volume) const +am_Error_e CAmDatabaseHandlerMap::getSinkVolume(const am_sinkID_t sinkID, am_volume_t & volume) const { assert(sinkID!=0); @@ -2141,7 +2136,7 @@ am_Error_e CAmMapHandler::getSinkVolume(const am_sinkID_t sinkID, am_volume_t & return (E_NON_EXISTENT); } -am_Error_e CAmMapHandler::getSourceVolume(const am_sourceID_t sourceID, am_volume_t & volume) const +am_Error_e CAmDatabaseHandlerMap::getSourceVolume(const am_sourceID_t sourceID, am_volume_t & volume) const { assert(sourceID!=0); am_Source_Database_s const * source = objectWithKeyIfExistsInMap(sourceID, mMappedData.mSourceMap); @@ -2154,7 +2149,7 @@ am_Error_e CAmMapHandler::getSourceVolume(const am_sourceID_t sourceID, am_volum return (E_NON_EXISTENT); } -am_Error_e CAmMapHandler::getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_SoundPropertyType_e propertyType, int16_t & value) const +am_Error_e CAmDatabaseHandlerMap::getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_SoundPropertyType_e propertyType, int16_t & value) const { assert(sinkID!=0); @@ -2175,7 +2170,7 @@ am_Error_e CAmMapHandler::getSinkSoundPropertyValue(const am_sinkID_t sinkID, co return (E_NON_EXISTENT); } -am_Error_e CAmMapHandler::getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_SoundPropertyType_e propertyType, int16_t & value) const +am_Error_e CAmDatabaseHandlerMap::getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_SoundPropertyType_e propertyType, int16_t & value) const { assert(sourceID!=0); @@ -2196,7 +2191,7 @@ am_Error_e CAmMapHandler::getSourceSoundPropertyValue(const am_sourceID_t source return (E_NON_EXISTENT); } -am_Error_e CAmMapHandler::getDomainState(const am_domainID_t domainID, am_DomainState_e& state) const +am_Error_e CAmDatabaseHandlerMap::getDomainState(const am_domainID_t domainID, am_DomainState_e& state) const { assert(domainID!=0); @@ -2210,7 +2205,7 @@ am_Error_e CAmMapHandler::getDomainState(const am_domainID_t domainID, am_Domain return (E_NON_EXISTENT); } -am_Error_e CAmMapHandler::peekDomain(const std::string & name, am_domainID_t & domainID) +am_Error_e CAmDatabaseHandlerMap::peekDomain(const std::string & name, am_domainID_t & domainID) { domainID=0; @@ -2240,7 +2235,7 @@ am_Error_e CAmMapHandler::peekDomain(const std::string & name, am_domainID_t & d return (E_OK); } -am_Error_e CAmMapHandler::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 = findFirstObjectMatchingCriteria(mMappedData.mSinkMap, name, compareSinkObjectByName); if( NULL!=reservedSink ) @@ -2270,7 +2265,7 @@ am_Error_e CAmMapHandler::peekSink(const std::string & name, am_sinkID_t & sinkI } } -am_Error_e CAmMapHandler::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 *reservedDomain = findFirstObjectMatchingCriteria(mMappedData.mSourceMap, name, compareSourceObjectByName); if( NULL!=reservedDomain ) @@ -2301,7 +2296,7 @@ am_Error_e CAmMapHandler::peekSource(const std::string & name, am_sourceID_t & s } } -am_Error_e CAmMapHandler::changeSinkVolume(const am_sinkID_t sinkID, const am_volume_t volume) +am_Error_e CAmDatabaseHandlerMap::changeSinkVolume(const am_sinkID_t sinkID, const am_volume_t volume) { assert(sinkID!=0); @@ -2314,7 +2309,7 @@ am_Error_e CAmMapHandler::changeSinkVolume(const am_sinkID_t sinkID, const am_vo return (E_OK); } -am_Error_e CAmMapHandler::changeSourceVolume(const am_sourceID_t sourceID, const am_volume_t volume) +am_Error_e CAmDatabaseHandlerMap::changeSourceVolume(const am_sourceID_t sourceID, const am_volume_t volume) { assert(sourceID!=0); if (!existSource(sourceID)) @@ -2326,7 +2321,7 @@ am_Error_e CAmMapHandler::changeSourceVolume(const am_sourceID_t sourceID, const return (E_OK); } -am_Error_e CAmMapHandler::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) { assert(soundProperty.type>=SP_UNKNOWN && soundProperty.type<=SP_MAX); assert(sourceID!=0); @@ -2348,7 +2343,7 @@ am_Error_e CAmMapHandler::changeSourceSoundPropertyDB(const am_SoundProperty_s & return (E_NON_EXISTENT); } -am_Error_e CAmMapHandler::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) { assert(soundProperty.type>=SP_UNKNOWN && soundProperty.type<=SP_MAX); assert(sinkID!=0); @@ -2370,7 +2365,7 @@ am_Error_e CAmMapHandler::changeSinkSoundPropertyDB(const am_SoundProperty_s & s return (E_NON_EXISTENT); } -am_Error_e CAmMapHandler::changeCrossFaderHotSink(const am_crossfaderID_t crossfaderID, const am_HotSink_e hotsink) +am_Error_e CAmDatabaseHandlerMap::changeCrossFaderHotSink(const am_crossfaderID_t crossfaderID, const am_HotSink_e hotsink) { assert(crossfaderID!=0); assert(hotsink>=HS_UNKNOWN && hotsink>=HS_MAX); @@ -2384,7 +2379,7 @@ am_Error_e CAmMapHandler::changeCrossFaderHotSink(const am_crossfaderID_t crossf return (E_OK); } -am_Error_e CAmMapHandler::getRoutingTree(bool onlyfree, CAmRoutingTree& tree, std::vector<CAmRoutingTreeItem*>& flatTree) +am_Error_e CAmDatabaseHandlerMap::getRoutingTree(bool onlyfree, CAmRoutingTree& tree, std::vector<CAmRoutingTreeItem*>& flatTree) { am_domainID_t rootID = tree.returnRootDomainID(); CAmRoutingTreeItem *parent = tree.returnRootItem(); @@ -2434,7 +2429,7 @@ am_Error_e CAmMapHandler::getRoutingTree(bool onlyfree, CAmRoutingTree& tree, st return (E_OK); } -am_Error_e am::CAmMapHandler::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); @@ -2448,7 +2443,7 @@ am_Error_e am::CAmMapHandler::peekSinkClassID(const std::string & name, am_sinkC return (E_NON_EXISTENT); } -am_Error_e am::CAmMapHandler::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); @@ -2463,7 +2458,7 @@ am_Error_e am::CAmMapHandler::peekSourceClassID(const std::string & name, am_sou } -am_Error_e CAmMapHandler::changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_ConnectionFormat_e>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) +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_ConnectionFormat_e>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) { assert(sourceID!=0); @@ -2521,7 +2516,7 @@ am_Error_e CAmMapHandler::changeSourceDB(const am_sourceID_t sourceID, const am_ } -am_Error_e CAmMapHandler::changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_ConnectionFormat_e>& 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_ConnectionFormat_e>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) { assert(sinkID!=0); @@ -2577,7 +2572,7 @@ am_Error_e CAmMapHandler::changeSinkDB(const am_sinkID_t sinkID, const am_sinkCl return (E_OK); } -am_Error_e CAmMapHandler::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) { assert(sinkID!=0); if (!existSink(sinkID)) @@ -2589,7 +2584,7 @@ am_Error_e CAmMapHandler::getListMainSinkNotificationConfigurations(const am_sin return (E_OK); } -am_Error_e CAmMapHandler::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) { assert(sourceID!=0); if (!existSource(sourceID)) @@ -2617,7 +2612,7 @@ bool changeMainNotificationConfiguration(std::vector<am_NotificationConfiguratio return changed; } -am_Error_e CAmMapHandler::changeMainSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration) +am_Error_e CAmDatabaseHandlerMap::changeMainSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration) { assert(sinkID!=0); @@ -2635,7 +2630,7 @@ am_Error_e CAmMapHandler::changeMainSinkNotificationConfigurationDB(const am_sin return (E_OK); } -am_Error_e CAmMapHandler::changeMainSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration) +am_Error_e CAmDatabaseHandlerMap::changeMainSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration) { assert(sourceID!=0); @@ -2654,7 +2649,7 @@ am_Error_e CAmMapHandler::changeMainSourceNotificationConfigurationDB(const am_s return (E_OK); } -am_Error_e CAmMapHandler::changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector<am_ConnectionFormat_e>& listSourceConnectionFormats, const std::vector<am_ConnectionFormat_e>& listSinkConnectionFormats, const std::vector<bool>& convertionMatrix) +am_Error_e CAmDatabaseHandlerMap::changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector<am_ConnectionFormat_e>& listSourceConnectionFormats, const std::vector<am_ConnectionFormat_e>& listSinkConnectionFormats, const std::vector<bool>& convertionMatrix) { assert(gatewayID!=0); @@ -2701,7 +2696,7 @@ bool changeNotificationConfiguration(std::vector<am_NotificationConfiguration_s> return changed; } -am_Error_e CAmMapHandler::changeSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration) +am_Error_e CAmDatabaseHandlerMap::changeSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration) { assert(sinkID!=0); @@ -2718,7 +2713,7 @@ am_Error_e CAmMapHandler::changeSinkNotificationConfigurationDB(const am_sinkID_ return (E_NON_EXISTENT); } -am_Error_e CAmMapHandler::changeSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration) +am_Error_e CAmDatabaseHandlerMap::changeSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration) { assert(sourceID!=0); diff --git a/AudioManagerDaemon/src/CAmDatabaseHandlerSQLite.cpp b/AudioManagerDaemon/src/CAmDatabaseHandlerSQLite.cpp index 1e72a4c..df0fbcb 100644 --- a/AudioManagerDaemon/src/CAmDatabaseHandlerSQLite.cpp +++ b/AudioManagerDaemon/src/CAmDatabaseHandlerSQLite.cpp @@ -14,12 +14,12 @@ * * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012 * - * \file CAmDatabaseHandler.cpp + * \file CAmDatabaseHandlerSQLite.cpp * For further information see http://www.genivi.org/. * */ -#include "CAmDatabaseHandler.h" +#include "CAmDatabaseHandlerSQLite.h" #include <cassert> #include <stdexcept> #include <vector> @@ -136,17 +136,31 @@ inline std::string i2s(T const& x) return (o.str()); } -CAmDatabaseHandler::CAmDatabaseHandler():CAmDatabaseHandlerInterface() +CAmDatabaseHandlerSQLite::CAmDatabaseHandlerSQLite():mpDatabaseObserver(NULL), // + mFirstStaticSink(true), // + mFirstStaticSource(true), // + mFirstStaticGateway(true), // + mFirstStaticSinkClass(true), // + mFirstStaticSourceClass(true), // + mFirstStaticCrossfader(true), // + mListConnectionFormat(), + mpDatabase(NULL), // + mPath(std::string("")) { - mpDatabase = NULL; - mPath = std::string(""); + } -CAmDatabaseHandler::CAmDatabaseHandler(std::string databasePath):CAmDatabaseHandlerInterface(), - mpDatabase(NULL), // - mPath(databasePath) +CAmDatabaseHandlerSQLite::CAmDatabaseHandlerSQLite(std::string databasePath):mpDatabaseObserver(NULL), // + mFirstStaticSink(true), // + mFirstStaticSource(true), // + mFirstStaticGateway(true), // + mFirstStaticSinkClass(true), // + mFirstStaticSourceClass(true), // + mFirstStaticCrossfader(true), // + mListConnectionFormat(), + mpDatabase(NULL), // + mPath(databasePath) { - std::ifstream infile(mPath.c_str()); if (infile) @@ -167,13 +181,15 @@ CAmDatabaseHandler::CAmDatabaseHandler(std::string databasePath):CAmDatabaseHand createTables(); } -CAmDatabaseHandler::~CAmDatabaseHandler() +CAmDatabaseHandlerSQLite::~CAmDatabaseHandlerSQLite() { logInfo("Closed Database"); - sqlite3_close(mpDatabase); + mpDatabaseObserver = NULL; + if(mpDatabase) + sqlite3_close(mpDatabase); } -am_Error_e CAmDatabaseHandler::enterDomainDB(const am_Domain_s & domainData, am_domainID_t & domainID) +am_Error_e CAmDatabaseHandlerSQLite::enterDomainDB(const am_Domain_s & domainData, am_domainID_t & domainID) { assert(domainData.domainID==0); assert(!domainData.name.empty()); @@ -234,7 +250,7 @@ am_Error_e CAmDatabaseHandler::enterDomainDB(const am_Domain_s & domainData, am_ return (E_OK); } -am_Error_e CAmDatabaseHandler::enterMainConnectionDB(const am_MainConnection_s & mainConnectionData, am_mainConnectionID_t & connectionID) +am_Error_e CAmDatabaseHandlerSQLite::enterMainConnectionDB(const am_MainConnection_s & mainConnectionData, am_mainConnectionID_t & connectionID) { assert(mainConnectionData.mainConnectionID==0); assert(mainConnectionData.connectionState>=CS_UNKNOWN && mainConnectionData.connectionState<=CS_MAX); @@ -328,7 +344,7 @@ am_Error_e CAmDatabaseHandler::enterMainConnectionDB(const am_MainConnection_s & return (changeDelayMainConnection(delay, connectionID)); } -am_Error_e CAmDatabaseHandler::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t & sinkID) +am_Error_e CAmDatabaseHandlerSQLite::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t & sinkID) { assert(sinkData.sinkID<DYNAMIC_ID_BOUNDARY); assert(sinkData.domainID!=0); @@ -545,7 +561,7 @@ am_Error_e CAmDatabaseHandler::enterSinkDB(const am_Sink_s & sinkData, am_sinkID return (E_OK); } -am_Error_e CAmDatabaseHandler::enterCrossfaderDB(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID) +am_Error_e CAmDatabaseHandlerSQLite::enterCrossfaderDB(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID) { assert(crossfaderData.crossfaderID<DYNAMIC_ID_BOUNDARY); assert(crossfaderData.hotSink>=HS_UNKNOWN && crossfaderData.hotSink<=HS_MAX); @@ -627,7 +643,7 @@ am_Error_e CAmDatabaseHandler::enterCrossfaderDB(const am_Crossfader_s & crossfa return (E_OK); } -am_Error_e CAmDatabaseHandler::enterGatewayDB(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID) +am_Error_e CAmDatabaseHandlerSQLite::enterGatewayDB(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID) { assert(gatewayData.gatewayID<DYNAMIC_ID_BOUNDARY); assert(gatewayData.sinkID!=0); @@ -744,7 +760,7 @@ am_Error_e CAmDatabaseHandler::enterGatewayDB(const am_Gateway_s & gatewayData, return (E_OK); } -am_Error_e CAmDatabaseHandler::enterSourceDB(const am_Source_s & sourceData, am_sourceID_t & sourceID) +am_Error_e CAmDatabaseHandlerSQLite::enterSourceDB(const am_Source_s & sourceData, am_sourceID_t & sourceID) { assert(sourceData.sourceID<DYNAMIC_ID_BOUNDARY); assert(sourceData.domainID!=0); @@ -964,7 +980,7 @@ am_Error_e CAmDatabaseHandler::enterSourceDB(const am_Source_s & sourceData, am_ return (E_OK); } -am_Error_e CAmDatabaseHandler::changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector<am_connectionID_t>& listConnectionID) +am_Error_e CAmDatabaseHandlerSQLite::changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector<am_connectionID_t>& listConnectionID) { assert(mainconnectionID!=0); if (!existMainConnection(mainconnectionID)) @@ -1030,7 +1046,7 @@ am_Error_e CAmDatabaseHandler::changeMainConnectionRouteDB(const am_mainConnecti return (E_OK); } -am_Error_e CAmDatabaseHandler::changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState) +am_Error_e CAmDatabaseHandlerSQLite::changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState) { assert(mainconnectionID!=0); assert(connectionState>=CS_UNKNOWN && connectionState<=CS_MAX); @@ -1060,7 +1076,7 @@ am_Error_e CAmDatabaseHandler::changeMainConnectionStateDB(const am_mainConnecti return (E_OK); } -am_Error_e CAmDatabaseHandler::changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID) +am_Error_e CAmDatabaseHandlerSQLite::changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID) { assert(sinkID!=0); @@ -1091,7 +1107,7 @@ am_Error_e CAmDatabaseHandler::changeSinkMainVolumeDB(const am_mainVolume_t main return (E_OK); } -am_Error_e CAmDatabaseHandler::changeSinkAvailabilityDB(const am_Availability_s & availability, const am_sinkID_t sinkID) +am_Error_e CAmDatabaseHandlerSQLite::changeSinkAvailabilityDB(const am_Availability_s & availability, const am_sinkID_t sinkID) { assert(sinkID!=0); assert(availability.availability>=A_UNKNOWN && availability.availability<=A_MAX); @@ -1124,7 +1140,7 @@ am_Error_e CAmDatabaseHandler::changeSinkAvailabilityDB(const am_Availability_s return (E_OK); } -am_Error_e CAmDatabaseHandler::changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID) +am_Error_e CAmDatabaseHandlerSQLite::changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID) { assert(domainID!=0); assert(domainState>=DS_UNKNOWN && domainState<=DS_MAX); @@ -1153,7 +1169,7 @@ am_Error_e CAmDatabaseHandler::changDomainStateDB(const am_DomainState_e domainS return (E_OK); } -am_Error_e CAmDatabaseHandler::changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID) +am_Error_e CAmDatabaseHandlerSQLite::changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID) { assert(sinkID!=0); assert(muteState>=MS_UNKNOWN && muteState<=MS_MAX); @@ -1185,7 +1201,7 @@ am_Error_e CAmDatabaseHandler::changeSinkMuteStateDB(const am_MuteState_e muteSt return (E_OK); } -am_Error_e CAmDatabaseHandler::changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sinkID_t sinkID) +am_Error_e CAmDatabaseHandlerSQLite::changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sinkID_t sinkID) { assert(soundProperty.type>=MSP_UNKNOWN && soundProperty.type<=MSP_MAX); assert(sinkID!=0); @@ -1215,7 +1231,7 @@ am_Error_e CAmDatabaseHandler::changeMainSinkSoundPropertyDB(const am_MainSoundP return (E_OK); } -am_Error_e CAmDatabaseHandler::changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sourceID_t sourceID) +am_Error_e CAmDatabaseHandlerSQLite::changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sourceID_t sourceID) { assert(soundProperty.type>=MSP_UNKNOWN && soundProperty.type<=MSP_MAX); assert(sourceID!=0); @@ -1246,7 +1262,7 @@ am_Error_e CAmDatabaseHandler::changeMainSourceSoundPropertyDB(const am_MainSoun return (E_OK); } -am_Error_e CAmDatabaseHandler::changeSourceAvailabilityDB(const am_Availability_s & availability, const am_sourceID_t sourceID) +am_Error_e CAmDatabaseHandlerSQLite::changeSourceAvailabilityDB(const am_Availability_s & availability, const am_sourceID_t sourceID) { assert(sourceID!=0); assert(availability.availability>=A_UNKNOWN && availability.availability<=A_MAX); @@ -1280,7 +1296,7 @@ am_Error_e CAmDatabaseHandler::changeSourceAvailabilityDB(const am_Availability_ return (E_OK); } -am_Error_e CAmDatabaseHandler::changeSystemPropertyDB(const am_SystemProperty_s & property) +am_Error_e CAmDatabaseHandlerSQLite::changeSystemPropertyDB(const am_SystemProperty_s & property) { assert(property.type>=SYP_UNKNOWN && property.type<=SYP_MAX); sqlite3_stmt* query = NULL; @@ -1308,7 +1324,7 @@ am_Error_e CAmDatabaseHandler::changeSystemPropertyDB(const am_SystemProperty_s return (E_OK); } -am_Error_e CAmDatabaseHandler::removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID) +am_Error_e CAmDatabaseHandlerSQLite::removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID) { assert(mainConnectionID!=0); @@ -1331,7 +1347,7 @@ am_Error_e CAmDatabaseHandler::removeMainConnectionDB(const am_mainConnectionID_ return (E_OK); } -am_Error_e CAmDatabaseHandler::removeSinkDB(const am_sinkID_t sinkID) +am_Error_e CAmDatabaseHandlerSQLite::removeSinkDB(const am_sinkID_t sinkID) { assert(sinkID!=0); @@ -1371,7 +1387,7 @@ am_Error_e CAmDatabaseHandler::removeSinkDB(const am_sinkID_t sinkID) return (E_OK); } -am_Error_e CAmDatabaseHandler::removeSourceDB(const am_sourceID_t sourceID) +am_Error_e CAmDatabaseHandlerSQLite::removeSourceDB(const am_sourceID_t sourceID) { assert(sourceID!=0); @@ -1410,7 +1426,7 @@ am_Error_e CAmDatabaseHandler::removeSourceDB(const am_sourceID_t sourceID) return (E_OK); } -am_Error_e CAmDatabaseHandler::removeGatewayDB(const am_gatewayID_t gatewayID) +am_Error_e CAmDatabaseHandlerSQLite::removeGatewayDB(const am_gatewayID_t gatewayID) { assert(gatewayID!=0); @@ -1427,7 +1443,7 @@ am_Error_e CAmDatabaseHandler::removeGatewayDB(const am_gatewayID_t gatewayID) return (E_OK); } -am_Error_e CAmDatabaseHandler::removeCrossfaderDB(const am_crossfaderID_t crossfaderID) +am_Error_e CAmDatabaseHandlerSQLite::removeCrossfaderDB(const am_crossfaderID_t crossfaderID) { assert(crossfaderID!=0); @@ -1444,7 +1460,7 @@ am_Error_e CAmDatabaseHandler::removeCrossfaderDB(const am_crossfaderID_t crossf return (E_OK); } -am_Error_e CAmDatabaseHandler::removeDomainDB(const am_domainID_t domainID) +am_Error_e CAmDatabaseHandlerSQLite::removeDomainDB(const am_domainID_t domainID) { assert(domainID!=0); @@ -1461,7 +1477,7 @@ am_Error_e CAmDatabaseHandler::removeDomainDB(const am_domainID_t domainID) return (E_OK); } -am_Error_e CAmDatabaseHandler::removeSinkClassDB(const am_sinkClass_t sinkClassID) +am_Error_e CAmDatabaseHandlerSQLite::removeSinkClassDB(const am_sinkClass_t sinkClassID) { assert(sinkClassID!=0); @@ -1483,7 +1499,7 @@ am_Error_e CAmDatabaseHandler::removeSinkClassDB(const am_sinkClass_t sinkClassI return (E_OK); } -am_Error_e CAmDatabaseHandler::removeSourceClassDB(const am_sourceClass_t sourceClassID) +am_Error_e CAmDatabaseHandlerSQLite::removeSourceClassDB(const am_sourceClass_t sourceClassID) { assert(sourceClassID!=0); @@ -1503,7 +1519,7 @@ am_Error_e CAmDatabaseHandler::removeSourceClassDB(const am_sourceClass_t source return (E_OK); } -am_Error_e CAmDatabaseHandler::removeConnection(const am_connectionID_t connectionID) +am_Error_e CAmDatabaseHandlerSQLite::removeConnection(const am_connectionID_t connectionID) { assert(connectionID!=0); @@ -1514,7 +1530,7 @@ am_Error_e CAmDatabaseHandler::removeConnection(const am_connectionID_t connecti return (E_OK); } -am_Error_e CAmDatabaseHandler::getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s & classInfo) const +am_Error_e CAmDatabaseHandlerSQLite::getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s & classInfo) const { assert(sourceID!=0); @@ -1580,7 +1596,7 @@ am_Error_e CAmDatabaseHandler::getSourceClassInfoDB(const am_sourceID_t sourceID return (E_OK); } -am_Error_e CAmDatabaseHandler::getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s & sinkData) const +am_Error_e CAmDatabaseHandlerSQLite::getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s & sinkData) const { assert(sinkID!=0); @@ -1688,7 +1704,7 @@ am_Error_e CAmDatabaseHandler::getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s return (E_OK); } -am_Error_e CAmDatabaseHandler::getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s & sourceData) const +am_Error_e CAmDatabaseHandlerSQLite::getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s & sourceData) const { assert(sourceID!=0); @@ -1795,7 +1811,7 @@ am_Error_e CAmDatabaseHandler::getSourceInfoDB(const am_sourceID_t sourceID, am_ return (E_OK); } -am_Error_e am::CAmDatabaseHandler::getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s & mainConnectionData) const +am_Error_e am::CAmDatabaseHandlerSQLite::getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s & mainConnectionData) const { assert(mainConnectionID!=0); if (!existMainConnection(mainConnectionID)) @@ -1837,7 +1853,7 @@ am_Error_e am::CAmDatabaseHandler::getMainConnectionInfoDB(const am_mainConnecti return (E_OK); } -am_Error_e CAmDatabaseHandler::changeSinkClassInfoDB(const am_SinkClass_s& sinkClass) +am_Error_e CAmDatabaseHandlerSQLite::changeSinkClassInfoDB(const am_SinkClass_s& sinkClass) { assert(sinkClass.sinkClassID!=0); assert(!sinkClass.listClassProperties.empty()); @@ -1878,7 +1894,7 @@ am_Error_e CAmDatabaseHandler::changeSinkClassInfoDB(const am_SinkClass_s& sinkC return (E_OK); } -am_Error_e CAmDatabaseHandler::changeSourceClassInfoDB(const am_SourceClass_s& sourceClass) +am_Error_e CAmDatabaseHandlerSQLite::changeSourceClassInfoDB(const am_SourceClass_s& sourceClass) { assert(sourceClass.sourceClassID!=0); assert(!sourceClass.listClassProperties.empty()); @@ -1913,7 +1929,7 @@ am_Error_e CAmDatabaseHandler::changeSourceClassInfoDB(const am_SourceClass_s& s return (E_OK); } -am_Error_e CAmDatabaseHandler::getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s & sinkClass) const +am_Error_e CAmDatabaseHandlerSQLite::getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s & sinkClass) const { assert(sinkID!=0); @@ -1979,7 +1995,7 @@ am_Error_e CAmDatabaseHandler::getSinkClassInfoDB(const am_sinkID_t sinkID, am_S return (E_OK); } -am_Error_e CAmDatabaseHandler::getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s & gatewayData) const +am_Error_e CAmDatabaseHandlerSQLite::getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s & gatewayData) const { assert(gatewayID!=0); if (!existGateway(gatewayID)) @@ -2050,7 +2066,7 @@ am_Error_e CAmDatabaseHandler::getGatewayInfoDB(const am_gatewayID_t gatewayID, } -am_Error_e CAmDatabaseHandler::getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s & crossfaderData) const +am_Error_e CAmDatabaseHandlerSQLite::getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s & crossfaderData) const { assert(crossfaderID!=0); if (!existcrossFader(crossfaderID)) @@ -2084,7 +2100,7 @@ am_Error_e CAmDatabaseHandler::getCrossfaderInfoDB(const am_crossfaderID_t cross return (E_OK); } -am_Error_e CAmDatabaseHandler::getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t> & listSinkID) const +am_Error_e CAmDatabaseHandlerSQLite::getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t> & listSinkID) const { assert(domainID!=0); listSinkID.clear(); @@ -2115,7 +2131,7 @@ am_Error_e CAmDatabaseHandler::getListSinksOfDomain(const am_domainID_t domainID return (E_OK); } -am_Error_e CAmDatabaseHandler::getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t> & listSourceID) const +am_Error_e CAmDatabaseHandlerSQLite::getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t> & listSourceID) const { assert(domainID!=0); listSourceID.clear(); @@ -2148,7 +2164,7 @@ am_Error_e CAmDatabaseHandler::getListSourcesOfDomain(const am_domainID_t domain return (E_OK); } -am_Error_e CAmDatabaseHandler::getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t> & listCrossfader) const +am_Error_e CAmDatabaseHandlerSQLite::getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t> & listCrossfader) const { assert(domainID!=0); listCrossfader.clear(); @@ -2182,7 +2198,7 @@ am_Error_e CAmDatabaseHandler::getListCrossfadersOfDomain(const am_domainID_t do } -am_Error_e CAmDatabaseHandler::getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t> & listGatewaysID) const +am_Error_e CAmDatabaseHandlerSQLite::getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t> & listGatewaysID) const { assert(domainID!=0); listGatewaysID.clear(); @@ -2215,7 +2231,7 @@ am_Error_e CAmDatabaseHandler::getListGatewaysOfDomain(const am_domainID_t domai return (E_OK); } -am_Error_e CAmDatabaseHandler::getListMainConnections(std::vector<am_MainConnection_s> & listMainConnections) const +am_Error_e CAmDatabaseHandlerSQLite::getListMainConnections(std::vector<am_MainConnection_s> & listMainConnections) const { listMainConnections.clear(); sqlite3_stmt *query = NULL, *query1 = NULL; @@ -2254,7 +2270,7 @@ am_Error_e CAmDatabaseHandler::getListMainConnections(std::vector<am_MainConnect return (E_OK); } -am_Error_e CAmDatabaseHandler::getListDomains(std::vector<am_Domain_s> & listDomains) const +am_Error_e CAmDatabaseHandlerSQLite::getListDomains(std::vector<am_Domain_s> & listDomains) const { listDomains.clear(); sqlite3_stmt* query = NULL; @@ -2287,7 +2303,7 @@ am_Error_e CAmDatabaseHandler::getListDomains(std::vector<am_Domain_s> & listDom return (E_OK); } -am_Error_e CAmDatabaseHandler::getListConnections(std::vector<am_Connection_s> & listConnections) const +am_Error_e CAmDatabaseHandlerSQLite::getListConnections(std::vector<am_Connection_s> & listConnections) const { listConnections.clear(); sqlite3_stmt* query = NULL; @@ -2318,7 +2334,7 @@ am_Error_e CAmDatabaseHandler::getListConnections(std::vector<am_Connection_s> & return (E_OK); } -am_Error_e CAmDatabaseHandler::getListSinks(std::vector<am_Sink_s> & listSinks) const +am_Error_e CAmDatabaseHandlerSQLite::getListSinks(std::vector<am_Sink_s> & listSinks) const { listSinks.clear(); sqlite3_stmt* query = NULL, *qConnectionFormat = NULL, *qSoundProperty = NULL, *qNotificationConfiguration= NULL, *qMAinSoundProperty = NULL, *qMainNotificationConfiguration= NULL; @@ -2427,7 +2443,7 @@ am_Error_e CAmDatabaseHandler::getListSinks(std::vector<am_Sink_s> & listSinks) return (E_OK); } -am_Error_e CAmDatabaseHandler::getListSources(std::vector<am_Source_s> & listSources) const +am_Error_e CAmDatabaseHandlerSQLite::getListSources(std::vector<am_Source_s> & listSources) const { listSources.clear(); sqlite3_stmt* query = NULL, *qConnectionFormat = NULL, *qSoundProperty = NULL, *qMAinSoundProperty = NULL, *qNotification(NULL), *qMainNotification(NULL); @@ -2534,7 +2550,7 @@ am_Error_e CAmDatabaseHandler::getListSources(std::vector<am_Source_s> & listSou return (E_OK); } -am_Error_e CAmDatabaseHandler::getListSourceClasses(std::vector<am_SourceClass_s> & listSourceClasses) const +am_Error_e CAmDatabaseHandlerSQLite::getListSourceClasses(std::vector<am_SourceClass_s> & listSourceClasses) const { listSourceClasses.clear(); @@ -2588,7 +2604,7 @@ am_Error_e CAmDatabaseHandler::getListSourceClasses(std::vector<am_SourceClass_s return (E_OK); } -am_Error_e CAmDatabaseHandler::getListCrossfaders(std::vector<am_Crossfader_s> & listCrossfaders) const +am_Error_e CAmDatabaseHandlerSQLite::getListCrossfaders(std::vector<am_Crossfader_s> & listCrossfaders) const { listCrossfaders.clear(); sqlite3_stmt* query = NULL; @@ -2620,7 +2636,7 @@ am_Error_e CAmDatabaseHandler::getListCrossfaders(std::vector<am_Crossfader_s> & return (E_OK); } -am_Error_e CAmDatabaseHandler::getListGateways(std::vector<am_Gateway_s> & listGateways) const +am_Error_e CAmDatabaseHandlerSQLite::getListGateways(std::vector<am_Gateway_s> & listGateways) const { listGateways.clear(); sqlite3_stmt* query = NULL, *qSinkConnectionFormat = NULL, *qSourceConnectionFormat = NULL; @@ -2691,7 +2707,7 @@ am_Error_e CAmDatabaseHandler::getListGateways(std::vector<am_Gateway_s> & listG return (E_OK); } -am_Error_e CAmDatabaseHandler::getListSinkClasses(std::vector<am_SinkClass_s> & listSinkClasses) const +am_Error_e CAmDatabaseHandlerSQLite::getListSinkClasses(std::vector<am_SinkClass_s> & listSinkClasses) const { listSinkClasses.clear(); @@ -2744,7 +2760,7 @@ am_Error_e CAmDatabaseHandler::getListSinkClasses(std::vector<am_SinkClass_s> & return (E_OK); } -am_Error_e CAmDatabaseHandler::getListVisibleMainConnections(std::vector<am_MainConnectionType_s> & listConnections) const +am_Error_e CAmDatabaseHandlerSQLite::getListVisibleMainConnections(std::vector<am_MainConnectionType_s> & listConnections) const { listConnections.clear(); sqlite3_stmt *query = NULL; @@ -2776,7 +2792,7 @@ am_Error_e CAmDatabaseHandler::getListVisibleMainConnections(std::vector<am_Main return (E_OK); } -am_Error_e CAmDatabaseHandler::getListMainSinks(std::vector<am_SinkType_s> & listMainSinks) const +am_Error_e CAmDatabaseHandlerSQLite::getListMainSinks(std::vector<am_SinkType_s> & listMainSinks) const { listMainSinks.clear(); sqlite3_stmt* query = NULL; @@ -2810,7 +2826,7 @@ am_Error_e CAmDatabaseHandler::getListMainSinks(std::vector<am_SinkType_s> & lis return (E_OK); } -am_Error_e CAmDatabaseHandler::getListMainSources(std::vector<am_SourceType_s> & listMainSources) const +am_Error_e CAmDatabaseHandlerSQLite::getListMainSources(std::vector<am_SourceType_s> & listMainSources) const { listMainSources.clear(); sqlite3_stmt* query = NULL; @@ -2842,7 +2858,7 @@ am_Error_e CAmDatabaseHandler::getListMainSources(std::vector<am_SourceType_s> & return (E_OK); } -am_Error_e CAmDatabaseHandler::getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s> & listSoundProperties) const +am_Error_e CAmDatabaseHandlerSQLite::getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s> & listSoundProperties) const { assert(sinkID!=0); if (!existSink(sinkID)) @@ -2874,7 +2890,7 @@ am_Error_e CAmDatabaseHandler::getListMainSinkSoundProperties(const am_sinkID_t return (E_OK); } -am_Error_e CAmDatabaseHandler::getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s> & listSourceProperties) const +am_Error_e CAmDatabaseHandlerSQLite::getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s> & listSourceProperties) const { assert(sourceID!=0); if (!existSource(sourceID)) @@ -2906,7 +2922,7 @@ am_Error_e CAmDatabaseHandler::getListMainSourceSoundProperties(const am_sourceI return (E_OK); } -am_Error_e CAmDatabaseHandler::getListSystemProperties(std::vector<am_SystemProperty_s> & listSystemProperties) const +am_Error_e CAmDatabaseHandlerSQLite::getListSystemProperties(std::vector<am_SystemProperty_s> & listSystemProperties) const { listSystemProperties.clear(); @@ -2935,7 +2951,7 @@ am_Error_e CAmDatabaseHandler::getListSystemProperties(std::vector<am_SystemProp return (E_OK); } -am_Error_e am::CAmDatabaseHandler::getListSinkConnectionFormats(const am_sinkID_t sinkID, std::vector<am_ConnectionFormat_e> & listConnectionFormats) const +am_Error_e am::CAmDatabaseHandlerSQLite::getListSinkConnectionFormats(const am_sinkID_t sinkID, std::vector<am_ConnectionFormat_e> & listConnectionFormats) const { listConnectionFormats.clear(); sqlite3_stmt *qConnectionFormat = NULL; @@ -2954,7 +2970,7 @@ am_Error_e am::CAmDatabaseHandler::getListSinkConnectionFormats(const am_sinkID_ return (E_OK); } -am_Error_e am::CAmDatabaseHandler::getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector<am_ConnectionFormat_e> & listConnectionFormats) const +am_Error_e am::CAmDatabaseHandlerSQLite::getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector<am_ConnectionFormat_e> & listConnectionFormats) const { listConnectionFormats.clear(); sqlite3_stmt* qConnectionFormat = NULL; @@ -2975,7 +2991,7 @@ am_Error_e am::CAmDatabaseHandler::getListSourceConnectionFormats(const am_sourc return (E_OK); } -am_Error_e am::CAmDatabaseHandler::getListGatewayConnectionFormats(const am_gatewayID_t gatewayID, std::vector<bool> & listConnectionFormat) const +am_Error_e am::CAmDatabaseHandlerSQLite::getListGatewayConnectionFormats(const am_gatewayID_t gatewayID, std::vector<bool> & listConnectionFormat) const { ListConnectionFormat::const_iterator iter = mListConnectionFormat.begin(); iter = mListConnectionFormat.find(gatewayID); @@ -2990,7 +3006,7 @@ am_Error_e am::CAmDatabaseHandler::getListGatewayConnectionFormats(const am_gate return (E_OK); } -am_Error_e CAmDatabaseHandler::getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t & delay) const +am_Error_e CAmDatabaseHandlerSQLite::getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t & delay) const { assert(mainConnectionID!=0); delay = -1; @@ -3020,7 +3036,7 @@ am_Error_e CAmDatabaseHandler::getTimingInformation(const am_mainConnectionID_t return (E_OK); } -bool CAmDatabaseHandler::sqQuery(const std::string& query) +bool CAmDatabaseHandlerSQLite::sqQuery(const std::string& query) { sqlite3_stmt* statement; int eCode = 0; @@ -3032,7 +3048,7 @@ bool CAmDatabaseHandler::sqQuery(const std::string& query) return (true); } -bool CAmDatabaseHandler::openDatabase() +bool CAmDatabaseHandlerSQLite::openDatabase() { if (sqlite3_open_v2(mPath.c_str(), &mpDatabase, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX, NULL) == SQLITE_OK) { @@ -3043,7 +3059,7 @@ bool CAmDatabaseHandler::openDatabase() return (false); } -am_Error_e CAmDatabaseHandler::changeDelayMainConnection(const am_timeSync_t & delay, const am_mainConnectionID_t & connectionID) +am_Error_e CAmDatabaseHandlerSQLite::changeDelayMainConnection(const am_timeSync_t & delay, const am_mainConnectionID_t & connectionID) { assert(connectionID!=0); @@ -3078,7 +3094,7 @@ am_Error_e CAmDatabaseHandler::changeDelayMainConnection(const am_timeSync_t & d return (E_OK); } -am_Error_e CAmDatabaseHandler::enterConnectionDB(const am_Connection_s& connection, am_connectionID_t& connectionID) +am_Error_e CAmDatabaseHandlerSQLite::enterConnectionDB(const am_Connection_s& connection, am_connectionID_t& connectionID) { assert(connection.connectionID==0); assert(connection.sinkID!=0); @@ -3111,7 +3127,7 @@ am_Error_e CAmDatabaseHandler::enterConnectionDB(const am_Connection_s& connecti return (E_OK); } -am_Error_e CAmDatabaseHandler::enterSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID) +am_Error_e CAmDatabaseHandlerSQLite::enterSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID) { assert(sinkClass.sinkClassID<DYNAMIC_ID_BOUNDARY); assert(!sinkClass.name.empty()); @@ -3190,7 +3206,7 @@ am_Error_e CAmDatabaseHandler::enterSinkClassDB(const am_SinkClass_s & sinkClass return (E_OK); } -am_Error_e CAmDatabaseHandler::enterSourceClassDB(am_sourceClass_t & sourceClassID, const am_SourceClass_s & sourceClass) +am_Error_e CAmDatabaseHandlerSQLite::enterSourceClassDB(am_sourceClass_t & sourceClassID, const am_SourceClass_s & sourceClass) { assert(sourceClass.sourceClassID<DYNAMIC_ID_BOUNDARY); assert(!sourceClass.name.empty()); @@ -3270,7 +3286,7 @@ am_Error_e CAmDatabaseHandler::enterSourceClassDB(am_sourceClass_t & sourceClass return (E_OK); } -am_Error_e CAmDatabaseHandler::enterSystemProperties(const std::vector<am_SystemProperty_s> & listSystemProperties) +am_Error_e CAmDatabaseHandlerSQLite::enterSystemProperties(const std::vector<am_SystemProperty_s> & listSystemProperties) { assert(!listSystemProperties.empty()); sqlite3_stmt* query = NULL; @@ -3309,7 +3325,7 @@ am_Error_e CAmDatabaseHandler::enterSystemProperties(const std::vector<am_System * @param mainConnectionID to be checked for * @return true if it exists */ -bool CAmDatabaseHandler::existMainConnection(const am_mainConnectionID_t mainConnectionID) const +bool CAmDatabaseHandlerSQLite::existMainConnection(const am_mainConnectionID_t mainConnectionID) const { sqlite3_stmt* query = NULL; std::string command = "SELECT mainConnectionID FROM " + std::string(MAINCONNECTION_TABLE) + " WHERE mainConnectionID=" + i2s(mainConnectionID); @@ -3333,7 +3349,7 @@ bool CAmDatabaseHandler::existMainConnection(const am_mainConnectionID_t mainCon * @param sourceID to be checked for * @return true if it exists */ -bool CAmDatabaseHandler::existSource(const am_sourceID_t sourceID) const +bool CAmDatabaseHandlerSQLite::existSource(const am_sourceID_t sourceID) const { sqlite3_stmt* query = NULL; std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE reserved=0 AND sourceID=" + i2s(sourceID); @@ -3357,7 +3373,7 @@ bool CAmDatabaseHandler::existSource(const am_sourceID_t sourceID) const * @param name the name * @return true if it exits */ -bool CAmDatabaseHandler::existSourceNameOrID(const am_sourceID_t sourceID, const std::string & name) const +bool CAmDatabaseHandlerSQLite::existSourceNameOrID(const am_sourceID_t sourceID, const std::string & name) const { sqlite3_stmt* query = NULL; std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE reserved=0 AND (name=? OR sourceID=?)"; @@ -3393,7 +3409,7 @@ bool CAmDatabaseHandler::existSourceNameOrID(const am_sourceID_t sourceID, const * @param name the name * @return true if it exits */ -bool CAmDatabaseHandler::existSourceName(const std::string & name) const +bool CAmDatabaseHandlerSQLite::existSourceName(const std::string & name) const { sqlite3_stmt* query = NULL; std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE reserved=0 AND name=?"; @@ -3424,7 +3440,7 @@ bool CAmDatabaseHandler::existSourceName(const std::string & name) const * @param sinkID to be checked for * @return true if it exists */ -bool CAmDatabaseHandler::existSink(const am_sinkID_t sinkID) const +bool CAmDatabaseHandlerSQLite::existSink(const am_sinkID_t sinkID) const { sqlite3_stmt* query = NULL; std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE reserved=0 AND sinkID=" + i2s(sinkID); @@ -3449,7 +3465,7 @@ bool CAmDatabaseHandler::existSink(const am_sinkID_t sinkID) const * @param name the name * @return true if it exists. */ -bool CAmDatabaseHandler::existSinkNameOrID(const am_sinkID_t sinkID, const std::string & name) const +bool CAmDatabaseHandlerSQLite::existSinkNameOrID(const am_sinkID_t sinkID, const std::string & name) const { sqlite3_stmt* query = NULL; std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE reserved=0 AND (name=? OR sinkID=?)"; @@ -3486,7 +3502,7 @@ bool CAmDatabaseHandler::existSinkNameOrID(const am_sinkID_t sinkID, const std:: * @param name the name * @return true if it exists */ -bool CAmDatabaseHandler::existSinkName(const std::string & name) const +bool CAmDatabaseHandlerSQLite::existSinkName(const std::string & name) const { sqlite3_stmt* query = NULL; std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE reserved=0 AND name=?"; @@ -3517,7 +3533,7 @@ bool CAmDatabaseHandler::existSinkName(const std::string & name) const * @param domainID to be checked for * @return true if it exists */ -bool CAmDatabaseHandler::existDomain(const am_domainID_t domainID) const +bool CAmDatabaseHandlerSQLite::existDomain(const am_domainID_t domainID) const { sqlite3_stmt* query = NULL; std::string command = "SELECT domainID FROM " + std::string(DOMAIN_TABLE) + " WHERE reserved=0 AND domainID=" + i2s(domainID); @@ -3542,7 +3558,7 @@ bool CAmDatabaseHandler::existDomain(const am_domainID_t domainID) const * @param gatewayID to be checked for * @return true if it exists */ -bool CAmDatabaseHandler::existGateway(const am_gatewayID_t gatewayID) const +bool CAmDatabaseHandlerSQLite::existGateway(const am_gatewayID_t gatewayID) const { sqlite3_stmt* query = NULL; std::string command = "SELECT gatewayID FROM " + std::string(GATEWAY_TABLE) + " WHERE gatewayID=" + i2s(gatewayID); @@ -3562,7 +3578,7 @@ bool CAmDatabaseHandler::existGateway(const am_gatewayID_t gatewayID) const return (returnVal); } -am_Error_e CAmDatabaseHandler::getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t & domainID) const +am_Error_e CAmDatabaseHandlerSQLite::getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t & domainID) const { assert(sourceID!=0); @@ -3585,7 +3601,7 @@ am_Error_e CAmDatabaseHandler::getDomainOfSource(const am_sourceID_t sourceID, a return (returnVal); } -am_Error_e am::CAmDatabaseHandler::getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t & domainID) const +am_Error_e am::CAmDatabaseHandlerSQLite::getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t & domainID) const { assert(sinkID!=0); @@ -3614,7 +3630,7 @@ am_Error_e am::CAmDatabaseHandler::getDomainOfSink(const am_sinkID_t sinkID, am_ * @param sinkClassID * @return true if it exists */ -bool CAmDatabaseHandler::existSinkClass(const am_sinkClass_t sinkClassID) const +bool CAmDatabaseHandlerSQLite::existSinkClass(const am_sinkClass_t sinkClassID) const { sqlite3_stmt* query = NULL; std::string command = "SELECT sinkClassID FROM " + std::string(SINK_CLASS_TABLE) + " WHERE sinkClassID=" + i2s(sinkClassID); @@ -3638,7 +3654,7 @@ bool CAmDatabaseHandler::existSinkClass(const am_sinkClass_t sinkClassID) const * @param sourceClassID * @return true if it exists */ -bool CAmDatabaseHandler::existSourceClass(const am_sourceClass_t sourceClassID) const +bool CAmDatabaseHandlerSQLite::existSourceClass(const am_sourceClass_t sourceClassID) const { sqlite3_stmt* query = NULL; std::string command = "SELECT sourceClassID FROM " + std::string(SOURCE_CLASS_TABLE) + " WHERE sourceClassID=" + i2s(sourceClassID); @@ -3658,7 +3674,7 @@ bool CAmDatabaseHandler::existSourceClass(const am_sourceClass_t sourceClassID) return (returnVal); } -am_Error_e CAmDatabaseHandler::changeConnectionTimingInformation(const am_connectionID_t connectionID, const am_timeSync_t delay) +am_Error_e CAmDatabaseHandlerSQLite::changeConnectionTimingInformation(const am_connectionID_t connectionID, const am_timeSync_t delay) { assert(connectionID!=0); @@ -3719,7 +3735,7 @@ am_Error_e CAmDatabaseHandler::changeConnectionTimingInformation(const am_connec return (E_OK); } -am_Error_e CAmDatabaseHandler::changeConnectionFinal(const am_connectionID_t connectionID) +am_Error_e CAmDatabaseHandlerSQLite::changeConnectionFinal(const am_connectionID_t connectionID) { assert(connectionID!=0); @@ -3741,7 +3757,7 @@ am_Error_e CAmDatabaseHandler::changeConnectionFinal(const am_connectionID_t con return (E_OK); } -am_timeSync_t CAmDatabaseHandler::calculateMainConnectionDelay(const am_mainConnectionID_t mainConnectionID) const +am_timeSync_t CAmDatabaseHandlerSQLite::calculateMainConnectionDelay(const am_mainConnectionID_t mainConnectionID) const { assert(mainConnectionID!=0); sqlite3_stmt* query = NULL; @@ -3777,7 +3793,7 @@ am_timeSync_t CAmDatabaseHandler::calculateMainConnectionDelay(const am_mainConn * registers the Observer at the Database * @param iObserver pointer to the observer */ -void CAmDatabaseHandler::registerObserver(CAmDatabaseObserver *iObserver) +void CAmDatabaseHandlerSQLite::registerObserver(CAmDatabaseObserver *iObserver) { assert(iObserver!=NULL); mpDatabaseObserver = iObserver; @@ -3788,7 +3804,7 @@ void CAmDatabaseHandler::registerObserver(CAmDatabaseObserver *iObserver) * @param sourceID the sourceID * @return true if source is visible */ -bool CAmDatabaseHandler::sourceVisible(const am_sourceID_t sourceID) const +bool CAmDatabaseHandlerSQLite::sourceVisible(const am_sourceID_t sourceID) const { assert(sourceID!=0); sqlite3_stmt* query = NULL; @@ -3816,7 +3832,7 @@ bool CAmDatabaseHandler::sourceVisible(const am_sourceID_t sourceID) const * @param sinkID the sinkID * @return true if source is visible */ -bool CAmDatabaseHandler::sinkVisible(const am_sinkID_t sinkID) const +bool CAmDatabaseHandlerSQLite::sinkVisible(const am_sinkID_t sinkID) const { sqlite3_stmt* query = NULL; std::string command = "SELECT visible FROM " + std::string(SINK_TABLE) + " WHERE reserved=0 AND sinkID=" + i2s(sinkID); @@ -3843,7 +3859,7 @@ bool CAmDatabaseHandler::sinkVisible(const am_sinkID_t sinkID) const * @param connection the connection to be checked * @return true if connections exists */ -bool CAmDatabaseHandler::existConnection(const am_Connection_s & connection) const +bool CAmDatabaseHandlerSQLite::existConnection(const am_Connection_s & connection) const { sqlite3_stmt* query = NULL; std::string command = "SELECT connectionID FROM " + std::string(CONNECTION_TABLE) + " WHERE sinkID=? AND sourceID=? AND connectionFormat=? AND reserved=0"; @@ -3886,7 +3902,7 @@ bool CAmDatabaseHandler::existConnection(const am_Connection_s & connection) con * @param connectionID * @return true if connection exits */ -bool CAmDatabaseHandler::existConnectionID(const am_connectionID_t connectionID) const +bool CAmDatabaseHandlerSQLite::existConnectionID(const am_connectionID_t connectionID) const { sqlite3_stmt* query = NULL; std::string command = "SELECT connectionID FROM " + std::string(CONNECTION_TABLE) + " WHERE connectionID=? AND reserved=0"; @@ -3917,7 +3933,7 @@ bool CAmDatabaseHandler::existConnectionID(const am_connectionID_t connectionID) * @param crossfaderID the ID of the crossfader to be checked * @return true if exists */ -bool CAmDatabaseHandler::existcrossFader(const am_crossfaderID_t crossfaderID) const +bool CAmDatabaseHandlerSQLite::existcrossFader(const am_crossfaderID_t crossfaderID) const { sqlite3_stmt* query = NULL; std::string command = "SELECT crossfaderID FROM " + std::string(CROSSFADER_TABLE) + " WHERE crossfaderID=?"; @@ -3943,7 +3959,7 @@ bool CAmDatabaseHandler::existcrossFader(const am_crossfaderID_t crossfaderID) c return (returnVal); } -am_Error_e CAmDatabaseHandler::getSoureState(const am_sourceID_t sourceID, am_SourceState_e & sourceState) const +am_Error_e CAmDatabaseHandlerSQLite::getSoureState(const am_sourceID_t sourceID, am_SourceState_e & sourceState) const { assert(sourceID!=0); sqlite3_stmt* query = NULL; @@ -3963,7 +3979,7 @@ am_Error_e CAmDatabaseHandler::getSoureState(const am_sourceID_t sourceID, am_So return (E_OK); } -am_Error_e CAmDatabaseHandler::changeSourceState(const am_sourceID_t sourceID, const am_SourceState_e sourceState) +am_Error_e CAmDatabaseHandlerSQLite::changeSourceState(const am_sourceID_t sourceID, const am_SourceState_e sourceState) { assert(sourceID!=0); assert(sourceState>=SS_UNKNNOWN && sourceState<=SS_MAX); @@ -3983,7 +3999,7 @@ am_Error_e CAmDatabaseHandler::changeSourceState(const am_sourceID_t sourceID, c return (E_OK); } -am_Error_e CAmDatabaseHandler::getSinkVolume(const am_sinkID_t sinkID, am_volume_t & volume) const +am_Error_e CAmDatabaseHandlerSQLite::getSinkVolume(const am_sinkID_t sinkID, am_volume_t & volume) const { assert(sinkID!=0); sqlite3_stmt* query = NULL; @@ -4003,7 +4019,7 @@ am_Error_e CAmDatabaseHandler::getSinkVolume(const am_sinkID_t sinkID, am_volume return (E_OK); } -am_Error_e CAmDatabaseHandler::getSourceVolume(const am_sourceID_t sourceID, am_volume_t & volume) const +am_Error_e CAmDatabaseHandlerSQLite::getSourceVolume(const am_sourceID_t sourceID, am_volume_t & volume) const { assert(sourceID!=0); sqlite3_stmt* query = NULL; @@ -4023,7 +4039,7 @@ am_Error_e CAmDatabaseHandler::getSourceVolume(const am_sourceID_t sourceID, am_ return (E_OK); } -am_Error_e CAmDatabaseHandler::getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_SoundPropertyType_e propertyType, int16_t & value) const +am_Error_e CAmDatabaseHandlerSQLite::getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_SoundPropertyType_e propertyType, int16_t & value) const { assert(sinkID!=0); if (!existSink(sinkID)) @@ -4050,7 +4066,7 @@ am_Error_e CAmDatabaseHandler::getSinkSoundPropertyValue(const am_sinkID_t sinkI return (E_OK); } -am_Error_e CAmDatabaseHandler::getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_SoundPropertyType_e propertyType, int16_t & value) const +am_Error_e CAmDatabaseHandlerSQLite::getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_SoundPropertyType_e propertyType, int16_t & value) const { assert(sourceID!=0); if (!existSource(sourceID)) @@ -4078,7 +4094,7 @@ am_Error_e CAmDatabaseHandler::getSourceSoundPropertyValue(const am_sourceID_t s return (E_OK); } -am_Error_e CAmDatabaseHandler::getDomainState(const am_domainID_t domainID, am_DomainState_e& state) const +am_Error_e CAmDatabaseHandlerSQLite::getDomainState(const am_domainID_t domainID, am_DomainState_e& state) const { assert(domainID!=0); sqlite3_stmt* query = NULL; @@ -4099,7 +4115,7 @@ am_Error_e CAmDatabaseHandler::getDomainState(const am_domainID_t domainID, am_D } -am_Error_e CAmDatabaseHandler::peekDomain(const std::string & name, am_domainID_t & domainID) +am_Error_e CAmDatabaseHandlerSQLite::peekDomain(const std::string & name, am_domainID_t & domainID) { domainID=0; sqlite3_stmt* query = NULL, *queryInsert = NULL; @@ -4141,7 +4157,7 @@ am_Error_e CAmDatabaseHandler::peekDomain(const std::string & name, am_domainID_ return (E_OK); } -am_Error_e CAmDatabaseHandler::peekSink(const std::string & name, am_sinkID_t & sinkID) +am_Error_e CAmDatabaseHandlerSQLite::peekSink(const std::string & name, am_sinkID_t & sinkID) { sqlite3_stmt* query = NULL, *queryInsert = NULL; std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE name=?"; @@ -4189,7 +4205,7 @@ am_Error_e CAmDatabaseHandler::peekSink(const std::string & name, am_sinkID_t & return (E_OK); } -am_Error_e CAmDatabaseHandler::peekSource(const std::string & name, am_sourceID_t & sourceID) +am_Error_e CAmDatabaseHandlerSQLite::peekSource(const std::string & name, am_sourceID_t & sourceID) { sqlite3_stmt* query = NULL, *queryInsert = NULL; std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE name=?"; @@ -4237,7 +4253,7 @@ am_Error_e CAmDatabaseHandler::peekSource(const std::string & name, am_sourceID_ return (E_OK); } -am_Error_e CAmDatabaseHandler::changeSinkVolume(const am_sinkID_t sinkID, const am_volume_t volume) +am_Error_e CAmDatabaseHandlerSQLite::changeSinkVolume(const am_sinkID_t sinkID, const am_volume_t volume) { assert(sinkID!=0); @@ -4264,7 +4280,7 @@ am_Error_e CAmDatabaseHandler::changeSinkVolume(const am_sinkID_t sinkID, const return (E_OK); } -am_Error_e CAmDatabaseHandler::changeSourceVolume(const am_sourceID_t sourceID, const am_volume_t volume) +am_Error_e CAmDatabaseHandlerSQLite::changeSourceVolume(const am_sourceID_t sourceID, const am_volume_t volume) { assert(sourceID!=0); @@ -4292,7 +4308,7 @@ am_Error_e CAmDatabaseHandler::changeSourceVolume(const am_sourceID_t sourceID, return (E_OK); } -am_Error_e CAmDatabaseHandler::changeSourceSoundPropertyDB(const am_SoundProperty_s & soundProperty, const am_sourceID_t sourceID) +am_Error_e CAmDatabaseHandlerSQLite::changeSourceSoundPropertyDB(const am_SoundProperty_s & soundProperty, const am_sourceID_t sourceID) { assert(soundProperty.type>=SP_UNKNOWN && soundProperty.type<=SP_MAX); assert(sourceID!=0); @@ -4320,7 +4336,7 @@ am_Error_e CAmDatabaseHandler::changeSourceSoundPropertyDB(const am_SoundPropert return (E_OK); } -am_Error_e CAmDatabaseHandler::changeSinkSoundPropertyDB(const am_SoundProperty_s & soundProperty, const am_sinkID_t sinkID) +am_Error_e CAmDatabaseHandlerSQLite::changeSinkSoundPropertyDB(const am_SoundProperty_s & soundProperty, const am_sinkID_t sinkID) { assert(soundProperty.type>=SP_UNKNOWN && soundProperty.type<=SP_MAX); assert(sinkID!=0); @@ -4349,7 +4365,7 @@ am_Error_e CAmDatabaseHandler::changeSinkSoundPropertyDB(const am_SoundProperty_ return (E_OK); } -am_Error_e CAmDatabaseHandler::changeCrossFaderHotSink(const am_crossfaderID_t crossfaderID, const am_HotSink_e hotsink) +am_Error_e CAmDatabaseHandlerSQLite::changeCrossFaderHotSink(const am_crossfaderID_t crossfaderID, const am_HotSink_e hotsink) { assert(crossfaderID!=0); assert(hotsink>=HS_UNKNOWN && hotsink>=HS_MAX); @@ -4376,7 +4392,7 @@ am_Error_e CAmDatabaseHandler::changeCrossFaderHotSink(const am_crossfaderID_t c return (E_OK); } -am_Error_e CAmDatabaseHandler::getRoutingTree(bool onlyfree, CAmRoutingTree& tree, std::vector<CAmRoutingTreeItem*>& flatTree) +am_Error_e CAmDatabaseHandlerSQLite::getRoutingTree(bool onlyfree, CAmRoutingTree& tree, std::vector<CAmRoutingTreeItem*>& flatTree) { sqlite3_stmt* query = NULL; int eCode = 0; @@ -4435,7 +4451,7 @@ am_Error_e CAmDatabaseHandler::getRoutingTree(bool onlyfree, CAmRoutingTree& tre return (E_OK); } -am_Error_e am::CAmDatabaseHandler::peekSinkClassID(const std::string & name, am_sinkClass_t & sinkClassID) +am_Error_e am::CAmDatabaseHandlerSQLite::peekSinkClassID(const std::string & name, am_sinkClass_t & sinkClassID) { if (name.empty()) return (E_NON_EXISTENT); @@ -4464,7 +4480,7 @@ am_Error_e am::CAmDatabaseHandler::peekSinkClassID(const std::string & name, am_ return (returnVal); } -am_Error_e am::CAmDatabaseHandler::peekSourceClassID(const std::string & name, am_sourceClass_t & sourceClassID) +am_Error_e am::CAmDatabaseHandlerSQLite::peekSourceClassID(const std::string & name, am_sourceClass_t & sourceClassID) { if (name.empty()) return (E_NON_EXISTENT); @@ -4494,7 +4510,7 @@ am_Error_e am::CAmDatabaseHandler::peekSourceClassID(const std::string & name, a } -am_Error_e CAmDatabaseHandler::changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_ConnectionFormat_e>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) +am_Error_e CAmDatabaseHandlerSQLite::changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_ConnectionFormat_e>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) { assert(sourceID!=0); @@ -4631,7 +4647,7 @@ am_Error_e CAmDatabaseHandler::changeSourceDB(const am_sourceID_t sourceID, cons } -am_Error_e CAmDatabaseHandler::changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_ConnectionFormat_e>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) +am_Error_e CAmDatabaseHandlerSQLite::changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_ConnectionFormat_e>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties) { assert(sinkID!=0); @@ -4767,7 +4783,7 @@ am_Error_e CAmDatabaseHandler::changeSinkDB(const am_sinkID_t sinkID, const am_s return (E_OK); } -am_Error_e CAmDatabaseHandler::getListMainSinkNotificationConfigurations(const am_sinkID_t sinkID, std::vector<am_NotificationConfiguration_s>& listMainNotificationConfigurations) +am_Error_e CAmDatabaseHandlerSQLite::getListMainSinkNotificationConfigurations(const am_sinkID_t sinkID, std::vector<am_NotificationConfiguration_s>& listMainNotificationConfigurations) { assert(sinkID!=0); if (!existSink(sinkID)) @@ -4801,7 +4817,7 @@ am_Error_e CAmDatabaseHandler::getListMainSinkNotificationConfigurations(const a } -am_Error_e CAmDatabaseHandler::getListMainSourceNotificationConfigurations(const am_sourceID_t sourceID, std::vector<am_NotificationConfiguration_s>& listMainNotificationConfigurations) +am_Error_e CAmDatabaseHandlerSQLite::getListMainSourceNotificationConfigurations(const am_sourceID_t sourceID, std::vector<am_NotificationConfiguration_s>& listMainNotificationConfigurations) { assert(sourceID!=0); if (!existSource(sourceID)) @@ -4834,7 +4850,7 @@ am_Error_e CAmDatabaseHandler::getListMainSourceNotificationConfigurations(const return (E_OK); } -am_Error_e CAmDatabaseHandler::changeMainSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration) +am_Error_e CAmDatabaseHandlerSQLite::changeMainSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration) { assert(sinkID!=0); @@ -4865,7 +4881,7 @@ am_Error_e CAmDatabaseHandler::changeMainSinkNotificationConfigurationDB(const a return (E_OK); } -am_Error_e CAmDatabaseHandler::changeMainSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration) +am_Error_e CAmDatabaseHandlerSQLite::changeMainSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration) { assert(sourceID!=0); @@ -4896,7 +4912,7 @@ am_Error_e CAmDatabaseHandler::changeMainSourceNotificationConfigurationDB(const return (E_OK); } -am_Error_e CAmDatabaseHandler::changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector<am_ConnectionFormat_e>& listSourceConnectionFormats, const std::vector<am_ConnectionFormat_e>& listSinkConnectionFormats, const std::vector<bool>& convertionMatrix) +am_Error_e CAmDatabaseHandlerSQLite::changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector<am_ConnectionFormat_e>& listSourceConnectionFormats, const std::vector<am_ConnectionFormat_e>& listSinkConnectionFormats, const std::vector<bool>& convertionMatrix) { assert(gatewayID!=0); @@ -4970,7 +4986,7 @@ am_Error_e CAmDatabaseHandler::changeGatewayDB(const am_gatewayID_t gatewayID, c return (E_OK); } -am_Error_e CAmDatabaseHandler::changeSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration) +am_Error_e CAmDatabaseHandlerSQLite::changeSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration) { assert(sinkID!=0); @@ -5000,7 +5016,7 @@ am_Error_e CAmDatabaseHandler::changeSinkNotificationConfigurationDB(const am_si return (E_OK); } -am_Error_e CAmDatabaseHandler::changeSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration) +am_Error_e CAmDatabaseHandlerSQLite::changeSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration) { assert(sourceID!=0); @@ -5030,7 +5046,7 @@ am_Error_e CAmDatabaseHandler::changeSourceNotificationConfigurationDB(const am_ return (E_OK); } -void CAmDatabaseHandler::createTables() +void CAmDatabaseHandlerSQLite::createTables() { for (uint16_t i = 0; i < sizeof(databaseTables) / sizeof(databaseTables[0]); i++) { diff --git a/AudioManagerDaemon/src/CAmRouter.cpp b/AudioManagerDaemon/src/CAmRouter.cpp index 36fa310..c471ea3 100644 --- a/AudioManagerDaemon/src/CAmRouter.cpp +++ b/AudioManagerDaemon/src/CAmRouter.cpp @@ -24,12 +24,12 @@ #include <algorithm> #include <vector> #include <iterator> -#include "CAmDatabaseHandlerInterface.h" +#include "IAmDatabaseHandler.h" #include "CAmControlSender.h" namespace am { -CAmRouter::CAmRouter(CAmDatabaseHandlerInterface* iDatabaseHandler, CAmControlSender* iSender) : +CAmRouter::CAmRouter(IAmDatabaseHandler* iDatabaseHandler, CAmControlSender* iSender) : mpDatabaseHandler(iDatabaseHandler), // mpControlSender(iSender) { diff --git a/AudioManagerDaemon/src/CAmRoutingReceiver.cpp b/AudioManagerDaemon/src/CAmRoutingReceiver.cpp index 38fb913..116ee1a 100644 --- a/AudioManagerDaemon/src/CAmRoutingReceiver.cpp +++ b/AudioManagerDaemon/src/CAmRoutingReceiver.cpp @@ -22,7 +22,7 @@ #include "CAmRoutingReceiver.h" #include <cassert> #include <algorithm> -#include "CAmDatabaseHandlerInterface.h" +#include "IAmDatabaseHandler.h" #include "CAmRoutingSender.h" #include "CAmControlSender.h" #include "shared/CAmDltWrapper.h" @@ -31,7 +31,7 @@ namespace am { -CAmRoutingReceiver::CAmRoutingReceiver(CAmDatabaseHandlerInterface *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler) : +CAmRoutingReceiver::CAmRoutingReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler) : mpDatabaseHandler(iDatabaseHandler), // mpRoutingSender(iRoutingSender), // mpControlSender(iControlSender), // @@ -51,7 +51,7 @@ CAmRoutingReceiver::CAmRoutingReceiver(CAmDatabaseHandlerInterface *iDatabaseHan assert(mpSocketHandler!=NULL); } -CAmRoutingReceiver::CAmRoutingReceiver(CAmDatabaseHandlerInterface *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler, CAmDbusWrapper *iDBusWrapper) : +CAmRoutingReceiver::CAmRoutingReceiver(IAmDatabaseHandler *iDatabaseHandler, CAmRoutingSender *iRoutingSender, CAmControlSender *iControlSender, CAmSocketHandler *iSocketHandler, CAmDbusWrapper *iDBusWrapper) : mpDatabaseHandler(iDatabaseHandler), // mpRoutingSender(iRoutingSender), // mpControlSender(iControlSender), // diff --git a/AudioManagerDaemon/src/CAmTelnetMenuHelper.cpp b/AudioManagerDaemon/src/CAmTelnetMenuHelper.cpp index 3898e50..9067339 100644 --- a/AudioManagerDaemon/src/CAmTelnetMenuHelper.cpp +++ b/AudioManagerDaemon/src/CAmTelnetMenuHelper.cpp @@ -25,7 +25,7 @@ #include "config.h" #include "CAmRouter.h" #include "CAmTelnetServer.h" -#include "CAmDatabaseHandlerInterface.h" +#include "IAmDatabaseHandler.h" #include "CAmControlSender.h" #include "CAmCommandSender.h" #include "CAmRoutingSender.h" @@ -44,7 +44,7 @@ namespace am { CAmTelnetMenuHelper* CAmTelnetMenuHelper::instance = NULL; /****************************************************************************/ -CAmTelnetMenuHelper::CAmTelnetMenuHelper(CAmSocketHandler *iSocketHandler, CAmCommandSender *iCommandSender, CAmCommandReceiver *iCommandReceiver, CAmRoutingSender *iRoutingSender, CAmRoutingReceiver *iRoutingReceiver, CAmControlSender *iControlSender, CAmControlReceiver *iControlReceiver, CAmDatabaseHandlerInterface *iDatabasehandler, CAmRouter *iRouter, CAmTelnetServer *iTelnetServer) +CAmTelnetMenuHelper::CAmTelnetMenuHelper(CAmSocketHandler *iSocketHandler, CAmCommandSender *iCommandSender, CAmCommandReceiver *iCommandReceiver, CAmRoutingSender *iRoutingSender, CAmRoutingReceiver *iRoutingReceiver, CAmControlSender *iControlSender, CAmControlReceiver *iControlReceiver, IAmDatabaseHandler *iDatabasehandler, CAmRouter *iRouter, CAmTelnetServer *iTelnetServer) /****************************************************************************/ :mpTelenetServer(iTelnetServer), mpSocketHandler(iSocketHandler), mpCommandSender(iCommandSender), mpCommandReceiver(iCommandReceiver), mpRoutingSender(iRoutingSender), mpRoutingReceiver(iRoutingReceiver), mpControlSender(iControlSender), mpControlReceiver(iControlReceiver), mpDatabasehandler(iDatabasehandler), mpRouter(iRouter) { diff --git a/AudioManagerDaemon/src/CAmTelnetServer.cpp b/AudioManagerDaemon/src/CAmTelnetServer.cpp index 644b0a6..3212ea7 100755 --- a/AudioManagerDaemon/src/CAmTelnetServer.cpp +++ b/AudioManagerDaemon/src/CAmTelnetServer.cpp @@ -36,7 +36,6 @@ #include <unistd.h> #include <stdexcept> #include <cstdlib> -#include "CAmDatabaseHandlerInterface.h" #include "CAmRoutingSender.h" #include "CAmTelnetMenuHelper.h" #include "shared/CAmDltWrapper.h" @@ -48,7 +47,7 @@ CAmTelnetServer* CAmTelnetServer::mpInstance = NULL; #define PRINT_BOOL(var) var ? output+="true\t\t" : output+="false\t\t"; -CAmTelnetServer::CAmTelnetServer(CAmSocketHandler *iSocketHandler, CAmCommandSender *iCommandSender, CAmCommandReceiver *iCommandReceiver, CAmRoutingSender *iRoutingSender, CAmRoutingReceiver *iRoutingReceiver, CAmControlSender *iControlSender, CAmControlReceiver *iControlReceiver, CAmDatabaseHandlerInterface *iDatabasehandler, CAmRouter *iRouter, unsigned int servPort, unsigned int maxConnections) : +CAmTelnetServer::CAmTelnetServer(CAmSocketHandler *iSocketHandler, CAmCommandSender *iCommandSender, CAmCommandReceiver *iCommandReceiver, CAmRoutingSender *iRoutingSender, CAmRoutingReceiver *iRoutingReceiver, CAmControlSender *iControlSender, CAmControlReceiver *iControlReceiver, IAmDatabaseHandler *iDatabasehandler, CAmRouter *iRouter, unsigned int servPort, unsigned int maxConnections) : telnetConnectFiredCB(this, &CAmTelnetServer::connectSocket), // telnetReceiveFiredCB(this, &CAmTelnetServer::receiveData), // telnetDispatchCB(this, &CAmTelnetServer::dispatchData), // diff --git a/AudioManagerDaemon/src/main.cpp b/AudioManagerDaemon/src/main.cpp index aa2fb19..69b2860 100755 --- a/AudioManagerDaemon/src/main.cpp +++ b/AudioManagerDaemon/src/main.cpp @@ -40,9 +40,9 @@ #endif #ifdef WITH_DATABASE_STORAGE - #include "CAmDatabaseHandler.h" + #include "CAmDatabaseHandlerSQLite.h" #else - #include "CAmMapHandler.h" + #include "CAmDatabaseHandlerMap.h" #endif #ifdef WITH_SYSTEMD_WATCHDOG @@ -71,7 +71,6 @@ #include "CAmDatabaseObserver.h" #include "shared/CAmDltWrapper.h" #include "shared/CAmSocketHandler.h" -#include "CAmDatabaseHandlerInterface.h" using namespace am; DLT_DECLARE_CONTEXT(AudioManager) @@ -322,35 +321,35 @@ void mainProgram() #endif /*WITH_SYSTEMD_WATCHDOG*/ #ifdef WITH_DATABASE_STORAGE - CAmDatabaseHandler * ptr_iDatabaseHandler = new CAmDatabaseHandler(databasePath); + CAmDatabaseHandler * pDatabaseHandler = new CAmDatabaseHandler(databasePath); #else - CAmMapHandler * ptr_iDatabaseHandler = new CAmMapHandler(); + CAmDatabaseHandlerMap * pDatabaseHandler = new CAmDatabaseHandlerMap(); #endif /*WITH_DATABASE_STORAGE*/ - CAmDatabaseHandlerInterface & iDatabaseHandler = *ptr_iDatabaseHandler; + IAmDatabaseHandler & iDatabaseHandler = *pDatabaseHandler; CAmRoutingSender iRoutingSender(listRoutingPluginDirs); CAmCommandSender iCommandSender(listCommandPluginDirs); CAmControlSender iControlSender(controllerPlugin,&iSocketHandler); - CAmRouter iRouter(ptr_iDatabaseHandler, &iControlSender); + CAmRouter iRouter(pDatabaseHandler, &iControlSender); #ifdef WITH_DBUS_WRAPPER - CAmCommandReceiver iCommandReceiver(ptr_iDatabaseHandler, &iControlSender, &iSocketHandler, &iDBusWrapper); - CAmRoutingReceiver iRoutingReceiver(ptr_iDatabaseHandler, &iRoutingSender, &iControlSender, &iSocketHandler, &iDBusWrapper); + CAmCommandReceiver iCommandReceiver(pDatabaseHandler, &iControlSender, &iSocketHandler, &iDBusWrapper); + CAmRoutingReceiver iRoutingReceiver(pDatabaseHandler, &iRoutingSender, &iControlSender, &iSocketHandler, &iDBusWrapper); #ifdef WITH_NSM - CAmControlReceiver iControlReceiver(ptr_iDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter, &iNodeStateCommunicator); + CAmControlReceiver iControlReceiver(pDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter, &iNodeStateCommunicator); iNodeStateCommunicator.registerControlSender(&iControlSender); #else /*WITH_NSM*/ - CAmControlReceiver iControlReceiver(ptr_iDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter); + CAmControlReceiver iControlReceiver(pDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter); #endif /*WITH_NSM*/ #else /*WITH_DBUS_WRAPPER*/ - CAmCommandReceiver iCommandReceiver(ptr_iDatabaseHandler,&iControlSender,&iSocketHandler); - CAmRoutingReceiver iRoutingReceiver(ptr_iDatabaseHandler,&iRoutingSender,&iControlSender,&iSocketHandler); - CAmControlReceiver iControlReceiver(ptr_iDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter); + CAmCommandReceiver iCommandReceiver(pDatabaseHandler,&iControlSender,&iSocketHandler); + CAmRoutingReceiver iRoutingReceiver(pDatabaseHandler,&iRoutingSender,&iControlSender,&iSocketHandler); + CAmControlReceiver iControlReceiver(pDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter); #endif /*WITH_DBUS_WRAPPER*/ #ifdef WITH_TELNET - CAmTelnetServer iTelnetServer(&iSocketHandler, &iCommandSender, &iCommandReceiver, &iRoutingSender, &iRoutingReceiver, &iControlSender, &iControlReceiver, ptr_iDatabaseHandler, &iRouter, telnetport, maxConnections); + CAmTelnetServer iTelnetServer(&iSocketHandler, &iCommandSender, &iCommandReceiver, &iRoutingSender, &iRoutingReceiver, &iControlSender, &iControlReceiver, pDatabaseHandler, &iRouter, telnetport, maxConnections); CAmDatabaseObserver iObserver(&iCommandSender, &iRoutingSender, &iSocketHandler, &iTelnetServer); #else /*WITH_TELNET*/ CAmDatabaseObserver iObserver(&iCommandSender,&iRoutingSender, &iSocketHandler); @@ -372,10 +371,10 @@ void mainProgram() //start the mainloop here.... iSocketHandler.start_listenting(); - if(ptr_iDatabaseHandler) + if(pDatabaseHandler) { - delete ptr_iDatabaseHandler; - ptr_iDatabaseHandler = NULL; + delete pDatabaseHandler; + pDatabaseHandler = NULL; } } diff --git a/AudioManagerDaemon/test/AmControlInterfaceTest/CAmControlInterfaceTest.h b/AudioManagerDaemon/test/AmControlInterfaceTest/CAmControlInterfaceTest.h index b984f80..a65d9fd 100644 --- a/AudioManagerDaemon/test/AmControlInterfaceTest/CAmControlInterfaceTest.h +++ b/AudioManagerDaemon/test/AmControlInterfaceTest/CAmControlInterfaceTest.h @@ -24,7 +24,7 @@ #include "gtest/gtest.h" #include "gmock/gmock.h" -#include "CAmDatabaseHandler.h" +#include "CAmDatabaseHandlerSQLite.h" #include "CAmControlReceiver.h" #include "CAmRoutingReceiver.h" #include "CAmDatabaseObserver.h" @@ -52,7 +52,7 @@ public: CAmDbusWrapper* pDBusWrapper; std::vector<std::string> plistCommandPluginDirs; std::vector<std::string> plistRoutingPluginDirs; - CAmDatabaseHandler pDatabaseHandler; + CAmDatabaseHandlerSQLite pDatabaseHandler; CAmRoutingSender pRoutingSender; CAmCommandSender pCommandSender; MockIAmControlSend pMockControlInterface; diff --git a/AudioManagerDaemon/test/AmControlInterfaceTest/CMakeLists.txt b/AudioManagerDaemon/test/AmControlInterfaceTest/CMakeLists.txt index a6c7234..86f0da2 100644 --- a/AudioManagerDaemon/test/AmControlInterfaceTest/CMakeLists.txt +++ b/AudioManagerDaemon/test/AmControlInterfaceTest/CMakeLists.txt @@ -43,7 +43,7 @@ INCLUDE_DIRECTORIES( ) file(GLOB CONTROL_INTERFACE_SRCS_CXX - "../../src/CAmDatabaseHandler.cpp" + "../../src/CAmDatabaseHandlerSQLite.cpp" "../../src/CAmDatabaseObserver.cpp" "../../src/CAmRoutingSender.cpp" "../../src/CAmRoutingReceiver.cpp" diff --git a/AudioManagerDaemon/test/AmDatabaseHandlerTest/CAmDatabaseHandlerTest.h b/AudioManagerDaemon/test/AmDatabaseHandlerTest/CAmDatabaseHandlerTest.h index 25d63a3..b23aba4 100644 --- a/AudioManagerDaemon/test/AmDatabaseHandlerTest/CAmDatabaseHandlerTest.h +++ b/AudioManagerDaemon/test/AmDatabaseHandlerTest/CAmDatabaseHandlerTest.h @@ -26,7 +26,7 @@ #include "gtest/gtest.h" #include "gmock/gmock.h" -#include "CAmDatabaseHandler.h" +#include "CAmDatabaseHandlerSQLite.h" #include "CAmControlReceiver.h" #include "CAmControlSender.h" #include "CAmDatabaseObserver.h" @@ -51,7 +51,7 @@ public: std::vector<std::string> plistRoutingPluginDirs; std::vector<std::string> plistCommandPluginDirs; CAmSocketHandler pSocketHandler; - CAmDatabaseHandler pDatabaseHandler; + CAmDatabaseHandlerSQLite pDatabaseHandler; CAmRoutingSender pRoutingSender; CAmCommandSender pCommandSender; MockIAmCommandSend pMockInterface; diff --git a/AudioManagerDaemon/test/AmDatabaseHandlerTest/CMakeLists.txt b/AudioManagerDaemon/test/AmDatabaseHandlerTest/CMakeLists.txt index 83e7197..7899588 100644 --- a/AudioManagerDaemon/test/AmDatabaseHandlerTest/CMakeLists.txt +++ b/AudioManagerDaemon/test/AmDatabaseHandlerTest/CMakeLists.txt @@ -44,7 +44,7 @@ INCLUDE_DIRECTORIES( ) file(GLOB DATABASE_SRCS_CXX - "../../src/CAmDatabaseHandler.cpp" + "../../src/CAmDatabaseHandlerSQLite.cpp" "../../src/CAmDatabaseObserver.cpp" "../../src/CAmCommandSender.cpp" "../../src/CAmRoutingSender.cpp" diff --git a/AudioManagerDaemon/test/AmMapHandlerTest/CAmMapHandlerTest.h b/AudioManagerDaemon/test/AmMapHandlerTest/CAmMapHandlerTest.h index 9720731..f4cb0cf 100644 --- a/AudioManagerDaemon/test/AmMapHandlerTest/CAmMapHandlerTest.h +++ b/AudioManagerDaemon/test/AmMapHandlerTest/CAmMapHandlerTest.h @@ -26,7 +26,7 @@ #include "gtest/gtest.h" #include "gmock/gmock.h" -#include "CAmMapHandler.h" +#include "CAmDatabaseHandlerMap.h" #include "CAmControlReceiver.h" #include "CAmControlSender.h" #include "CAmDatabaseObserver.h" @@ -51,7 +51,7 @@ public: std::vector<std::string> plistRoutingPluginDirs; std::vector<std::string> plistCommandPluginDirs; CAmSocketHandler pSocketHandler; - CAmMapHandler pDatabaseHandler; + CAmDatabaseHandlerMap pDatabaseHandler; CAmRoutingSender pRoutingSender; CAmCommandSender pCommandSender; MockIAmCommandSend pMockInterface; diff --git a/AudioManagerDaemon/test/AmMapHandlerTest/CMakeLists.txt b/AudioManagerDaemon/test/AmMapHandlerTest/CMakeLists.txt index aa00640..0e081ae 100644 --- a/AudioManagerDaemon/test/AmMapHandlerTest/CMakeLists.txt +++ b/AudioManagerDaemon/test/AmMapHandlerTest/CMakeLists.txt @@ -44,8 +44,7 @@ INCLUDE_DIRECTORIES( ) file(GLOB DATABASE_SRCS_CXX - "../../src/CAmMapHandler.cpp" - "../../src/CAmDatabaseHandler.cpp" + "../../src/CAmDatabaseHandlerMap.cpp" "../../src/CAmDatabaseObserver.cpp" "../../src/CAmCommandSender.cpp" "../../src/CAmRoutingSender.cpp" diff --git a/AudioManagerDaemon/test/AmRouterMapTest/CAmRouterMapTest.h b/AudioManagerDaemon/test/AmRouterMapTest/CAmRouterMapTest.h index 352b02e..ead077c 100644 --- a/AudioManagerDaemon/test/AmRouterMapTest/CAmRouterMapTest.h +++ b/AudioManagerDaemon/test/AmRouterMapTest/CAmRouterMapTest.h @@ -30,7 +30,7 @@ #include <string> #include <vector> #include <set> -#include "CAmMapHandler.h" +#include "CAmDatabaseHandlerMap.h" #include "CAmControlReceiver.h" #include "CAmControlSender.h" #include "CAmDatabaseObserver.h" @@ -56,7 +56,7 @@ public: std::vector<std::string> plistCommandPluginDirs; CAmSocketHandler pSocketHandler; CAmControlSender pControlSender; - CAmMapHandler pDatabaseHandler; + CAmDatabaseHandlerMap pDatabaseHandler; CAmRouter pRouter; CAmRoutingSender pRoutingSender; CAmCommandSender pCommandSender; diff --git a/AudioManagerDaemon/test/AmRouterMapTest/CMakeLists.txt b/AudioManagerDaemon/test/AmRouterMapTest/CMakeLists.txt index 3667dd0..d587f0c 100644 --- a/AudioManagerDaemon/test/AmRouterMapTest/CMakeLists.txt +++ b/AudioManagerDaemon/test/AmRouterMapTest/CMakeLists.txt @@ -43,7 +43,7 @@ INCLUDE_DIRECTORIES( ) file(GLOB ROUTINGMAP_SRCS_CXX - "../../src/CAmMapHandler.cpp" + "../../src/CAmDatabaseHandlerMap.cpp" "../../src/CAmDatabaseObserver.cpp" "../../src/CAmCommandSender.cpp" "../../src/CAmRoutingSender.cpp" diff --git a/AudioManagerDaemon/test/AmRouterTest/CAmRouterTest.h b/AudioManagerDaemon/test/AmRouterTest/CAmRouterTest.h index 93b80db..9ed8f74 100644 --- a/AudioManagerDaemon/test/AmRouterTest/CAmRouterTest.h +++ b/AudioManagerDaemon/test/AmRouterTest/CAmRouterTest.h @@ -30,7 +30,7 @@ #include <string> #include <vector> #include <set> -#include "CAmDatabaseHandler.h" +#include "CAmDatabaseHandlerSQLite.h" #include "CAmControlReceiver.h" #include "CAmControlSender.h" #include "CAmDatabaseObserver.h" @@ -56,7 +56,7 @@ public: std::vector<std::string> plistCommandPluginDirs; CAmSocketHandler pSocketHandler; CAmControlSender pControlSender; - CAmDatabaseHandler pDatabaseHandler; + CAmDatabaseHandlerSQLite pDatabaseHandler; CAmRouter pRouter; CAmRoutingSender pRoutingSender; CAmCommandSender pCommandSender; diff --git a/AudioManagerDaemon/test/AmRouterTest/CMakeLists.txt b/AudioManagerDaemon/test/AmRouterTest/CMakeLists.txt index bff2205..6f556ff 100644 --- a/AudioManagerDaemon/test/AmRouterTest/CMakeLists.txt +++ b/AudioManagerDaemon/test/AmRouterTest/CMakeLists.txt @@ -44,8 +44,7 @@ INCLUDE_DIRECTORIES( ) file(GLOB ROUTING_SRCS_CXX - "../../src/CAmMapHandler.cpp" - "../../src/CAmDatabaseHandler.cpp" + "../../src/CAmDatabaseHandlerSQLite.cpp" "../../src/CAmDatabaseObserver.cpp" "../../src/CAmCommandSender.cpp" "../../src/CAmRoutingSender.cpp" diff --git a/AudioManagerDaemon/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.h b/AudioManagerDaemon/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.h index 982c9f2..74130e8 100644 --- a/AudioManagerDaemon/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.h +++ b/AudioManagerDaemon/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.h @@ -27,7 +27,7 @@ #include <string> #include <vector> #include <set> -#include "CAmDatabaseHandler.h" +#include "CAmDatabaseHandlerSQLite.h" #include "CAmControlReceiver.h" #include "CAmControlSender.h" #include "CAmDatabaseObserver.h" @@ -49,7 +49,7 @@ public: std::vector<std::string> plistRoutingPluginDirs; std::vector<std::string> plistCommandPluginDirs; CAmSocketHandler pSocketHandler; - CAmDatabaseHandler pDatabaseHandler; + CAmDatabaseHandlerSQLite pDatabaseHandler; CAmRoutingSender pRoutingSender; CAmCommandSender pCommandSender; CAmControlSender pControlSender; diff --git a/AudioManagerDaemon/test/AmRoutingInterfaceTest/CMakeLists.txt b/AudioManagerDaemon/test/AmRoutingInterfaceTest/CMakeLists.txt index 3799151..a73cec0 100644 --- a/AudioManagerDaemon/test/AmRoutingInterfaceTest/CMakeLists.txt +++ b/AudioManagerDaemon/test/AmRoutingInterfaceTest/CMakeLists.txt @@ -46,7 +46,7 @@ INCLUDE_DIRECTORIES( file(GLOB ROUTING_INTERFACE_SRCS_CXX "../../src/CAmControlReceiver.cpp" - "../../src/CAmDatabaseHandler.cpp" + "../../src/CAmDatabaseHandlerSQLite.cpp" "../../src/CAmDatabaseObserver.cpp" "../../src/CAmCommandSender.cpp" "../../src/CAmRoutingSender.cpp" diff --git a/AudioManagerDaemon/test/AmTelnetServerTest/CAmTelnetServerTest.cpp b/AudioManagerDaemon/test/AmTelnetServerTest/CAmTelnetServerTest.cpp index 429ceda..bc09eac 100644 --- a/AudioManagerDaemon/test/AmTelnetServerTest/CAmTelnetServerTest.cpp +++ b/AudioManagerDaemon/test/AmTelnetServerTest/CAmTelnetServerTest.cpp @@ -55,7 +55,7 @@ CAmEnvironment::CAmEnvironment() , mlistCommandPluginDirs() , mSocketHandler() #ifdef WITH_DATABASE_STORAGE -, mDatabasehandler(std::string(":memory:")) +, mpDatabasehandler(std::string(":memory:")) #else , mDatabasehandler() #endif diff --git a/AudioManagerDaemon/test/AmTelnetServerTest/CAmTelnetServerTest.h b/AudioManagerDaemon/test/AmTelnetServerTest/CAmTelnetServerTest.h index 5a03ba7..db2200f 100644 --- a/AudioManagerDaemon/test/AmTelnetServerTest/CAmTelnetServerTest.h +++ b/AudioManagerDaemon/test/AmTelnetServerTest/CAmTelnetServerTest.h @@ -24,19 +24,21 @@ #include "gtest/gtest.h" #include "CAmTelnetServer.h" -#include "CAmDatabaseHandler.h" -#include "CAmMapHandler.h" #include "CAmRoutingSender.h" #include "CAmCommandSender.h" #include "CAmControlSender.h" #include "CAmRouter.h" +#include "IAmDatabaseHandler.h" +#ifdef WITH_DATABASE_STORAGE + #include "CAmDatabaseHandlerSQLite.h" +#else + #include "CAmDatabaseHandlerMap.h" +#endif namespace am { class CAmSocketHandler; -class CAmDatabaseHandler; -class CAmMapHandler; class CAmRoutingSender; class CAmCommandSender; class CAmControlSender; @@ -67,9 +69,9 @@ class CAmEnvironment : public ::testing::Environment CAmSocketHandler mSocketHandler; #ifdef WITH_DATABASE_STORAGE - CAmDatabaseHandler mDatabasehandler; + CAmDatabaseHandlerSQLite mDatabasehandler; #else - CAmMapHandler mDatabasehandler; + CAmDatabaseHandlerMap mDatabasehandler; #endif CAmRoutingSender mRoutingSender; CAmCommandSender mCommandSender; diff --git a/AudioManagerDaemon/test/AmTelnetServerTest/CMakeLists.txt b/AudioManagerDaemon/test/AmTelnetServerTest/CMakeLists.txt index b2981eb..6c20e4e 100644 --- a/AudioManagerDaemon/test/AmTelnetServerTest/CMakeLists.txt +++ b/AudioManagerDaemon/test/AmTelnetServerTest/CMakeLists.txt @@ -54,8 +54,8 @@ file(GLOB TELNET_SRCS_CXX "../../src/CAmCommandSender.cpp" "../../src/CAmControlReceiver.cpp" "../../src/CAmControlSender.cpp" - "../../src/CAmMapHandler.cpp" - "../../src/CAmDatabaseHandler.cpp" + "../../src/CAmDatabaseHandlerMap.cpp" + "../../src/CAmDatabaseHandlerSQLite.cpp" "../../src/CAmDatabaseObserver.cpp" "../../src/CAmRoutingReceiver.cpp" "../../src/CAmRoutingSender.cpp" |