home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / OpenStepConversion / 3.3Headers / eoaccess / EOEntity.h < prev    next >
Encoding:
Text File  |  1994-11-29  |  7.8 KB  |  221 lines

  1. // EOEntity.h
  2. // Copyright (c) 1994, NeXT Computer, Inc.  All rights reserved. 
  3.  
  4. #import "EOExpressionArray.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 EOAttribute;
  13. @class EOEntity;
  14. @class EORelationship;
  15. @class EOModel;
  16. @class EOQualifier;
  17.  
  18. // An EOEntity describes a table, file or collection in a database, and
  19. // associates an internal name with an external name by which the table is
  20. // known to the database.  An entity maintains an array of attributes and
  21. // another array of relationships.
  22. //
  23. // An EOEntity is associated with a specific class whose instances are used
  24. // to represent records (rows) from the database in applications using layers
  25. // at or above the database layer of the Enterprise Objects Framework.  If an
  26. // EOEntity doesn't have a specific class associated with it, instances of
  27. // EOGenericRecord are created.
  28.  
  29.  
  30. @interface EOEntity:NSObject
  31. {
  32.     NSString *_name;
  33.     NSDictionary *_userDictionary;
  34.     EOModel *_model;
  35.     NSString *_externalName;
  36.     NSString *_externalQuery;
  37.     NSMutableArray *_attributes;
  38.     NSMutableArray *_namesOfAttributesToSnapshot;
  39.     NSMutableArray *_relationships;
  40.     const char *_className;
  41.     NSMutableArray *_classProperties;
  42.     NSMutableArray *_classPropertyNames;
  43.     NSMutableArray *_primaryKeyAttributeNames;
  44.     NSMutableArray *_primaryKeyAttributes;
  45.     NSMutableArray *_attributesUsedForLocking;
  46.     NSMutableArray *_attributesToFetch;
  47.     NSMutableArray *_keysToWrite;
  48.     NSMutableArray *_propertiesToFault;
  49.     id _propertyDictionaryInitializer;
  50.     id _primaryKeyDictionaryInitializer;
  51.     id _snapshotDictionaryInitializer;
  52.     id _adaptorDictionaryInitializer;
  53.     id _propertyToAdaptorRowSubsetMapping;
  54.     id _snapshotToAdaptorRowSubsetMapping;
  55.     struct {
  56.     unsigned int isReadOnly:1;
  57.     unsigned int goodCache:1;
  58.     unsigned int hasToOneSelfRelationship:1;
  59.     unsigned int extraRefCount:29;
  60.     } _flags;
  61. }
  62.  
  63. + (BOOL)isValidName:(NSString *)name;
  64.     // Returns YES if name is a legal entity name and NO otherwise.
  65.     
  66. - initWithName:(NSString *)name;
  67.     // Initializes a newly allocated EOEntity with name as its internal name.
  68.     // The EOEntity needs to have more information set before it's usable.
  69.     // Returns self.
  70.  
  71. - (NSString *)name;
  72.     // Returns the internal name of the entity.
  73.  
  74. - (EOModel *)model;
  75.     // Returns the model that owns the entity.
  76.  
  77. - (NSString *)externalName;
  78.     // Returns the name of the entity as understood by the database server.
  79.  
  80. - (NSString *)externalQuery;
  81.     // Returns a query statement used for selecting rows from the entity.  May
  82.     // be nil.
  83.  
  84. - (BOOL)isReadOnly;
  85.     // Returns YES if the entity can't be modified, NO if it can.
  86.  
  87. - (const char *)className; 
  88.     // The name of the class that is bound to the entity.  When a row is
  89.     // fetched for the entity by a database-level object, it's returned as an
  90.     // instance of this class.
  91.  
  92. - (EOQualifier *)qualifier;
  93.     // Returns a qualifier for the entity that can be used in
  94.     // EOAdaptorChannel's -selectAttributes:...  method or EODatabaseChannel's
  95.     // -selectObjectsDescribedByQualifier:...  method.  This qualifier will
  96.     // select all rows for the entity.
  97.  
  98. - (EOAttribute *)attributeNamed: (NSString *)attributeName;
  99.     // Returns the attribute with the given name.
  100.  
  101. - (NSArray *)attributes;
  102.     // Returns all of the entity's attributes.
  103.  
  104. - (EORelationship *)relationshipNamed: (NSString *)relationshipName;
  105.     // Returns the relationship with the given name.
  106.  
  107. - (NSArray *)relationships;
  108.     // Returns all of the entity's relationships.
  109.  
  110. - (NSArray *)classProperties;
  111.     // Returns an array containing the properties that are bound to the
  112.     // entity's class (so that instances of the class will be passed values
  113.     // corresponding to those properties).  This is a subset of the entity's
  114.     // attributes and relationships.
  115.  
  116. - (NSArray *)classPropertyNames;
  117.     // An array containing the names of all the properties returned by
  118.     // -classProperties.
  119.  
  120. - (NSArray *)primaryKeyAttributes;
  121.     // Returns an array containing the attributes that make up the primary
  122.     // key for the entity.
  123.  
  124. - (NSArray *)primaryKeyAttributeNames;
  125.     // Returns an array containing the names of the attributes returned by
  126.     // -primaryKeyAttributes.
  127.  
  128. - (NSArray *)attributesUsedForLocking;
  129.     // Returns an array containing the properties whose values must not be
  130.     // different from a snapshot any time a row is updated (with an update
  131.     // strategy other than EOUpdateWithNoLocking).
  132.  
  133. - (NSDictionary *)primaryKeyForRow:(NSDictionary *)row;
  134.     // Returns the primary key in dictionary form for a row belonging to the
  135.     // entity.
  136.  
  137. - (BOOL)isValidAttributeUsedForLocking:(EOAttribute *)anAttribute;
  138.     // Returns NO if the attribute isn't an EOAttribute, if the EOAttribute
  139.     // doesn't belong to this entity, or if the EOAttribute is derived.
  140.     // Otherwise returns YES.
  141.  
  142. - (BOOL)isValidPrimaryKeyAttribute: (EOAttribute *)anAttribute;
  143.     // Returns NO if the attribute isn't an EOAttribute, if the EOAttribute
  144.     // doesn't belong to this entity, or if the EOAttribute is derived.
  145.     // Otherwise returns YES.
  146.  
  147. - (BOOL)isValidClassProperty:aProp;
  148.     // Returns NO if either the attribute isn't an EOAttribute or
  149.     // EORelationship, or, if the property doesn't belong to this entity.
  150.     // Otherwise returns YES.
  151.  
  152. - (NSDictionary *)userDictionary;
  153.     // Returns a dictionary of user data. You can use this to store any
  154.     // auxiliary information.
  155.  
  156. - (BOOL)referencesProperty:property; 
  157.     // True if any of the entity's attributes or relationships reference
  158.     // property.
  159.  
  160. - (NSMutableDictionary *)dictionaryForAdaptorRow;
  161.     // Returns an empty autoreleased dictionary optimized for use with
  162.     // rows that correspond to selects with this entity.
  163.  
  164. @end
  165.  
  166.  
  167. @interface EOEntity(EOEntityEditing)
  168.  
  169. - (BOOL)setClassProperties: (NSArray *)properties;
  170.     // Sets the entity's class properties to EOAttributes and EORelationships
  171.     // in properties.  Returns YES on success, NO if any of the objects in the
  172.     // array don't return YES to isValidClassProperty:.
  173.  
  174. - (BOOL)setPrimaryKeyAttributes: (NSArray *)keys;
  175.     // Sets the primary key attributes to the attributes in keys.  Returns YES
  176.     // on success, or NO if any object in the array don't return YES to
  177.     // isValidPrimaryKeyAttribute:.
  178.  
  179. - (BOOL)setAttributesUsedForLocking: (NSArray *)attributes;
  180.     // Takes an array of EOAttributes.  Fails if any of the objects in the
  181.     // array don't return YES to isValidAttributeUsedForLocking:.
  182.  
  183. - (BOOL)setName:(NSString *)name;
  184.     // Sets the entity's name and returns YES on success, NO if name is in use
  185.     // by another entity.
  186.  
  187. - (void)setExternalName:(NSString *)name;
  188.     // Sets the name of the entity as understood by the database server.
  189.  
  190. - (void)setExternalQuery:(NSString *)query;
  191.     // Sets the query statement used for selecting rows from the entity.
  192.  
  193. - (void)setReadOnly:(BOOL)yn;
  194.     // Sets whether the entity can be modified.
  195.  
  196. - (BOOL)addAttribute:(EOAttribute *)attribute;
  197.     // Adds attribute to the entity and returns YES on success, NO if
  198.     // attribute's name is already in use by another attribute or
  199.     // relationship.
  200.  
  201. - (void)removeAttributeNamed:(NSString *)name;
  202.     // Removes the attribute with the given name.
  203.  
  204. - (BOOL)addRelationship:(EORelationship *)relationship;
  205.     // Adds relationship to the entity and returns YES on success, NO if
  206.     // attribute's name is already in use by another attribute or
  207.     // relationship.
  208.  
  209. - (void)removeRelationshipNamed:(NSString *)name;
  210.     // Removes the relationship with the given name.
  211.  
  212. - (void)setClassName:(const char *)name;
  213.     // Sets the class name.
  214.  
  215. - (void)setUserDictionary:(NSDictionary *)dictionary;
  216.     // Sets the dictionary of auxiliary data, which your application can use
  217.     // for whatever it needs.
  218.  
  219. @end
  220.  
  221.