Skip to content

Commit 254bed6

Browse files
committed
remove duplicate MTRDeviceClusterData
1 parent 0d6f249 commit 254bed6

File tree

1 file changed

+0
-101
lines changed

1 file changed

+0
-101
lines changed

src/darwin/Framework/CHIP/MTRDevice_Concrete.mm

-101
Original file line numberDiff line numberDiff line change
@@ -251,107 +251,6 @@ typedef NS_ENUM(NSUInteger, MTRDeviceWorkItemDuplicateTypeID) {
251251
MTRDeviceWorkItemDuplicateReadTypeID = 1,
252252
};
253253

254-
@implementation MTRDeviceClusterData {
255-
NSMutableDictionary<NSNumber *, MTRDeviceDataValueDictionary> * _attributes;
256-
}
257-
258-
259-
- (void)storeValue:(MTRDeviceDataValueDictionary _Nullable)value forAttribute:(NSNumber *)attribute
260-
{
261-
_attributes[attribute] = value;
262-
}
263-
264-
- (void)removeValueForAttribute:(NSNumber *)attribute
265-
{
266-
[_attributes removeObjectForKey:attribute];
267-
}
268-
269-
- (NSDictionary<NSNumber *, MTRDeviceDataValueDictionary> *)attributes
270-
{
271-
return _attributes;
272-
}
273-
274-
+ (BOOL)supportsSecureCoding
275-
{
276-
return YES;
277-
}
278-
279-
- (NSString *)description
280-
{
281-
return [NSString stringWithFormat:@"<MTRDeviceClusterData: dataVersion %@ attributes count %lu>", _dataVersion, static_cast<unsigned long>(_attributes.count)];
282-
}
283-
284-
- (nullable instancetype)init
285-
{
286-
return [self initWithDataVersion:nil attributes:nil];
287-
}
288-
289-
// Attributes dictionary is: attributeID => data-value dictionary
290-
- (nullable instancetype)initWithDataVersion:(NSNumber * _Nullable)dataVersion attributes:(NSDictionary<NSNumber *, MTRDeviceDataValueDictionary> * _Nullable)attributes
291-
{
292-
self = [super init];
293-
if (self == nil) {
294-
return nil;
295-
}
296-
297-
_dataVersion = [dataVersion copy];
298-
_attributes = [NSMutableDictionary dictionaryWithCapacity:attributes.count];
299-
[_attributes addEntriesFromDictionary:attributes];
300-
301-
return self;
302-
}
303-
304-
- (nullable instancetype)initWithCoder:(NSCoder *)decoder
305-
{
306-
self = [super init];
307-
if (self == nil) {
308-
return nil;
309-
}
310-
311-
_dataVersion = [decoder decodeObjectOfClass:[NSNumber class] forKey:sDataVersionKey];
312-
if (_dataVersion != nil && ![_dataVersion isKindOfClass:[NSNumber class]]) {
313-
MTR_LOG_ERROR("MTRDeviceClusterData got %@ for data version, not NSNumber.", _dataVersion);
314-
return nil;
315-
}
316-
317-
static NSSet * const sAttributeValueClasses = [NSSet setWithObjects:[NSDictionary class], [NSArray class], [NSData class], [NSString class], [NSNumber class], nil];
318-
_attributes = [decoder decodeObjectOfClasses:sAttributeValueClasses forKey:sAttributesKey];
319-
if (_attributes != nil && ![_attributes isKindOfClass:[NSDictionary class]]) {
320-
MTR_LOG_ERROR("MTRDeviceClusterData got %@ for attributes, not NSDictionary.", _attributes);
321-
return nil;
322-
}
323-
324-
return self;
325-
}
326-
327-
- (void)encodeWithCoder:(NSCoder *)coder
328-
{
329-
[coder encodeObject:self.dataVersion forKey:sDataVersionKey];
330-
[coder encodeObject:self.attributes forKey:sAttributesKey];
331-
}
332-
333-
- (id)copyWithZone:(NSZone *)zone
334-
{
335-
return [[MTRDeviceClusterData alloc] initWithDataVersion:_dataVersion attributes:_attributes];
336-
}
337-
338-
- (BOOL)isEqualToClusterData:(MTRDeviceClusterData *)otherClusterData
339-
{
340-
return MTREqualObjects(_dataVersion, otherClusterData.dataVersion)
341-
&& MTREqualObjects(_attributes, otherClusterData.attributes);
342-
}
343-
344-
- (BOOL)isEqual:(id)object
345-
{
346-
if ([object class] != [self class]) {
347-
return NO;
348-
}
349-
350-
return [self isEqualToClusterData:object];
351-
}
352-
353-
@end
354-
355254
// Minimal time to wait since our last resubscribe failure before we will allow
356255
// a read attempt to prod our subscription.
357256
//

0 commit comments

Comments
 (0)