home *** CD-ROM | disk | FTP | other *** search
- // EOModel.h
- // Copyright (c) 1994, NeXT Software, Inc. All rights reserved.
-
- #import <EOControl/EOControl.h>
- #import <EOAccess/EOModelGroup.h>
- #import <EOAccess/EOEntity.h>
- #import <EOAccess/EOAttribute.h>
- #import <EOAccess/EORelationship.h>
- #import <EOAccess/EOJoin.h>
- #import <EOAccess/EOPropertyListEncoding.h>
- #import <EOAccess/EODefines.h>
-
- @class EOEntity;
- @class EOModelGroup;
- @class EOStoredProcedure;
-
- // 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.
- //
- // Models can have relationships that reference other models in the same
- // model group. The other models may map to different databases and types
- // of servers.
-
- @interface EOModel:NSObject
- {
- EOModelGroup *_group;
- NSString *_name;
- NSString *_path;
- NSDictionary *_userInfo;
- NSDictionary *_connectionDictionary;
- NSString *_adaptorName;
- NSMutableDictionary *_entitiesByName;
- void *_entitiesByClass;
- NSMutableArray *_storedProcedures;
- NSArray *_entities;
- NSMutableDictionary *_subEntitiesCache;
- unsigned _extraRefCount;
- }
-
- - (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 *)entityNames;
- // Returns the names of EOModel's entities.
-
- - (EOEntity *)entityNamed:(NSString *)name;
- // Returns the entity with the given name, or nil if no such entity
- // exists.
-
- - (NSArray *)entities;
- // Returns an array with all the entities. This method will load every
- // entity, and in so doing will defeat the benefits of incremental model
- // loading.
-
- - (NSArray *)storedProcedureNames;
- // Returns the names of all the stored procedures.
-
- - (EOStoredProcedure *)storedProcedureNamed:(NSString *)name;
- // Returns the stored procedure with the given name.
-
- - (NSArray *)storedProcedures;
- // Returns a arrays of all the stored procedures.
- // This method will load every stored procedure, and in so doing will
- // defeat the benefits of incremental model loading.
-
- - (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 *)userInfo;
- // Returns a dictionary of user data. You can use this to store any
- // auxiliary information.
-
- - (EOModelGroup *)modelGroup;
- // Returns the modelGroup that this model is a part of.
-
- - (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.
- @end
-
- @interface EOModel(EOModelFileAccess)
- - initWithContentsOfFile:(NSString *)path;
- // Initializes a newly allocated EOModel by reading the contents of
- // filename as a model archive. Set the name and the path. Raise on error
-
- - (void)writeToFile:(NSString *)path;
- // Save the model in the directory specified by "path". The last component
- // in path should be the model name. Calling this method has the side
- // effect of setting the model name.Use the name to build the filename.
- // This method resets the current path. It raises on any error with prevents
- // the file from being written to disk.
- @end
-
- @interface EOModel(EOModelPropertyList) <EOPropertyListEncoding>
-
- - initWithTableOfContentsPropertyList:(NSDictionary *)tableOfContents path:(NSString *)path;
- // Initializes a model from its table of contents.
-
- - (void)encodeTableOfContentsIntoPropertyList:(NSMutableDictionary *)propertyList;
- // Encodes a model into its table of contents.
-
- @end
-
- @interface EOModel(EOModelEditing)
-
- - (void)setName:(NSString *)name;
- // Sets the name of the model.
-
- - (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.
-
- - (void)setUserInfo:(NSDictionary *)dictionary;
- // Sets the dictionary of auxiliary data, which your application can
- // use for whatever it needs.
-
- - (void)addEntity:(EOEntity *)entity;
- // Adds entity to the model. Could raise if an
- // entity with the same name already exists in the model.
-
- - (void)removeEntity:(EOEntity *)entity;
- // Removes the entity with the given name without performing any
- // referential integrity checking.
-
- - (void)addStoredProcedure:(EOStoredProcedure *)storedProcedure;
- // Adds the stored procedure to the model. Could raise if a
- // stored procedure with the same name already exists in the
- // model.
-
- - (void)removeStoredProcedure:(EOStoredProcedure *)storedProcedure;
- // Removes the stored procedure with the given name without checking if
- // an entity uses it.
-
- - (void)setModelGroup:(EOModelGroup *)group;
- // model group should not be changed after the model has bound to
- // other models in its group.
-
- - (void)loadAllModelObjects;
- // This method will load any EOEntities, EOStoredProcedures, and
- // EORelationships that have not yet been loaded from the .eomodeld
-
- - (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.
-
- - (NSArray *)externalModelsReferenced;
- // returns a list of the models referenced by this model
-
- @end
-
- @interface EOModel(EOModelBeautifier)
- - (void)beautifyNames;
- // Make the model name and all of its named components conform
- // to the Next naming style
- // NAME -> name, FIRST_NAME -> firstName
- @end
-
- // Notifications:
- EOACCESS_EXTERN NSString *EOEntityLoadedNotification;
- // Sent whenever an EOEntity is loaded into memory.
- // [notification object] is the newly loaded EOEntity.
-
-
-