home *** CD-ROM | disk | FTP | other *** search
- // EOGenericRecord.h
- // Copyright (c) 1994, NeXT Computer, Inc. All rights reserved.
-
- #import "EOKeyValueCoding.h"
-
- #import <foundation/NSArray.h>
- #import <foundation/NSData.h>
- #import <foundation/NSDictionary.h>
- #import <foundation/NSObject.h>
- #import <foundation/NSString.h>
-
- @class EOEntity;
-
- // The EOEntityMapping protocol defines the only method that must be
- // implemented on classes which manage their own class to entity mapping. EOF
- // must be able to determine an entity for every enterprise object it creates.
- // This is normally accomplished by examining the model. The EOEntityMapping
- // protocol provides an opportunity for classes to implement their own
- // mapping. The entity mapping must not change during the life of the object.
- // It must also be the entity that was specifed when the object was created.
-
- @interface NSObject (EOEntityMapping)
- - (EOEntity *)entity;
- // Returns the entity with which the receiver is associated.
- @end
-
- // The EOClassMapping protocol defines a class method that allows a class
- // specified by a particular entity to substitute a different class based on
- // it's fetched row or primary key values. Note that the returned class MUST
- // be either a sublass of the original class, have an entity specified in the
- // model, or implement the EOEntityMapping informal protocol. This
- // requirement is not checked, but will cause insert, deletes, and updates to
- // fail if not met. If row is nil then a new object is being created,
- // probably for insertion.
-
- // The method is called in three situations.
- // 1. When a row is fetched. values will be the fetched row
- // 2. When an object is created by a data source, usually for insertion.
- // values will be nil.
- // 3. When an fault creates it's underlying object. values will be the
- // object's primary key.
-
- @interface NSObject (EOClassMapping)
- + (Class)classForEntity:(EOEntity *)entity values:(NSDictionary *)values;
- @end
-
- // This informal protocol defines the initialization method which may be
- // implemented by enterprise objects. If this method is not implemented by
- // an enterprise object init is used. The dictionary supplied contains the
- // value of the primary key associated with the enterprise object.
-
- @interface NSObject (EOInitialization)
- - initWithPrimaryKey:(NSDictionary *)key entity:(EOEntity *)entity;
- // Initializes a newly allocated Enterprise Object.
- @end
-
-
- // EOGenericRecords are associated with EOEntities for which you haven't
- // defined custom Enterprise Object classes. When a record from the entity's
- // table is fetched by an database-layer object, an EOGenericRecord is
- // instantiated and filled with the data from the row. Any other enterprise
- // object class is uniquely associated with an EOEntity object in a given
- // EOModel. Since EOGenericRecords need to be used for any entity, an
- // EOGenericRecord holds the entity with which it's associated.
-
- @interface EOGenericRecord:NSObject
- {
- EOEntity *entity;
- NSMutableDictionary *dictionary;
- }
-
- - initWithPrimaryKey:(NSDictionary *)key entity:(EOEntity *)entity;
- // Initializes a newly allocated EOGenericRecord, associating it with
- // entity.
-
- - (BOOL)takeValuesFromDictionary:(NSDictionary *)dictionary;
- - (NSDictionary *)valuesForKeys:(NSArray *)keys;
- // These are the standard methods for getting data into and out of
- // Enterprise Objects. See EOKeyValueCoding.h.
-
- - (void)setObject:object forKey:(NSString *)key;
- - objectForKey:(NSString *)key;
- - (void)removeObjectForKey:(NSString *)key;
- // These are convenience methods for accessing single key-value pairs.
-
- - (EOEntity *)entity;
- @end
-
-