Copyright ©1995 by NeXT Computer, Inc.  All Rights Reserved.

IXStoreDirectory



Inherits From: Object
Conforms To: IXBlockAndStoreAccess
IXNameAndFileAccess
Declared In: btree/IXStoreDirectory.h



Class Description

An IXStoreDirectory provides access to store clients by name instead of by block handle.  You can use this facility for more convenient access to objects within a single IXStore.  It's particularly useful in implementing the IXNameAndFileAccess protocol, which is used to support a conventional store file organization.  See the IXNameAndFileAccess protocol specification for more information on the conventional store file organization.  This class specification also assumes that you know about store clients, which are described in the IXBlockAndStoreAccess protocol specification.



Instance Variables

None declared in this class.



Adopted Protocols

IXBlockAndStoreAccess initInStore:
initFromBlock:inStore:
freeFromStore
+ freeFromBlock:inStore:
getBlock:andStore:
IXNameAndFileAccess initWithName:inFile:
initFromName:inFile:forWriting:
freeFromStore
+ freeFromName:andFile:
getName:andFile:



Method Types

Adding entries or objects addEntryNamed:ofClass:
addEntryNamed:ofClass:atBlock:
addEntryNamed:forObject:
Removing entries freeEntryNamed:
removeName:
empty
reset
Getting entries hasEntryNamed:
getBlock:ofEntryNamed:
getClass:ofEntryNamed:
openEntryNamed:
entries



Instance Methods

addEntryNamed:forObject:
addEntryNamed:(const char *)aName forObject:anObject

Associates anObject with aNameanObject must conform to the IXBlockAndStoreAccess protocol, and must be a client of the same IXStore as the IXStoreDirectory.  Returns the newly created instance, or nil if an entry already exists with the specified name.

Use this method to associate a name with an existing and instantiated store client.  If you want to associate a name with a store client that has already been created, but isn't currently instantiated (that is, its data exists in the IXStore, but there's no run-time object accessing it), use addEntryNamed:ofClass:atBlock:.  If you want to immediately create a new store client and associate a name with it, use addEntryNamed:ofClass:.

If aName is NULL or empty, anObject doesn't respond to getBlock:andStore:, or anObject isn't a client of the same IXStore as the IXStoreDirectory, IX_ArgumentError is raised.

See also:  addEntryNamed:ofClass:atBlock:, openEntryNamed:



addEntryNamed:ofClass:
addEntryNamed:(const char *)aName ofClass:aClass

Creates an instance of class aClass, initializes it by sending initInStore: (an IXBlockAndStoreAccess protocol method), and associates it with aName.  Returns the newly created instance.

If an entry already exists for aName, IX_DuplicateError is raised.  If aName is NULL or empty, or if instances of aClass don't respond to initInStore:, IX_ArgumentError is raised.

See also:  addEntryNamed:ofClass:atBlock:, openEntryNamed:, initInStore: (IXBlockAndStoreAccess protocol)



addEntryNamed:ofClass:atBlock:
addEntryNamed:(const char *)aName
ofClass:aClass
atBlock:(IXBlockHandle)aHandle

Creates an instance of class aClass, reconstitutes it from the block at aHandle by sending initFromBlock:inStore: (an IXBlockAndStoreAccess protocol method), and associates it with aName.  If aHandle is 0, this method is equivalent to addEntryNamed:ofClass:, and creates a new instance of aClass.  Returns the reconstituted or created instance.

Use this method to associate a name with the data for a previously created store client.  The stored data should have been created by a previous instance of aClass.

If an entry already exists for aName, IX_DuplicateError is raised.  If aName is NULL or empty, or if instances of aClass don't respond to initFromBlock:inStore:, IX_ArgumentError is raised.

See also:  addEntryNamed:forObject:, addEntryNamed:ofClass:, openEntryNamed:, initFromBlock:inStore: (IXBlockAndStoreAccess protocol)



empty
empty

Removes all entries from the directory, instantiating the store clients, and freeing them from the store.  Returns self.

See also:  freeEntryNamed:, freeFromBlock:inStore: (IXBlockAndStoreAccess protocol)



entries
(const char **)entries

Creates and returns a NULL-terminated list of the names of all currently defined entries.  The sender of this message responsible for freeing the list, but not the strings in the list, which are NXAtoms.

If space for the array of entries can't be allocated, IX_MemoryError is raised.



freeEntryNamed:
freeEntryNamed:(const char *)aName

Removes the named entry from the directory by sending freeFromBlock:inStore to the named entry's class object.  Returns self.

See also:  empty, freeFromBlock:inStore: (IXBlockAndStoreAccess protocol)



getClass:ofEntryNamed:
getClass:(id *)aClass ofEntryNamed:(const char *)aName

Returns by reference the class object for the entry named aName, or nil if there is no such entry.  Returns self.



hasEntryNamed:
(BOOL)hasEntryNamed:(const char *)aName

Returns YES if there is an entry named aName, NO otherwise.



openEntryNamed:
openEntryNamed:(const char *)aName

Creates and initializes (with initFromBlock:inStore:) an instance of the object previously entered as aName, or nil if there is no such entry.  It's possible to create multiple instances from the same entry; your code should avoid doing this, as the separate objects may corrupt the data they share in the IXStore if they try to change it.

See also:  addEntryNamed:ofClass:, addEntryNamed:ofClass:atBlock:, initFromBlock:inStore: (IXBlockAndStoreAccess protocol)



removeName:
removeName:(const char *)aName

Removes aName as an entry in the IXStoreDirectory, but doesn't remove the store client.  That is, the client can still be recovered by handle.  Returns self.

See also:  reset, initFromBlock:inStore: (IXBlockAndStoreAccess protocol)



reset
reset

Removes all entries in the IXStoreDirectory, but doesn't remove the store clients.  That is, the clients can still be recovered by handle.  Returns self.

See also:  removeName:, initFromBlock:inStore: (IXBlockAndStoreAccess protocol)