FSTDocument.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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.h"
  18. #include "Firestore/core/src/firebase/firestore/model/document_key.h"
  19. #include "Firestore/core/src/firebase/firestore/model/field_path.h"
  20. #include "Firestore/core/src/firebase/firestore/model/field_value.h"
  21. #include "Firestore/core/src/firebase/firestore/model/snapshot_version.h"
  22. #include "absl/types/optional.h"
  23. @class GCFSDocument;
  24. @class FSTObjectValue;
  25. namespace model = firebase::firestore::model;
  26. NS_ASSUME_NONNULL_BEGIN
  27. /**
  28. * The result of a lookup for a given path may be an existing document or a tombstone that marks
  29. * the path deleted.
  30. */
  31. @interface FSTMaybeDocument : NSObject <NSCopying>
  32. - (id)init __attribute__((unavailable("Abstract base class")));
  33. - (const model::DocumentKey &)key;
  34. - (const model::SnapshotVersion &)version;
  35. /**
  36. * Whether this document has a local mutation applied that has not yet been acknowledged by Watch.
  37. */
  38. - (bool)hasPendingWrites;
  39. @end
  40. @interface FSTDocument : FSTMaybeDocument
  41. + (instancetype)documentWithData:(model::ObjectValue)data
  42. key:(model::DocumentKey)key
  43. version:(model::SnapshotVersion)version
  44. state:(model::DocumentState)state;
  45. + (instancetype)documentWithData:(model::ObjectValue)data
  46. key:(model::DocumentKey)key
  47. version:(model::SnapshotVersion)version
  48. state:(model::DocumentState)state
  49. proto:(GCFSDocument *)proto;
  50. - (absl::optional<model::FieldValue>)fieldForPath:(const model::FieldPath &)path;
  51. - (bool)hasLocalMutations;
  52. - (bool)hasCommittedMutations;
  53. @property(nonatomic, assign, readonly) const model::ObjectValue &data;
  54. /**
  55. * Memoized serialized form of the document for optimization purposes (avoids repeated
  56. * serialization). Might be nil.
  57. */
  58. @property(nullable, nonatomic, strong, readonly) GCFSDocument *proto;
  59. @end
  60. @interface FSTDeletedDocument : FSTMaybeDocument
  61. + (instancetype)documentWithKey:(model::DocumentKey)key
  62. version:(model::SnapshotVersion)version
  63. hasCommittedMutations:(bool)committedMutations;
  64. - (bool)hasCommittedMutations;
  65. @end
  66. @interface FSTUnknownDocument : FSTMaybeDocument
  67. + (instancetype)documentWithKey:(model::DocumentKey)key version:(model::SnapshotVersion)version;
  68. @end
  69. NS_ASSUME_NONNULL_END