GNUstep Core Data  0.1
NSManagedObjectContext.h
1 /* Interface of the NSManagedObjectContext class for the GNUstep
2  Core Data framework.
3  Copyright (C) 2005 Free Software Foundation, Inc.
4 
5  Written by: Saso Kiselkov <diablos@manga.sk>
6  Date: August 2005
7 
8  This file is part of the GNUstep Core Data framework.
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Lesser General Public
12  License as published by the Free Software Foundation; either
13  version 2.1 of the License, or (at your option) any later version.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, write to the Free
22  Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
23  */
24 
25 #ifndef _NSManagedObjectContext_h_
26 #define _NSManagedObjectContext_h_
27 
28 #import <Foundation/NSObject.h>
29 #import <Foundation/NSLock.h>
30 #import <Foundation/NSDate.h>
31 
32 @class NSArray, NSString, NSError, NSSet, NSMutableSet;
33 @class NSUndoManager;
35  NSPersistentStoreCoordinator;
36 
37 extern id NSErrorMergePolicy;
38 extern id NSMergeByPropertyStoreTrumpMergePolicy;
39 extern id NSMergeByPropertyObjectTrumpMergePolicy;
40 extern id NSOverwriteMergePolicy;
41 extern id NSRollbackMergePolicy;
42 
43 @interface NSManagedObjectContext : NSObject <NSCoding, NSLocking>
44 {
45  NSRecursiveLock * _lock;
46 
47  NSPersistentStoreCoordinator * _storeCoordinator;
48 
49  // objects that are registered with the context
50  NSMutableSet * _registeredObjects;
51 
52  // objects inserted into the context since the last save
53  NSMutableSet * _insertedObjects;
54  // objects updated since the last save
55  NSMutableSet * _updatedObjects;
56  // objects deleted since the last save
57  NSMutableSet * _deletedObjects;
58 
59  BOOL _propagesDeletesAtEventEnd;
60  BOOL _retainsRegisteredObjects;
61 
62  NSUndoManager * _undoManager;
63  id _mergePolicy;
64 
65  NSTimeInterval _stalenessInterval;
66 }
67 
68 // Getting and setting the persistent store coordinator.
69 - (NSPersistentStoreCoordinator *) persistentStoreCoordinator;
70 - (void) setPersistentStoreCoordinator:
71  (NSPersistentStoreCoordinator *) aCoordinator;
72 
73 // Undo/redo control.
74 - (NSUndoManager *) undoManager;
75 - (void) setUndoManager: (NSUndoManager *) aManager;
76 - (void) undo;
77 - (void) redo;
78 - (void) reset;
79 - (void) rollback;
80 - (BOOL) save: (NSError **) anErrorPointer;
81 - (BOOL) hasChanges;
82 
83 // Registering and fetching objects.
84 - (NSManagedObject *) objectRegisteredForID: (NSManagedObjectID *) anObjectID;
85 - (NSManagedObject *) objectWithID: (NSManagedObjectID *) anObjectID;
86 - (NSArray *) executeFetchRequest: (NSFetchRequest *) aRequest
87  error: (NSError **) anErrorPointer;
88 
89 // Managed object management.
90 - (void) insertObject: (NSManagedObject *) anObject;
91 - (void) deleteObject: (NSManagedObject *) anObject;
92 - (void) assignObject: (id) anObject toPersistentStore: (id) aStore;
93 - (void) detectConflictsForObject: (NSManagedObject *) anObject;
94 - (void) refreshObject: (NSManagedObject *) anObject
95  mergeChanges: (BOOL) mergeChanges;
96 - (void) processPendingChanges;
97 - (NSSet *) insertedObjects;
98 - (NSSet *) updatedObjects;
99 - (NSSet *) deletedObjects;
100 - (NSSet *) registeredObjects;
101 
102 // Locking (NSLocking protocol).
103 - (void) lock;
104 - (void) unlock;
105 - (BOOL) tryLock;
106 
107 // Controlling delete propagation.
108 - (BOOL) propagatesDeletesAtEndOfEvent;
109 - (void) setPropagatesDeletesAtEndOfEvent: (BOOL) flag;
110 
111 // Controlling whether registered objects are retained.
112 - (BOOL) retainsRegisteredObjects;
113 - (void) setRetainsRegisteredObjects: (BOOL) flag;
114 
115 // Controlling the staleness interval.
116 - (NSTimeInterval) stalenessInterval;
117 - (void) setStalenessInterval: (NSTimeInterval) aTimeInterval;
118 
119 // Controlling the merge policy.
120 - (id) mergePolicy;
121 - (void) setMergePolicy: (id) aPolicy;
122 
123 @end
124 
125 // Notifications.
126 extern NSString * const NSManagedObjectContextObjectsDidChangeNotification;
127 extern NSString * const NSManagedObjectContextDidSaveNotification;
128 
129 extern NSString * const NSInsertedObjectsKey;
130 extern NSString * const NSUpdatedObjectsKey;
131 extern NSString * const NSDeletedObjectsKey;
132 
133 #endif // _NSManagedObjectContext_h_
An object for storing details about managed object fetches.
For implementation notes see "Documentation/NSManagedObjectID.txt" in the source distribution of the ...
Validates whether value'' is a valid value forattribute'', returning YES if it is,...