]> err.no Git - sope/blob - sope-core/EOControl/EOClassDescription.h
Xcode project
[sope] / sope-core / EOControl / EOClassDescription.h
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #ifndef __EOControl_EOClassDescription_H__
24 #define __EOControl_EOClassDescription_H__
25
26 #import <Foundation/Foundation.h>
27 #include <EOControl/EOGlobalID.h>
28
29 @class NSException, NSString, NSFormatter;
30
31 @interface EOClassDescription : NSClassDescription
32
33 @end
34
35 @interface NSClassDescription(EOClassDescription)
36
37 /* model */
38
39 - (NSString *)entityName;
40 - (NSString *)inverseForRelationshipKey:(NSString *)_key;
41 - (NSClassDescription *)classDescriptionForDestinationKey:(NSString *)_key;
42
43 /* object initialization */
44
45 - (id)createInstanceWithEditingContext:(id)_ec
46   globalID:(EOGlobalID *)_oid
47   zone:(NSZone *)_zone;
48
49 - (void)awakeObject:(id)_object fromFetchInEditingContext:(id)_ec;
50 - (void)awakeObject:(id)_object fromInsertionInEditingContext:(id)_ec;
51
52 /* delete */
53
54 - (void)propagateDeleteForObject:(id)_object editingContext:(id)_ec;
55
56 /* entity names */
57
58 #if 0
59 // used by: EOGenericRecord.m
60 + (NSClassDescription *)classDescriptionForEntityName:(NSString *)_entityName;
61 #endif
62
63 /* formatting */
64
65 - (NSFormatter *)defaultFormatterForKey:(NSString *)_key;
66 - (NSFormatter *)defaultFormatterForKeyPath:(NSString *)_keyPath;
67
68 @end
69
70 @interface NSClassDescription(EOValidation)
71
72 - (NSException *)validateObjectForDelete:(id)_object;
73 - (NSException *)validateObjectForSave:(id)_object;
74 - (NSException *)validateValue:(id *)_value forKey:(NSString *)_key;
75
76 @end
77
78 @interface NSObject(EOClassDescriptionInit)
79
80 /* object initialization */
81
82 - (id)initWithEditingContext:(id)_ec
83   classDescription:(NSClassDescription *)_classDesc
84   globalID:(EOGlobalID *)_oid;
85
86 - (void)awakeFromFetchInEditingContext:(id)_ec;
87 - (void)awakeFromInsertionInEditingContext:(id)_ec;
88
89 /* model */
90
91 - (NSString *)entityName;
92 - (NSString *)inverseForRelationshipKey:(NSString *)_key;
93 - (NSArray *)attributeKeys;
94 - (NSArray *)toManyRelationshipKeys;
95 - (NSArray *)toOneRelationshipKeys;
96
97 - (BOOL)isToManyKey:(NSString *)_key;
98 - (NSArray *)allPropertyKeys;
99
100 /* delete */
101
102 - (void)propagateDeleteWithEditingContext:(id)_ec;
103
104 @end
105
106 /* validation */
107
108 @interface NSObject(EOValidation)
109
110 - (NSException *)validateForDelete;
111 - (NSException *)validateForInsert;
112 - (NSException *)validateForUpdate;
113 - (NSException *)validateForSave;
114
115 @end
116
117 @interface NSException(EOValidation)
118
119 + (NSException *)aggregateExceptionWithExceptions:(NSArray *)_exceptions;
120
121 @end
122
123 /* snapshots */
124
125 @interface NSObject(EOSnapshots)
126
127 - (NSDictionary *)snapshot;
128 - (void)updateFromSnapshot:(NSDictionary *)_snapshot;
129 - (NSDictionary *)changesFromSnapshot:(NSDictionary *)_snapshot;
130
131 @end
132
133 /* relationships */
134
135 @interface NSObject(EORelationshipManipulation)
136
137 - (void)addObject:(id)_o    toBothSidesOfRelationshipWithKey:(NSString *)_key;
138 - (void)removeObject:(id)_o fromBothSidesOfRelationshipWithKey:(NSString *)_key;
139
140 - (void)addObject:(id)_object    toPropertyWithKey:(NSString *)_key;
141 - (void)removeObject:(id)_object fromPropertyWithKey:(NSString *)_key;
142
143 @end
144
145 /* shallow array copying */
146
147 @interface NSArray(ShallowCopy)
148 - (id)shallowCopy;
149 @end
150
151 #endif /* __EOControl_EOClassDescription_H__ */