|
Revision 4601, 1.2 KB
(checked in by pmoura, 7 weeks ago)
|
|
Added svn:mime-type property to source files (set to text/x-logtalk).
|
-
Property svn:mime-type set to
text/x-logtalk
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 | |
|---|
| 2 | :- object(database). |
|---|
| 3 | |
|---|
| 4 | :- info([ |
|---|
| 5 | version is 2.0, |
|---|
| 6 | author is 'Paulo Moura', |
|---|
| 7 | date is 2007/04/17, |
|---|
| 8 | comment is 'Dynamic database benchmark utility predicates.']). |
|---|
| 9 | |
|---|
| 10 | :- public(this_dyndb/1). |
|---|
| 11 | :- mode(this_dyndb(+nonvar), one). |
|---|
| 12 | :- info(this_dyndb/1, [ |
|---|
| 13 | comment is 'Asserts and retracts a predicate in "this".', |
|---|
| 14 | argnames is ['Term']]). |
|---|
| 15 | |
|---|
| 16 | :- public(self_dyndb/1). |
|---|
| 17 | :- mode(self_dyndb(+nonvar), one). |
|---|
| 18 | :- info(self_dyndb/1, [ |
|---|
| 19 | comment is 'Asserts and retracts a predicate using ::/1.', |
|---|
| 20 | argnames is ['Term']]). |
|---|
| 21 | |
|---|
| 22 | :- public(obj_dyndb/1). |
|---|
| 23 | :- mode(obj_dyndb(+nonvar), one). |
|---|
| 24 | :- info(obj_dyndb/1, [ |
|---|
| 25 | comment is 'Asserts and retracts a predicate using ::/2.', |
|---|
| 26 | argnames is ['Term']]). |
|---|
| 27 | |
|---|
| 28 | :- private([pred_this/1, pred_self/1, pred_obj/1]). |
|---|
| 29 | :- dynamic([pred_this/1, pred_self/1, pred_obj/1]). |
|---|
| 30 | |
|---|
| 31 | % direct calls to assertz/1 and retract/1: |
|---|
| 32 | this_dyndb(N) :- |
|---|
| 33 | assertz(pred_this(N)), |
|---|
| 34 | retract(pred_this(N)). |
|---|
| 35 | |
|---|
| 36 | % calls to assertz/1 and retract/1 using ::/1: |
|---|
| 37 | self_dyndb(N) :- |
|---|
| 38 | ::assertz(pred_self(N)), |
|---|
| 39 | ::retract(pred_self(N)). |
|---|
| 40 | |
|---|
| 41 | % calls to assertz/1 and retract/1 using ::/2: |
|---|
| 42 | obj_dyndb(N) :- |
|---|
| 43 | this(This), |
|---|
| 44 | This::assertz(pred_obj(N)), |
|---|
| 45 | This::retract(pred_obj(N)). |
|---|
| 46 | |
|---|
| 47 | :- end_object. |
|---|