FSTDocument.h 3.1 KB

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