2001-06-06 20:40:57 +01:00
|
|
|
|
|
|
|
:- category(monitor,
|
|
|
|
implements(monitorp)).
|
|
|
|
|
|
|
|
|
|
|
|
:- info([
|
2004-04-02 15:39:36 +01:00
|
|
|
version is 1.1,
|
2003-02-05 00:15:28 +00:00
|
|
|
author is 'Paulo Moura',
|
2004-04-02 15:39:36 +01:00
|
|
|
date is 2004/3/31,
|
2001-06-06 20:40:57 +01:00
|
|
|
comment is 'Monitor predicates.']).
|
|
|
|
|
|
|
|
|
|
|
|
:- private(spy_point_/4).
|
|
|
|
:- dynamic(spy_point_/4).
|
|
|
|
|
|
|
|
:- mode(spy_point_(?event, ?object, ?callable, ?object), zero_or_more).
|
|
|
|
|
|
|
|
:- info(spy_point_/4, [
|
|
|
|
comment is 'Stores current spy points.',
|
|
|
|
argnames is ['Event', 'Object', 'Message', 'Sender']]).
|
|
|
|
|
|
|
|
|
|
|
|
monitor_activated :-
|
|
|
|
self(Self),
|
|
|
|
once(current_event(_, _, _, _, Self)).
|
|
|
|
|
|
|
|
|
|
|
|
activate_monitor :-
|
|
|
|
self(Self),
|
|
|
|
abolish_events(before, _, _, _, Self),
|
|
|
|
abolish_events(after, _, _, _, Self),
|
|
|
|
forall(
|
|
|
|
::spy_point_(Event, Object, Message, Sender),
|
|
|
|
define_events(Event, Object, Message, Sender, Self)).
|
|
|
|
|
|
|
|
|
|
|
|
suspend_monitor :-
|
|
|
|
self(Self),
|
|
|
|
abolish_events(before, _, _, _, Self),
|
|
|
|
abolish_events(after, _, _, _, Self).
|
|
|
|
|
|
|
|
|
|
|
|
reset_monitor :-
|
|
|
|
self(Self),
|
|
|
|
abolish_events(before, _, _, _, Self),
|
2004-04-02 15:39:36 +01:00
|
|
|
abolish_events(after, _, _, _, Self),
|
2001-06-06 20:40:57 +01:00
|
|
|
::retractall(spy_point_(_, _, _, _)).
|
|
|
|
|
|
|
|
|
|
|
|
spy_point(Event, Object, Message, Sender) :-
|
|
|
|
::spy_point_(Event, Object, Message, Sender).
|
|
|
|
|
|
|
|
|
|
|
|
set_spy_point(Event, Object, Message, Sender) :-
|
|
|
|
::retractall(spy_point_(Event, Object, Message, Sender)),
|
|
|
|
once((var(Event); Event = before; Event = after)),
|
|
|
|
::assertz(spy_point_(Event, Object, Message, Sender)).
|
|
|
|
|
|
|
|
|
|
|
|
del_spy_points(Event, Object, Message, Sender) :-
|
|
|
|
::retractall(spy_point_(Event, Object, Message, Sender)).
|
|
|
|
|
|
|
|
|
|
|
|
:- end_category.
|