FRepo.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 "FirebaseDatabase/Sources/Core/FPersistentConnection.h"
  17. #import "FirebaseDatabase/Sources/Core/FRepoInfo.h"
  18. #import "FirebaseDatabase/Sources/Public/FirebaseDatabase/FIRDataEventType.h"
  19. #import "FirebaseDatabase/Sources/Utilities/Tuples/FTupleUserCallback.h"
  20. #import <Foundation/Foundation.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
  32. config:(FIRDatabaseConfig *)config
  33. database:(FIRDatabase *)database;
  34. - (void)set:(FPath *)path
  35. withNode:(id)node
  36. withCallback:(fbt_void_nserror_ref)onComplete;
  37. - (void)update:(FPath *)path
  38. withNodes:(FCompoundWrite *)compoundWrite
  39. withCallback:(fbt_void_nserror_ref)callback;
  40. - (void)purgeOutstandingWrites;
  41. - (void)addEventRegistration:(id<FEventRegistration>)eventRegistration
  42. forQuery:(FQuerySpec *)query;
  43. - (void)removeEventRegistration:(id<FEventRegistration>)eventRegistration
  44. forQuery:(FQuerySpec *)query;
  45. - (void)keepQuery:(FQuerySpec *)query synced:(BOOL)synced;
  46. - (NSString *)name;
  47. - (NSTimeInterval)serverTime;
  48. - (void)onDataUpdate:(FPersistentConnection *)fpconnection
  49. forPath:(NSString *)pathString
  50. message:(id)message
  51. isMerge:(BOOL)isMerge
  52. tagId:(NSNumber *)tagId;
  53. - (void)onConnect:(FPersistentConnection *)fpconnection;
  54. - (void)onDisconnect:(FPersistentConnection *)fpconnection;
  55. // Disconnect methods
  56. - (void)onDisconnectCancel:(FPath *)path
  57. withCallback:(fbt_void_nserror_ref)callback;
  58. - (void)onDisconnectSet:(FPath *)path
  59. withNode:(id<FNode>)node
  60. withCallback:(fbt_void_nserror_ref)callback;
  61. - (void)onDisconnectUpdate:(FPath *)path
  62. withNodes:(FCompoundWrite *)compoundWrite
  63. withCallback:(fbt_void_nserror_ref)callback;
  64. // Connection Management.
  65. - (void)interrupt;
  66. - (void)resume;
  67. // Transactions
  68. - (void)startTransactionOnPath:(FPath *)path
  69. update:(fbt_transactionresult_mutabledata)update
  70. onComplete:(fbt_void_nserror_bool_datasnapshot)onComplete
  71. withLocalEvents:(BOOL)applyLocally;
  72. // Testing methods
  73. - (NSDictionary *)dumpListens;
  74. - (void)dispose;
  75. - (void)setHijackHash:(BOOL)hijack;
  76. @property(nonatomic, strong, readonly) FAuthenticationManager *auth;
  77. @property(nonatomic, strong, readonly) FIRDatabase *database;
  78. @end