]> err.no Git - sope/blob - skyrix-core/NGExtensions/NGExtensions/EOKeyMapDataSource.h
added svn:keywords and svn:ignore where appropriate. removed CVS artifacts.
[sope] / skyrix-core / NGExtensions / NGExtensions / EOKeyMapDataSource.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 __NGExtensions_EOKeyMapDataSource_H__
24 #define __NGExtensions_EOKeyMapDataSource_H__
25
26 #import <EOControl/EODataSource.h>
27
28 /*
29   EOKeyMapDataSource
30   
31   This class allows you to remap the keys of a source datasource on the fly. It
32   fully supports fetch enumerators.
33   
34   The class description of the datasource describes what keys the resulting
35   objects should have (note that the fetchspec isn't checked for validaty on
36   that).
37 */
38
39 @class NSException, NSEnumerator, NSArray, NSClassDescription;
40 @class NSMutableDictionary, NSDictionary;
41 @class EOFetchSpecification, EOGlobalID;
42
43 @interface EOKeyMapDataSource : EODataSource
44 {
45   EOFetchSpecification *fspec;
46   EODataSource         *source;
47   NSClassDescription   *classDescription;
48   NSArray *entityKeys;
49   NSArray *mappedKeys;
50   id      map;
51 }
52
53 - (id)initWithDataSource:(EODataSource *)_ds map:(id)_map;
54
55 /* accessors */
56
57 - (void)setSource:(EODataSource *)_source;
58 - (EODataSource *)source;
59 - (void)setFetchSpecification:(EOFetchSpecification *)_fetchSpec;
60 - (EOFetchSpecification *)fetchSpecification;
61
62 - (NSException *)lastException;
63
64 /* mappings (default implementations use the map) */
65
66 - (EOFetchSpecification *)mapFetchSpecification:(EOFetchSpecification *)_fs;
67
68 - (void)setClassDescriptionForObjects:(NSClassDescription *)_cd;
69 - (NSClassDescription *)classDescriptionForObjects;
70
71 - (id)mapCreatedObject:(id)_object;
72 - (id)mapObjectForUpdate:(id)_object;
73 - (id)mapObjectForInsert:(id)_object;
74 - (id)mapObjectForDelete:(id)_object;
75 - (id)mapFetchedObject:(id)_object;
76
77 - (id)mapFromSourceObject:(id)_object;
78 - (id)mapToSourceObject:(id)_object;
79
80 /* fetching */
81
82 - (Class)fetchEnumeratorClass;
83 - (NSEnumerator *)fetchEnumerator;
84 - (NSArray *)fetchObjects;
85
86 - (void)clear;
87
88 /* operations */
89
90 - (void)updateObject:(id)_obj;
91 - (void)insertObject:(id)_obj;
92 - (void)deleteObject:(id)_obj;
93 - (id)createObject;
94
95 @end
96
97 #import <Foundation/NSEnumerator.h>
98
99 @interface EOKeyMapDataSourceEnumerator : NSEnumerator
100 {
101   EOKeyMapDataSource *ds;
102   NSEnumerator       *source;
103 }
104
105 - (id)initWithKeyMapDataSource:(EOKeyMapDataSource *)_ds
106   fetchEnumerator:(NSEnumerator *)_enum;
107
108 @end
109
110 @interface EOMappedObject : NSObject
111 {
112   id         original;
113   EOGlobalID *globalID;
114   NSMutableDictionary *values;
115   struct {
116     BOOL didChange:1;
117     int  reserved:31;
118   } flags;
119 }
120
121 - (id)initWithObject:(id)_object values:(NSDictionary *)_values;
122
123 /* accessors */
124
125 - (id)mappedObject;
126 - (EOGlobalID *)globalID;
127
128 - (BOOL)isModified;
129 - (void)willChange;
130 - (void)applyChangesOnObject;
131
132 /* mimic dictionary */
133
134 - (void)setObject:(id)_obj forKey:(id)_key;
135 - (id)objectForKey:(id)_key;
136 - (void)removeObjectForKey:(id)_key;
137
138 - (NSEnumerator *)keyEnumerator;
139 - (NSEnumerator *)objectEnumerator;
140
141 /* KVC */
142
143 - (void)takeValue:(id)_value forKey:(NSString *)_key;
144 - (id)valueForKey:(NSString *)_key;
145
146 @end
147
148 #endif /* __NGExtensions_EOKeyMapDataSource_H__ */