FSyncTree.h 3.3 KB

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