FSyncTree.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 FIndexedNode;
  18. @class FListenProvider;
  19. @protocol FNode;
  20. @class FPath;
  21. @protocol FEventRegistration;
  22. @protocol FPersistedServerCache;
  23. @class FQuerySpec;
  24. @class FCompoundWrite;
  25. @class FPersistenceManager;
  26. @class FCompoundHash;
  27. @protocol FClock;
  28. @protocol FSyncTreeHash <NSObject>
  29. - (NSString *)simpleHash;
  30. - (FCompoundHash *)compoundHash;
  31. - (BOOL)includeCompoundHash;
  32. @end
  33. @interface FSyncTree : NSObject
  34. - (id)initWithListenProvider:(FListenProvider *)provider;
  35. - (id)initWithPersistenceManager:(FPersistenceManager *)persistenceManager
  36. listenProvider:(FListenProvider *)provider;
  37. // These methods all return NSArray of FEvent
  38. - (NSArray *)applyUserOverwriteAtPath:(FPath *)path
  39. newData:(id<FNode>)newData
  40. writeId:(NSInteger)writeId
  41. isVisible:(BOOL)visible;
  42. - (NSArray *)applyUserMergeAtPath:(FPath *)path
  43. changedChildren:(FCompoundWrite *)changedChildren
  44. writeId:(NSInteger)writeId;
  45. - (NSArray *)ackUserWriteWithWriteId:(NSInteger)writeId
  46. revert:(BOOL)revert
  47. persist:(BOOL)persist
  48. clock:(id<FClock>)clock;
  49. - (NSArray *)applyServerOverwriteAtPath:(FPath *)path
  50. newData:(id<FNode>)newData;
  51. - (NSArray *)applyServerMergeAtPath:(FPath *)path
  52. changedChildren:(FCompoundWrite *)changedChildren;
  53. - (NSArray *)applyServerRangeMergeAtPath:(FPath *)path
  54. updates:(NSArray *)ranges;
  55. - (NSArray *)applyTaggedQueryOverwriteAtPath:(FPath *)path
  56. newData:(id<FNode>)newData
  57. tagId:(NSNumber *)tagId;
  58. - (NSArray *)applyTaggedQueryMergeAtPath:(FPath *)path
  59. changedChildren:(FCompoundWrite *)changedChildren
  60. tagId:(NSNumber *)tagId;
  61. - (NSArray *)applyTaggedServerRangeMergeAtPath:(FPath *)path
  62. updates:(NSArray *)ranges
  63. tagId:(NSNumber *)tagId;
  64. - (NSArray *)addEventRegistration:(id<FEventRegistration>)eventRegistration
  65. forQuery:(FQuerySpec *)query;
  66. - (NSArray *)removeEventRegistration:(id<FEventRegistration>)eventRegistration
  67. forQuery:(FQuerySpec *)query
  68. cancelError:(NSError *)cancelError;
  69. - (void)keepQuery:(FQuerySpec *)query synced:(BOOL)keepSynced;
  70. - (NSArray *)removeAllWrites;
  71. - (FIndexedNode *)persistenceServerCache:(FQuerySpec *)querySpec;
  72. - (id<FNode>)getServerValue:(FQuerySpec *)query;
  73. - (id<FNode>)calcCompleteEventCacheAtPath:(FPath *)path
  74. excludeWriteIds:(NSArray *)writeIdsToExclude;
  75. @end