diff options
author | Christian Linke <Christian.Linke@bmw.de> | 2016-05-17 04:23:57 -0700 |
---|---|---|
committer | Christian Linke <Christian.Linke@bmw.de> | 2016-05-17 04:25:05 -0700 |
commit | 7a9f1e9c0f07f7f58d84e1096638dac5be2d9680 (patch) | |
tree | 9b0c4f6b81819d6316ec06356862ae59a1d02f2d /AudioManagerUtilities/include/CAmDltWrapper.h | |
parent | 8239fe1a21926e6cce97e82779781194b720e2e8 (diff) | |
download | audiomanager-7a9f1e9c0f07f7f58d84e1096638dac5be2d9680.tar.gz |
optimize static const in audiomanagertypes.h and CAmDltWrapper template specializations
Signed-off-by: Christian Linke <Christian.Linke@bmw.de>
Diffstat (limited to 'AudioManagerUtilities/include/CAmDltWrapper.h')
-rw-r--r-- | AudioManagerUtilities/include/CAmDltWrapper.h | 134 |
1 files changed, 31 insertions, 103 deletions
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<const char*> mStr_error; + static const std::vector<const char*> mStr_sourceState; + static const std::vector<const char*> mStr_MuteState; + static const std::vector<const char*> mStr_DomainState; + static const std::vector<const char*> mStr_ConnectionState; + static const std::vector<const char*> mStr_Availability; + static const std::vector<const char*> mStr_Interrupt; + static const std::vector<const char*> mStr_Handle; + static const std::vector<const char*> mStr_NotificationStatus; + +public: // specialization for const am_Error_e template<typename T = const am_Error_e> void append(const am_Error_e value) { - const std::vector<const char*> 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<typename T = const am_SourceState_e> void append(const am_SourceState_e value) { - const std::vector<const char*> 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<typename T = const am_MuteState_e> void append(const am_MuteState_e value) { - const std::vector<const char*> 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<typename T = const am_DomainState_e> void append(const am_DomainState_e value) { - const std::vector<const char*> 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<typename T = const am_ConnectionState_e> void append(const am_ConnectionState_e value) { - const std::vector<const char*> 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<typename T = const am_Availability_e> void append(const am_Availability_e value) { - const std::vector<const char*> 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<typename T = const am_InterruptState_e> void append(const am_InterruptState_e value) { - const std::vector<const char*> 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<typename T = const am_Handle_e> void append(const am_Handle_e value) { - const std::vector<const char*> 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<typename T = const am_NotificationStatus_e> void append(const am_NotificationStatus_e value) { - const std::vector<const char*> 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<typename T> void append(T* value) { |