1:-module(node_cnt).
2:-comment(author,"Helmut Simonis").
3:-comment(status,"experimental").
4:-comment(copyright,"2010, Helmut Simonis").
5:-comment(categories,["Development Tools","Visualization"]).
6:-comment(summary,"Primitives to exchange node count information between visualization.ecl and visualize_tree.ecl").
7:-comment(description,"Internal use only").
8
9:-comment(current_node_cnt/1,[summary:"Synchronisation between variable and tree node numbers",
10                  args:["Id":"returns the current node id number"],
11                  amode:current_node_cnt(-),
12                  desc:html("Internal use only, needed to exchange information between visualization.ecl and visualize_tree.ecl"),
13                  see_also:[set_node_cnt/1,
14                            new_node_cnt/4]]).
15
16
17:-export(current_node_cnt/1).
18
19:-comment(set_node_cnt/1,[summary:"Synchronisation between variable and tree node numbers",
20                  args:["Id":"set the node count to this id"],
21                  amode:set_node_cnt(++),
22                  desc:html("Internal use only, needed to exchange information between visualization.ecl and visualize_tree.ecl"),
23                  see_also:[current_node_cnt/1,
24                            new_node_cnt/4]]).
25:-export(set_node_cnt/1).
26
27:-comment(new_node_cnt/4,[summary:"Synchronisation between variable and tree node numbers",
28                  args:["Handle":"the opaque visualization handle",
29                        "Id":"returns the current node id number",
30                        "Parent":"returns the id of the parent node",
31                        "Stream":"returns the file descriptor for the tree stream"],
32                  amode:new_node_cnt(+,-,-,-),
33                  desc:html("Internal use only, needed to exchange information between visualization.ecl and visualize_tree.ecl"),
34                  see_also:[current_node_cnt/1,
35                            set_node_cnt/1]]).
36:-export(new_node_cnt/4).
37
38:-use_module(vis_structures).
39:-use_module(vis_options).
40
41
42% counting nodes in tree
43:-local variable(node_cnt).
44
45new_node_cnt(Handle,Id,Parent,Stream):-
46        Handle = visualization{parent:Parent,tree_stream:Stream},
47        incval(node_cnt),
48        getval(node_cnt,Id),
49        setarg(parent of visualization,Handle,Id).
50
51current_node_cnt(Id):-
52        getval(node_cnt,Id).
53
54set_node_cnt(N):-
55        setval(node_cnt,N).
56
57