GNUstep Core Data  0.1
NSPersistentStoreCoordinator.h
00001 /* Interface of the NSPersistentStoreCoordinator class for the GNUstep
00002    Core Data framework.
00003    Copyright (C) 2005 Free Software Foundation, Inc.
00004 
00005    Written by:  Saso Kiselkov <diablos@manga.sk>
00006    Date: August 2005
00007 
00008    This file is part of the GNUstep Core Data framework.
00009 
00010    This library is free software; you can redistribute it and/or
00011    modify it under the terms of the GNU Lesser General Public
00012    License as published by the Free Software Foundation; either
00013    version 2.1 of the License, or (at your option) any later version.
00014 
00015    This library is distributed in the hope that it will be useful,
00016    but WITHOUT ANY WARRANTY; without even the implied warranty of
00017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018    Lesser General Public License for more details.
00019 
00020    You should have received a copy of the GNU Lesser General Public
00021    License along with this library; if not, write to the Free
00022    Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
00023  */
00024 
00025 #ifndef _NSPersistentStoreCoordinator_h_
00026 #define _NSPersistentStoreCoordinator_h_
00027 
00028 #import <Foundation/NSObject.h>
00029 #import <Foundation/NSLock.h>
00030 
00031 @class NSString,
00032        NSDictionary,
00033        NSMutableDictionary,
00034        NSURL,
00035        NSError;
00036 @class NSManagedObjectModel,
00037        NSManagedObjectID;
00038 
00039 // Persistent store types.
00040 extern NSString * const NSSQLiteStoreType;
00041 extern NSString * const NSXMLStoreType;
00042 extern NSString * const NSBinaryStoreType;
00043 extern NSString * const NSInMemoryStoreType;
00044 
00045 // Persistent store option keys.
00046 extern NSString * const NSReadOnlyPersistentStoreOption;
00047 extern NSString * const NSValidateXMLStoreOption;
00048 
00049 // Persistent store type keys.
00050 extern NSString * const NSStoreTypeKey;
00051 extern NSString * const NSStoreUUIDKey;
00052 
00053 @interface NSPersistentStoreCoordinator : NSObject <NSLocking>
00054 {
00055   NSManagedObjectModel * _model;
00056 
00057   // a dictionary where stores are keyed to their URLs
00058   NSMutableDictionary * _persistentStores;
00059   NSRecursiveLock * _lock;
00060 
00071   BOOL _configurationSet;
00072   // YES if the first added store passed a non-nil configuration,
00073   // NO otherwise.
00074   BOOL _multipleConfigurationsAllowed;
00075 
00082   BOOL _acquiredModel;
00083 }
00084 
00085 // Initialization.
00086 - (id) initWithManagedObjectModel: (NSManagedObjectModel *) aModel;
00087 - (NSManagedObjectModel *) managedObjectModel;
00088 
00089 // Managing the persistent stores.
00090 - (id) addPersistentStoreWithType: (NSString *) aStoreType
00091                     configuration: (NSString *) aConfiguration
00092                               URL: (NSURL *) aStoreURL
00093                           options: (NSDictionary *) someOptions
00094                             error: (NSError **) anErrorPointer;
00095 
00096 - (BOOL) removePersistentStore: (id) aPersistentStore
00097                          error: (NSError **) errorPointer;
00098 
00099 - (id) migratePersistentStore: (id) aPersistentStore
00100                         toURL: (NSURL *) aURL
00101                       options: (NSDictionary *) options
00102                      withType: (NSString *) newStoreType
00103                         error: (NSError **) errorPointer;
00104 
00105 - (NSArray *) persistentStores;
00106 - (id) persistentStoreForURL: (NSURL *) aURL;
00107 - (NSURL *) URLForPersistentStore: (id) aPersistentStore;
00108 
00109 // Locking.
00110 - (void) lock;
00111 - (void) unlock;
00112 - (BOOL) tryLock;
00113 
00114 // Store meta-data handling.
00115 + (NSDictionary *) metadataForPersistentStoreWithURL: (NSURL *) aUrl
00116                                                error: (NSError **) errorPtr;
00117 - (NSDictionary *) metadataForPersistentStore: (id) store;
00118 - (void) setMetadata: (NSDictionary *) metadata
00119   forPersistentStore: (id) store;
00120 
00121 // Getting managed object IDs.
00122 - (NSManagedObjectID *) managedObjectIDForURIRepresentation: (NSURL *) uri;
00123 
00124 @end
00125 
00126 #endif // _NSPersistentStoreCoordinator_h_