2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
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
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.
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
22 #include <EOControl/EOArrayDataSource.h>
23 #include <EOControl/EOFetchSpecification.h>
24 #include <EOControl/EOSortOrdering.h>
25 #include <EOControl/EOQualifier.h>
28 @interface EODataSource(PostChange)
29 - (void)postDataSourceChangedNotification;
32 @implementation EOArrayDataSource
35 if ((self = [super init])) {
36 self->objects = [[NSMutableArray alloc] init];
41 [self->fetchSpecification release];
42 [self->objects release];
48 - (void)setFetchSpecification:(EOFetchSpecification *)_fspec {
49 if ([self->fetchSpecification isEqual:_fspec])
52 [self->fetchSpecification autorelease];
53 self->fetchSpecification = [_fspec copy];
55 [self postDataSourceChangedNotification];
57 - (EOFetchSpecification *)fetchSpecification {
58 return self->fetchSpecification;
61 - (void)setArray:(NSArray *)_array {
62 [self->objects removeAllObjects];
63 [self->objects addObjectsFromArray:_array];
68 - (NSArray *)fetchObjects {
71 if (self->fetchSpecification == nil) {
72 result = [[self->objects copy] autorelease];
78 q = [self->fetchSpecification qualifier];
79 sort = [self->fetchSpecification sortOrderings];
83 result = [self->objects sortedArrayUsingKeyOrderArray:sort];
85 result = [[self->objects copy] autorelease];
88 result = [self->objects filteredArrayUsingQualifier:q];
89 if (sort) result = [result sortedArrayUsingKeyOrderArray:sort];
97 - (void)deleteObject:(id)_object {
98 [self->objects removeObjectIdenticalTo:_object];
99 [self postDataSourceChangedNotification];
102 - (void)insertObject:(id)_object {
103 [self->objects addObject:_object];
104 [self postDataSourceChangedNotification];
108 return [NSMutableDictionary dictionaryWithCapacity:16];
111 @end /* EOArrayDataSource */