From 7a9f1e9c0f07f7f58d84e1096638dac5be2d9680 Mon Sep 17 00:00:00 2001 From: Christian Linke Date: Tue, 17 May 2016 04:23:57 -0700 Subject: optimize static const in audiomanagertypes.h and CAmDltWrapper template specializations Signed-off-by: Christian Linke --- AudioManagerUtilities/include/CAmDltWrapper.h | 134 ++++++-------------------- 1 file changed, 31 insertions(+), 103 deletions(-) (limited to 'AudioManagerUtilities/include/CAmDltWrapper.h') diff --git a/AudioManagerUtilities/include/CAmDltWrapper.h b/AudioManagerUtilities/include/CAmDltWrapper.h index 4a00f6f..90ce903 100644 --- a/AudioManagerUtilities/include/CAmDltWrapper.h +++ b/AudioManagerUtilities/include/CAmDltWrapper.h @@ -194,194 +194,122 @@ public: #endif //WITH_DLT } + +private: + static const std::vector mStr_error; + static const std::vector mStr_sourceState; + static const std::vector mStr_MuteState; + static const std::vector mStr_DomainState; + static const std::vector mStr_ConnectionState; + static const std::vector mStr_Availability; + static const std::vector mStr_Interrupt; + static const std::vector mStr_Handle; + static const std::vector mStr_NotificationStatus; + +public: // specialization for const am_Error_e template void append(const am_Error_e value) { - const std::vector str_error = { - "E_OK", - "E_UNKNOWN", - "E_OUT_OF_RANGE", - "E_NOT_USED", - "E_DATABASE_ERROR", - "E_ALREADY_EXISTS", - "E_NO_CHANGE", - "E_NOT_POSSIBLE", - "E_NON_EXISTENT", - "E_ABORTED", - "E_WRONG_FORMAT", - "E_COMMUNICATION", - "E_MAX" - }; - if ((int)value >=str_error.size()) + if ((int)value >=mStr_error.size()) { append("value for am_Error_e out of bounds!"); append(value); return; } - append(str_error[value]); + append(mStr_error[value]); } // specialization for const am_Error_e template void append(const am_SourceState_e value) { - const std::vector str_sourceState = { - "SS_UNKNNOWN", - "SS_ON", - "SS_OFF", - "SS_PAUSED", - "SS_MAX" - }; - if ((int)value >=(str_sourceState.size())) + if ((int)value >=(mStr_sourceState.size())) { append("value for am_SourceState_e out of bounds!"); append(value); return; } - append(str_sourceState[value]); + append(mStr_sourceState[value]); } template void append(const am_MuteState_e value) { - const std::vector str_MuteState= { - "MS_UNKNOWN" , - "MS_MUTED" , - "MS_UNMUTED" , - "MS_MAX" - }; - if ((int)value >=str_MuteState.size()) + if ((int)value >=mStr_MuteState.size()) { append("value for am_MuteState_e out of bounds!"); append(value); return; } - append(str_MuteState[value]); + append(mStr_MuteState[value]); } template void append(const am_DomainState_e value) { - const std::vector str_DomainState = { - "DS_UNKNOWN", - "DS_CONTROLLED", - "DS_INDEPENDENT_STARTUP", - "DS_INDEPENDENT_RUNDOWN", - "DS_MAX" - }; - if ((int)value >= str_DomainState.size()) + if ((int)value >= mStr_DomainState.size()) { append("value for am_DomainState_e out of bounds!"); append(value); return; } - append(str_DomainState[value]); + append(mStr_DomainState[value]); } template void append(const am_ConnectionState_e value) { - const std::vector str_ConnectionState = { - "CS_UNKNOWN", - "CS_CONNECTING", - "CS_CONNECTED", - "CS_DISCONNECTING", - "CS_DISCONNECTED", - "CS_SUSPENDED", - "CS_MAX" - }; - if ((int)value >=str_ConnectionState.size()) + if ((int)value >=mStr_ConnectionState.size()) { append("value for am_ConnectionState_e out of bounds!"); append(value); return; } - append(str_ConnectionState[value]); + append(mStr_ConnectionState[value]); } template void append(const am_Availability_e value) { - const std::vector str_Availability = { - "A_UNKNOWN", - "A_AVAILABLE", - "A_UNAVAILABLE", - "A_MAX" - }; - if ((int)value >= str_Availability.size()) + if ((int)value >= mStr_Availability.size()) { append("value for am_Availability_e out of bounds!"); append(value); return; } - append(str_Availability[value]); + append(mStr_Availability[value]); } template void append(const am_InterruptState_e value) { - const std::vector str_Interrupt = { - "IS_UNKNOWN", - "IS_OFF", - "IS_INTERRUPTED", - "IS_MAX" - }; - if ((int)value >=str_Interrupt.size()) + if ((int)value >=mStr_Interrupt.size()) { append("value for am_InterruptState_e out of bounds!"); append(value); return; } - append(str_Interrupt[value]); + append(mStr_Interrupt[value]); } template void append(const am_Handle_e value) { - const std::vector str_Handle = { - "H_UNKNOWN", - "H_CONNECT", - "H_DISCONNECT", - "H_SETSOURCESTATE", - "H_SETSINKVOLUME", - "H_SETSOURCEVOLUME", - "H_SETSINKSOUNDPROPERTY", - "H_SETSOURCESOUNDPROPERTY", - "H_SETSINKSOUNDPROPERTIES", - "H_SETSOURCESOUNDPROPERTIES", - "H_CROSSFADE", - "H_SETVOLUMES", - "H_SETSINKNOTIFICATION", - "H_SETSOURCENOTIFICATION", - "H_MAX" - }; - if ((int)value >=str_Handle.size()) + if ((int)value >=mStr_Handle.size()) { append("value for am_Handle_e out of bounds!"); append(value); return; } - append(str_Handle[value]); + append(mStr_Handle[value]); } template void append(const am_NotificationStatus_e value) { - const std::vector str_NotificationStatus = { - "NS_UNKNOWN", - "NS_OFF", - "NS_PERIODIC", - "NS_MINIMUM", - "NS_MAXIMUM", - "NS_CHANGE", - "NS_MAX" - }; - if ((int)value >=str_NotificationStatus.size()) + if ((int)value >=mStr_NotificationStatus.size()) { append("value for am_NotificationStatus_e out of bounds!"); append(value); return; } - append(str_NotificationStatus[value]); + append(mStr_NotificationStatus[value]); } - - - // Template to print unknown pointer types with their address template void append(T* value) { -- cgit v1.2.1