register.mli 2.98 KB
Newer Older
1
(* Time-stamp: <modified the 06/07/2020 (at 17:01) by Erwan Jahier> *)
2

erwan's avatar
erwan committed
3
(**  This module  duplicates and  extends the  Algo module  with get_*
4
5
6
   functions.

    The rationale for defining such a module is to be able to hide the
erwan's avatar
erwan committed
7
8
9
   get_*  functions from  the Algo  interface. Indeed,  they are  only
   called  by the  sasa engine,  and it  is dangerous  and useless  to
   expose them to algorithms designers.  *)
erwan's avatar
erwan committed
10
11
12

type 's neighbor = {
  state:  's ;
13
14
  pid: string; 
  spid: string; 
erwan's avatar
erwan committed
15
  reply: unit -> int; 
16
  weight: unit -> int; 
erwan's avatar
erwan committed
17
18
19
20
21
22
23
}

type algo_id = string
type action  = string 
type 's enable_fun = 's neighbor list -> 's -> action list
type 's step_fun   = 's neighbor list -> 's -> action -> 's

24
type pid = string
25
type 's pf_info = { neighbors: 's neighbor list; curr: 's ; next: 's; action: action }
26
type 's potential_fun = pid list -> (pid -> 's pf_info) -> float
erwan's avatar
erwan committed
27

28
val reg_init_state : algo_id -> (int -> string -> 's) -> unit
erwan's avatar
erwan committed
29
30
val reg_enable : algo_id -> 's enable_fun -> unit
val reg_step : algo_id -> 's step_fun -> unit
31
val reg_potential : 's potential_fun option -> unit
32
val reg_fault : (int -> string -> 's) option -> unit
33
val reg_actions : action list -> unit
erwan's avatar
erwan committed
34
val reg_value_to_string : ('s -> string) -> unit
35
val reg_value_of_string : (string -> 's) -> unit
erwan's avatar
erwan committed
36
37
val reg_copy_value : ('s -> 's) -> unit

38
39
40
41
42
43
44
val card : unit -> int
val min_degree : unit -> int
val mean_degree : unit -> float
val max_degree : unit -> int
val is_cyclic : unit -> bool
val is_connected : unit -> bool
val is_tree : unit -> bool
45
val is_directed : unit -> bool
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

(** If height () = None, then the graph doesn't have a height (because it isn't a tree)
   Otherwise, height () = Some h.*)
val height : unit -> (string -> int) option
val links_number : unit -> int
val diameter : unit -> int

val verbose_level: int ref

val get_graph_attribute : string -> string


(* All the remaining functions are used only by the sasa Engine, while
   the functions above are only used in the Algo module (i.e., by
   distributed algorithm designers. *)
erwan's avatar
erwan committed
61
62
63

val get_enable : algo_id -> 's enable_fun
val get_step   : algo_id -> 's step_fun
64
val get_init_state : algo_id -> int -> string -> 's
65
val get_actions   : unit -> action list
66
val get_potential   : unit -> 's potential_fun option
67
val get_fault   : unit -> (int -> string -> 's) option
erwan's avatar
erwan committed
68
val get_value_to_string : unit -> 's -> string
69
val get_value_of_string : unit -> (string -> 's) option
erwan's avatar
erwan committed
70
71
72
val get_copy_value : unit -> ('s -> 's)
val to_string : 's -> string

73
(** Those are called by sasa once the graph has been parsed  *)
74
75
76
77
val set_card : (unit -> int) -> unit
val set_degrees : (unit -> int*int) -> unit
val set_mean_deg : (unit -> float) -> unit
val set_is_connected_cyclic : (unit -> bool*bool) -> unit
78
val set_is_directed : (unit -> bool) -> unit
79
type node_id = string (* cf topology.mli *)
80
val set_height : (node_id -> int) -> unit
81
val set_links_number : (unit -> int) -> unit
82
val set_diameter : (unit -> int) -> unit
erwan's avatar
erwan committed
83

84
val set_graph_attribute : string -> string -> unit
85
val graph_attribute_list: unit -> (string * string) list
erwan's avatar
erwan committed
86