FSTLocalDocumentsView.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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/remote_document_cache.h"
  18. #include "Firestore/core/src/firebase/firestore/model/document_key.h"
  19. #include "Firestore/core/src/firebase/firestore/model/document_key_set.h"
  20. #include "Firestore/core/src/firebase/firestore/model/document_map.h"
  21. @class FSTMaybeDocument;
  22. @class FSTQuery;
  23. @protocol FSTMutationQueue;
  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:(id<FSTMutationQueue>)mutationQueue;
  34. - (instancetype)init __attribute__((unavailable("Use a static constructor")));
  35. /**
  36. * Get the local view of the document identified by `key`.
  37. *
  38. * @return Local view of the document or nil if we don't have any cached state for it.
  39. */
  40. - (nullable FSTMaybeDocument *)documentForKey:(const firebase::firestore::model::DocumentKey &)key;
  41. /**
  42. * Gets the local view of the documents identified by `keys`.
  43. *
  44. * If we don't have cached state for a document in `keys`, a FSTDeletedDocument will be stored
  45. * for that key in the resulting set.
  46. */
  47. - (firebase::firestore::model::MaybeDocumentMap)documentsForKeys:
  48. (const firebase::firestore::model::DocumentKeySet &)keys;
  49. /**
  50. * Similar to `documentsForKeys`, but creates the local view from the given
  51. * `baseDocs` without retrieving documents from the local store.
  52. */
  53. - (firebase::firestore::model::MaybeDocumentMap)localViewsForDocuments:
  54. (const firebase::firestore::model::MaybeDocumentMap &)baseDocs;
  55. /** Performs a query against the local view of all documents. */
  56. - (firebase::firestore::model::DocumentMap)documentsMatchingQuery:(FSTQuery *)query;
  57. @end
  58. NS_ASSUME_NONNULL_END