Skip to content

Commit

Permalink
Rename RLMConfiguration to RLMRealmConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
segiddins committed Aug 12, 2015
1 parent 978ade1 commit 838f0d2
Show file tree
Hide file tree
Showing 30 changed files with 190 additions and 190 deletions.
80 changes: 40 additions & 40 deletions Realm.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions Realm/RLMRealm.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#import <Foundation/Foundation.h>
#import <Realm/RLMDefines.h>

@class RLMConfiguration, RLMObject, RLMSchema, RLMMigration, RLMNotificationToken;
@class RLMRealmConfiguration, RLMObject, RLMSchema, RLMMigration, RLMNotificationToken;

RLM_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -60,8 +60,8 @@ RLM_ASSUME_NONNULL_BEGIN
your Application on iOS, and in your application's Application Support
directory on OS X.
The default Realm is created using the default `RLMConfiguration`, which
can be changed via `+[RLMConfiguration setDefaultConfiguration:]`.
The default Realm is created using the default `RLMRealmConfiguration`, which
can be changed via `+[RLMRealmConfiguration setDefaultConfiguration:]`.
@return The default `RLMRealm` instance for the current thread.
*/
Expand All @@ -77,7 +77,7 @@ RLM_ASSUME_NONNULL_BEGIN
@return An `RLMRealm` instance.
*/
+ (nullable instancetype)realmWithConfiguration:(RLMConfiguration *)configuration error:(NSError **)error;
+ (nullable instancetype)realmWithConfiguration:(RLMRealmConfiguration *)configuration error:(NSError **)error;

/**
Obtains an `RLMRealm` instance persisted at a specific file path.
Expand Down Expand Up @@ -153,7 +153,7 @@ RLM_ASSUME_NONNULL_BEGIN
@param key 64-byte encryption key to use, or `nil` to unset.
@param path Realm path to set the encryption key for.
*/
+ (void)setEncryptionKey:(nullable NSData *)key forRealmsAtPath:(NSString *)path DEPRECATED_MSG_ATTRIBUTE("Use RLMConfiguration to set an encryption key");
+ (void)setEncryptionKey:(nullable NSData *)key forRealmsAtPath:(NSString *)path DEPRECATED_MSG_ATTRIBUTE("Use RLMRealmConfiguration to set an encryption key");

/**
Obtains an `RLMRealm` instance for an un-persisted in-memory Realm. The identifier
Expand Down Expand Up @@ -200,9 +200,9 @@ RLM_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) BOOL inWriteTransaction;

/**
Returns an `RLMConfiguration` that can be used to create this `RLMRealm` instance.
Returns an `RLMRealmConfiguration` that can be used to create this `RLMRealm` instance.
*/
@property (nonatomic, readonly) RLMConfiguration *configuration;
@property (nonatomic, readonly) RLMRealmConfiguration *configuration;

/**---------------------------------------------------------------------------------------
* @name Default Realm Path
Expand All @@ -219,7 +219,7 @@ RLM_ASSUME_NONNULL_BEGIN
@see defaultRealm
*/
+ (NSString *)defaultRealmPath DEPRECATED_MSG_ATTRIBUTE("Use [RLMConfiguration defaultConfiguration].path");
+ (NSString *)defaultRealmPath DEPRECATED_MSG_ATTRIBUTE("Use [RLMRealmConfiguration defaultConfiguration].path");

/**
Set the default Realm path to a given path.
Expand All @@ -228,7 +228,7 @@ RLM_ASSUME_NONNULL_BEGIN
@see defaultRealm
*/
+ (void)setDefaultRealmPath:(NSString *)defaultRealmPath DEPRECATED_MSG_ATTRIBUTE("Use +[RLMConfiguration setDefaultConfiguration:]");
+ (void)setDefaultRealmPath:(NSString *)defaultRealmPath DEPRECATED_MSG_ATTRIBUTE("Use +[RLMRealmConfiguration setDefaultConfiguration:]");


