/* * Copyright 2017 Google * * 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 "FIRFirestore.h" #include #include #include "Firestore/core/src/api/firestore.h" #include "Firestore/core/src/credentials/credentials_provider.h" #include "Firestore/core/src/util/async_queue.h" @class FIRApp; @class FSTUserDataReader; namespace firebase { namespace firestore { namespace remote { class FirebaseMetadataProvider; } // namespace remote } // namespace firestore } // namespace firebase namespace api = firebase::firestore::api; namespace credentials = firebase::firestore::credentials; namespace model = firebase::firestore::model; namespace remote = firebase::firestore::remote; NS_ASSUME_NONNULL_BEGIN /** Provides a registry management interface for FIRFirestore instances. */ @protocol FSTFirestoreInstanceRegistry /** Removes the FIRFirestore instance with given database name from registry. */ - (void)removeInstanceWithDatabase:(NSString *)database; @end @interface FIRFirestore (/* Init */) /** * Initializes a Firestore object with all the required parameters directly. This exists so that * tests can create FIRFirestore objects without needing FIRApp. */ - (instancetype)initWithDatabaseID:(model::DatabaseId)databaseID persistenceKey:(std::string)persistenceKey authCredentialsProvider: (std::shared_ptr)authCredentialsProvider appCheckCredentialsProvider: (std::shared_ptr)appCheckCredentialsProvider workerQueue: (std::shared_ptr)workerQueue firebaseMetadataProvider: (std::unique_ptr)firebaseMetadataProvider firebaseApp:(FIRApp *)app instanceRegistry:(nullable id)registry; @end /** Internal FIRFirestore API we don't want exposed in our public header files. */ @interface FIRFirestore (Internal) + (FIRFirestore *)recoverFromFirestore:(std::shared_ptr)firestore; - (void)terminateInternalWithCompletion:(nullable void (^)(NSError *_Nullable error))completion; - (const std::shared_ptr &)workerQueue; @property(nonatomic, assign, readonly) std::shared_ptr wrapped; @property(nonatomic, assign, readonly) const model::DatabaseId &databaseID; @property(nonatomic, strong, readonly) FSTUserDataReader *dataReader; /** * Creates, caches, and returns named `Firestore` object for the specified `FirebaseApp`. Each * subsequent invocation returns the same `Firestore` object. * * @param app The `FirebaseApp` instance to use for authentication and as a source of the Google * Cloud Project ID for your Firestore Database. If you want the default instance, you should * explicitly set it to `FirebaseApp.app()`. * @param database The database name. * * @return The named `Firestore` instance. */ + (instancetype)firestoreForApp:(FIRApp *)app database:(NSString *)database NS_SWIFT_NAME(firestore(app:database:)); /** * Creates, caches, and returns named `Firestore` object for the default _app_. Each subsequent * invocation returns the same `Firestore` object. * * @param database The database name. * * @return The named `Firestore` instance. */ + (instancetype)firestoreForDatabase:(NSString *)database NS_SWIFT_NAME(firestore(database:)); @end NS_ASSUME_NONNULL_END