home *** CD-ROM | disk | FTP | other *** search
- // EODatabaseDataSource.h
- // Copyright (c) 1994, NeXT Computer, Inc. All rights reserved.
-
- #import "EODataSources.h"
-
- #import <foundation/NSArray.h>
- #import <foundation/NSData.h>
- #import <foundation/NSDictionary.h>
- #import <foundation/NSObject.h>
- #import <foundation/NSString.h>
-
- @class EODatabaseChannel;
- @class EOQualifier;
- @class EOEntity;
-
-
- // An EODatabaseDataSource is a data source that fetches objects from and
- // saves objects to a database. It supports the EODataSources,
- // EOMasterDataSources, and EORollbackDataSources protocols, and adds
- // methods of its own for limiting the objects fetched as well as determining
- // the order they're fetched.
-
-
- @interface EODatabaseDataSource:NSObject <EOMasterDataSources, EOQualifiableDataSources, EORollbackDataSources>
- {
- EOQualifier *auxiliaryQualifier;
- EODatabaseChannel *channel;
- NSArray *fetchOrder;
- EOQualifier *qualifier;
- NSString *databaseName;
- NSString *contextName;
- NSString *channelName;
- struct {
- unsigned int autoTransaction:1;
- unsigned int autoTransactionsEnabled:1;
- unsigned int connected:1;
- unsigned int fetchEnabled:1;
- unsigned int _RESERVED:28;
- } _flags;
- }
-
- - initWithDatabaseChannel:(EODatabaseChannel *)aChannel
- entityNamed:(NSString *)anEntityName;
- // Initializes a newly allocated EODatabaseDataSource with aChannel and
- // an entity in the EODatabase's model named anEntityName. This is the
- // primitive initializer for EODatabaseDataSource objects.
-
- - initWithModelName:(NSString *)aModelName
- entityName:(NSString *)anEntityName databaseName:(NSString *)aDatabaseName
- contextName:(NSString *)aContextName channelName:(NSString *)aChannelName;
- // This method is used by IB to initialize an EODatabaseDataSource so that
- // it can share models, EODatabases, EODatabaseContexts, and
- // EODatabaseChannels with other EODatabaseDataSources. After finding or
- // creating what it needs, it calls initWithDatabaseChannel:entityNamed:.
-
- - initWithModelName:(NSString *)aModelName entityName:(NSString *)anEntityName;
- // A convenience for
- // [dataSource initWithModelName:aModelName entityName:anEntityName
- // databaseName:nil contextName:nil channelName:nil]
-
- - (EOEntity *)entity;
- // Returns the root entity of the EODatabaseDataSource. The objects it
- // supplies are fetched for this entity.
-
- - (EODatabaseChannel *)databaseChannel;
- // Returns the data source's connection to the database server.
-
- - (void)setFetchOrder:(NSArray *)fetchOrder;
- - (NSArray *)fetchOrder;
- // Set/return the fetch order used when supplying objects. See
- // EOAttributeOrdering.h for more information.
-
- - (void)setQualifier:(EOQualifier *)qualifier;
- - (EOQualifier *)qualifier;
- // Set/return the qualifier used when fetching objects. This allows an
- // EODatabaseDataSource to limit the scope of objects it supplies.
-
- - (void)setBeginsTransactionsAutomatically:(BOOL)yn;
- - (BOOL)beginsTransactionsAutomatically;
- // These methods control automatic transaction management. If enabled,
- // the channel will automatically start a transaction on the first
- // insert, update or remove, unless one is already in progress. If
- // disabled, the transactions must be controlled explicitly through the
- // database channel.
-
- - (EOQualifier *)qualifierForFetch;
- // Return the qualifier passed to the database channel when fetching
- // records. This is combination of the base qualifier and any
- // client qualifier (if any).
-
- - (void)setAuxiliaryQualifier:(EOQualifier *)newQualifier;
- - (EOQualifier *)auxiliaryQualifier;
-
- - (void)setFetchEnabled:(BOOL)yn;
- - (BOOL)isFetchEnabled;
-
- @end
-
- @interface EODatabaseDataSource (EODatabaseSharing)
-
- + (void)registerChannel:(EODatabaseChannel *)channel
- forRendezvousWithDatabaseName:(NSString *)aDatabaseName
- contextName:(NSString *)aContextName
- channelName:(NSString *)aChannelName;
- // Registers the channel, and its parent context and database in the
- // EODatabaseDataSource rendezvous dictionary. If a component is already
- // registered under the specified name, it is replaced with the new
- // component. A counter is associated with each named component. Each
- // time registerChannel... or an init method is invoked, the counter
- // associated with each of the names used by that method is incremented.
- // When an EODatabaseDataSource is dealloced, it decrements the counters
- // associated with any components that it rendezvous'ed with at init time.
- // The releaseObjectsWith... method also decrements the counters
- // associated with each of its name arguments. When the counter reaches
- // 0, its associated name and object are removed from the rendezvous
- // dictionary.
-
- + (void)releaseObjectsWithDatabaseName:(NSString *)aDatabaseName
- contextName:(NSString *)aContextName
- channelName:(NSString *)aChannelName;
- // Decrements the counter associated with each name and removes any
- // objects that are associated with names whose counter has the value of
- // 0.
-
- + (EODatabaseChannel *)databaseChannelWithDatabaseName:(NSString *)aDatabaseName
- contextName:(NSString *)aContextName
- channelName:(NSString *)aChannelName;
- // Returns the database channel registered under aDatabaseName,
- // aContextName, and aChannelName.
-
- @end
-
-