WIP: objective C storages

This commit is contained in:
John Estropia
2016-03-18 20:32:23 +09:00
parent f2df8f7171
commit 1507ac63f9
7 changed files with 188 additions and 147 deletions

View File

@@ -40,27 +40,39 @@ public protocol CSStorageInterface {
The `CSLocalStorageOptions` provides settings that tells the `CSDataStack` how to setup the persistent store for `CSLocalStorage` implementers.
*/
@objc
public enum CSLocalStorageOptions: Int {
public final class CSLocalStorageOptions: NSObject {
/**
Tells the `DataStack` that the store should not be migrated or recreated, and should simply fail on model mismatch
*/
case None = 0
@objc
public static let none = 0
/**
Tells the `DataStack` to delete and recreate the store on model mismatch, otherwise exceptions will be thrown on failure instead
*/
case RecreateStoreOnModelMismatch = 1
@objc
public static let recreateStoreOnModelMismatch = 1
/**
Tells the `DataStack` to prevent progressive migrations for the store
*/
case PreventProgressiveMigration = 2
@objc
public static let preventProgressiveMigration = 2
/**
Tells the `DataStack` to allow lightweight migration for the store when added synchronously
*/
case AllowSynchronousLightweightMigration = 4
@objc
public static let allowSynchronousLightweightMigration = 4
// MARK: Private
private override init() {
fatalError()
}
}
@@ -88,7 +100,7 @@ public protocol CSLocalStorage: CSStorageInterface {
Options that tell the `DataStack` how to setup the persistent store
*/
@objc
var localStorageOptions: CSLocalStorageOptions { get }
var localStorageOptions: Int { get }
/**
Called by the `CSDataStack` to perform actual deletion of the store file from disk. Do not call directly! The `sourceModel` argument is a hint for the existing store's model version. Implementers can use the `sourceModel` to perform necessary store operations. (SQLite stores for example, can convert WAL journaling mode to DELETE before deleting)