FSTDocumentReference.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. @class FSTDocumentKey;
  18. NS_ASSUME_NONNULL_BEGIN
  19. /**
  20. * An immutable value used to keep track of an association between some referencing target or batch
  21. * and a document key that the target or batch references.
  22. *
  23. * A reference can be from either listen targets (identified by their FSTTargetID) or mutation
  24. * batches (identified by their FSTBatchID). See FSTGarbageCollector for more details.
  25. *
  26. * Not to be confused with FIRDocumentReference.
  27. */
  28. @interface FSTDocumentReference : NSObject <NSCopying>
  29. /** Initializes the document reference with the given key and ID. */
  30. - (instancetype)initWithKey:(FSTDocumentKey *)key ID:(int)ID NS_DESIGNATED_INITIALIZER;
  31. - (instancetype)init NS_UNAVAILABLE;
  32. /** The document key that's the target of this reference. */
  33. @property(nonatomic, strong, readonly) FSTDocumentKey *key;
  34. /**
  35. * The targetID of a referring target or the batchID of a referring mutation batch. (Which this
  36. * is depends upon which FSTReferenceSet this reference is a part of.)
  37. */
  38. @property(nonatomic, assign, readonly) int ID;
  39. @end
  40. #pragma mark Comparators
  41. /** Sorts document references by key then ID. */
  42. extern const NSComparator FSTDocumentReferenceComparatorByKey;
  43. /** Sorts document references by ID then key. */
  44. extern const NSComparator FSTDocumentReferenceComparatorByID;
  45. /** A callback for use when enumerating an FSTImmutableSortedSet of FSTDocumentReferences. */
  46. typedef void (^FSTDocumentReferenceBlock)(FSTDocumentReference *reference, BOOL *stop);
  47. NS_ASSUME_NONNULL_END