home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / EODEV.Z / EODatabase.h < prev    next >
Encoding:
Text File  |  1996-09-09  |  3.6 KB  |  100 lines

  1. // EODatabase.h
  2. // Copyright (c) 1994, NeXT Software, Inc. All rights reserved.
  3.  
  4. #import <EOControl/EOControl.h>
  5. #import <EOAccess/EODefines.h>
  6.  
  7. @class EODatabaseContext;
  8. @class EOModel;
  9. @class EOEntity;
  10. @class EOAdaptor;
  11. @class EOEditingContext;
  12. @class EOGlobalID;
  13.  
  14. // Exceptions raised by EODatabase layer when errors occur during DBMS interactions.
  15. EOACCESS_EXTERN NSString *EOGeneralDatabaseException;
  16.  
  17. /* An EODatabase represents a database server. It contains a list of databaseContexts that are connected to this server, a list of models which describe the server's schema, an adaptor which is is capable of communicating with the server and a set of snapshots representing the state of all objects stored in this server */
  18.  
  19. @interface EODatabase:NSObject
  20. {
  21.     NSMutableArray *_registeredContexts;
  22.     EOAdaptor *_adaptor;
  23.     NSMutableDictionary *_snapshots;
  24.     NSMutableArray *_models;
  25. }
  26.  
  27. - initWithAdaptor:(EOAdaptor *)adaptor;
  28.     // Initializes a newly allocated EODatabase with adaptor as its adaptor.
  29.     // Returns self.  You must never associate more than one EODatabase with
  30.     // a given adaptor instance.
  31.  
  32. - initWithModel:(EOModel *)model;
  33.     // Calls [EOAdaptor adaptorWithModel:] and then [self initWithAdaptor:]
  34.     // and [self addModel:]
  35.  
  36. - (NSArray *)registeredContexts;
  37.     // Returns an array containing all contexts that have been registered for
  38.     // use with this database;
  39.  
  40. - (void)registerContext:(EODatabaseContext *)context;
  41. - (void)unregisterContext:(EODatabaseContext *)context;
  42.     // Registers or unregisters a channel with a EODatabaseContext. Normally,
  43.     // these methods are called by [EODatabaseContext initWithDatabaseContext:]
  44.     // and [EODatabaseContext dealloc] respectively.
  45.  
  46. - (EOAdaptor *)adaptor;
  47.     // Returns the EOAdaptor instance used by the EODatabase for communication
  48.     // with the database server.
  49.  
  50. // Model list support
  51. - (void)addModel:(EOModel *)model;
  52. - (void)removeModel:(EOModel *)model;
  53. - (BOOL)addModelIfCompatible:(EOModel *)model;
  54.     // Returns YES if model already added.  If not, and this model specifies
  55.     // the same adaptor name as the database's adaptor and the adaptor responds
  56.     // YES to canServiceModel:, adds it and returns YES.
  57.     // Otherwise returns NO.
  58.  
  59. - (NSArray *)models;
  60.     // Returns the list of models held by this EODatabase.
  61.  
  62. - (EOEntity *)entityNamed:(NSString *)entityName;
  63.     // Forwards the entityNamed: method to each model in the model list and returns
  64.     // the first entity found with entityName. Returns nil if non is found.
  65.  
  66. - (EOEntity *)entityForObject:(id)object;
  67.     // Forwards the entityForObject: method to each model in the model list and returns
  68.     // the first entity found. Returns nil if non is found.
  69. @end
  70.  
  71.  
  72. // The EOUniquing category defines methods for recording and forgetting snapshots
  73. // of an object based on the objects globalID
  74.  
  75. @interface EODatabase (EOUniquing)
  76.  
  77. - (void)recordSnapshot:(NSDictionary *)snapshot forGlobalID:(EOGlobalID *)gid;
  78.     // Records the snapshot for the globalID.
  79.  
  80. - (NSDictionary *)snapshotForGlobalID:(EOGlobalID *)gid;
  81.     // Returns the snapshot assocated with the GlobalID if there is one;
  82.     // else returns nil.
  83.  
  84. - (void)forgetSnapshotForGlobalID:(EOGlobalID *)gid;
  85.     // Remove the snapshot from snapshot table
  86.  
  87. - (void)forgetSnapshotsForGlobalIDs:(NSArray *)array;
  88.     // Removes each snapshot from snapshot table
  89.  
  90. - (void)forgetAllSnapshots;
  91.     // Removes all snapshots from the snapshot table.
  92.  
  93. - (void)recordSnapshots:(NSDictionary *)snapshots;
  94.     // record a bunch of snapshots from a dictionary keyed by Global ID
  95.  
  96. - (NSDictionary *)snapshots;
  97.     // returns dictionary of snapshots keyed by GlobalID
  98. @end
  99.  
  100.