home *** CD-ROM | disk | FTP | other *** search
- // EORelationship.h
- // Copyright (c) 1994, NeXT Computer, Inc. All rights reserved.
-
- #import "EOJoin.h"
-
- #import <foundation/NSArray.h>
- #import <foundation/NSData.h>
- #import <foundation/NSDictionary.h>
- #import <foundation/NSObject.h>
- #import <foundation/NSString.h>
-
- @class EOEntity;
- @class EOAttribute;
- @class EOExpressionArray;
-
- // An EORelationship describes an association between two entities in a
- // database. The assocation can be to-one or to-many, and is directional: no
- // inverse is implied. A relationship maintains an array of joins identifying
- // attributes from the related entities. See EOJoin.h for more information.
-
-
- @interface EORelationship:NSObject
- {
- NSString *_name;
- EOEntity *_entity;
- EOEntity *_destination;
- EOExpressionArray *_definitionArray;
- NSMutableArray *_joins;
- NSMutableDictionary *_sourceNames;
- NSMutableDictionary *_destinationNames;
- NSString *_proxyClassName;
- NSDictionary *_userDictionary;
- EOExpressionArray *_expressionArray;
- NSMutableArray *_flattenedForeignKeysAttributes;
- struct {
- unsigned int isToMany:1;
- unsigned int extraRefCount:31;
- } _flags;
- id _sourceRowToForeignKeyMapping;
- }
-
- + (BOOL)isValidName:(NSString *)name;
- // Returns YES if name is a legal relationship name and NO otherwise.
-
- - initWithName:(NSString *)name;
- // Initializes a newly allocated EORelationship with name as its internal
- // name. The EORelationship needs to have more information set before
- // it's usable. Returns self.
-
- - (NSString *)name;
- // Returns the internal name of the relationship.
-
- - (EOEntity *)entity;
- // Returns the source entity of the relationship.
-
- - (EOEntity *)destinationEntity;
- // Returns the destination entity of the relationship
-
- - (NSString *)definition;
- // A path containing relationships that defines a flattened relationship.
- // This may be something like "toAuthor.toPublisher".
-
- - (BOOL)isFlattened;
- // Returns YES if the relationship has a definition; that is, if the
- // relationship traverses more than two entities.
-
- - (BOOL)isToMany;
- // Returns YES if this is a one-to-many relationship, NO if it's a
- // one-to-one relationship.
-
- - (BOOL)isCompound;
- // Returns YES if this joins more than one pair of attributes, NO if it
- // joins only one.
-
- - (NSArray *)sourceAttributes;
- // Returns the source attributes of the relationship.
-
- - (NSArray *)destinationAttributes;
- // Returns the destination attributes of the relationship.
-
- - (NSArray *)joins;
- // Returns all joins used by relationship.
-
- - (NSArray *)componentRelationships;
- // Returns an array of sub-relationships making up a flattened
- // relationship. Returns nil if the relationship is not flattened.
-
- - (NSDictionary *)userDictionary;
- // Returns a dictionary of user data. Your application can use this data
- // for whatever it needs.
-
- - (BOOL)referencesProperty:property;
- // Returns YES if property is in the relationship's data path or is a join
- // attribute of the relationship, NO otherwise.
-
- @end
-
-
- @interface EORelationship(EORelationshipEditing)
-
- - (BOOL)setName:(NSString *)name;
- // Sets the relationship's name. Returns YES if successful, NO if name
- // is already in use by another attribute or relationship of the same
- // entity.
-
- - (void)setDefinition:(NSString *)definition;
- // Sets the definition of the relationship. This method will release
- // any joins and source/destination attributes that may be associated
- // with the relationship. This method will not function correctly if
- // the relationship's entity has not been set.
-
- - (void)setEntity:(EOEntity *)entity;
- // Sets the entity of the relationship. If the relationship is currently
- // owned by a different entity, this method will remove the relationship
- // from that entity. This method does not add the attribute to the new
- // entity. EOEntity's addRelationship: method invokes this method.
-
- - (BOOL)setToMany:(BOOL)yn;
- // Sets whether the relationship is one-to-many or one-to-one.
-
- - (BOOL)addJoin:(EOJoin *)join;
- // Adds a source/destination attribute pair to the relationship. Returns
- // YES if successful, NO otherwise.
-
- - (void)removeJoin:(EOJoin *)join;
- // Deletes a source/destination attribute pair from the relationship.
-
- - (void)setUserDictionary:(NSDictionary *)dictionary;
- // Sets the dictionary of auxiliary data, which your application can use
- // for whatever it needs.
-
- @end
-
-