FRepo.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #import "FRepoInfo.h"
  18. #import "FPersistentConnection.h"
  19. #import "FIRDataEventType.h"
  20. #import "FTupleUserCallback.h"
  21. @class FQuerySpec;
  22. @class FPersistence;
  23. @class FAuthenticationManager;
  24. @class FIRDatabaseConfig;
  25. @protocol FEventRegistration;
  26. @class FCompoundWrite;
  27. @protocol FClock;
  28. @class FIRDatabase;
  29. @interface FRepo : NSObject <FPersistentConnectionDelegate>
  30. @property (nonatomic, strong) FIRDatabaseConfig *config;
  31. - (id)initWithRepoInfo:(FRepoInfo *)info config:(FIRDatabaseConfig *)config database:(FIRDatabase *)database;
  32. - (void) set:(FPath *)path withNode:(id)node withCallback:(fbt_void_nserror_ref)onComplete;
  33. - (void) update:(FPath *)path withNodes:(FCompoundWrite *)compoundWrite withCallback:(fbt_void_nserror_ref)callback;
  34. - (void) purgeOutstandingWrites;
  35. - (void) addEventRegistration:(id<FEventRegistration>)eventRegistration forQuery:(FQuerySpec *)query;
  36. - (void) removeEventRegistration:(id<FEventRegistration>)eventRegistration forQuery:(FQuerySpec *)query;
  37. - (void) keepQuery:(FQuerySpec *)query synced:(BOOL)synced;
  38. - (NSString*)name;
  39. - (NSTimeInterval)serverTime;
  40. - (void) onDataUpdate:(FPersistentConnection *)fpconnection forPath:(NSString *)pathString message:(id)message isMerge:(BOOL)isMerge tagId:(NSNumber *)tagId;
  41. - (void) onConnect:(FPersistentConnection *)fpconnection;
  42. - (void) onDisconnect:(FPersistentConnection *)fpconnection;
  43. // Disconnect methods
  44. - (void) onDisconnectCancel:(FPath *)path withCallback:(fbt_void_nserror_ref)callback;
  45. - (void) onDisconnectSet:(FPath *)path withNode:(id<FNode>)node withCallback:(fbt_void_nserror_ref)callback;
  46. - (void) onDisconnectUpdate:(FPath *)path withNodes:(FCompoundWrite *)compoundWrite withCallback:(fbt_void_nserror_ref)callback;
  47. // Connection Management.
  48. - (void) interrupt;
  49. - (void) resume;
  50. // Transactions
  51. - (void) startTransactionOnPath:(FPath *)path
  52. update:(fbt_transactionresult_mutabledata)update
  53. onComplete:(fbt_void_nserror_bool_datasnapshot)onComplete
  54. withLocalEvents:(BOOL)applyLocally;
  55. // Testing methods
  56. - (NSDictionary *) dumpListens;
  57. - (void) dispose;
  58. - (void) setHijackHash:(BOOL)hijack;
  59. @property (nonatomic, strong, readonly) FAuthenticationManager *auth;
  60. @property (nonatomic, strong, readonly) FIRDatabase *database;
  61. @end