FSTLocalDocumentsView.h 2.7 KB

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