Private
Public Access
1
0
Files
Kordophone/kordophone/Bridge/Operations/MBIMBridgeOperation.m

59 lines
1.4 KiB
Mathematica
Raw Normal View History

2018-11-13 12:29:15 -08:00
//
// MBIMBridgeOperation.m
// kordophoned
//
// Created by James Magahern on 11/13/18.
// Copyright © 2018 James Magahern. All rights reserved.
//
#import "MBIMBridgeOperation.h"
@interface MBIMBridgeOperation (/*INTERNAL*/)
@property (nonatomic, strong) NSURL *requestURL;
@property (nonatomic, copy) MBIMBridgeOperationCompletionBlock serverCompletionBlock;
2018-11-13 12:29:15 -08:00
@end
@implementation MBIMBridgeOperation
+ (NSString *)endpointName
{
// To be inplemented by subclasses
return @"__unimplemented__";
}
+ (NSMutableDictionary *)_operationClassMapping
{
static dispatch_once_t onceToken;
static NSMutableDictionary *operationClassMapping = nil;
dispatch_once(&onceToken, ^{
operationClassMapping = [[NSMutableDictionary alloc] init];
});
return operationClassMapping;
}
+ (void)load
{
if ([self class] != [MBIMBridgeOperation class]) {
[[self _operationClassMapping] setObject:[self class] forKey:[self endpointName]];
}
}
+ (nullable Class)operationClassForEndpointName:(NSString *)endpointName
{
return [[self _operationClassMapping] objectForKey:endpointName];
}
- (instancetype)initWithRequestURL:(NSURL *)requestURL completion:(MBIMBridgeOperationCompletionBlock)completionBlock
2018-11-13 12:29:15 -08:00
{
self = [super init];
if (self) {
self.requestURL = requestURL;
2018-11-13 12:29:15 -08:00
self.serverCompletionBlock = completionBlock;
}
return self;
}
@end