2 Copyright (C) 2000-2003 SKYRIX Software AG
4 This file is part of OGo
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
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.
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
23 #ifndef __NGExtensions_EOKeyMapDataSource_H__
24 #define __NGExtensions_EOKeyMapDataSource_H__
26 #import <EOControl/EODataSource.h>
31 This class allows you to remap the keys of a source datasource on the fly. It
32 fully supports fetch enumerators.
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
39 @class NSException, NSEnumerator, NSArray, NSClassDescription;
40 @class NSMutableDictionary, NSDictionary;
41 @class EOFetchSpecification, EOGlobalID;
43 @interface EOKeyMapDataSource : EODataSource
45 EOFetchSpecification *fspec;
47 NSClassDescription *classDescription;
53 - (id)initWithDataSource:(EODataSource *)_ds map:(id)_map;
57 - (void)setSource:(EODataSource *)_source;
58 - (EODataSource *)source;
59 - (void)setFetchSpecification:(EOFetchSpecification *)_fetchSpec;
60 - (EOFetchSpecification *)fetchSpecification;
62 - (NSException *)lastException;
64 /* mappings (default implementations use the map) */
66 - (EOFetchSpecification *)mapFetchSpecification:(EOFetchSpecification *)_fs;
68 - (void)setClassDescriptionForObjects:(NSClassDescription *)_cd;
69 - (NSClassDescription *)classDescriptionForObjects;
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;
77 - (id)mapFromSourceObject:(id)_object;
78 - (id)mapToSourceObject:(id)_object;
82 - (Class)fetchEnumeratorClass;
83 - (NSEnumerator *)fetchEnumerator;
84 - (NSArray *)fetchObjects;
90 - (void)updateObject:(id)_obj;
91 - (void)insertObject:(id)_obj;
92 - (void)deleteObject:(id)_obj;
97 #import <Foundation/NSEnumerator.h>
99 @interface EOKeyMapDataSourceEnumerator : NSEnumerator
101 EOKeyMapDataSource *ds;
102 NSEnumerator *source;
105 - (id)initWithKeyMapDataSource:(EOKeyMapDataSource *)_ds
106 fetchEnumerator:(NSEnumerator *)_enum;
110 @interface EOMappedObject : NSObject
113 EOGlobalID *globalID;
114 NSMutableDictionary *values;
121 - (id)initWithObject:(id)_object values:(NSDictionary *)_values;
126 - (EOGlobalID *)globalID;
130 - (void)applyChangesOnObject;
132 /* mimic dictionary */
134 - (void)setObject:(id)_obj forKey:(id)_key;
135 - (id)objectForKey:(id)_key;
136 - (void)removeObjectForKey:(id)_key;
138 - (NSEnumerator *)keyEnumerator;
139 - (NSEnumerator *)objectEnumerator;
143 - (void)takeValue:(id)_value forKey:(NSString *)_key;
144 - (id)valueForKey:(NSString *)_key;
148 #endif /* __NGExtensions_EOKeyMapDataSource_H__ */