#pragma mark - Notifications
Expand Down Expand Up @@ -546,7 +546,7 @@ typedef void (^RLMMigrationBlock)(RLMMigration *migration, uint64_t oldSchemaVer
@see RLMMigration
*/
+ (void)setDefaultRealmSchemaVersion:(uint64_t)version withMigrationBlock:(nullable RLMMigrationBlock)block DEPRECATED_MSG_ATTRIBUTE("Use RLMConfiguration.schemaVersion and RLMConfiguration.migrationBlock");
+ (void)setDefaultRealmSchemaVersion:(uint64_t)version withMigrationBlock:(nullable RLMMigrationBlock)block DEPRECATED_MSG_ATTRIBUTE("Use RLMRealmConfiguration.schemaVersion and RLMRealmConfiguration.migrationBlock");

/**
Specify a schema version and an associated migration block which is applied when
Expand All @@ -558,7 +558,7 @@ typedef void (^RLMMigrationBlock)(RLMMigration *migration, uint64_t oldSchemaVer
@see RLMMigration
*/
+ (void)setSchemaVersion:(uint64_t)version forRealmAtPath:(NSString *)realmPath withMigrationBlock:(nullable RLMMigrationBlock)block DEPRECATED_MSG_ATTRIBUTE("Use RLMConfiguration.schemaVersion and RLMConfiguration.migrationBlock");
+ (void)setSchemaVersion:(uint64_t)version forRealmAtPath:(NSString *)realmPath withMigrationBlock:(nullable RLMMigrationBlock)block DEPRECATED_MSG_ATTRIBUTE("Use RLMRealmConfiguration.schemaVersion and RLMRealmConfiguration.migrationBlock");

/**
Get the schema version for a Realm at a given path.
Expand All @@ -585,7 +585,7 @@ typedef void (^RLMMigrationBlock)(RLMMigration *migration, uint64_t oldSchemaVer
*/
+ (uint64_t)schemaVersionAtPath:(NSString *)realmPath encryptionKey:(nullable NSData *)key error:(NSError **)error;

+ (NSError *)migrateRealm:(RLMConfiguration *)configuration;
+ (NSError *)migrateRealm:(RLMRealmConfiguration *)configuration;

/**
Performs the registered migration block on a Realm at the given path.
Expand Down
32 changes: 16 additions & 16 deletions Realm/RLMRealm.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#import "RLMAnalytics.hpp"
#import "RLMArray_Private.hpp"
#import "RLMConfiguration_Private.h"
#import "RLMRealmConfiguration_Private.h"
#import "RLMMigration_Private.h"
#import "RLMObjectSchema_Private.hpp"
#import "RLMObjectStore.h"
Expand Down Expand Up @@ -159,7 +159,7 @@ static void clearMigrationCache() {
}
}

void RLMRealmAddPathSettingsToConfiguration(RLMConfiguration *configuration) {
void RLMRealmAddPathSettingsToConfiguration(RLMRealmConfiguration *configuration) {
if (!configuration.encryptionKey) {
configuration.encryptionKey = keyForPath(configuration.path);
}
Expand Down Expand Up @@ -282,11 +282,11 @@ - (instancetype)initWithPath:(NSString *)path key:(NSData *)key readOnly:(BOOL)r

+ (NSString *)defaultRealmPath
{
return [RLMConfiguration defaultConfiguration].path;
return [RLMRealmConfiguration defaultConfiguration].path;
}

+ (void)setDefaultRealmPath:(NSString *)defaultRealmPath {
[RLMConfiguration setDefaultPath:defaultRealmPath];
[RLMRealmConfiguration setDefaultPath:defaultRealmPath];
}

+ (NSString *)writeableTemporaryPathForFile:(NSString *)fileName
Expand All @@ -296,7 +296,7 @@ + (NSString *)writeableTemporaryPathForFile:(NSString *)fileName

+ (instancetype)defaultRealm
{
RLMConfiguration *configuration = [RLMConfiguration defaultConfiguration];
RLMRealmConfiguration *configuration = [RLMRealmConfiguration defaultConfiguration];
RLMRealmAddPathSettingsToConfiguration(configuration);
return [RLMRealm realmWithConfiguration:configuration error:nil];
}
Expand All @@ -314,7 +314,7 @@ + (instancetype)realmWithPath:(NSString *)path
}

+ (instancetype)inMemoryRealmWithIdentifier:(NSString *)identifier {
RLMConfiguration *configuration = [[RLMConfiguration alloc] init];
RLMRealmConfiguration *configuration = [[RLMRealmConfiguration alloc] init];
configuration.inMemoryIdentifier = identifier;
return [RLMRealm realmWithConfiguration:configuration error:nil];
}
Expand All @@ -339,7 +339,7 @@ + (instancetype)realmWithPath:(NSString *)path
schema:(RLMSchema *)customSchema
error:(NSError **)outError
{
RLMConfiguration *configuration = [[RLMConfiguration alloc] init];
RLMRealmConfiguration *configuration = [[RLMRealmConfiguration alloc] init];
configuration.path = path;
configuration.inMemoryIdentifier = inMemory ? path.lastPathComponent : nil;
configuration.encryptionKey = key;
Expand All @@ -359,7 +359,7 @@ static id RLMAutorelease(id value) {
return value ? (__bridge id)CFAutorelease((__bridge_retained CFTypeRef)value) : nil;
}

+ (instancetype)realmWithConfiguration:(RLMConfiguration *)configuration error:(NSError **)error {
+ (instancetype)realmWithConfiguration:(RLMRealmConfiguration *)configuration error:(NSError **)error {
NSString *path = configuration.path;
bool inMemory = false;
if (configuration.inMemoryIdentifier) {
Expand Down Expand Up @@ -478,7 +478,7 @@ + (instancetype)realmWithConfiguration:(RLMConfiguration *)configuration error:(
}

+ (void)setEncryptionKey:(NSData *)key forRealmsAtPath:(NSString *)path {
RLMConfigurationUsePerPath(_cmd);
RLMRealmConfigurationUsePerPath(_cmd);
@synchronized (s_keysPerPath) {
if (RLMGetAnyCachedRealmForPath(path)) {
NSData *existingKey = keyForPath(path);
Expand All @@ -502,7 +502,7 @@ + (void)resetRealmState {
clearMigrationCache();
clearKeyCache();
RLMClearRealmCache();
[RLMConfiguration resetRealmConfigurationState];
[RLMRealmConfiguration resetRealmConfigurationState];
}

static void CheckReadWrite(RLMRealm *realm, NSString *msg=@"Cannot write to a read-only Realm") {
Expand Down Expand Up @@ -545,8 +545,8 @@ - (void)sendNotifications:(NSString *)notification {
}
}

- (RLMConfiguration *)configuration {
RLMConfiguration *configuration = [[RLMConfiguration alloc] init];
- (RLMRealmConfiguration *)configuration {
RLMRealmConfiguration *configuration = [[RLMRealmConfiguration alloc] init];
configuration.path = self.path;
configuration.schemaVersion = [RLMRealm schemaVersionAtPath:_path encryptionKey:_encryptionKey error:nil];
if (_inMemory) {
Expand Down Expand Up @@ -855,7 +855,7 @@ + (void)setDefaultRealmSchemaVersion:(uint64_t)version withMigrationBlock:(RLMMi
}

+ (void)setSchemaVersion:(uint64_t)version forRealmAtPath:(NSString *)realmPath withMigrationBlock:(RLMMigrationBlock)block {
RLMConfigurationUsePerPath(_cmd);
RLMRealmConfigurationUsePerPath(_cmd);
@synchronized(s_migrationBlocks) {
if (RLMGetAnyCachedRealmForPath(realmPath) && schemaVersionForPath(realmPath) != version) {
@throw RLMException(@"Cannot set schema version for Realms that are already open.");
Expand Down Expand Up @@ -902,7 +902,7 @@ + (uint64_t)schemaVersionAtPath:(NSString *)realmPath encryptionKey:(NSData *)ke
}

+ (NSError *)migrateRealmAtPath:(NSString *)realmPath {
RLMConfiguration *configuration = [RLMConfiguration defaultConfiguration];
RLMRealmConfiguration *configuration = [RLMRealmConfiguration defaultConfiguration];
configuration.path = realmPath;
return [self migrateRealm:configuration];
}
Expand All @@ -911,13 +911,13 @@ + (NSError *)migrateRealmAtPath:(NSString *)realmPath encryptionKey:(NSData *)ke
if (!key) {
@throw RLMException(@"Encryption key must not be nil");
}
RLMConfiguration *configuration = [RLMConfiguration defaultConfiguration];
RLMRealmConfiguration *configuration = [RLMRealmConfiguration defaultConfiguration];
configuration.path = realmPath;
configuration.encryptionKey = key;
return [self migrateRealm:configuration];
}

+ (NSError *)migrateRealm:(RLMConfiguration *)configuration {
+ (NSError *)migrateRealm:(RLMRealmConfiguration *)configuration {
NSString *realmPath = configuration.path;
if (RLMGetAnyCachedRealmForPath(realmPath)) {
@throw RLMException(@"Cannot migrate Realms that are already open.");
Expand Down
8 changes: 4 additions & 4 deletions Realm/RLMConfiguration.h → Realm/RLMRealmConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
RLM_ASSUME_NONNULL_BEGIN

/**
An `RLMConfiguration` is used to describe the different options used to
An `RLMRealmConfiguration` is used to describe the different options used to
create an `RLMRealm` instance.
*/
@interface RLMConfiguration : NSObject<NSCopying>
@interface RLMRealmConfiguration : NSObject<NSCopying>

/**
Returns the default configuration used to create Realms when no other
Expand All @@ -36,11 +36,11 @@ RLM_ASSUME_NONNULL_BEGIN
+ (instancetype)defaultConfiguration;

/**
Sets the default configuration to the given `RLMConfiguration`.
Sets the default configuration to the given `RLMRealmConfiguration`.
@param configuration The new default Realm configuration.
*/
+ (void)setDefaultConfiguration:(RLMConfiguration *)configuration;
+ (void)setDefaultConfiguration:(RLMRealmConfiguration *)configuration;

/// The path to the realm file. Mutually exclusive with `inMemoryIdentifier`.
@property (nonatomic, copy, nullable) NSString *path;
Expand Down
44 changes: 22 additions & 22 deletions Realm/RLMConfiguration.mm → Realm/RLMRealmConfiguration.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
//
////////////////////////////////////////////////////////////////////////////

#import "RLMConfiguration_Private.h"
#import "RLMRealmConfiguration_Private.h"
#import "RLMRealm_Private.h"
#import "RLMUtil.hpp"

#include <atomic>

static NSString * const c_RLMConfigurationProperties[] = {
static NSString * const c_RLMRealmConfigurationProperties[] = {
@"path",
@"inMemoryIdentifier",
@"encryptionKey",
Expand All @@ -32,19 +32,19 @@
@"dynamic",
@"customSchema",
};
static const NSUInteger c_RLMConfigurationPropertiesCount = sizeof(c_RLMConfigurationProperties) / sizeof(NSString *);
static const NSUInteger c_RLMRealmConfigurationPropertiesCount = sizeof(c_RLMRealmConfigurationProperties) / sizeof(NSString *);

typedef NS_ENUM(NSUInteger, RLMConfigurationUsage) {
RLMConfigurationUsageNone,
RLMConfigurationUsageConfiguration,
RLMConfigurationUsagePerPath,
typedef NS_ENUM(NSUInteger, RLMRealmConfigurationUsage) {
RLMRealmConfigurationUsageNone,
RLMRealmConfigurationUsageConfiguration,
RLMRealmConfigurationUsagePerPath,
};

static std::atomic<RLMConfigurationUsage> s_configurationUsage;
static std::atomic<RLMRealmConfigurationUsage> s_configurationUsage;

@implementation RLMConfiguration
@implementation RLMRealmConfiguration

RLMConfiguration *s_defaultConfiguration;
RLMRealmConfiguration *s_defaultConfiguration;
static NSString * const c_defaultRealmFileName = @"default.realm";

+ (NSString *)defaultRealmPath
Expand Down Expand Up @@ -86,13 +86,13 @@ + (NSString *)writeablePathForFile:(NSString*)fileName

+ (instancetype)defaultConfiguration {
if (!s_defaultConfiguration) {
s_defaultConfiguration = [[RLMConfiguration alloc] init];
s_defaultConfiguration = [[RLMRealmConfiguration alloc] init];
}
return [s_defaultConfiguration copy];
}

+ (void)setDefaultConfiguration:(RLMConfiguration *)configuration {
if (s_configurationUsage.exchange(RLMConfigurationUsageConfiguration) == RLMConfigurationUsagePerPath) {
+ (void)setDefaultConfiguration:(RLMRealmConfiguration *)configuration {
if (s_configurationUsage.exchange(RLMRealmConfigurationUsageConfiguration) == RLMRealmConfigurationUsagePerPath) {
@throw RLMException(@"Cannot set a default configuration after using per-path configuration methods.");
}
if (!configuration) {
Expand All @@ -102,14 +102,14 @@ + (void)setDefaultConfiguration:(RLMConfiguration *)configuration {
}

+ (void)setDefaultPath:(NSString *)path {
RLMConfiguration *configuration = [[RLMConfiguration alloc] init];
RLMRealmConfiguration *configuration = [[RLMRealmConfiguration alloc] init];
configuration.path = path;
s_defaultConfiguration = configuration;
}

+ (void)resetRealmConfigurationState {
s_defaultConfiguration = nil;
s_configurationUsage = RLMConfigurationUsageNone;
s_configurationUsage = RLMRealmConfigurationUsageNone;
}

- (instancetype)init {
Expand All @@ -122,18 +122,18 @@ - (instancetype)init {
}

- (instancetype)copyWithZone:(NSZone *)zone {
RLMConfiguration *configuration = [[[self class] allocWithZone:zone] init];
for (NSUInteger i = 0; i < c_RLMConfigurationPropertiesCount; i++) {
NSString *key = c_RLMConfigurationProperties[i];
RLMRealmConfiguration *configuration = [[[self class] allocWithZone:zone] init];
for (NSUInteger i = 0; i < c_RLMRealmConfigurationPropertiesCount; i++) {
NSString *key = c_RLMRealmConfigurationProperties[i];
[configuration setValue:[self valueForKey:key] forKey:key];
}
return configuration;
}

- (NSString *)description {
NSMutableString *string = [NSMutableString stringWithFormat:@"%@ {\n", self.class];
for (NSUInteger i = 0; i < c_RLMConfigurationPropertiesCount; i++) {
NSString *key = c_RLMConfigurationProperties[i];
for (NSUInteger i = 0; i < c_RLMRealmConfigurationPropertiesCount; i++) {
NSString *key = c_RLMRealmConfigurationProperties[i];
NSString *description = [[self valueForKey:key] description];
description = [description stringByReplacingOccurrencesOfString:@"\n" withString:@"\n\t"];

Expand Down Expand Up @@ -166,8 +166,8 @@ - (void)setSchemaVersion:(uint64_t)schemaVersion {

@end

void RLMConfigurationUsePerPath(SEL callingMethod) {
if (s_configurationUsage.exchange(RLMConfigurationUsagePerPath) == RLMConfigurationUsageConfiguration) {
void RLMRealmConfigurationUsePerPath(SEL callingMethod) {
if (s_configurationUsage.exchange(RLMRealmConfigurationUsagePerPath) == RLMRealmConfigurationUsageConfiguration) {
@throw RLMException([NSString stringWithFormat:@"Cannot call %@ after setting a default configuration.", NSStringFromSelector(callingMethod)]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
//
////////////////////////////////////////////////////////////////////////////

#import <Realm/RLMConfiguration.h>
#import <Realm/RLMRealmConfiguration.h>

@class RLMSchema;

@interface RLMConfiguration ()
@interface RLMRealmConfiguration ()

@property (nonatomic, readwrite) bool dynamic;
@property (nonatomic, copy, readwrite) RLMSchema *customSchema;
Expand All @@ -33,4 +33,4 @@

@end

FOUNDATION_EXTERN void RLMConfigurationUsePerPath(SEL methodName);
FOUNDATION_EXTERN void RLMRealmConfigurationUsePerPath(SEL methodName);
2 changes: 1 addition & 1 deletion Realm/RLMRealm_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ FOUNDATION_EXTERN void RLMRealmSetEncryptionKeyForPath(NSData *encryptionKey, NS

FOUNDATION_EXTERN void RLMRealmSetSchemaVersionForPath(uint64_t version, NSString *path, RLMMigrationBlock migrationBlock);

FOUNDATION_EXTERN void RLMRealmAddPathSettingsToConfiguration(RLMConfiguration *configuration);
FOUNDATION_EXTERN void RLMRealmAddPathSettingsToConfiguration(RLMRealmConfiguration *configuration);

// RLMRealm private members
@interface RLMRealm () {
Expand Down
Loading

0 comments on commit 838f0d2

Please sign in to comment.