background image
C H A P T E R 1 2
Special-Purpose Objects for Data Storage and Retrieval
12-14
Using Special-Purpose Data Storage Objects
Getting the Store Part
12
Store parts (also known as package stores) are made available by the
GetPackageStore
function. Package stores do not appear in the
GetStores
result array, which is reserved for normal store objects.
The
GetPackageStore
function retrieves the store by name, so each package
store must be given a unique name when it is built. Generally, this is ensured by
including the unique package symbol in the store name.
Accessing Data in Store Parts
12
Although store parts support most of the messages that normal soups do, remember
that store parts are read-only. Sending to a store part those messages that would
normally change a soup or its store (such as
CreateSoupXmit
,
SetName
and so
on) throws an exception.
Another thing to keep in mind is that soups on store parts do not participate in
union soups. You need to check explicitly for the presence of your store and soup.
The
GetPackageStore
and
GetPackageStores
functions provide two
different ways to find a store part. Usually, you use the global function
GetPackageStore
and pass the name of the store part you created as its
argument. Assuming the example code shown in "Creating a Store Part" on
page 12-13 was used to create the store part, you could use code similar to the
following example to check for the existence of the read-only soup residing on the
store part:
local pStore := GetPackageStore(kStoreName) ;
if pStore then
local pSoup := pStore:GetSoup(kSoupName) ;
Using Mock Entries
12
A mock entry has two parts: one is a cached frame, which the NewtonScript
interpreter treats as the entry when doing assignment, slot lookup, and so on; the
other is the handler frame that retrieves the actual entry data and implements a
suite of methods that manipulate it.
Topics discussed in this section include
implementing the
EntryAccess
method
creating a mock entry
testing the validity of a mock entry
getting entry cache data
getting and setting mock entry handlers
implementing additional handler methods
© 2007-2017, o7 studio » при воспроизведении материала сайта ссылка обязательна