home *** CD-ROM | disk | FTP | other *** search
- // EOModel.h
- // Copyright (c) 1994, NeXT Computer, Inc. All rights reserved.
-
- #import <foundation/NSArray.h>
- #import <foundation/NSData.h>
- #import <foundation/NSDictionary.h>
- #import <foundation/NSObject.h>
- #import <foundation/NSString.h>
-
- @class EOEntity;
-
- // An EOModel represents a mapping between a database model and a set of
- // classes based on the entity-relationship model. The model contains a
- // number of EOEntity objects representing the entities (tables) of the
- // database model. Each EOEntity object has a number of EOAttribute and
- // EORelationship objects representing the properties (columns or fields) of
- // the entity in the database model. See EOAttribute.h and EORelationship.h
- // for more information on attributes and relationships.
- //
- // An EOModel is specific to a particular database server, and can store
- // information needed to connect to that server as well as the name of an
- // adaptor bundle to load so that the Enterprise Objects Framework can
- // communicate with the database.
-
-
- @interface EOModel:NSObject
- {
- NSString *_name;
- NSString *_path;
- NSDictionary *_userDictionary;
- NSDictionary *_connectionDictionary;
- NSString *_adaptorName;
- NSMutableArray *_entities;
- NSMutableDictionary *_entitiesByName;
- void *_entitiesByClass;
- unsigned _extraRefCount;
- }
-
- + (NSString *)findPathForModelNamed:(NSString *)name;
- // Returns the file system path to the model of the specified name.
- // Name should not include the ".eomodel" file extension.
- // Searches for name in the application wrapper, ~/Library/Models,
- // /LocalLibrary/Models, and /NextModels, in that order. The returned
- // name is suitable for use in an -initWithContentsOfFile: message.
-
- - initWithName:(NSString *)name;
- // Initializes a newly allocated EOModel with name as its name. The
- // EOModel needs to have more information set before it's usable.
- // Returns self.
-
- - initWithPropertyList:propertyList;
- // Initializes a newly allocated EOModel from a property list
- // representation generated by -modelAsPropertyList.
-
- - initWithContentsOfFile:(NSString *)filename;
- // Initializes a newly allocated EOModel by reading the contents of
- // filename as a model archive. If the filename doesn't exist tries to
- // find the path using +findPathForModelNamed:.
-
- - modelAsPropertyList;
- // Returns the EOModel as a property list.
-
- - (NSString *)name;
- // Returns the name of the model.
-
- - (NSString *)path;
- // Returns the name of the model file used to create the EOModel. This
- // method may return nil if the model wasn't initialized from a file.
-
- - (NSArray *)entities;
- // Returns the EOModel's entities.
-
- - (EOEntity *)entityNamed:(NSString *)name;
- // Returns the entity with the given name, or nil if no such entity
- // exists.
-
- - (EOEntity *)entityForObject:object;
- // Returns the entity associated with object, whether object is an
- // instance of an Enterprise Object class, an instance of EOGenericRecord,
- // or a fault object. Returns nil if the object has no associated entity.
- // See EOGenericRecord.h and EOFault.h for more information.
-
- - (NSString *)adaptorName;
- // Returns the name of the adaptor for this model. This name can be used
- // with EOAdaptor's +adaptorWithName: method to create an adaptor.
-
- - (NSDictionary *)connectionDictionary;
- // Returns a dictionary containing information used to connect to the
- // database. See CONNECTING TO THE SERVER in EOAdaptor.h for more
- // information.
-
- - (NSDictionary *)userDictionary;
- // Returns a dictionary of user data. You can use this to store any
- // auxiliary information.
-
- - (NSArray *)referencesToProperty:property;
- // Returns an array of all properties in the model that reference
- // property, whether derived attributes, relationships that reference
- // property, and so on.
-
- @end
-
-
- @interface EOModel(EOModelEditing)
-
- - (BOOL)addEntity:(EOEntity *)entity;
- // Adds entity to the model. Returns YES if successful, NO if an entity
- // with the same name already exists in the model.
-
- - (void)removeEntityNamed:(NSString *)name;
- // Removes the entity with the given name.
-
- - (void)setAdaptorName:(NSString *)adaptorName;
- // Sets the name of the model's adaptor.
-
- - (void)setConnectionDictionary:(NSDictionary *)connectionDictionary;
- // Sets the dictionary containing information used to connect to the
- // database. See CONNECTING TO THE SERVER in EOAdaptor.h for more
- // information.
-
- - (BOOL)incorporateModel:(EOModel *)model;
- // Copies the contents of another model into this model. Returns YES if
- // successful, NO if any identically-named elements of the two models
- // differ.
-
- - (void)setUserDictionary:(NSDictionary *)dictionary;
- // Sets the dictionary of auxiliary data, which your application can use
- // for whatever it needs.
-
- @end
-
-