Navigation:  Programming Cookbook > Binary Filing Objects >

Making use of the filer context

Previous pageReturn to chapter overviewNext page

Both STBInFilers and STBOutFilers contain a single, user-specified instance variable which can be accessed using #context: and #context. These are typically set before a filing session commences and then queried by the filed objects or proxies to determine the 'context' of the session. The filer itself puts no interpretation on this information, it just makes it available.

For example, it is sometimes useful to 'snip out' an object from its environment before you save it so that we don't save its entire neighbourhood. When the object is subsequently loaded it initially lives nowhere but its proxy can query STBInFiler>>#context to ascertain the new neighbourhood. Use STBInFiler>>#context: to specify the context information at any time prior to the send of #next that requires the information.

For example, the filing of views (which are really operating system windows) makes use of this context scheme to ensure that when a view is filed in it is given a parent view that will own it. This parent is specified to the STBInFiler using #context:. See ResourceSTBFileAccessor>>loadWithContext: for an example of this in use.