Our example client programmer is a user of the Stack library. This programmer understands when an Objection may be raised and understands the default and recovery actions associated with that Objection in each instance in which it may occur.
The client programmer has three choices of action regarding any Objection which may be raised. The user can:
The Objection operations used by a client programmer to determine what will
happen when an Objection is raised are
Objection::appoint(). A call to
appoint() with no arguments, e.g.,
Stack::underflow.appoint(), associates an initial
handler that will invoke the subsequent handler (the default action).
The user calls the
ignore() function, e.g.,
Stack::underflow.ignore(), to ignore the error.
ignore() associates an initial handler which will
bypass the subsequent handler and thus the
recovery action will be performed when
the Objection is raised.
The client can
also pass to
appoint() an initial handler to be
associated with the Objection,
The type of the argument to
Objection_action*, which is defined by the Objection
library to be the name of a user-defined
function which has one argument of type
const char* and returns an integer
raise()'ed. (See ``Objections for the Software Author'').
The integer returned from this new
initial handler determines whether the subsequent
handler (and thus the default action)
is executed (return 0) or whether the recovery
(return non-zero) action happens after
the Objection is raised and the function has
been executed. The
const char* argument to the
user-defined function is an error
message passed to the function from the library.
functions return an Objection_action*,
whose value is the previous action associated
with the Objection.
The rest of this section will illustrate how the Stack library client associates actions with Objections.