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

  1. // EOGenericRecord.h
  2. // Copyright (c) 1994, NeXT Computer, Inc. All rights reserved.
  3.  
  4. #import    "EOKeyValueCoding.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.  
  14. // The EOEntityMapping protocol defines the only method that must be
  15. // implemented on classes which manage their own class to entity mapping.  EOF
  16. // must be able to determine an entity for every enterprise object it creates.
  17. // This is normally accomplished by examining the model.  The EOEntityMapping
  18. // protocol provides an opportunity for classes to implement their own
  19. // mapping.  The entity mapping must not change during the life of the object.
  20. // It must also be the entity that was specifed when the object was created.
  21.  
  22. @interface NSObject (EOEntityMapping)
  23. - (EOEntity *)entity;
  24.     // Returns the entity with which the receiver is associated.
  25. @end
  26.  
  27. // The EOClassMapping protocol defines a class method that allows a class
  28. // specified by a particular entity to substitute a different class based on
  29. // it's fetched row or primary key values.  Note that the returned class MUST
  30. // be either a sublass of the original class, have an entity specified in the
  31. // model, or implement the EOEntityMapping informal protocol.  This
  32. // requirement is not checked, but will cause insert, deletes, and updates to
  33. // fail if not met.  If row is nil then a new object is being created,
  34. // probably for insertion.
  35.  
  36. // The method is called in three situations.
  37. // 1. When a row is fetched.  values will be the fetched row
  38. // 2.  When an object is created by a data source, usually for insertion.
  39. // values will be nil.
  40. // 3.  When an fault creates it's underlying object.  values will be the
  41. // object's primary key.
  42.  
  43. @interface NSObject (EOClassMapping)
  44. + (Class)classForEntity:(EOEntity *)entity values:(NSDictionary *)values;
  45. @end
  46.  
  47. // This informal protocol defines the initialization method which may be
  48. // implemented by enterprise objects.  If this method is not implemented by
  49. // an enterprise object init is used.  The dictionary supplied contains the
  50. // value of the primary key associated with the enterprise object.
  51.  
  52. @interface NSObject (EOInitialization)
  53. - initWithPrimaryKey:(NSDictionary *)key entity:(EOEntity *)entity;
  54.     // Initializes a newly allocated Enterprise Object.
  55. @end
  56.  
  57.  
  58. // EOGenericRecords are associated with EOEntities for which you haven't
  59. // defined custom Enterprise Object classes.  When a record from the entity's
  60. // table is fetched by an database-layer object, an EOGenericRecord is
  61. // instantiated and filled with the data from the row.  Any other enterprise
  62. // object class is uniquely associated with an EOEntity object in a given
  63. // EOModel.  Since EOGenericRecords need to be used for any entity, an
  64. // EOGenericRecord holds the entity with which it's associated.
  65.  
  66. @interface EOGenericRecord:NSObject
  67. {
  68.     EOEntity *entity;
  69.     NSMutableDictionary *dictionary;
  70. }
  71.  
  72. - initWithPrimaryKey:(NSDictionary *)key entity:(EOEntity *)entity;
  73.     // Initializes a newly allocated EOGenericRecord, associating it with
  74.     // entity.
  75.  
  76. - (BOOL)takeValuesFromDictionary:(NSDictionary *)dictionary;
  77. - (NSDictionary *)valuesForKeys:(NSArray *)keys;
  78.     // These are the standard methods for getting data into and out of
  79.     // Enterprise Objects.  See EOKeyValueCoding.h.
  80.  
  81. - (void)setObject:object forKey:(NSString *)key;
  82. - objectForKey:(NSString *)key;
  83. - (void)removeObjectForKey:(NSString *)key;
  84.     // These are convenience methods for accessing single key-value pairs.
  85.  
  86. - (EOEntity *)entity;
  87. @end
  88.  
  89.