FSTLocalDocumentsView.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright 2017 Google
  3. *
  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
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  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.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #include "Firestore/core/src/firebase/firestore/local/index_manager.h"
  18. #include "Firestore/core/src/firebase/firestore/local/mutation_queue.h"
  19. #include "Firestore/core/src/firebase/firestore/local/remote_document_cache.h"
  20. #include "Firestore/core/src/firebase/firestore/model/document_key.h"
  21. #include "Firestore/core/src/firebase/firestore/model/document_key_set.h"
  22. #include "Firestore/core/src/firebase/firestore/model/document_map.h"
  23. @class FSTMaybeDocument;
  24. @class FSTQuery;
  25. NS_ASSUME_NONNULL_BEGIN
  26. /**
  27. * A readonly view of the local state of all documents we're tracking (i.e. we have a cached
  28. * version in remoteDocumentCache or local mutations for the document). The view is computed by
  29. * applying the mutations in the FSTMutationQueue to the FSTRemoteDocumentCache.
  30. */
  31. @interface FSTLocalDocumentsView : NSObject
  32. + (instancetype)
  33. viewWithRemoteDocumentCache:
  34. (firebase::firestore::local::RemoteDocumentCache *)remoteDocumentCache
  35. mutationQueue:(firebase::firestore::local::MutationQueue *)mutationQueue
  36. indexManager:(firebase::firestore::local::IndexManager *)indexManager;
  37. - (instancetype)init __attribute__((unavailable("Use a static constructor")));
  38. /**
  39. * Get the local view of the document identified by `key`.
  40. *
  41. * @return Local view of the document or nil if we don't have any cached state for it.
  42. */
  43. - (nullable FSTMaybeDocument *)documentForKey:(const firebase::firestore::model::DocumentKey &)key;
  44. /**
  45. * Gets the local view of the documents identified by `keys`.
  46. *
  47. * If we don't have cached state for a document in `keys`, a FSTDeletedDocument will be stored
  48. * for that key in the resulting set.
  49. */
  50. - (firebase::firestore::model::MaybeDocumentMap)documentsForKeys:
  51. (const firebase::firestore::model::DocumentKeySet &)keys;
  52. /**
  53. * Similar to `documentsForKeys`, but creates the local view from the given
  54. * `baseDocs` without retrieving documents from the local store.
  55. */
  56. - (firebase::firestore::model::MaybeDocumentMap)localViewsForDocuments:
  57. (const firebase::firestore::model::MaybeDocumentMap &)baseDocs;
  58. /** Performs a query against the local view of all documents. */
  59. - (firebase::firestore::model::DocumentMap)documentsMatchingQuery:(FSTQuery *)query;
  60. @end
  61. NS_ASSUME_NONNULL_END