summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLVersion.h
blob: 22ff79dc76e1309e8d98009c84a0644d7ac6ff67 (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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//
//  SDLVersion.h
//  SmartDeviceLink
//
//  Created by Joel Fischer on 2/19/19.
//  Copyright © 2019 smartdevicelink. All rights reserved.
//

#import <Foundation/Foundation.h>

@class SDLSyncMsgVersion;
@class SDLMsgVersion;

NS_ASSUME_NONNULL_BEGIN

/// Specifies a major / minor / patch version number for semantic versioning purposes and comparisons
@interface SDLVersion : NSObject <NSCopying>

/// Major version (e.g. X.0.0)
@property (nonatomic, assign) NSUInteger major;

/// Minor version (e.g. 0.X.0)
@property (nonatomic, assign) NSUInteger minor;

/// Patch version (e.g. 0.0.X)
@property (nonatomic, assign) NSUInteger patch;

/// A String format of the current SDLVersion
@property (nonatomic, copy, readonly) NSString *stringVersion;

/// Convenience init
///
/// @param major Major version
/// @param minor Minor version
/// @param patch Patch version
/// @return An SDLVersion object
- (instancetype)initWithMajor:(NSUInteger)major minor:(NSUInteger)minor patch:(NSUInteger)patch;

/// Convenience init
///
/// @param major Major version
/// @param minor Minor version
/// @param patch Patch version
/// @return An SDLVersion object
+ (instancetype)versionWithMajor:(NSUInteger)major minor:(NSUInteger)minor patch:(NSUInteger)patch;

/// Convenience init
///
/// @param versionString String representation of the version
/// @return An SDLVersion object
- (nullable instancetype)initWithString:(NSString *)versionString;

/// Convenience init
///
/// @param versionString String representation of the version
/// @return An SDLVersion object
+ (nullable instancetype)versionWithString:(NSString *)versionString;

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
/// Deprecated convenience init to set version using SDLSyncMsgVersion
///
/// @param syncMsgVersion Specifies the version number of the SmartDeviceLink protocol that is supported by the mobile application.
/// @return An SDLVersion object
- (instancetype)initWithSyncMsgVersion:(SDLSyncMsgVersion *)syncMsgVersion __deprecated_msg(("Use initWithSDLMsgVersion:sdlMsgVersion: instead"));

/// Deprecated convenience init to set version using SDLSyncMsgVersion
///
/// @param syncMsgVersion Specifies the version number of the SmartDeviceLink protocol that is supported by the mobile application.
/// @return An SDLVersion object
+ (instancetype)versionWithSyncMsgVersion:(SDLSyncMsgVersion *)syncMsgVersion __deprecated_msg(("Use versionWithSDLMsgVersion:sdlMsgVersion instead"));
#pragma clang diagnostic pop

/// Convenience init to set version using SDLMsgVersion
///
/// @param sdlMsgVersion Specifies the version number of the SmartDeviceLink protocol that is supported by the mobile application.
/// @return An SDLVersion object
- (instancetype)initWithSDLMsgVersion:(SDLMsgVersion *)sdlMsgVersion;

/// Convenience init to set version using SDLMsgVersion
///
/// @param sdlMsgVersion Specifies the version number of the SmartDeviceLink protocol that is supported by the mobile application.
/// @return SDLVersion object
+ (instancetype)versionWithSDLMsgVersion:(SDLMsgVersion *)sdlMsgVersion;

/// Compare two SDLVersions
- (NSComparisonResult)compare:(SDLVersion *)otherVersion;

/// Compare is less than
///
/// @param otherVersion SDLVersion Object
/// @return BOOL
- (BOOL)isLessThanVersion:(SDLVersion *)otherVersion;

/// Compare is equal to
///
/// @param otherVersion SDLVersion Object
/// @return BOOL
- (BOOL)isEqualToVersion:(SDLVersion *)otherVersion;

/// Compare is greater than
///
/// @param otherVersion SDLVersion Object
/// @return BOOL
- (BOOL)isGreaterThanVersion:(SDLVersion *)otherVersion;

/// Compare is greater than or equal to
///
/// @param otherVersion SDLVersion Object
/// @return BOOL
- (BOOL)isGreaterThanOrEqualToVersion:(SDLVersion *)otherVersion;

/// Compare is less than or equal to
///
/// @param otherVersion SDLVersion Object
/// @return BOOL
- (BOOL)isLessThanOrEqualToVersion:(SDLVersion *)otherVersion;

@end

NS_ASSUME_NONNULL_END