GNUstep Core Data
0.1
|
00001 /* Implementation of the NSFetchRequest class for the GNUstep 00002 Core Data framework. 00003 Copyright (C) 2005 Free Software Foundation, Inc. 00004 00005 Written by: Saso Kiselkov <diablos@manga.sk> 00006 Date: August 2005 00007 00008 This file is part of the GNUstep Core Data framework. 00009 00010 This library is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU Lesser General Public 00012 License as published by the Free Software Foundation; either 00013 version 2.1 of the License, or (at your option) any later version. 00014 00015 This library is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 Lesser General Public License for more details. 00019 00020 You should have received a copy of the GNU Lesser General Public 00021 License along with this library; if not, write to the Free 00022 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. 00023 */ 00024 00025 #import "CoreDataHeaders.h" 00026 00038 @implementation NSFetchRequest 00039 00040 - (void) dealloc 00041 { 00042 TEST_RELEASE(_affectedStores); 00043 TEST_RELEASE(_entity); 00044 TEST_RELEASE(_predicate); 00045 00046 [super dealloc]; 00047 } 00048 00052 - (id) _initWithAffectedStores: (NSArray *) affectedStores 00053 entity: (NSEntityDescription *) entity 00054 fetchLimit: (unsigned int) fetchLimit 00055 predicate: (NSPredicate *) predicate 00056 sortDescriptors: (NSArray *) sortDescriptors 00057 { 00058 if ((self = [self init])) 00059 { 00060 ASSIGN(_affectedStores, affectedStores); 00061 ASSIGN(_entity, entity); 00062 _fetchLimit = fetchLimit; 00063 ASSIGN(_predicate, predicate); 00064 ASSIGN(_sortDescriptors, sortDescriptors); 00065 00066 } 00067 return self; 00068 } 00069 00073 - (NSArray *) affectedStores 00074 { 00075 return _affectedStores; 00076 } 00077 00081 - (void) setAffectedStores: (NSArray *) stores 00082 { 00083 ASSIGN(_affectedStores, stores); 00084 } 00085 00090 - (NSEntityDescription *) entity 00091 { 00092 return _entity; 00093 } 00094 00099 - (void) setEntity: (NSEntityDescription *) entity 00100 { 00101 ASSIGN(_entity, entity); 00102 } 00103 00108 - (unsigned int) fetchLimit 00109 { 00110 return _fetchLimit; 00111 } 00112 00116 - (void) setFetchLimit: (unsigned int) aLimit 00117 { 00118 _fetchLimit = aLimit; 00119 } 00120 00125 - (NSPredicate *) predicate 00126 { 00127 return _predicate; 00128 } 00129 00134 - (void) setPredicate: (NSPredicate *) predicate 00135 { 00136 ASSIGN(_predicate, predicate); 00137 } 00138 00143 - (NSArray *) sortDescriptors 00144 { 00145 return _sortDescriptors; 00146 } 00147 00153 - (void) setSortDescriptors: (NSArray *) sortDescriptors 00154 { 00155 ASSIGN(_sortDescriptors, sortDescriptors); 00156 } 00157 00158 // NSCopying 00159 00160 - (id) copyWithZone: (NSZone *) zone 00161 { 00162 return [[NSFetchRequest allocWithZone: zone] 00163 _initWithAffectedStores: _affectedStores 00164 entity: _entity 00165 fetchLimit: _fetchLimit 00166 predicate: _predicate 00167 sortDescriptors: _sortDescriptors]; 00168 } 00169 00170 // NSCoding 00171 00172 - (void) encodeWithCoder: (NSCoder *) coder 00173 { 00174 if ([coder allowsKeyedCoding]) 00175 { 00176 [coder encodeObject: _affectedStores forKey: @"AffectedStores"]; 00177 [coder encodeObject: _entity forKey: @"Entity"]; 00178 [coder encodeInt: _fetchLimit forKey: @"FetchLimit"]; 00179 [coder encodeObject: _predicate forKey: @"Predicate"]; 00180 [coder encodeObject: _sortDescriptors forKey: @"SortDescriptors"]; 00181 } 00182 else 00183 { 00184 [coder encodeObject: _affectedStores]; 00185 [coder encodeObject: _entity]; 00186 [coder encodeValueOfObjCType: @encode(unsigned int) at: &_fetchLimit]; 00187 [coder encodeObject: _predicate]; 00188 [coder encodeObject: _sortDescriptors]; 00189 } 00190 } 00191 00192 - (id) initWithCoder: (NSCoder *) coder 00193 { 00194 if ((self = [self init])) 00195 { 00196 if ([coder allowsKeyedCoding]) 00197 { 00198 ASSIGN(_affectedStores, [coder 00199 decodeObjectForKey: @"AffectedStores"]); 00200 ASSIGN(_entity, [coder decodeObjectForKey: @"Entity"]); 00201 _fetchLimit = [coder decodeIntForKey: @"FetchLimit"]; 00202 ASSIGN(_predicate, [coder decodeObjectForKey: @"Predicate"]); 00203 ASSIGN(_sortDescriptors, [coder 00204 decodeObjectForKey: @"SortDescriptors"]); 00205 } 00206 else 00207 { 00208 ASSIGN(_affectedStores, [coder decodeObject]); 00209 ASSIGN(_entity, [coder decodeObject]); 00210 [coder decodeValueOfObjCType: @encode(unsigned int) 00211 at: &_fetchLimit]; 00212 ASSIGN(_predicate, [coder decodeObject]); 00213 ASSIGN(_sortDescriptors, [coder decodeObject]); 00214 } 00215 00216 } 00217 return self; 00218 } 00219 00220 @end