FSTDocumentReference.h 2.2 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. #include "Firestore/core/src/firebase/firestore/model/document_key.h"
  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:(firebase::firestore::model::DocumentKey)key
  31. ID:(int32_t)ID NS_DESIGNATED_INITIALIZER;
  32. - (instancetype)init NS_UNAVAILABLE;
  33. /** The document key that's the target of this reference. */
  34. - (const firebase::firestore::model::DocumentKey &)key;
  35. /**
  36. * The targetID of a referring target or the batchID of a referring mutation batch. (Which this
  37. * is depends upon which FSTReferenceSet this reference is a part of.)
  38. */
  39. @property(nonatomic, assign, readonly) int32_t ID;
  40. @end
  41. #pragma mark Comparators
  42. /** Sorts document references by key then ID. */
  43. extern const NSComparator FSTDocumentReferenceComparatorByKey;
  44. /** Sorts document references by ID then key. */
  45. extern const NSComparator FSTDocumentReferenceComparatorByID;
  46. /** A callback for use when enumerating an FSTImmutableSortedSet of FSTDocumentReferences. */
  47. typedef void (^FSTDocumentReferenceBlock)(FSTDocumentReference *reference, BOOL *stop);
  48. NS_ASSUME_NONNULL_END