TOC | PREV | NEXT

*************************** SDEntry.h ******************************



@interface SDEntry:NSObject

{
NSString *name;
NSString *classname;
Class theClass;
id theObject;
SDStore *storeFile;
int blockNumber;
}

- initWithName:(NSString *)aName class:(Class)aClass forStoreFile:(id) aStoreFile;
- (void)encodeWithCoder:(NSCoder *)aCoder;
- (id) initWithCoder:(NSCoder *)aDecoder;
- (id) theObject;
- (void) setStoreFile:(SDStore *)aStoreFile;
- (int) blockNumber;
- (void) freeObjectFromBlock;

@end


*************************** SDEntry.m ******************************

#import "ixCover.h"

@implementation SDEntry:NSObject

- initWithName:(NSString *)aName class:(Class)aClass forStoreFile:(id) aStoreFile
{
name = [[NSString allocWithZone:[self zone]] initWithString:aName];
theClass = aClass;
classname = [[NSString allocWithZone:[self zone]] initWithString:NSStringFromClass(theClass)];
storeFile = aStoreFile;
theObject = [[[theClass alloc] initInStore:storeFile] retain];
blockNumber = [theObject blockNumber];
return self;
}


- (void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject:name];
[aCoder encodeObject:classname];
[aCoder encodeValuesOfObjCTypes:"i", &blockNumber];

}

- (id) initWithCoder:(NSCoder *)aDecoder
{
name = [[aDecoder decodeObject] retain];
classname = [[aDecoder decodeObject] retain];
[aDecoder decodeValuesOfObjCTypes:"i", &blockNumber];
theClass = NSClassFromString(classname);
theObject = nil;
storeFile = nil;
return self;
}

- (id) theObject
{
if (!theObject) {
      theObject = [[[theClass alloc] initFromBlock:blockNumber inStore:storeFile] retain];
}
return theObject;
}

- (void) setStoreFile:(SDStore *)aStoreFile
{
storeFile = aStoreFile;
}

- (void) freeObjectFromBlock
{
if (!theObject) {
[theClass freeFromBlock:blockNumber inStore:storeFile];
} else {
[theObject freeFromStore];
[theObject release];
theObject = nil;
}
}

- (int) blockNumber
{
return blockNumber;
}

- (void) dealloc
{
[name release];
[classname release];
[theObject release];
[super dealloc];
}

@end


TOC | PREV | NEXT
Created by Stone Design's Create on 3/12/1998