FSTQueryData.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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/Core/FSTTypes.h"
  18. @class FSTQuery;
  19. @class FSTSnapshotVersion;
  20. NS_ASSUME_NONNULL_BEGIN
  21. /** An enumeration of the different purposes we have for queries. */
  22. typedef NS_ENUM(NSInteger, FSTQueryPurpose) {
  23. /** A regular, normal query. */
  24. FSTQueryPurposeListen,
  25. /** The query was used to refill a query after an existence filter mismatch. */
  26. FSTQueryPurposeExistenceFilterMismatch,
  27. /** The query was used to resolve a limbo document. */
  28. FSTQueryPurposeLimboResolution,
  29. };
  30. /** An immutable set of metadata that the store will need to keep track of for each query. */
  31. @interface FSTQueryData : NSObject
  32. - (instancetype)initWithQuery:(FSTQuery *)query
  33. targetID:(FSTTargetID)targetID
  34. purpose:(FSTQueryPurpose)purpose
  35. snapshotVersion:(FSTSnapshotVersion *)snapshotVersion
  36. resumeToken:(NSData *)resumeToken NS_DESIGNATED_INITIALIZER;
  37. /** Convenience initializer for use when creating an FSTQueryData for the first time. */
  38. - (instancetype)initWithQuery:(FSTQuery *)query
  39. targetID:(FSTTargetID)targetID
  40. purpose:(FSTQueryPurpose)purpose;
  41. - (instancetype)init NS_UNAVAILABLE;
  42. /** Creates a new query data instance with an updated snapshot version and resume token. */
  43. - (instancetype)queryDataByReplacingSnapshotVersion:(FSTSnapshotVersion *)snapshotVersion
  44. resumeToken:(NSData *)resumeToken;
  45. /** The query being listened to. */
  46. @property(nonatomic, strong, readonly) FSTQuery *query;
  47. /**
  48. * The targetID to which the query corresponds, assigned by the FSTLocalStore for user queries or
  49. * the FSTSyncEngine for limbo queries.
  50. */
  51. @property(nonatomic, assign, readonly) FSTTargetID targetID;
  52. /** The purpose of the query. */
  53. @property(nonatomic, assign, readonly) FSTQueryPurpose purpose;
  54. /** The latest snapshot version seen for this target. */
  55. @property(nonatomic, strong, readonly) FSTSnapshotVersion *snapshotVersion;
  56. /**
  57. * An opaque, server-assigned token that allows watching a query to be resumed after disconnecting
  58. * without retransmitting all the data that matches the query. The resume token essentially
  59. * identifies a point in time from which the server should resume sending results.
  60. */
  61. @property(nonatomic, copy, readonly) NSData *resumeToken;
  62. @end
  63. NS_ASSUME_NONNULL_END