root/trunk/examples/classvars/classvars.lgt

Revision 4601, 0.8 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(root,             % avoid infinite metaclass regression by
3    instantiates(root)).    % making the class its own metaclass
4
5    :- private(cv_/1).
6    :- dynamic(cv_/1).
7    :- mode(cv_(?integer), zero_or_one).
8
9    :- public(cv/1).
10    :- mode(cv(?integer), zero_or_one).
11
12    :- public(set_cv/1).
13    :- mode(set_cv(+integer), one).
14
15    cv_(0).                     % cv_/1 value is stored locally, in this class
16
17    cv(Value) :-
18        cv_(Value).             % retrive cv_/1 value, shared for all instances
19
20    set_cv(Value) :-
21        retractall(cv_(_)),     % retract old cv_/1 value from this class
22        asserta(cv_(Value)).    % assert the new value into this class
23
24:- end_object.
25
26
27:- object(instance1,
28    instantiates(root)).
29
30:- end_object.
31
32
33:- object(instance2,
34    instantiates(root)).
35
36:- end_object.
37
38
39:- object(instance3,
40    instantiates(root)).
41
42:- end_object.
Note: See TracBrowser for help on using the browser.