RLMRealm_Private.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. ////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2014 Realm Inc.
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. //
  17. ////////////////////////////////////////////////////////////////////////////
  18. #import <Realm/RLMRealm.h>
  19. @class RLMFastEnumerator, RLMScheduler, RLMAsyncRefreshTask, RLMAsyncWriteTask;
  20. RLM_HEADER_AUDIT_BEGIN(nullability)
  21. // Disable syncing files to disk. Cannot be re-enabled. Use only for tests.
  22. FOUNDATION_EXTERN void RLMDisableSyncToDisk(void);
  23. // Set whether the skip backup attribute should be set on temporary files.
  24. FOUNDATION_EXTERN void RLMSetSkipBackupAttribute(bool value);
  25. FOUNDATION_EXTERN NSData * _Nullable RLMRealmValidatedEncryptionKey(NSData *key);
  26. // Set the queue used for async open. For testing purposes only.
  27. FOUNDATION_EXTERN void RLMSetAsyncOpenQueue(dispatch_queue_t queue);
  28. // Translate an in-flight exception resulting from an operation on a SharedGroup to
  29. // an NSError or NSException (if error is nil)
  30. void RLMRealmTranslateException(NSError **error);
  31. // Block until the Realm at the given path is closed.
  32. FOUNDATION_EXTERN void RLMWaitForRealmToClose(NSString *path);
  33. BOOL RLMIsRealmCachedAtPath(NSString *path);
  34. // Register a block to be called from the next before_notify() invocation
  35. FOUNDATION_EXTERN void RLMAddBeforeNotifyBlock(RLMRealm *realm, dispatch_block_t block);
  36. // Test hook to run the async notifiers for a Realm which has the background thread disabled
  37. FOUNDATION_EXTERN void RLMRunAsyncNotifiers(NSString *path);
  38. // Get the cached Realm for the given configuration and scheduler, if any
  39. FOUNDATION_EXTERN RLMRealm *_Nullable RLMGetCachedRealm(RLMRealmConfiguration *, RLMScheduler *) NS_RETURNS_RETAINED;
  40. // Get a cached Realm for the given configuration and any scheduler. The returned
  41. // Realm is not confined to the current thread, so very few operations are safe
  42. // to perform on it
  43. FOUNDATION_EXTERN RLMRealm *_Nullable RLMGetAnyCachedRealm(RLMRealmConfiguration *) NS_RETURNS_RETAINED;
  44. // Scheduler an async refresh for the given Realm
  45. FOUNDATION_EXTERN RLMAsyncRefreshTask *_Nullable RLMRealmRefreshAsync(RLMRealm *rlmRealm) NS_RETURNS_RETAINED;
  46. FOUNDATION_EXTERN void RLMRealmSubscribeToAll(RLMRealm *);
  47. // RLMRealm private members
  48. @interface RLMRealm ()
  49. @property (nonatomic, readonly) BOOL dynamic;
  50. @property (nonatomic, readwrite) RLMSchema *schema;
  51. @property (nonatomic, readonly, nullable) id actor;
  52. @property (nonatomic, readonly) bool isFlexibleSync;
  53. + (void)resetRealmState;
  54. - (void)registerEnumerator:(RLMFastEnumerator *)enumerator;
  55. - (void)unregisterEnumerator:(RLMFastEnumerator *)enumerator;
  56. - (void)detachAllEnumerators;
  57. - (void)sendNotifications:(RLMNotification)notification;
  58. - (void)verifyThread;
  59. - (void)verifyNotificationsAreSupported:(bool)isCollection;
  60. - (RLMRealm *)frozenCopy NS_RETURNS_RETAINED;
  61. + (nullable instancetype)realmWithConfiguration:(RLMRealmConfiguration *)configuration
  62. confinedTo:(RLMScheduler *)options
  63. error:(NSError **)error;
  64. - (RLMAsyncWriteTask *)beginAsyncWrite NS_RETURNS_RETAINED;
  65. - (void)commitAsyncWriteWithGrouping:(bool)allowGrouping
  66. completion:(void(^)(NSError *_Nullable))completion;
  67. @end
  68. @interface RLMPinnedRealm : NSObject
  69. @property (nonatomic, readonly) RLMRealmConfiguration *configuration;
  70. - (instancetype)initWithRealm:(RLMRealm *)realm;
  71. - (void)unpin;
  72. @end
  73. RLM_HEADER_AUDIT_END(nullability)