FSTLocalDocumentsView.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #import "Firestore/Source/Model/FSTDocumentDictionary.h"
  18. #import "Firestore/Source/Model/FSTDocumentKeySet.h"
  19. @class FSTDocumentKey;
  20. @class FSTMaybeDocument;
  21. @class FSTQuery;
  22. @protocol FSTMutationQueue;
  23. @protocol FSTRemoteDocumentCache;
  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:(id<FSTRemoteDocumentCache>)remoteDocumentCache
  32. mutationQueue:(id<FSTMutationQueue>)mutationQueue;
  33. - (instancetype)init __attribute__((unavailable("Use a static constructor")));
  34. /**
  35. * Get the local view of the document identified by `key`.
  36. *
  37. * @return Local view of the document or nil if we don't have any cached state for it.
  38. */
  39. - (nullable FSTMaybeDocument *)documentForKey:(FSTDocumentKey *)key;
  40. /**
  41. * Gets the local view of the documents identified by `keys`.
  42. *
  43. * If we don't have cached state for a document in `keys`, a FSTDeletedDocument will be stored
  44. * for that key in the resulting set.
  45. */
  46. - (FSTMaybeDocumentDictionary *)documentsForKeys:(FSTDocumentKeySet *)keys;
  47. /** Performs a query against the local view of all documents. */
  48. - (FSTDocumentDictionary *)documentsMatchingQuery:(FSTQuery *)query;
  49. @end
  50. NS_ASSUME_NONNULL_END