GNUstep Core Data  0.1
NSManagedObject.h
1 /* Interface of the NSManagedObject 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 _NSManagedObject_h_
26 #define _NSManagedObject_h_
27 
28 #import <Foundation/NSObject.h>
29 #import <Foundation/NSArray.h> // temporary workaround for
30  // NSKeyValueObserving.h include bug
31 #import <Foundation/NSKeyValueObserving.h>
32 
33 @class NSString, NSMutableDictionary, NSDictionary, NSSet, NSError;
34 @class NSManagedObjectContext, NSEntityDescription, NSManagedObjectID;
35 
36 @interface NSManagedObject : NSObject
37 {
38  // weak reference
39  NSManagedObjectContext * _context;
40 
41  NSEntityDescription * _entity;
42  NSManagedObjectID * _objectID;
43  BOOL _isUpdated,
44  _isDeleted,
45  _isFault;
46 
47  NSMutableDictionary * _changedValues;
48 
49  // the actual data payload of a managed object
50  NSMutableDictionary * _data;
51 }
52 
53 + (BOOL) automaticallyNotifiesObserversForKey: (NSString *) aKey;
54 
55 // The designated initializer.
56 - (id) initWithEntity: (NSEntityDescription *) anEntity
57  insertIntoManagedObjectContext: (NSManagedObjectContext *) aContext;
58 
59 // Determining the object's identity.
60 - (NSManagedObjectContext *) managedObjectContext;
61 - (NSEntityDescription *) entity;
62 - (NSManagedObjectID *) objectID;
63 
64 // State information
65 - (BOOL) isInserted;
66 - (BOOL) isUpdated;
67 - (BOOL) isDeleted;
68 - (BOOL) isFault;
69 
70 // Life cycle and change management
71 - (void) awakeFromFetch;
72 - (void) awakeFromInsert;
73 - (NSDictionary *) changedValues;
74 - (NSDictionary *) commitedValuesForKeys: (NSArray *) someKeys;
75 - (void) didSave;
76 - (void) willSave;
77 - (void) didTurnIntoFault;
78 
79 // Key-value coding
80 - (id) valueForKey: (NSString *) aKey;
81 - (void) setValue: (id) aValue forKey: (NSString *) aKey;
82 - (id) primitiveValueForKey: (NSString *) aKey;
83 - (void) setPrimitiveValue: (id) aPrimitiveValue forKey: (NSString *) aKey;
84 
85 // Validation
86 - (BOOL) validateValue: (id *) value
87  forKey: (NSString *) aKey
88  error: (NSError **) anErrorPointer;
89 - (BOOL) validateForDelete: (NSError **) anErrorPointer;
90 - (BOOL) validateForInsert: (NSError **) anErrorPointer;
91 - (BOOL) validateForUpdate: (NSError **) anErrorPointer;
92 
93 // Key-value observing
94 - (void) didAccessValueForKey: (NSString *) aKey;
95 - (void) didChangeValueForKey: (NSString *) aKey;
96 - (void) didChangeValueForKey: (NSString *) aKey
97  withSetMutation: (NSKeyValueSetMutationKind) aMutationKind
98  usingObjects: (NSSet *) someObjects;
99 - (void *) observationInfo;
100 - (void) setObservationInfo: (void *) someInfo;
101 - (void) willAccessValueForKey: (NSString *) aKey;
102 - (void) willChangeValueForKey: (NSString *) aKey;
103 - (void) willChangeValueForKey: (NSString *) aKey
104  withSetMutation: (NSKeyValueSetMutationKind) aMutationKind
105  usingObjects: (NSSet *) someObjects;
106 
107 @end
108 
109 #endif // _NSManagedObject_h_
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,...