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

  1. // EOModel.h
  2. // Copyright (c) 1994, NeXT Software, Inc. All rights reserved.
  3.  
  4. #import <EOControl/EOControl.h>
  5. #import <EOAccess/EOModelGroup.h>
  6. #import <EOAccess/EOEntity.h>
  7. #import <EOAccess/EOAttribute.h>
  8. #import <EOAccess/EORelationship.h>
  9. #import <EOAccess/EOJoin.h>
  10. #import <EOAccess/EOPropertyListEncoding.h>
  11. #import <EOAccess/EODefines.h>
  12.  
  13. @class EOEntity;
  14. @class EOModelGroup;
  15. @class EOStoredProcedure;
  16.  
  17. // An EOModel represents a mapping between a database model and a set of
  18. // classes based on the entity-relationship model.  The model contains a
  19. // number of EOEntity objects representing the entities (tables) of the
  20. // database model.  Each EOEntity object has a number of EOAttribute and
  21. // EORelationship objects representing the properties (columns or
  22. // fields) of the entity in the database model.  See EOAttribute.h and
  23. // EORelationship.h for more information on attributes and
  24. // relationships.
  25. //
  26. // An EOModel is specific to a particular database server, and can store
  27. // information needed to connect to that server as well as the name of
  28. // an adaptor bundle to load so that the Enterprise Objects Framework
  29. // can communicate with the database.
  30. //
  31. // Models can have relationships that reference other models in the same
  32. // model group. The other models may map to different databases and types
  33. // of servers.
  34.  
  35. @interface EOModel:NSObject
  36. {
  37.     EOModelGroup *_group;
  38.     NSString *_name;
  39.     NSString *_path;
  40.     NSDictionary *_userInfo;
  41.     NSDictionary *_connectionDictionary;
  42.     NSString *_adaptorName;
  43.     NSMutableDictionary *_entitiesByName;
  44.     void *_entitiesByClass;
  45.     NSMutableArray *_storedProcedures;
  46.     NSArray *_entities;
  47.     NSMutableDictionary *_subEntitiesCache;
  48.     unsigned _extraRefCount;
  49. }
  50.  
  51. - (NSString *)name;
  52.     // Returns the name of the model.
  53.  
  54. - (NSString *)path;
  55.     // Returns the name of the model file used to create the EOModel.
  56.     // This method may return nil if the model wasn't initialized from a
  57.     // file.
  58.  
  59. - (NSArray *)entityNames;
  60.     // Returns the names of EOModel's entities.
  61.  
  62. - (EOEntity *)entityNamed:(NSString *)name;
  63.     // Returns the entity with the given name, or nil if no such entity
  64.     // exists.
  65.  
  66. - (NSArray *)entities;
  67.     // Returns an array with all the entities. This method will load every
  68.     // entity, and in so doing will defeat the benefits of incremental model
  69.     // loading.
  70.  
  71. - (NSArray *)storedProcedureNames;
  72.     // Returns the names of all the stored procedures.
  73.  
  74. - (EOStoredProcedure *)storedProcedureNamed:(NSString *)name;
  75.     // Returns the stored procedure with the given name.
  76.  
  77. - (NSArray *)storedProcedures;
  78.     // Returns a arrays of all the stored procedures.
  79.     // This method will load every stored procedure, and in so doing will
  80.     // defeat the benefits of incremental model loading.
  81.  
  82. - (NSString *)adaptorName;
  83.     // Returns the name of the adaptor for this model.  This name can be
  84.     // used with EOAdaptor's +adaptorWithName: method to create an
  85.     // adaptor.
  86.  
  87. - (NSDictionary *)connectionDictionary;
  88.     // Returns a dictionary containing information used to connect to
  89.     // the database.  See CONNECTING TO THE SERVER in EOAdaptor.h for
  90.     // more information.
  91.  
  92. - (NSDictionary *)userInfo;
  93.     // Returns a dictionary of user data. You can use this to store any
  94.     // auxiliary information.
  95.  
  96. - (EOModelGroup *)modelGroup;
  97.     // Returns the modelGroup that this model is a part of.
  98.  
  99. - (EOEntity *)entityForObject:object;
  100.     // Returns the entity associated with object, whether object is an
  101.     // instance of an Enterprise Object class, an instance of
  102.     // EOGenericRecord, or a fault object.  Returns nil if the object
  103.     // has no associated entity.
  104. @end
  105.  
  106. @interface EOModel(EOModelFileAccess)
  107. - initWithContentsOfFile:(NSString *)path;
  108.     // Initializes a newly allocated EOModel by reading the contents of
  109.     // filename as a model archive. Set the name and the path. Raise on error
  110.  
  111. - (void)writeToFile:(NSString *)path;
  112.     // Save the model in the directory specified by "path". The last component
  113.     // in path should be the model name. Calling this method has the side
  114.     // effect of setting the model name.Use the name to build the filename.
  115.     // This method resets the current path. It raises on any error with prevents
  116.     // the file from being written to disk.
  117. @end
  118.  
  119. @interface EOModel(EOModelPropertyList) <EOPropertyListEncoding>
  120.  
  121. - initWithTableOfContentsPropertyList:(NSDictionary *)tableOfContents path:(NSString *)path;
  122.     // Initializes a model from its table of contents.
  123.  
  124. - (void)encodeTableOfContentsIntoPropertyList:(NSMutableDictionary *)propertyList;
  125.     // Encodes a model into its table of contents.
  126.  
  127. @end
  128.  
  129. @interface EOModel(EOModelEditing)
  130.  
  131. - (void)setName:(NSString *)name;
  132.     // Sets the name of the model.     
  133.  
  134. - (void)setAdaptorName:(NSString *)adaptorName;
  135.     // Sets the name of the model's adaptor.
  136.  
  137. - (void)setConnectionDictionary:(NSDictionary *)connectionDictionary;
  138.     // Sets the dictionary containing information used to connect to the
  139.     // database.  See CONNECTING TO THE SERVER in EOAdaptor.h for more
  140.     // information.
  141.  
  142. - (void)setUserInfo:(NSDictionary *)dictionary;
  143.     // Sets the dictionary of auxiliary data, which your application can
  144.     // use for whatever it needs.
  145.  
  146. - (void)addEntity:(EOEntity *)entity;
  147.     // Adds entity to the model.  Could raise if an
  148.     // entity with the same name already exists in the model.
  149.  
  150. - (void)removeEntity:(EOEntity *)entity;
  151.     // Removes the entity with the given name without performing any
  152.     // referential integrity checking.
  153.  
  154. - (void)addStoredProcedure:(EOStoredProcedure *)storedProcedure;
  155.     // Adds the stored procedure to the model. Could raise if a 
  156.     // stored procedure with the same name already exists in the
  157.     // model.
  158.  
  159. - (void)removeStoredProcedure:(EOStoredProcedure *)storedProcedure;
  160.     // Removes the stored procedure with the given name without checking if
  161.     // an entity uses it.
  162.  
  163. - (void)setModelGroup:(EOModelGroup *)group;
  164.     // model group should not be changed after the model has bound to
  165.     // other models in its group.
  166.  
  167. - (void)loadAllModelObjects;
  168.     // This method will load any EOEntities, EOStoredProcedures, and
  169.     // EORelationships that have not yet been loaded from the .eomodeld
  170.  
  171. - (NSArray *)referencesToProperty:property;
  172.     // Returns an array of all properties in the model that reference
  173.     // property, whether derived attributes, relationships that
  174.     // reference property, and so on.
  175.  
  176. - (NSArray *)externalModelsReferenced;
  177.     // returns a list of the models referenced by this model
  178.  
  179. @end
  180.  
  181. @interface EOModel(EOModelBeautifier)
  182. - (void)beautifyNames;
  183.     // Make the model name and all of its named components conform
  184.     // to the Next naming style
  185.     // NAME -> name, FIRST_NAME -> firstName
  186. @end
  187.  
  188. // Notifications:
  189. EOACCESS_EXTERN NSString *EOEntityLoadedNotification;
  190.     // Sent whenever an EOEntity is loaded into memory.
  191.     // [notification object] is the newly loaded EOEntity.
  192.  
  193.  
  194.