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

  1. // EODatabase.h
  2. // Copyright (c) 1994, NeXT Computer, Inc. All rights reserved.
  3.  
  4. #import <foundation/NSArray.h>
  5. #import <foundation/NSData.h>
  6. #import <foundation/NSDictionary.h>
  7. #import <foundation/NSObject.h>
  8. #import <foundation/NSString.h>
  9.  
  10. @class EODatabaseContext;
  11. @class EOModel;
  12. @class EOEntity;
  13. @class EOAdaptor;
  14. @class _EOUniqueTable;
  15.  
  16. // An EODatabase represents a database server, and consequently encapsulates
  17. // all of the characteristics of that database, including its name, connection
  18. // information, and model. An EODatabase handles uniquing and snapshotting of
  19. // objects fetched from the database.
  20.  
  21. @interface EODatabase:NSObject
  22. {
  23.     NSMutableArray *_contexts;
  24.     NSMutableArray *_contextRefs;
  25.     EOAdaptor *_adaptor;
  26.     _EOUniqueTable *_uniqueTable;
  27.     struct {
  28.     unsigned int uniquesObjects:1;
  29.     unsigned int keepsSnapshots:1;
  30.     unsigned int _RESERVED:30;
  31.     } _flags;
  32. }
  33.  
  34. - initWithModel:(EOModel *)model;
  35.     // Calls [EOAdaptor adaptorWithModel:] and then [self initWithAdaptor:].
  36.  
  37. - initWithAdaptor:(EOAdaptor *)adaptor;
  38.     // Initializes a newly allocated EODatabase with adaptor as its adaptor.
  39.     // Returns self.  You must never associate more than one EODatabase with
  40.     // a given adaptor.
  41.  
  42. - (NSArray *)contexts;
  43.     // Returns the EODatabaseContexts managing transaction scopes for the
  44.     // database object.
  45.  
  46. - (EOAdaptor *)adaptor;
  47.     // Returns the EOAdaptor used by the EODatabase for communication with the
  48.     // database server.
  49.  
  50. - (BOOL)hasOpenChannels;
  51.     // Returns YES if the database has any open channels, NO otherwise. See
  52.     // -openChannel in EODatabaseChannel.h.
  53.  
  54. - (void)setUniquesObjects:(BOOL)yn;
  55. - (BOOL)uniquesObjects;
  56.     // These methods determine whether the database uniques objects fetched
  57.     // from the database.  The default is YES.
  58.  
  59. - (void)setKeepsSnapshots:(BOOL)yn;
  60. - (BOOL)keepsSnapshots;
  61.     // These methods determine whether the database keeps snapshots for
  62.     // objects fetched from the database.  An EODatabase keeps snapshots
  63.     // across transactions.  The default is YES.
  64.  
  65. @end
  66.  
  67.  
  68. // The EOUniquing category defines methods for preventing multiple instances
  69. // of equivalent object from being fetched from the database.  When a
  70. // database-layer object fetches an object and uniquing is turned on, the
  71. // object's primary key is checked against all other uniqued objects' primary
  72. // keys.  If the key is found, the fetched object is released and the
  73. // previously uniqued object is returned.
  74. //
  75. // EOUniquing also includes methods for keeping snapshots of an object.
  76. // Snapshots are used when updating; see EODatabaseContext.h for a discussion
  77. // of how snapshots are used in updating.
  78.  
  79.  
  80. @interface EODatabase (EOUniquing)
  81.  
  82. + (void)forgetObject:eo;
  83.     // This removes eo from all EODatabase instances in the task.
  84.  
  85. - (void)recordObject:eo primaryKey:(NSDictionary *)key 
  86.     snapshot:(NSDictionary *)snapshot;
  87.     // If uniquing is turned on, records eo under the primary key.  Also,
  88.     // if snapshotting is turned on this method records the eo's snapshot.
  89.  
  90. - (void)forgetObject:eo;
  91.     // If uniquing is turned on, removes the eo associated with the
  92.     // primary key from the uniquing table, and if snapshotting is turned on
  93.     // the eo's snapshot is also destroyed.
  94.  
  95. - (void)forgetAllObjects;
  96.     // Removes all objects from the uniquing table and destroys all the
  97.     // associated snapshots.
  98.  
  99. - (NSDictionary *)snapshotForObject:eo;
  100.     // Returns the snapshot assocated with eo, if there is one; else
  101.     // returns nil.
  102.  
  103. - objectForPrimaryKey:(NSDictionary *)key entity:(EOEntity *)entity;
  104.     // Returns the unique eo for the given primary key and entity, or nil
  105.     // if one can't be found.
  106.  
  107. @end
  108.  
  109.