The AWeb OO model
Introduction
AWeb internally uses its own object oriented model for representation of data.
By means of the plugin interface, this model can be expanded by the plugin
modules. This document does not explain object oriented modelling, that is
something assumed to be known to the reader.
The OO system used by AWeb is similar to BOOPSI, although it is a completely
separate system. The existing BOOPSI image and gadget models were not
useable because of AWeb's scrolling and RastPort clipping demands. Building
a new model using BOOPSI would have been possible, but I decided to build
my own system instead, for the following reasons:
- The way BOOPSI implements inheritance is basically very good. If you
derive a class from a certain superclass, you can only access the
superclasses attributes through its methods. That is perfect when
deriving from a foreign class, but if you own the superclass as well,
it's a bit of a hassle. One of the very few things I like about C++
is the way you can access your superclasses public attributes as if
they were your own.
- Building my own central dispatcher allowed me to add a trace option.
Simply by specifying a couple of arguments when starting AWeb, I can
make a full trace of every single message that is sent around.
Filtering is possible by class, or by method, or both. A great help
when debugging.
Usage
Dispatcher
Like BOOPSI, every class must have a dispatcher function that handles
incoming OO messages.
Invoking methods of other objects is done by calling the
Amethod[A]() function,
AWebs equivalent of DoMethod[A](). This function forwards
the message to the dispatcher of the class.
Inheritance
Deriving a class from a superclass is different from the way it is
done in BOOPSI. The object instance data structure of the derived class must
start with the data structure for the superclass. This implies that
you must know the data structure of the superclass, so either
it must be public, or it must be your own private class. It is not
possible to inherit from other classes, you should use delegation
instead. (Popularly, delegation is having a pointer to another object
and forward the messages to it.)
There is no such function as DoSuperMethod(), in the AWeb
OO system the central dispatcher does not know what your superclass is.
To pass a message to your superclass you must use
Amethodas[A](), AWebs
version of CoerceMethod[A]().
Every object implementation must have a dispatcher to process
messages sent to the object.
Synopsis
retval = Dispatch(object, message)
D0 A0 A1
ULONG Dispatch(struct Aobject *, struct Amessage *);
Function
The dispatcher function is called whenever a message is sent to the object.
Depending on the message type (method),
the object code should take appropriate actions.
Inputs
| Parameter
| Description
|
|---|
| object
| A pointer to the object instance that the message was sent to.
This will be NULL for the AOM_NEW method.
|
| message
| A pointer to the message that was sent to the object.
|
Results
The value to return depends on the method invoked. See the documentation
for the individual methods.