home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / OpenStepConversion / 3.3Headers / eoaccess / EODatabaseDataSource.h < prev    next >
Encoding:
Text File  |  1994-11-12  |  5.3 KB  |  133 lines

  1. // EODatabaseDataSource.h
  2. // Copyright (c) 1994, NeXT Computer, Inc. All rights reserved.
  3.  
  4. #import    "EODataSources.h"
  5.  
  6. #import <foundation/NSArray.h>
  7. #import <foundation/NSData.h>
  8. #import <foundation/NSDictionary.h>
  9. #import <foundation/NSObject.h>
  10. #import <foundation/NSString.h>
  11.  
  12. @class EODatabaseChannel;
  13. @class EOQualifier;
  14. @class EOEntity;
  15.  
  16.  
  17. // An EODatabaseDataSource is a data source that fetches objects from and
  18. // saves objects to a database.  It supports the EODataSources,
  19. // EOMasterDataSources, and EORollbackDataSources protocols, and adds
  20. // methods of its own for limiting the objects fetched as well as determining
  21. // the order they're fetched.
  22.  
  23.  
  24. @interface EODatabaseDataSource:NSObject <EOMasterDataSources, EOQualifiableDataSources, EORollbackDataSources>
  25. {
  26.     EOQualifier *auxiliaryQualifier;
  27.     EODatabaseChannel *channel;
  28.     NSArray *fetchOrder;
  29.     EOQualifier *qualifier;
  30.     NSString *databaseName;
  31.     NSString *contextName;
  32.     NSString *channelName;
  33.     struct {
  34.     unsigned int autoTransaction:1;
  35.     unsigned int autoTransactionsEnabled:1;
  36.     unsigned int connected:1;
  37.     unsigned int fetchEnabled:1;
  38.     unsigned int _RESERVED:28;
  39.     } _flags;
  40. }
  41.  
  42. - initWithDatabaseChannel:(EODatabaseChannel *)aChannel
  43.     entityNamed:(NSString *)anEntityName;
  44.     // Initializes a newly allocated EODatabaseDataSource with aChannel and
  45.     // an entity in the EODatabase's model named anEntityName.  This is the
  46.     // primitive initializer for EODatabaseDataSource objects.
  47.  
  48. - initWithModelName:(NSString *)aModelName
  49.     entityName:(NSString *)anEntityName databaseName:(NSString *)aDatabaseName
  50.     contextName:(NSString *)aContextName channelName:(NSString *)aChannelName;
  51.     // This method is used by IB to initialize an EODatabaseDataSource so that
  52.     // it can share models, EODatabases, EODatabaseContexts, and
  53.     // EODatabaseChannels with other EODatabaseDataSources.  After finding or
  54.     // creating what it needs, it calls initWithDatabaseChannel:entityNamed:.
  55.  
  56. - initWithModelName:(NSString *)aModelName entityName:(NSString *)anEntityName;
  57.     // A convenience for
  58.     // [dataSource initWithModelName:aModelName entityName:anEntityName
  59.     //     databaseName:nil contextName:nil channelName:nil]
  60.     
  61. - (EOEntity *)entity;
  62.     // Returns the root entity of the EODatabaseDataSource.  The objects it
  63.     // supplies are fetched for this entity.
  64.  
  65. - (EODatabaseChannel *)databaseChannel;
  66.     // Returns the data source's connection to the database server.
  67.  
  68. - (void)setFetchOrder:(NSArray *)fetchOrder;
  69. - (NSArray *)fetchOrder;
  70.     // Set/return the fetch order used when supplying objects.  See
  71.     // EOAttributeOrdering.h for more information.
  72.  
  73. - (void)setQualifier:(EOQualifier *)qualifier;
  74. - (EOQualifier *)qualifier;
  75.     // Set/return the qualifier used when fetching objects.  This allows an
  76.     // EODatabaseDataSource to limit the scope of objects it supplies.
  77.  
  78. - (void)setBeginsTransactionsAutomatically:(BOOL)yn;
  79. - (BOOL)beginsTransactionsAutomatically;
  80.     // These methods control automatic transaction management. If enabled,
  81.     // the channel will automatically start a transaction on the first
  82.     // insert, update or remove, unless one is already in progress.  If
  83.     // disabled, the transactions must be controlled explicitly through the
  84.     // database channel.
  85.  
  86. - (EOQualifier *)qualifierForFetch;
  87.     // Return the qualifier passed to the database channel when fetching
  88.     // records.  This is combination of the base qualifier and any 
  89.     // client qualifier (if any).
  90.     
  91. - (void)setAuxiliaryQualifier:(EOQualifier *)newQualifier;
  92. - (EOQualifier *)auxiliaryQualifier;
  93.  
  94. - (void)setFetchEnabled:(BOOL)yn;
  95. - (BOOL)isFetchEnabled;
  96.  
  97. @end
  98.  
  99. @interface EODatabaseDataSource (EODatabaseSharing)
  100.  
  101. + (void)registerChannel:(EODatabaseChannel *)channel
  102.     forRendezvousWithDatabaseName:(NSString *)aDatabaseName
  103.     contextName:(NSString *)aContextName
  104.     channelName:(NSString *)aChannelName;
  105.     // Registers the channel, and its parent context and database in the
  106.     // EODatabaseDataSource rendezvous dictionary.  If a component is already
  107.     // registered under the specified name, it is replaced with the new
  108.     // component.  A counter is associated with each named component.  Each
  109.     // time registerChannel...  or an init method is invoked, the counter
  110.     // associated with each of the names used by that method is incremented.
  111.     // When an EODatabaseDataSource is dealloced, it decrements the counters
  112.     // associated with any components that it rendezvous'ed with at init time.
  113.     // The releaseObjectsWith...  method also decrements the counters
  114.     // associated with each of its name arguments.  When the counter reaches
  115.     // 0, its associated name and object are removed from the rendezvous
  116.     // dictionary.
  117.     
  118. + (void)releaseObjectsWithDatabaseName:(NSString *)aDatabaseName
  119.     contextName:(NSString *)aContextName
  120.     channelName:(NSString *)aChannelName;
  121.     // Decrements the counter associated with each name and removes any
  122.     // objects that are associated with names whose counter has the value of
  123.     // 0.
  124.     
  125. + (EODatabaseChannel *)databaseChannelWithDatabaseName:(NSString *)aDatabaseName
  126.     contextName:(NSString *)aContextName
  127.     channelName:(NSString *)aChannelName;
  128.     // Returns the database channel registered under aDatabaseName,
  129.     // aContextName, and aChannelName.
  130.  
  131. @end
  132.  
  133.