2 * Copyright 2018 Google
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #import <Foundation/Foundation.h>
18 #import "FIRComponentType.h"
20 NS_ASSUME_NONNULL_BEGIN
22 /// A type-safe macro to retrieve a component from a container. This should be used to retrieve
23 /// components instead of using the container directly.
24 #define FIR_COMPONENT(type, container) \
25 [FIRComponentType<id<type>> instanceForProtocol:@protocol(type) inContainer:container]
29 /// A container that holds different components that are registered via the
30 /// `registerAsComponentRegistrant:` call. These classes should conform to `FIRComponentRegistrant`
31 /// in order to properly register components for Core.
32 NS_SWIFT_NAME(FirebaseComponentContainer)
33 @interface FIRComponentContainer : NSObject
35 /// A weak reference to the app that an instance of the container belongs to.
36 @property(nonatomic, weak, readonly) FIRApp *app;
38 /// Unavailable. Use the `container` property on `FIRApp`.
39 - (instancetype)init NS_UNAVAILABLE;
41 /// Register a class to provide components for the interoperability system. The class should conform
42 /// to `FIRComponentRegistrant` and provide an array of `FIRComponent` objects.
43 + (void)registerAsComponentRegistrant:(Class)klass;