The Proxy module provides a
basic Proxy pattern through its ProxyService
and service classes. The idea behind the proxy pattern is to provide a means of
redirecting messages sent to objects that do not define the required property to
service objects that do.
A ProxyService object is a composite object composed of a parent
object (the ProxyService object), components (service objects), and a pointer
to a class that will handle any properties not handled by the ProxyService or one of the service objects.
The basic rules for
redirection and delegation are:
We can use inner classes to
make the ProxyService object definition more compact.
Suppose we want to create a
desk that has a surface and an inside. We can do so compactly by defining it
with nested objects for each of its components:
woodenDesk: ProxyService
{
'wooden
desk' 'wooden desk' @entryway
proteusServiceFor(Service)
{
mySurface: Fixed, Surface
{
'desk surface' 'desk surface'
}
myContainer:
Fixed, OpenableContainer
{
'desk drawer' 'desk drawer'
}
}
}
A sample transcript of what
this simple definition can do follows:
Entryway
This large, formal entryway is slightly intimidating:
the walls are lined with somber portraits of gray-haired men from decades past;
a medieval suit of armor, posed with a battle axe at the ready, towers over a
single straight-backed wooden chair. The front door leads back outside to the
south. A hallway leads north.
You see a wooden desk here.
>put axe in
desk
(first taking the battle axe)
(first opening the desk drawer)
Done.
>put axe on
desk
(first taking the battle axe)
Done.
>close desk
Closed.
>l
Entryway
This large, formal entryway is slightly
intimidating: the walls are lined with somber portraits of gray-haired men from
decades past; a medieval suit of armor towers over a single straight-backed
wooden chair. The front door leads back outside to the south. A hallway leads north.
You see a wooden desk here. On the desk surface is a
battle axe.
This file is part of the TADS 3
Proteus Library Extension
Copyright ©
2001-2004 Kevin Forchione. All rights reserved.