home *** CD-ROM | disk | FTP | other *** search
- // EOEntity.h
- // Copyright (c) 1994, NeXT Computer, Inc. All rights reserved.
-
- #import "EOExpressionArray.h"
-
- #import <foundation/NSArray.h>
- #import <foundation/NSData.h>
- #import <foundation/NSDictionary.h>
- #import <foundation/NSObject.h>
- #import <foundation/NSString.h>
-
- @class EOAttribute;
- @class EOEntity;
- @class EORelationship;
- @class EOModel;
- @class EOQualifier;
-
- // An EOEntity describes a table, file or collection in a database, and
- // associates an internal name with an external name by which the table is
- // known to the database. An entity maintains an array of attributes and
- // another array of relationships.
- //
- // An EOEntity is associated with a specific class whose instances are used
- // to represent records (rows) from the database in applications using layers
- // at or above the database layer of the Enterprise Objects Framework. If an
- // EOEntity doesn't have a specific class associated with it, instances of
- // EOGenericRecord are created.
-
-
- @interface EOEntity:NSObject
- {
- NSString *_name;
- NSDictionary *_userDictionary;
- EOModel *_model;
- NSString *_externalName;
- NSString *_externalQuery;
- NSMutableArray *_attributes;
- NSMutableArray *_namesOfAttributesToSnapshot;
- NSMutableArray *_relationships;
- const char *_className;
- NSMutableArray *_classProperties;
- NSMutableArray *_classPropertyNames;
- NSMutableArray *_primaryKeyAttributeNames;
- NSMutableArray *_primaryKeyAttributes;
- NSMutableArray *_attributesUsedForLocking;
- NSMutableArray *_attributesToFetch;
- NSMutableArray *_keysToWrite;
- NSMutableArray *_propertiesToFault;
- id _propertyDictionaryInitializer;
- id _primaryKeyDictionaryInitializer;
- id _snapshotDictionaryInitializer;
- id _adaptorDictionaryInitializer;
- id _propertyToAdaptorRowSubsetMapping;
- id _snapshotToAdaptorRowSubsetMapping;
- struct {
- unsigned int isReadOnly:1;
- unsigned int goodCache:1;
- unsigned int hasToOneSelfRelationship:1;
- unsigned int extraRefCount:29;
- } _flags;
- }
-
- + (BOOL)isValidName:(NSString *)name;
- // Returns YES if name is a legal entity name and NO otherwise.
-
- - initWithName:(NSString *)name;
- // Initializes a newly allocated EOEntity with name as its internal name.
- // The EOEntity needs to have more information set before it's usable.
- // Returns self.
-
- - (NSString *)name;
- // Returns the internal name of the entity.
-
- - (EOModel *)model;
- // Returns the model that owns the entity.
-
- - (NSString *)externalName;
- // Returns the name of the entity as understood by the database server.
-
- - (NSString *)externalQuery;
- // Returns a query statement used for selecting rows from the entity. May
- // be nil.
-
- - (BOOL)isReadOnly;
- // Returns YES if the entity can't be modified, NO if it can.
-
- - (const char *)className;
- // The name of the class that is bound to the entity. When a row is
- // fetched for the entity by a database-level object, it's returned as an
- // instance of this class.
-
- - (EOQualifier *)qualifier;
- // Returns a qualifier for the entity that can be used in
- // EOAdaptorChannel's -selectAttributes:... method or EODatabaseChannel's
- // -selectObjectsDescribedByQualifier:... method. This qualifier will
- // select all rows for the entity.
-
- - (EOAttribute *)attributeNamed: (NSString *)attributeName;
- // Returns the attribute with the given name.
-
- - (NSArray *)attributes;
- // Returns all of the entity's attributes.
-
- - (EORelationship *)relationshipNamed: (NSString *)relationshipName;
- // Returns the relationship with the given name.
-
- - (NSArray *)relationships;
- // Returns all of the entity's relationships.
-
- - (NSArray *)classProperties;
- // Returns an array containing the properties that are bound to the
- // entity's class (so that instances of the class will be passed values
- // corresponding to those properties). This is a subset of the entity's
- // attributes and relationships.
-
- - (NSArray *)classPropertyNames;
- // An array containing the names of all the properties returned by
- // -classProperties.
-
- - (NSArray *)primaryKeyAttributes;
- // Returns an array containing the attributes that make up the primary
- // key for the entity.
-
- - (NSArray *)primaryKeyAttributeNames;
- // Returns an array containing the names of the attributes returned by
- // -primaryKeyAttributes.
-
- - (NSArray *)attributesUsedForLocking;
- // Returns an array containing the properties whose values must not be
- // different from a snapshot any time a row is updated (with an update
- // strategy other than EOUpdateWithNoLocking).
-
- - (NSDictionary *)primaryKeyForRow:(NSDictionary *)row;
- // Returns the primary key in dictionary form for a row belonging to the
- // entity.
-
- - (BOOL)isValidAttributeUsedForLocking:(EOAttribute *)anAttribute;
- // Returns NO if the attribute isn't an EOAttribute, if the EOAttribute
- // doesn't belong to this entity, or if the EOAttribute is derived.
- // Otherwise returns YES.
-
- - (BOOL)isValidPrimaryKeyAttribute: (EOAttribute *)anAttribute;
- // Returns NO if the attribute isn't an EOAttribute, if the EOAttribute
- // doesn't belong to this entity, or if the EOAttribute is derived.
- // Otherwise returns YES.
-
- - (BOOL)isValidClassProperty:aProp;
- // Returns NO if either the attribute isn't an EOAttribute or
- // EORelationship, or, if the property doesn't belong to this entity.
- // Otherwise returns YES.
-
- - (NSDictionary *)userDictionary;
- // Returns a dictionary of user data. You can use this to store any
- // auxiliary information.
-
- - (BOOL)referencesProperty:property;
- // True if any of the entity's attributes or relationships reference
- // property.
-
- - (NSMutableDictionary *)dictionaryForAdaptorRow;
- // Returns an empty autoreleased dictionary optimized for use with
- // rows that correspond to selects with this entity.
-
- @end
-
-
- @interface EOEntity(EOEntityEditing)
-
- - (BOOL)setClassProperties: (NSArray *)properties;
- // Sets the entity's class properties to EOAttributes and EORelationships
- // in properties. Returns YES on success, NO if any of the objects in the
- // array don't return YES to isValidClassProperty:.
-
- - (BOOL)setPrimaryKeyAttributes: (NSArray *)keys;
- // Sets the primary key attributes to the attributes in keys. Returns YES
- // on success, or NO if any object in the array don't return YES to
- // isValidPrimaryKeyAttribute:.
-
- - (BOOL)setAttributesUsedForLocking: (NSArray *)attributes;
- // Takes an array of EOAttributes. Fails if any of the objects in the
- // array don't return YES to isValidAttributeUsedForLocking:.
-
- - (BOOL)setName:(NSString *)name;
- // Sets the entity's name and returns YES on success, NO if name is in use
- // by another entity.
-
- - (void)setExternalName:(NSString *)name;
- // Sets the name of the entity as understood by the database server.
-
- - (void)setExternalQuery:(NSString *)query;
- // Sets the query statement used for selecting rows from the entity.
-
- - (void)setReadOnly:(BOOL)yn;
- // Sets whether the entity can be modified.
-
- - (BOOL)addAttribute:(EOAttribute *)attribute;
- // Adds attribute to the entity and returns YES on success, NO if
- // attribute's name is already in use by another attribute or
- // relationship.
-
- - (void)removeAttributeNamed:(NSString *)name;
- // Removes the attribute with the given name.
-
- - (BOOL)addRelationship:(EORelationship *)relationship;
- // Adds relationship to the entity and returns YES on success, NO if
- // attribute's name is already in use by another attribute or
- // relationship.
-
- - (void)removeRelationshipNamed:(NSString *)name;
- // Removes the relationship with the given name.
-
- - (void)setClassName:(const char *)name;
- // Sets the class name.
-
- - (void)setUserDictionary:(NSDictionary *)dictionary;
- // Sets the dictionary of auxiliary data, which your application can use
- // for whatever it needs.
-
- @end
-
-