summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLFunctionID.m
diff options
context:
space:
mode:
Diffstat (limited to 'SmartDeviceLink/SDLFunctionID.m')
-rw-r--r--SmartDeviceLink/SDLFunctionID.m98
1 files changed, 80 insertions, 18 deletions
diff --git a/SmartDeviceLink/SDLFunctionID.m b/SmartDeviceLink/SDLFunctionID.m
index 802ee3df3..f03826df4 100644
--- a/SmartDeviceLink/SDLFunctionID.m
+++ b/SmartDeviceLink/SDLFunctionID.m
@@ -4,36 +4,98 @@
#import "SDLFunctionID.h"
-#import "SDLNames.h"
+@interface SDLFunctionID ()
+
+@property (nonatomic, strong, nonnull) NSDictionary* functionIds;
+
+@end
@implementation SDLFunctionID
++ (instancetype)sharedInstance {
+ static SDLFunctionID* functionId = nil;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ functionId = [[SDLFunctionID alloc] init];
+ });
+ return functionId;
+}
+
- (instancetype)init {
if (self = [super init]) {
- functionIDs = [NSDictionary dictionaryWithObjectsAndKeys:
- NAMES_reserved, @"0", NAMES_RegisterAppInterface, @"1", NAMES_UnregisterAppInterface, @"2", NAMES_SetGlobalProperties, @"3", NAMES_ResetGlobalProperties, @"4", NAMES_AddCommand, @"5", NAMES_DeleteCommand, @"6", NAMES_AddSubMenu, @"7", NAMES_DeleteSubMenu, @"8", NAMES_CreateInteractionChoiceSet, @"9", NAMES_PerformInteraction, @"10", NAMES_DeleteInteractionChoiceSet, @"11", NAMES_Alert, @"12", NAMES_Show, @"13", NAMES_Speak, @"14", NAMES_SetMediaClockTimer, @"15", NAMES_PerformAudioPassThru, @"16", NAMES_EndAudioPassThru, @"17", NAMES_SubscribeButton, @"18", NAMES_UnsubscribeButton, @"19", NAMES_SubscribeVehicleData, @"20", NAMES_UnsubscribeVehicleData, @"21", NAMES_GetVehicleData, @"22", NAMES_ReadDID, @"23", NAMES_GetDTCs, @"24", NAMES_ScrollableMessage, @"25", NAMES_Slider, @"26", NAMES_ShowConstantTBT, @"27", NAMES_AlertManeuver, @"28", NAMES_UpdateTurnList, @"29", NAMES_ChangeRegistration, @"30", NAMES_GenericResponse, @"31", NAMES_PutFile, @"32", NAMES_DeleteFile, @"33", NAMES_ListFiles, @"34", NAMES_SetAppIcon, @"35", NAMES_SetDisplayLayout, @"36", NAMES_DiagnosticMessage, @"37", NAMES_SystemRequest, @"38", NAMES_SendLocation, @"39", NAMES_DialNumber, @"40", NAMES_OnHMIStatus, @"32768", NAMES_OnAppInterfaceUnregistered, @"32769", NAMES_OnButtonEvent, @"32770", NAMES_OnButtonPress, @"32771", NAMES_OnVehicleData, @"32772", NAMES_OnCommand, @"32773", NAMES_OnTBTClientState, @"32774", NAMES_OnDriverDistraction, @"32775", NAMES_OnPermissionsChange, @"32776", NAMES_OnAudioPassThru, @"32777", NAMES_OnLanguageChange, @"32778", NAMES_OnKeyboardInput, @"32779", NAMES_OnTouchEvent, @"32780", NAMES_OnSystemRequest, @"32781", NAMES_OnHashChange, @"32782",
-
- NAMES_EncodedSyncPData,
- @"65536",
- NAMES_SyncPData,
- @"65537",
-
- NAMES_OnEncodedSyncPData,
- @"98304",
- NAMES_OnSyncPData,
- @"98305",
- nil];
+ self.functionIds = @{
+ @0: SDLNameReserved,
+ @1: SDLNameRegisterAppInterface,
+ @2: SDLNameUnregisterAppInterface,
+ @3: SDLNameSetGlobalProperties,
+ @4: SDLNameResetGlobalProperties,
+ @5: SDLNameAddCommand,
+ @6: SDLNameDeleteCommand,
+ @7: SDLNameAddSubMenu,
+ @8: SDLNameDeleteSubMenu,
+ @9: SDLNameCreateInteractionChoiceSet,
+ @10: SDLNamePerformInteraction,
+ @11: SDLNameDeleteInteractionChoiceSet,
+ @12: SDLNameAlert,
+ @13: SDLNameShow,
+ @14: SDLNameSpeak,
+ @15: SDLNameSetMediaClockTimer,
+ @16: SDLNamePerformAudioPassThru,
+ @17: SDLNameEndAudioPassThru,
+ @18: SDLNameSubscribeButton,
+ @19: SDLNameUnsubscribeButton,
+ @20: SDLNameSubscribeVehicleData,
+ @21: SDLNameUnsubscribeVehicleData,
+ @22: SDLNameGetVehicleData,
+ @23: SDLNameReadDID,
+ @24: SDLNameGetDTCs,
+ @25: SDLNameScrollableMessage,
+ @26: SDLNameSlider,
+ @27: SDLNameShowConstantTBT,
+ @28: SDLNameAlertManeuver,
+ @29: SDLNameUpdateTurnList,
+ @30: SDLNameChangeRegistration,
+ @31: SDLNameGenericResponse,
+ @32: SDLNamePutFile,
+ @33: SDLNameDeleteFile,
+ @34: SDLNameListFiles,
+ @35: SDLNameSetAppIcon,
+ @36: SDLNameSetDisplayLayout,
+ @37: SDLNameDiagnosticMessage,
+ @38: SDLNameSystemRequest,
+ @39: SDLNameSendLocation,
+ @40: SDLNameDialNumber,
+ @32768: SDLNameOnHMIStatus,
+ @32769: SDLNameOnAppInterfaceUnregistered,
+ @32770: SDLNameOnButtonEvent,
+ @32771: SDLNameOnButtonPress,
+ @32772: SDLNameOnVehicleData,
+ @32773: SDLNameOnCommand,
+ @32774: SDLNameOnTBTClientState,
+ @32775: SDLNameOnDriverDistraction,
+ @32776: SDLNameOnPermissionsChange,
+ @32777: SDLNameOnAudioPassThru,
+ @32778: SDLNameOnLanguageChange,
+ @32779: SDLNameOnKeyboardInput,
+ @32780: SDLNameOnTouchEvent,
+ @32781: SDLNameOnSystemRequest,
+ @32782: SDLNameOnHashChange,
+ @65536: SDLNameEncodedSyncPData,
+ @65537: SDLNameSyncPData,
+ @98304: SDLNameOnEncodedSyncPData,
+ @98305: SDLNameOnSyncPData
+ };
}
return self;
}
-- (NSString *)getFunctionName:(int)functionID {
- return [functionIDs objectForKey:[NSString stringWithFormat:@"%d", functionID]];
+- (SDLName)functionNameForId:(int)functionID {
+ return self.functionIds[@(functionID)];
}
-- (NSNumber *)getFunctionID:(NSString *)functionName {
- return [NSNumber numberWithInt:[[[functionIDs allKeysForObject:functionName] objectAtIndex:0] intValue]];
+- (NSNumber *)functionIdForName:(SDLName)functionName {
+ return [[self.functionIds allKeysForObject:functionName] firstObject];
}