@@ -150,9 +150,9 @@ @implementation MTRDeviceControllerFactory {
150
150
// must lock.
151
151
// D. Locking around reads not from the Matter queue is OK but not required.
152
152
os_unfair_lock _controllersLock;
153
- NSMutableArray <MTRDeviceController *> * _controllers;
154
- MTRDeviceController * _controllerBeingStarted;
155
- MTRDeviceController * _controllerBeingShutDown;
153
+ NSMutableArray <MTRDeviceController_Concrete *> * _controllers;
154
+ MTRDeviceController_Concrete * _controllerBeingStarted;
155
+ MTRDeviceController_Concrete * _controllerBeingShutDown;
156
156
157
157
// Next available fabric index. Only valid when _controllerBeingStarted is
158
158
// non-nil, and then it corresponds to the controller being started. This
@@ -461,12 +461,12 @@ - (void)stopControllerFactory
461
461
* The provided controller is expected to have just been allocated and to not be
462
462
* initialized yet.
463
463
*/
464
- - (MTRDeviceController * _Nullable)_startDeviceController : (MTRDeviceController_Concrete *)controller
465
- startupParams : (id )startupParams
466
- fabricChecker : (MTRDeviceControllerStartupParamsInternal * (^)(FabricTable * fabricTable,
467
- MTRDeviceController * controller,
468
- CHIP_ERROR & fabricError))fabricChecker
469
- error : (NSError * __autoreleasing *)error
464
+ - (MTRDeviceController_Concrete * _Nullable)_startDeviceController : (MTRDeviceController_Concrete *)controller
465
+ startupParams : (id )startupParams
466
+ fabricChecker : (MTRDeviceControllerStartupParamsInternal * (^)(FabricTable * fabricTable,
467
+ MTRDeviceController_Concrete * controller,
468
+ CHIP_ERROR & fabricError))fabricChecker
469
+ error : (NSError * __autoreleasing *)error
470
470
{
471
471
[self _assertCurrentQueueIsNotMatterQueue ];
472
472
@@ -590,7 +590,7 @@ - (MTRDeviceController * _Nullable)_startDeviceController:(MTRDeviceController_C
590
590
// Check that we are not trying to start a controller with a uniqueIdentifier that
591
591
// matches a running controller.
592
592
auto * controllersCopy = [self getRunningControllers ];
593
- for (MTRDeviceController * existing in controllersCopy) {
593
+ for (MTRDeviceController_Concrete * existing in controllersCopy) {
594
594
if (existing != controller && [existing.uniqueIdentifier isEqual: params.uniqueIdentifier]) {
595
595
MTR_LOG_ERROR (" Already have running controller with uniqueIdentifier %@" , existing.uniqueIdentifier );
596
596
fabricError = CHIP_ERROR_INVALID_ARGUMENT;
@@ -661,15 +661,15 @@ - (MTRDeviceController * _Nullable)createControllerOnExistingFabric:(MTRDeviceCo
661
661
}
662
662
663
663
// If there is a controller already running with matching parameters that is conceptually shut down from the API consumer's viewpoint, re-use it.
664
- MTRDeviceController * existingController = [self _findPendingShutdownControllerWithOperationalCertificate: startupParams.operationalCertificate andRootCertificate: startupParams.rootCertificate];
664
+ auto * existingController = [self _findPendingShutdownControllerWithOperationalCertificate: startupParams.operationalCertificate andRootCertificate: startupParams.rootCertificate];
665
665
if (existingController) {
666
666
return existingController;
667
667
}
668
668
669
669
return [self _startDeviceController: [MTRDeviceController_Concrete alloc ]
670
670
startupParams: startupParams
671
671
fabricChecker: ^MTRDeviceControllerStartupParamsInternal *(
672
- FabricTable * fabricTable, MTRDeviceController * controller, CHIP_ERROR & fabricError) {
672
+ FabricTable * fabricTable, MTRDeviceController_Concrete * controller, CHIP_ERROR & fabricError) {
673
673
const FabricInfo * fabric = nullptr ;
674
674
BOOL ok = [self findMatchingFabric: *fabricTable params: startupParams fabric: &fabric];
675
675
if (!ok) {
@@ -686,7 +686,7 @@ - (MTRDeviceController * _Nullable)createControllerOnExistingFabric:(MTRDeviceCo
686
686
687
687
auto * controllersCopy = [self getRunningControllers ];
688
688
689
- for (MTRDeviceController * existing in controllersCopy) {
689
+ for (MTRDeviceController_Concrete * existing in controllersCopy) {
690
690
BOOL isRunning = YES ; // assume the worst
691
691
if ([existing isRunningOnFabric: fabricTable
692
692
fabricIndex: fabric->GetFabricIndex ()
@@ -741,7 +741,7 @@ - (MTRDeviceController * _Nullable)createControllerOnNewFabric:(MTRDeviceControl
741
741
return [self _startDeviceController: [MTRDeviceController_Concrete alloc ]
742
742
startupParams: startupParams
743
743
fabricChecker: ^MTRDeviceControllerStartupParamsInternal *(
744
- FabricTable * fabricTable, MTRDeviceController * controller, CHIP_ERROR & fabricError) {
744
+ FabricTable * fabricTable, MTRDeviceController_Concrete * controller, CHIP_ERROR & fabricError) {
745
745
const FabricInfo * fabric = nullptr ;
746
746
BOOL ok = [self findMatchingFabric: *fabricTable params: startupParams fabric: &fabric];
747
747
if (!ok) {
@@ -969,7 +969,7 @@ - (void)controllerShuttingDown:(MTRDeviceController_Concrete *)controller
969
969
[controller deinitFromFactory ];
970
970
}
971
971
972
- - (NSArray <MTRDeviceController *> *)getRunningControllers
972
+ - (NSArray <MTRDeviceController_Concrete *> *)getRunningControllers
973
973
{
974
974
std::lock_guard lock (_controllersLock);
975
975
return [_controllers copy ];
@@ -984,11 +984,11 @@ - (nullable MTRDeviceController *)runningControllerForFabricIndex:(FabricIndex)f
984
984
auto * controllersCopy = [self getRunningControllers ];
985
985
986
986
os_unfair_lock_lock (&_controllersLock);
987
- MTRDeviceController * controllerBeingStarted = _controllerBeingStarted;
988
- MTRDeviceController * controllerBeingShutDown = _controllerBeingShutDown;
987
+ auto * controllerBeingStarted = _controllerBeingStarted;
988
+ auto * controllerBeingShutDown = _controllerBeingShutDown;
989
989
os_unfair_lock_unlock (&_controllersLock);
990
990
991
- for (MTRDeviceController * existing in controllersCopy) {
991
+ for (MTRDeviceController_Concrete * existing in controllersCopy) {
992
992
if (existing.fabricIndex == fabricIndex) {
993
993
return existing;
994
994
}
@@ -1088,7 +1088,7 @@ - (nullable NSNumber *)neededReadPrivilegeForClusterID:(NSNumber *)clusterID att
1088
1088
}
1089
1089
}
1090
1090
1091
- for (MTRDeviceController * controller in [self getRunningControllers ]) {
1091
+ for (MTRDeviceController_Concrete * controller in [self getRunningControllers ]) {
1092
1092
NSNumber * _Nullable neededPrivilege = [controller neededReadPrivilegeForClusterID: clusterID attributeID: attributeID];
1093
1093
if (neededPrivilege != nil ) {
1094
1094
return neededPrivilege;
@@ -1127,7 +1127,7 @@ - (void)operationalInstanceAdded:(chip::PeerId &)operationalID
1127
1127
1128
1128
auto * controllersCopy = [self getRunningControllers ];
1129
1129
1130
- for (MTRDeviceController * controller in controllersCopy) {
1130
+ for (MTRDeviceController_Concrete * controller in controllersCopy) {
1131
1131
auto * compressedFabricId = controller.compressedFabricID ;
1132
1132
if (compressedFabricId != nil && compressedFabricId.unsignedLongLongValue == operationalID.GetCompressedFabricId ()) {
1133
1133
ChipLogProgress (Controller, " Notifying controller at fabric index %u about new operational node 0x" ChipLogFormatX64,
@@ -1140,10 +1140,10 @@ - (void)operationalInstanceAdded:(chip::PeerId &)operationalID
1140
1140
}
1141
1141
}
1142
1142
1143
- - (nullable MTRDeviceController *)_findPendingShutdownControllerWithOperationalCertificate : (nullable MTRCertificateDERBytes)operationalCertificate andRootCertificate : (nullable MTRCertificateDERBytes)rootCertificate
1143
+ - (nullable MTRDeviceController_Concrete *)_findPendingShutdownControllerWithOperationalCertificate : (nullable MTRCertificateDERBytes)operationalCertificate andRootCertificate : (nullable MTRCertificateDERBytes)rootCertificate
1144
1144
{
1145
1145
std::lock_guard lock (_controllersLock);
1146
- for (MTRDeviceController * controller in _controllers) {
1146
+ for (MTRDeviceController_Concrete * controller in _controllers) {
1147
1147
// TODO: Once we know our controllers are MTRDeviceController_Concrete, move
1148
1148
// matchesPendingShutdownControllerWithOperationalCertificate and clearPendingShutdown to that
1149
1149
// interface and remove them from base MTRDeviceController_Internal.
@@ -1156,22 +1156,22 @@ - (nullable MTRDeviceController *)_findPendingShutdownControllerWithOperationalC
1156
1156
return nil ;
1157
1157
}
1158
1158
1159
- - (nullable MTRDeviceController *)initializeController : (MTRDeviceController_Concrete *)controller
1160
- withParameters : (MTRDeviceControllerParameters *)parameters
1161
- error : (NSError * __autoreleasing *)error
1159
+ - (nullable MTRDeviceController_Concrete *)initializeController : (MTRDeviceController_Concrete *)controller
1160
+ withParameters : (MTRDeviceControllerParameters *)parameters
1161
+ error : (NSError * __autoreleasing *)error
1162
1162
{
1163
1163
[self _assertCurrentQueueIsNotMatterQueue ];
1164
1164
1165
1165
// If there is a controller already running with matching parameters that is conceptually shut down from the API consumer's viewpoint, re-use it.
1166
- MTRDeviceController * existingController = [self _findPendingShutdownControllerWithOperationalCertificate: parameters.operationalCertificate andRootCertificate: parameters.rootCertificate];
1166
+ MTRDeviceController_Concrete * existingController = [self _findPendingShutdownControllerWithOperationalCertificate: parameters.operationalCertificate andRootCertificate: parameters.rootCertificate];
1167
1167
if (existingController) {
1168
1168
return existingController;
1169
1169
}
1170
1170
1171
1171
return [self _startDeviceController: controller
1172
1172
startupParams: parameters
1173
1173
fabricChecker: ^MTRDeviceControllerStartupParamsInternal *(
1174
- FabricTable * fabricTable, MTRDeviceController * controller, CHIP_ERROR & fabricError) {
1174
+ FabricTable * fabricTable, MTRDeviceController_Concrete * controller, CHIP_ERROR & fabricError) {
1175
1175
auto advertiseOperational = self->_advertiseOperational && parameters.shouldAdvertiseOperational ;
1176
1176
auto * params =
1177
1177
[[MTRDeviceControllerStartupParamsInternal alloc ] initForNewController: controller
0 commit comments