FSyncTree.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 newData:(id <FNode>)newData writeId:(NSInteger)writeId isVisible:(BOOL)visible;
  38. - (NSArray *) applyUserMergeAtPath:(FPath *)path changedChildren:(FCompoundWrite *)changedChildren writeId:(NSInteger)writeId;
  39. - (NSArray *) ackUserWriteWithWriteId:(NSInteger)writeId revert:(BOOL)revert persist:(BOOL)persist clock:(id<FClock>)clock;
  40. - (NSArray *) applyServerOverwriteAtPath:(FPath *)path newData:(id<FNode>)newData;
  41. - (NSArray *) applyServerMergeAtPath:(FPath *)path changedChildren:(FCompoundWrite *)changedChildren;
  42. - (NSArray *) applyServerRangeMergeAtPath:(FPath *)path updates:(NSArray *)ranges;
  43. - (NSArray *) applyTaggedQueryOverwriteAtPath:(FPath *)path newData:(id <FNode>)newData tagId:(NSNumber *)tagId;
  44. - (NSArray *) applyTaggedQueryMergeAtPath:(FPath *)path changedChildren:(FCompoundWrite *)changedChildren tagId:(NSNumber *)tagId;
  45. - (NSArray *) applyTaggedServerRangeMergeAtPath:(FPath *)path updates:(NSArray *)ranges tagId:(NSNumber *)tagId;
  46. - (NSArray *) addEventRegistration:(id<FEventRegistration>)eventRegistration forQuery:(FQuerySpec *)query;
  47. - (NSArray *) removeEventRegistration:(id <FEventRegistration>)eventRegistration forQuery:(FQuerySpec *)query cancelError:(NSError *)cancelError;
  48. - (void)keepQuery:(FQuerySpec *)query synced:(BOOL)keepSynced;
  49. - (NSArray *) removeAllWrites;
  50. - (id<FNode>) calcCompleteEventCacheAtPath:(FPath *)path excludeWriteIds:(NSArray *)writeIdsToExclude;
  51. @end