RLMRealm_Private.h 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. // RLMRealm private members
  47. @interface RLMRealm ()
  48. @property (nonatomic, readonly) BOOL dynamic;
  49. @property (nonatomic, readwrite) RLMSchema *schema;
  50. @property (nonatomic, readonly, nullable) id actor;
  51. @property (nonatomic, readonly) bool isFlexibleSync;
  52. + (void)resetRealmState;
  53. - (void)registerEnumerator:(RLMFastEnumerator *)enumerator;
  54. - (void)unregisterEnumerator:(RLMFastEnumerator *)enumerator;
  55. - (void)detachAllEnumerators;
  56. - (void)sendNotifications:(RLMNotification)notification;
  57. - (void)verifyThread;
  58. - (void)verifyNotificationsAreSupported:(bool)isCollection;
  59. - (RLMRealm *)frozenCopy NS_RETURNS_RETAINED;
  60. + (nullable instancetype)realmWithConfiguration:(RLMRealmConfiguration *)configuration
  61. confinedTo:(RLMScheduler *)options
  62. error:(NSError **)error;
  63. - (RLMAsyncWriteTask *)beginAsyncWrite NS_RETURNS_RETAINED;
  64. - (void)commitAsyncWriteWithGrouping:(bool)allowGrouping
  65. completion:(void(^)(NSError *_Nullable))completion;
  66. @end
  67. @interface RLMPinnedRealm : NSObject
  68. @property (nonatomic, readonly) RLMRealmConfiguration *configuration;
  69. - (instancetype)initWithRealm:(RLMRealm *)realm;
  70. - (void)unpin;
  71. @end
  72. RLM_HEADER_AUDIT_END(nullability)