home *** CD-ROM | disk | FTP | other *** search
- // EODataSources.h
- // Copyright (c) 1994, NeXT Computer, Inc. All rights reserved.
-
- #import <foundation/NSArray.h>
- #import <foundation/NSData.h>
- #import <foundation/NSDictionary.h>
- #import <foundation/NSObject.h>
- #import <foundation/NSString.h>
-
- // The EODataSources protocol defines the interface for a source of
- // data-bearing objects retrieved from some external store, such as an RDBMS.
- // EODataSources uses a simple insert/delete/update/fetch model.
- //
- // Changes to the objects provided by a data source are made in two phases.
- // First, you can modify an object independently of the data source. These
- // changes don't affect the external store until you send an -insertObject:,
- // -deleteObject:, or -updateObject: message. For example, if you release an
- // object you received from the data source, it isn't deleted from the
- // external store. Invoking one of the messages listed sends the changes
- // associated with the object to the external store. You must invoke
- // -saveObjects to make your changes permanent. If an external store supports
- // rolling back of changes you can invoke -rollback (declared in the
- // EORollbackDataSources protocol) to undo the changes made since the last
- // -saveObjects message.
-
-
- @protocol EODataSources <NSObject>
-
- - (NSArray *)keys;
- // Returns the names of the keys that describe the data-bearing objects.
-
- - createObject;
- // Returns a new data bearing object with no values set, or nil if the
- // data source won't allow object insertion. You're responsible for
- // assigning a proper primary key.
-
- - (BOOL)insertObject:object;
- // Inserts object into the data source. Returns YES on success, NO on
- // failure for any reason.
-
- - (BOOL)deleteObject:object;
- // Deletes object from the data source. Returns YES on success, NO on
- // failure for any reason.
-
- - (BOOL)updateObject:object;
- // Saves changes to object to the data source. Returns YES on success,
- // NO on failure for any reason.
-
- - (NSArray *)fetchObjects;
- // Returns an array of the data-bearing objects in the data source.
-
- - (BOOL)saveObjects;
- // Saves objects to persistent storage, if needed. Returns YES on
- // success, NO on failure for any reason.
-
- - (BOOL)canDelete;
- // Returns YES if the data source allows objects to be deleted, NO if it
- // doesn't.
-
- - coerceValue: value forKey: (NSString *)key;
- // Coerce a value to the appropriate type.
- // This method should convert to either an NSNumber, NSString, NSData,
- // a custom type, or nil. The value return by this method may be safely
- // passed to an EO via takeValuesFromDictionary:. This method is used
- // by controllers to coerce values supplied from associations before
- // those values are passed on to the EOs.
-
- @end
-
-
- @protocol EOQualifiableDataSources <EODataSources>
-
- - (void)qualifyWithRelationshipKey:(NSString *)key ofObject:sourceObject;
- // qualify ourselves according to the relationship from
- // the given source object
- // A nil object will set up a qualifier that returns no records.
-
- @end
-
-
- @protocol EOMasterDataSources <EODataSources>
-
- - (id <EOQualifiableDataSources>)dataSourceQualifiedByKey:(NSString *)key;
- // Returns a data source that can be set with
- // qualifyWithRelationshipKey:ofObject to supply objects associated
- // with a another objects key. This is a useful way to get an appropriate
- // detail data source for a given master data source.
-
- @end
-
-
- @protocol EORollbackDataSources <EODataSources>
-
- - (void)rollback;
- // Reverses any changes made by -insertObject:, -deleteObject:, or
- // -updateObject: since the data source was last sent a -saveObjects
- // message.
-
- @end
-