home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / OpenStepConversion / 3.3Headers / eoaccess / EORelationship.h < prev    next >
Encoding:
Text File  |  1994-12-06  |  4.4 KB  |  134 lines

  1. // EORelationship.h
  2. // Copyright (c) 1994, NeXT Computer, Inc. All rights reserved. 
  3.  
  4. #import "EOJoin.h"
  5.  
  6. #import <foundation/NSArray.h>
  7. #import <foundation/NSData.h>
  8. #import <foundation/NSDictionary.h>
  9. #import <foundation/NSObject.h>
  10. #import <foundation/NSString.h>
  11.  
  12. @class EOEntity;
  13. @class EOAttribute;
  14. @class EOExpressionArray;
  15.  
  16. // An EORelationship describes an association between two entities in a
  17. // database.  The assocation can be to-one or to-many, and is directional: no
  18. // inverse is implied.  A relationship maintains an array of joins identifying
  19. // attributes from the related entities.  See EOJoin.h for more information.
  20.  
  21.  
  22. @interface EORelationship:NSObject
  23. {
  24.     NSString *_name;
  25.     EOEntity *_entity;
  26.     EOEntity *_destination;
  27.     EOExpressionArray *_definitionArray;
  28.     NSMutableArray *_joins;
  29.     NSMutableDictionary *_sourceNames;
  30.     NSMutableDictionary *_destinationNames;
  31.     NSString *_proxyClassName;
  32.     NSDictionary *_userDictionary;
  33.     EOExpressionArray *_expressionArray;
  34.     NSMutableArray *_flattenedForeignKeysAttributes;
  35.     struct {
  36.     unsigned int isToMany:1;
  37.     unsigned int extraRefCount:31;
  38.     } _flags;
  39.     id _sourceRowToForeignKeyMapping;
  40. }
  41.  
  42. + (BOOL)isValidName:(NSString *)name;
  43.     // Returns YES if name is a legal relationship name and NO otherwise.
  44.     
  45. - initWithName:(NSString *)name;
  46.     // Initializes a newly allocated EORelationship with name as its internal
  47.     // name.  The EORelationship needs to have more information set before
  48.     // it's usable.  Returns self.
  49.  
  50. - (NSString *)name;
  51.      // Returns the internal name of the relationship.
  52.  
  53. - (EOEntity *)entity;
  54.     // Returns the source entity of the relationship.
  55.  
  56. - (EOEntity *)destinationEntity;
  57.     // Returns the destination entity of the relationship
  58.  
  59. - (NSString *)definition;
  60.     // A path containing relationships that defines a flattened relationship.
  61.     // This may be something like "toAuthor.toPublisher". 
  62.  
  63. - (BOOL)isFlattened;
  64.     // Returns YES if the relationship has a definition; that is, if the
  65.     // relationship traverses more than two entities. 
  66.  
  67. - (BOOL)isToMany;
  68.     // Returns YES if this is a one-to-many relationship, NO if it's a
  69.     // one-to-one relationship.
  70.  
  71. - (BOOL)isCompound;
  72.     // Returns YES if this joins more than one pair of attributes, NO if it
  73.     // joins only one.
  74.  
  75. - (NSArray *)sourceAttributes;
  76.     // Returns the source attributes of the relationship.
  77.  
  78. - (NSArray *)destinationAttributes;
  79.     // Returns the destination attributes of the relationship.
  80.  
  81. - (NSArray *)joins;
  82.     // Returns all joins used by relationship.
  83.  
  84. - (NSArray *)componentRelationships;
  85.     // Returns an array of sub-relationships making up a flattened
  86.     // relationship.  Returns nil if the relationship is not flattened.
  87.  
  88. - (NSDictionary *)userDictionary;
  89.     // Returns a dictionary of user data.  Your application can use this data
  90.     // for whatever it needs.
  91.  
  92. - (BOOL)referencesProperty:property;
  93.     // Returns YES if property is in the relationship's data path or is a join
  94.     // attribute of the relationship, NO otherwise.
  95.  
  96. @end
  97.  
  98.  
  99. @interface EORelationship(EORelationshipEditing)
  100.  
  101. - (BOOL)setName:(NSString *)name;
  102.     // Sets the relationship's name.  Returns YES if successful, NO if name
  103.     // is already in use by another attribute or relationship of the same
  104.     // entity.
  105.  
  106. - (void)setDefinition:(NSString *)definition;
  107.     // Sets the definition of the relationship. This method will release 
  108.     // any joins and source/destination attributes that may be associated
  109.     // with the relationship. This method will not function correctly if
  110.     // the relationship's entity has not been set.
  111.     
  112. - (void)setEntity:(EOEntity *)entity;
  113.     // Sets the entity of the relationship. If the relationship is currently
  114.     // owned by a different entity, this method will remove the relationship
  115.     // from that entity. This method does not add the attribute to the new
  116.     // entity. EOEntity's addRelationship: method invokes this method.
  117.  
  118. - (BOOL)setToMany:(BOOL)yn;
  119.     // Sets whether the relationship is one-to-many or one-to-one.
  120.  
  121. - (BOOL)addJoin:(EOJoin *)join;
  122.     // Adds a source/destination attribute pair to the relationship.  Returns
  123.     // YES if successful, NO otherwise.
  124.  
  125. - (void)removeJoin:(EOJoin *)join;
  126.     // Deletes a source/destination attribute pair from the relationship.
  127.  
  128. - (void)setUserDictionary:(NSDictionary *)dictionary;
  129.     // Sets the dictionary of auxiliary data, which your application can use
  130.     // for whatever it needs.
  131.  
  132. @end
  133.  
  134.