FSTDocumentReference.h 2.2 KB

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