Annotation of Examples/EnterpriseObjects/MasteringDetails/EOFExtensions.subproj/KeyGenerator.h, revision 1.1

1.1     ! root        1: /* KeyGenerator.h created by cfeder on Wed 26-Oct-1994 */
        !             2: 
        !             3: #import <eoaccess/eoaccess.h>
        !             4: 
        !             5: // This code provides an example of a generic key generation facility.
        !             6: // This implementation is closely related to the UniqueKey example
        !             7: // in /NextDeveloper/Examples/EnterpriseObjects.  See the README file
        !             8: // there for more information.
        !             9: 
        !            10: @interface KeyGenerator : NSObject
        !            11: {
        !            12:     EODatabaseDataSource *dataSource;
        !            13:     EOEntity *entity;
        !            14:     id currentMaxRecord;  // uniqued object from the database
        !            15:     unsigned lastGranted, lastReserved;
        !            16: }
        !            17: - initWithEntity:(EOEntity *)entity dataSource:(EODatabaseDataSource *)dataSource;
        !            18: - (unsigned)nextKey;
        !            19: + keyGeneratorForEntity:(EOEntity *)entity;
        !            20:     // Returns a key generator object for the given entity.
        !            21:     // If called repeatedly with the same entity, returns the the same object.
        !            22: + (unsigned)nexKeyForEntity:(EOEntity *)entity;
        !            23:     // Convenience for [[KeyGenerator keyGeneratorForEntity] nextKey]
        !            24: 
        !            25: @end
        !            26: 
        !            27: // Informal protocol on object to tell them to assign
        !            28: // themselves primary keys.  EO classes may want to override
        !            29: // this with their own key generation scheme.  The default implementation
        !            30: // uses the KeyGenerator (above).
        !            31: @interface NSObject (assignPrimaryKey)
        !            32: - (void)assignPrimaryKeyForEntity:(EOEntity *)entity;
        !            33:     // uses the key generator to assign a new primary key to the entity
        !            34: 
        !            35: - (void)assignPrimaryKeyIfNotAlreadyPresentForEntity:(EOEntity *)entity;
        !            36:     // does the above only if the object does not already have a
        !            37:     // primary key assigned.
        !            38: @end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.