background image
C H A P T E R 1 2
Special-Purpose Objects for Data Storage and Retrieval
12-6
About Special-Purpose Storage Objects
// create new mock entry w/ no cached frame
local m := NewMockEntry(myHandler, nil);
// referencing m doesn't create cached frame
local x := m;
// either statement could invoke myHandler:EntryAccess()
local a := x.foo;
local b := m.foo;
To almost all of the system, the mock entry appears to be a normal soup entry;
for example:
m.foo
evaluates to
'bar
ClassOf(m)
is
'frame
m.baz := 42
adds a slot to the
handler.object
frame and this modified
frame is returned the next time the mock entry is accessed.
Only the
IsMockEntry
global function can determine that
m
is a mock entry,
rather than a soup entry. Note that the
IsSoupEntry
function returns
true
for
both mock entries and normal soup entries.
Mock Stores, Mock Soups, and Mock Cursors
12
The current implementation of the Newton object system provides only mock
entries; you must implement appropriate mock cursors, mock soups, and mock
stores as required.
The mock store is a frame you supply which responds appropriately to all the
messages that might normally be sent to a store object. For example, when the
mock store's
GetSoup
method is invoked, it should return a mock soup.
The mock soup is a frame you supply which responds appropriately to all the
messages that might normally be sent to a soup object. For example, when the
mock soup's
Query
method is called, the mock soup should return a mock cursor.
Mock soups cannot participate in union soups; however, you can implement your
own mock union soup objects that manage the interaction of your mock soups with
normal soups or union soups.
A mock cursor is a frame you supply that can respond appropriately to all the
messages that might normally be sent to a cursor object. For example, when the
mock cursor's
Entry
method is invoked, it should return a mock entry.
© 2007-2024, o7 studio » при воспроизведении материала сайта ссылка обязательна