home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / OpenStepConversion / 3.3Headers / eoaccess / EOModel.h < prev    next >
Encoding:
Text File  |  1994-10-28  |  4.8 KB  |  132 lines

  1. // EOModel.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 EOEntity;
  11.  
  12. // An EOModel represents a mapping between a database model and a set of
  13. // classes based on the entity-relationship model.  The model contains a
  14. // number of EOEntity objects representing the entities (tables) of the
  15. // database model.  Each EOEntity object has a number of EOAttribute and
  16. // EORelationship objects representing the properties (columns or fields) of
  17. // the entity in the database model.  See EOAttribute.h and EORelationship.h
  18. // for more information on attributes and relationships.
  19. //
  20. // An EOModel is specific to a particular database server, and can store
  21. // information needed to connect to that server as well as the name of an
  22. // adaptor bundle to load so that the Enterprise Objects Framework can
  23. // communicate with the database.
  24.  
  25.  
  26. @interface EOModel:NSObject
  27. {
  28.     NSString *_name;
  29.     NSString *_path;
  30.     NSDictionary *_userDictionary;
  31.     NSDictionary *_connectionDictionary;
  32.     NSString *_adaptorName;
  33.     NSMutableArray *_entities;
  34.     NSMutableDictionary *_entitiesByName;
  35.     void *_entitiesByClass;
  36.     unsigned _extraRefCount;
  37. }
  38.  
  39. + (NSString *)findPathForModelNamed:(NSString *)name;
  40.     // Returns the file system path to the model of the specified name.
  41.     // Name should not include the ".eomodel" file extension.
  42.     // Searches for name in the application wrapper, ~/Library/Models,
  43.     // /LocalLibrary/Models, and /NextModels, in that order.  The returned
  44.     // name is suitable for use in an -initWithContentsOfFile: message.
  45.  
  46. - initWithName:(NSString *)name;
  47.     // Initializes a newly allocated EOModel with name as its name.  The
  48.     // EOModel needs to have more information set before it's usable.
  49.     // Returns self.
  50.  
  51. - initWithPropertyList:propertyList;
  52.     // Initializes a newly allocated EOModel from a property list
  53.     // representation generated by -modelAsPropertyList.
  54.  
  55. - initWithContentsOfFile:(NSString *)filename;
  56.     // Initializes a newly allocated EOModel by reading the contents of
  57.     // filename as a model archive.  If the filename doesn't exist tries to
  58.     // find the path using +findPathForModelNamed:.
  59.  
  60. - modelAsPropertyList;
  61.     // Returns the EOModel as a property list.
  62.  
  63. - (NSString *)name;
  64.     // Returns the name of the model.
  65.  
  66. - (NSString *)path;
  67.     // Returns the name of the model file used to create the EOModel.  This
  68.     // method may return nil if the model wasn't initialized from a file.
  69.  
  70. - (NSArray *)entities;
  71.     // Returns the EOModel's entities.
  72.  
  73. - (EOEntity *)entityNamed:(NSString *)name;
  74.     // Returns the entity with the given name, or nil if no such entity
  75.     // exists.
  76.  
  77. - (EOEntity *)entityForObject:object;
  78.     // Returns the entity associated with object, whether object is an
  79.     // instance of an Enterprise Object class, an instance of EOGenericRecord,
  80.     // or a fault object.  Returns nil if the object has no associated entity.
  81.     // See EOGenericRecord.h and EOFault.h for more information.
  82.  
  83. - (NSString *)adaptorName;
  84.     // Returns the name of the adaptor for this model.  This name can be used
  85.     // with EOAdaptor's +adaptorWithName: method to create an adaptor.
  86.  
  87. - (NSDictionary *)connectionDictionary;
  88.     // Returns a dictionary containing information used to connect to the
  89.     // database.  See CONNECTING TO THE SERVER in EOAdaptor.h for more
  90.     // information.
  91.  
  92. - (NSDictionary *)userDictionary;
  93.     // Returns a dictionary of user data. You can use this to store any
  94.     // auxiliary information.
  95.  
  96. - (NSArray *)referencesToProperty:property; 
  97.     // Returns an array of all properties in the model that reference
  98.     // property, whether derived attributes, relationships that reference
  99.     // property, and so on.
  100.  
  101. @end
  102.  
  103.  
  104. @interface EOModel(EOModelEditing)
  105.  
  106. - (BOOL)addEntity:(EOEntity *)entity;
  107.     // Adds entity to the model.  Returns YES if successful, NO if an entity
  108.     // with the same name already exists in the model.
  109.  
  110. - (void)removeEntityNamed:(NSString *)name;
  111.     // Removes the entity with the given name.
  112.  
  113. - (void)setAdaptorName:(NSString *)adaptorName;
  114.     // Sets the name of the model's adaptor.
  115.  
  116. - (void)setConnectionDictionary:(NSDictionary *)connectionDictionary;
  117.     // Sets the dictionary containing information used to connect to the
  118.     // database.  See CONNECTING TO THE SERVER in EOAdaptor.h for more
  119.     // information.
  120.  
  121. - (BOOL)incorporateModel:(EOModel *)model;
  122.     // Copies the contents of another model into this model.  Returns YES if
  123.     // successful, NO if any identically-named elements of the two models
  124.     // differ.
  125.  
  126. - (void)setUserDictionary:(NSDictionary *)dictionary;
  127.     // Sets the dictionary of auxiliary data, which your application can use
  128.     // for whatever it needs.
  129.  
  130. @end
  131.  
  132.