summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLSystemContext.m
blob: 76c5c9f3825d3660fcd7841b82a64a5b2aacfdd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//  SDLSystemContext.m
//


#import "SDLSystemContext.h"

SDLSystemContext *SDLSystemContext_MAIN = nil;
SDLSystemContext *SDLSystemContext_VRSESSION = nil;
SDLSystemContext *SDLSystemContext_MENU = nil;
SDLSystemContext *SDLSystemContext_HMI_OBSCURED = nil;
SDLSystemContext *SDLSystemContext_ALERT = nil;

NSArray *SDLSystemContext_values = nil;

@implementation SDLSystemContext

+ (SDLSystemContext *)valueOf:(NSString *)value {
    for (SDLSystemContext *item in SDLSystemContext.values) {
        if ([item.value isEqualToString:value]) {
            return item;
        }
    }
    return nil;
}

+ (NSArray *)values {
    if (SDLSystemContext_values == nil) {
        SDLSystemContext_values = @[
            SDLSystemContext.MAIN,
            SDLSystemContext.VRSESSION,
            SDLSystemContext.MENU,
            SDLSystemContext.HMI_OBSCURED,
            SDLSystemContext.ALERT,
        ];
    }
    return SDLSystemContext_values;
}

+ (SDLSystemContext *)MAIN {
    if (SDLSystemContext_MAIN == nil) {
        SDLSystemContext_MAIN = [[SDLSystemContext alloc] initWithValue:@"MAIN"];
    }
    return SDLSystemContext_MAIN;
}

+ (SDLSystemContext *)VRSESSION {
    if (SDLSystemContext_VRSESSION == nil) {
        SDLSystemContext_VRSESSION = [[SDLSystemContext alloc] initWithValue:@"VRSESSION"];
    }
    return SDLSystemContext_VRSESSION;
}

+ (SDLSystemContext *)MENU {
    if (SDLSystemContext_MENU == nil) {
        SDLSystemContext_MENU = [[SDLSystemContext alloc] initWithValue:@"MENU"];
    }
    return SDLSystemContext_MENU;
}

+ (SDLSystemContext *)HMI_OBSCURED {
    if (SDLSystemContext_HMI_OBSCURED == nil) {
        SDLSystemContext_HMI_OBSCURED = [[SDLSystemContext alloc] initWithValue:@"HMI_OBSCURED"];
    }
    return SDLSystemContext_HMI_OBSCURED;
}

+ (SDLSystemContext *)ALERT {
    if (SDLSystemContext_ALERT == nil) {
        SDLSystemContext_ALERT = [[SDLSystemContext alloc] initWithValue:@"ALERT"];
    }
    return SDLSystemContext_ALERT;
}

@end