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

  1. // EOObjectStoreCoordinator.h
  2. // Copyright (c) 1995, NeXT Software, Inc. All rights reserved.
  3. //
  4. // EOObjectStoreCoordinator provides the abstraction of a single objects
  5. // store by coordinating the one or more CooperatingObjectStores.
  6. // For the basic ObjectStore methods, such as
  7. // objectsWithFetchSpecification:editingContext:, the coordinator forwards
  8. // the message to the appropriate CoorperatingObjectStore based on entity name.
  9. // For saveChangesInEditingContext:, the Coordinator guides its coorperating
  10. // object stores through a multi-pass save protocol in which each coorperating
  11. // object stores saves its own changes and forwards other changes on to other
  12. // object stores.  For example, if in its recordChangesInEditingContext: method
  13. // one store notices the removal of an object from an "owning" relationship, but
  14. // that object comes from another store, it should inform the other store by
  15. // passing the coordinator forwardPotentialDeleteForObject: message.
  16. //
  17.  
  18. #import <Foundation/Foundation.h>
  19. #import <EOControl/EOObjectStore.h>
  20. #import <EOControl/EODefines.h>
  21.  
  22. @class EOCooperatingObjectStore;
  23. @class EOQualifier;
  24.  
  25. @interface EOObjectStoreCoordinator:EOObjectStore
  26. {
  27.     NSMutableArray *_sources;
  28.     NSDictionary *_userInfo;
  29. }
  30.  
  31. - init;
  32.     // designated initializer.
  33.  
  34. - (void)addCooperatingObjectStore:(EOCooperatingObjectStore *)store;
  35.     // Adds an EOCooperatingObjectStore to the list of stores that need to be queried
  36.     // and notified about changes to EOs
  37.  
  38. - (void)removeCooperatingObjectStore:(EOCooperatingObjectStore *)store;
  39.     // Removes an EOCooperatingObjectStore from the list of stores that need to be queried
  40.     // and notified about changes to EOs
  41.  
  42. - (NSArray *)cooperatingObjectStores;
  43.     // Returns the array of objectStores currently held by the coordinator
  44.  
  45. - (void)forwardUpdateForObject:object changes:(NSDictionary *)changes;
  46.     // Communicates from one EOCooperatingObjectStore to another
  47.     // that certain changes need to be made to an object.
  48.     // For example, an insert of an object in a relationship property might
  49.     // require changing a foreign key property in an object owned by another
  50.     // store.
  51.  
  52. - (NSDictionary *)valuesForKeys:(NSArray *)keys object:object;
  53.     // Communicates with the appropriate EOCooperatingObjectStore to get
  54.     // values. This store might have some notion of a snapshot for the
  55.     // object that augments properties in the object itself. For instance,
  56.     // an EODatabaseContext stores foreign key properties for an object that
  57.     // may no be object properties.
  58.  
  59. - (EOCooperatingObjectStore *)objectStoreForGlobalID:(EOGlobalID *)gloablID;
  60.     // Returns the object store for the given global or nil if no object store
  61.     // can be found that responds YES to ownsGlobalID:.
  62.  
  63. - (EOCooperatingObjectStore *)objectStoreForObject:object;
  64.     // Returns the object store for the given global or nil if no object store
  65.     // can be found that responds YES to ownsObject:.
  66.  
  67. - (EOCooperatingObjectStore *)objectStoreForFetchSpecification:(EOFetchSpecification *)fetchSpecification;
  68.     // Returns the object store responsible for fetching objects with the given
  69.     // fetch specification, or nil if no object store can be found that responds
  70.     // YES to handlesFetchSpecification:.
  71.  
  72. - (NSDictionary *)userInfo;
  73. - (void)setUserInfo:(NSDictionary *)info;
  74.     // returns a state dictionary that other objects or categories can use
  75.     // to associate state with this coordinator.
  76.  
  77. + (void)setDefaultCoordinator:(EOObjectStoreCoordinator *)coordinator;
  78. + (id)defaultCoordinator;
  79.     // returns a shared instance EOObjectStoreCoordinator.
  80. @end
  81.  
  82. // Notifications:
  83. EOCONTROL_EXTERN NSString *EOCooperatingObjectStoreWasAdded;
  84. EOCONTROL_EXTERN NSString *EOCooperatingObjectStoreWasRemoved;
  85.  
  86. EOCONTROL_EXTERN NSString *EOCooperatingObjectStoreNeeded;
  87.     // called when a request is made which the coordinator cannot 
  88.     // service with any of its currently registered cooperating
  89.     // object stores.  The observer can call back to the coordinator
  90.     // to register an appropriate object store based on the info
  91.     // in the userInfo dictionary.
  92.     //     object = sending EOObjectStoreCoordinator
  93.     //     userInfo = {
  94.     //         // one of the following...
  95.     //         globalID = <globalID for operation>;
  96.     //         fetchSpecification = <fetchSpec for operation>;
  97.     //         object = <fetchSpec for operation>;
  98.     //     }
  99.  
  100. //
  101. // EOCooperatingObjectStore is an abstract class which defines an object that
  102. // can cooperate with other EOCooperatingObjectStores to manage data from several
  103. // distinct data sources when managed by an EOObjectStoreCoordinator.
  104. // Each CooperatingStore is given a list of changes to commit and can communicate
  105. // changes for other stores back through the StoreCoordinator.
  106. //
  107. @interface EOCooperatingObjectStore:EOObjectStore
  108. - (BOOL)ownsGlobalID:(EOGlobalID *)globalID;
  109.     // The store should return YES if is is the object store responsible for fetching
  110.     // and saving this object.
  111.  
  112. - (BOOL)ownsObject:(id)object;
  113.     // The store should return YES if is is the object store responsible for fetching
  114.     // and saving this object.
  115.  
  116. - (BOOL)handlesFetchSpecification:(EOFetchSpecification *)fetchSpecification;
  117.     // The store should return YES if is is the object store responsible for fetching
  118.     // objects described by the given fetch specification.
  119.  
  120. - (void)prepareForSaveWithCoordinator:(EOObjectStoreCoordinator *)coordinator editingContext:(EOEditingContext *)context;
  121.     // Notifies the EOCooperatingObjectStore that a multi-store save operation
  122.     // is beginning.  The store should now be prepared to receive any of the
  123.     // following messages:
  124.     //      recordChangesInEditingContext:
  125.     //      recordUpdateForObject:changes:
  126.     // Followed possibly by performChanges and then commitChanges or rollbackChanges.
  127.  
  128. - (void)recordChangesInEditingContext;
  129.     // Instructs the EOCooperatingObjectStores to examine the changed 
  130.     // objects in the context, record any database operations that need to 
  131.     // be performed, and notify the storage manager of any changes to be
  132.     // forwarded to other stores.
  133.  
  134. - (void)recordUpdateForObject:object changes:(NSDictionary *)changes;
  135.     // Used to communicate from one EOCooperatingObjectStore to another
  136.     // (via the EOObjectStoreCoordinator) that certain changes need to be 
  137.     // made to an object.
  138.     // For example, an insert of an object in a relationship property might
  139.     // require changing a foreign key property in an object owned by another
  140.     // store.
  141.  
  142. - (void)performChanges;
  143.     // Causes the EOCooperatingObjectStore to transmit any changes to it's underlying
  144.     // database. Raises an exception if an error occurs.
  145.  
  146. - (void)commitChanges;
  147. - (void)rollbackChanges;
  148.     // Causes the EOCooperatingObjectStore to either commit or rollback its changes
  149.     // to the underlying database.  If all participating stores return YES to
  150.     // performChanges, then commit is called.  Otherwise all stores are told to
  151.     // rollback. Raises an exception if an error occurs.
  152.  
  153. - (NSDictionary *)valuesForKeys:(NSArray *)keys object:object;
  154.     // Should return values held by the store that augment properties 
  155.     // in the object itself. For instance, an EODatabaseContext stores 
  156.     // foreign key properties for an object that may not be object properties.
  157. @end
  158.