1 /* 2 Copyright (C) 2000-2005 SKYRIX Software AG 3 4 This file is part of SOPE. 5 6 SOPE 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 SOPE 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 SOPE; 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 22 #ifndef __EOControl_EOClassDescription_H__ 23 #define __EOControl_EOClassDescription_H__ 24 25 #import <Foundation/Foundation.h> 26 #include <EOControl/EOGlobalID.h> 27 28 @class NSException, NSString, NSFormatter; 29 30 @interface EOClassDescription : NSClassDescription 31 32 @end 33 34 @interface NSClassDescription(EOClassDescription) 35 36 /* model */ 37 38 - (NSString *)entityName; 39 - (NSString *)inverseForRelationshipKey:(NSString *)_key; 40 - (NSClassDescription *)classDescriptionForDestinationKey:(NSString *)_key; 41 42 /* object initialization */ 43 44 - (id)createInstanceWithEditingContext:(id)_ec 45 globalID:(EOGlobalID *)_oid 46 zone:(NSZone *)_zone; 47 48 - (void)awakeObject:(id)_object fromFetchInEditingContext:(id)_ec; 49 - (void)awakeObject:(id)_object fromInsertionInEditingContext:(id)_ec; 50 51 /* delete */ 52 53 - (void)propagateDeleteForObject:(id)_object editingContext:(id)_ec; 54 55 /* entity names */ 56 57 #if 0 58 // used by: EOGenericRecord.m 59 + (NSClassDescription *)classDescriptionForEntityName:(NSString *)_entityName; 60 #endif 61 62 /* formatting */ 63 64 - (NSFormatter *)defaultFormatterForKey:(NSString *)_key; 65 - (NSFormatter *)defaultFormatterForKeyPath:(NSString *)_keyPath; 66 67 @end 68 69 @interface NSClassDescription(EOValidation) 70 71 - (NSException *)validateObjectForDelete:(id)_object; 72 - (NSException *)validateObjectForSave:(id)_object; 73 - (NSException *)validateValue:(id *)_value forKey:(NSString *)_key; 74 75 @end 76 77 @interface NSObject(EOClassDescriptionInit) 78 79 /* object initialization */ 80 81 - (id)initWithEditingContext:(id)_ec 82 classDescription:(NSClassDescription *)_classDesc 83 globalID:(EOGlobalID *)_oid; 84 85 - (void)awakeFromFetchInEditingContext:(id)_ec; 86 - (void)awakeFromInsertionInEditingContext:(id)_ec; 87 88 /* model */ 89 90 - (NSString *)entityName; 91 - (NSString *)inverseForRelationshipKey:(NSString *)_key; 92 - (NSArray *)attributeKeys; 93 - (NSArray *)toManyRelationshipKeys; 94 - (NSArray *)toOneRelationshipKeys; 95 96 - (BOOL)isToManyKey:(NSString *)_key; 97 - (NSArray *)allPropertyKeys; 98 99 /* delete */ 100 101 - (void)propagateDeleteWithEditingContext:(id)_ec; 102 103 @end 104 105 /* validation */ 106 107 @interface NSObject(EOValidation) 108 109 - (NSException *)validateForDelete; 110 - (NSException *)validateForInsert; 111 - (NSException *)validateForUpdate; 112 - (NSException *)validateForSave; 113 114 @end 115 116 @interface NSException(EOValidation) 117 118 + (NSException *)aggregateExceptionWithExceptions:(NSArray *)_exceptions; 119 120 @end 121 122 /* snapshots */ 123 124 @interface NSObject(EOSnapshots) 125 126 - (NSDictionary *)snapshot; 127 - (void)updateFromSnapshot:(NSDictionary *)_snapshot; 128 - (NSDictionary *)changesFromSnapshot:(NSDictionary *)_snapshot; 129 130 @end 131 132 /* relationships */ 133 134 @interface NSObject(EORelationshipManipulation) 135 136 - (void)addObject:(id)_o toBothSidesOfRelationshipWithKey:(NSString *)_key; 137 - (void)removeObject:(id)_o fromBothSidesOfRelationshipWithKey:(NSString *)_key; 138 139 - (void)addObject:(id)_object toPropertyWithKey:(NSString *)_key; 140 - (void)removeObject:(id)_object fromPropertyWithKey:(NSString *)_key; 141 142 @end 143 144 /* shallow array copying */ 145 146 @interface NSArray(ShallowCopy) 147 - (id)shallowCopy; 148 @end 149 150 #endif /* __EOControl_EOClassDescription_H__ */ 151