This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/Logtalk/library/monitor.lgt
pmoura 75392e54c7 Logtalk 2.15.0 release files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@757 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
2003-02-05 00:15:28 +00:00

65 lines
1.4 KiB
Plaintext

:- category(monitor,
implements(monitorp)).
:- info([
version is 1.0,
author is 'Paulo Moura',
date is 2000/7/24,
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),
abolish_events(after, _, _, _, Self).
::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.