home *** CD-ROM | disk | FTP | other *** search
- // EODatabase.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>
-
- @class EODatabaseContext;
- @class EOModel;
- @class EOEntity;
- @class EOAdaptor;
- @class _EOUniqueTable;
-
- // An EODatabase represents a database server, and consequently encapsulates
- // all of the characteristics of that database, including its name, connection
- // information, and model. An EODatabase handles uniquing and snapshotting of
- // objects fetched from the database.
-
- @interface EODatabase:NSObject
- {
- NSMutableArray *_contexts;
- NSMutableArray *_contextRefs;
- EOAdaptor *_adaptor;
- _EOUniqueTable *_uniqueTable;
- struct {
- unsigned int uniquesObjects:1;
- unsigned int keepsSnapshots:1;
- unsigned int _RESERVED:30;
- } _flags;
- }
-
- - initWithModel:(EOModel *)model;
- // Calls [EOAdaptor adaptorWithModel:] and then [self initWithAdaptor:].
-
- - initWithAdaptor:(EOAdaptor *)adaptor;
- // Initializes a newly allocated EODatabase with adaptor as its adaptor.
- // Returns self. You must never associate more than one EODatabase with
- // a given adaptor.
-
- - (NSArray *)contexts;
- // Returns the EODatabaseContexts managing transaction scopes for the
- // database object.
-
- - (EOAdaptor *)adaptor;
- // Returns the EOAdaptor used by the EODatabase for communication with the
- // database server.
-
- - (BOOL)hasOpenChannels;
- // Returns YES if the database has any open channels, NO otherwise. See
- // -openChannel in EODatabaseChannel.h.
-
- - (void)setUniquesObjects:(BOOL)yn;
- - (BOOL)uniquesObjects;
- // These methods determine whether the database uniques objects fetched
- // from the database. The default is YES.
-
- - (void)setKeepsSnapshots:(BOOL)yn;
- - (BOOL)keepsSnapshots;
- // These methods determine whether the database keeps snapshots for
- // objects fetched from the database. An EODatabase keeps snapshots
- // across transactions. The default is YES.
-
- @end
-
-
- // The EOUniquing category defines methods for preventing multiple instances
- // of equivalent object from being fetched from the database. When a
- // database-layer object fetches an object and uniquing is turned on, the
- // object's primary key is checked against all other uniqued objects' primary
- // keys. If the key is found, the fetched object is released and the
- // previously uniqued object is returned.
- //
- // EOUniquing also includes methods for keeping snapshots of an object.
- // Snapshots are used when updating; see EODatabaseContext.h for a discussion
- // of how snapshots are used in updating.
-
-
- @interface EODatabase (EOUniquing)
-
- + (void)forgetObject:eo;
- // This removes eo from all EODatabase instances in the task.
-
- - (void)recordObject:eo primaryKey:(NSDictionary *)key
- snapshot:(NSDictionary *)snapshot;
- // If uniquing is turned on, records eo under the primary key. Also,
- // if snapshotting is turned on this method records the eo's snapshot.
-
- - (void)forgetObject:eo;
- // If uniquing is turned on, removes the eo associated with the
- // primary key from the uniquing table, and if snapshotting is turned on
- // the eo's snapshot is also destroyed.
-
- - (void)forgetAllObjects;
- // Removes all objects from the uniquing table and destroys all the
- // associated snapshots.
-
- - (NSDictionary *)snapshotForObject:eo;
- // Returns the snapshot assocated with eo, if there is one; else
- // returns nil.
-
- - objectForPrimaryKey:(NSDictionary *)key entity:(EOEntity *)entity;
- // Returns the unique eo for the given primary key and entity, or nil
- // if one can't be found.
-
- @end
-
-