-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Darwin: Tidy up some device type meta-data classes
- Move MTRDeviceTypeRevision out of ServerEndpoint directory - Move MTRProductIdentity into its own file - Implement NSCopying and equality on MTRDeviceType and MTRProductIdentity - Implement description on all 3 types - Add tests
- Loading branch information
1 parent
ef5f838
commit 0abedfb
Showing
12 changed files
with
364 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import <Matter/MTRDefines.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/** | ||
* A representation of a (vendor, product) pair that identifies a specific product. | ||
*/ | ||
MTR_AVAILABLE(ios(17.0), macos(14.0), watchos(10.0), tvos(17.0)) | ||
@interface MTRProductIdentity : NSObject /* <NSCopying> (see below) */ | ||
|
||
- (instancetype)init NS_UNAVAILABLE; | ||
+ (instancetype)new NS_UNAVAILABLE; | ||
|
||
- (instancetype)initWithVendorID:(NSNumber *)vendorID productID:(NSNumber *)productID; | ||
|
||
@property (nonatomic, copy, readonly) NSNumber * vendorID; | ||
@property (nonatomic, copy, readonly) NSNumber * productID; | ||
|
||
@end | ||
|
||
MTR_NEWLY_AVAILABLE | ||
@interface MTRProductIdentity () <NSCopying> | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* Copyright (c) 2024 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#import "MTRProductIdentity.h" | ||
|
||
#import "MTRDefines_Internal.h" | ||
#import "MTRUtilities.h" | ||
|
||
#include <lib/support/CodeUtils.h> | ||
|
||
MTR_DIRECT_MEMBERS | ||
@implementation MTRProductIdentity | ||
|
||
- (instancetype)initWithVendorID:(NSNumber *)vendorID productID:(NSNumber *)productID | ||
{ | ||
self = [super init]; | ||
VerifyOrReturnValue(vendorID != nil && productID != nil, nil); | ||
_vendorID = vendorID; | ||
_productID = productID; | ||
return self; | ||
} | ||
|
||
- (id)copyWithZone:(NSZone *)zone | ||
{ | ||
return self; // immutable | ||
} | ||
|
||
- (NSUInteger)hash | ||
{ | ||
return _vendorID.hash ^ _productID.hash; | ||
} | ||
|
||
- (BOOL)isEqual:(id)object | ||
{ | ||
VerifyOrReturnValue([object class] == [self class], NO); | ||
MTRProductIdentity * other = object; | ||
return MTREqualObjects(_vendorID, other.vendorID) && MTREqualObjects(_productID, other.productID); | ||
} | ||
|
||
- (NSString *)description | ||
{ | ||
return [NSString stringWithFormat:@"<%@: vid 0x%u pid 0x%u>", self.class, _vendorID.unsignedIntValue, _productID.unsignedIntValue]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.