Skip to content
Snippets Groups Projects
algo.mli 2.61 KiB
Newer Older
(* Time-stamp: <modified the 07/06/2019 (at 14:29) by Erwan Jahier> *)
erwan's avatar
erwan committed

(** Process programmer API *)

type value = I of int | F of float | B of bool  | E of int | S of string
erwan's avatar
erwan committed
           | N of int  (* neighbor channel number *)
           | A of value array
erwan's avatar
erwan committed

(* val copy_value : value -> value *)

type local_env
  = string -> value 


(** Types of value *)
type varT = It | Ft | Bt (* int, float, bool *)
          | Et of int (* enum *)
          | St (* string *)
          | Nt (* neighbor channel *)
          | At of varT * int (* array *)
type vars = (string * varT) list 

val copy_local_env : vars -> local_env -> local_env

erwan's avatar
erwan committed
type neighbor = {
  lenv:  local_env;
  n_vars: vars;
  pid: unit -> string; (* Returns the pid of the neigbhor. This info
                          is not available in all modes (e.g.,
                          anonymous) *)
  reply: unit -> int; 
  (* Returns the channel number that let this neighbor access to the
     content of the process, if the neighbor can access to the
     process.  Returns -1 if the neigbor can not access to the
     process, which can happen in directed graphs only.  This info is
     not available in all modes *)
erwan's avatar
erwan committed
}

erwan's avatar
erwan committed
type action = string (* label *)
erwan's avatar
erwan committed
type enable_fun = neighbor list -> local_env -> action list
type step_fun   = neighbor list -> local_env -> action -> local_env
erwan's avatar
erwan committed

(** Those 3 registering functions must be called! *)
type algo_id = string
erwan's avatar
erwan committed
val reg_vars : algo_id -> vars -> unit
val reg_enable : algo_id  -> enable_fun -> unit
val reg_step : algo_id  -> step_fun -> unit

(** raised by sasa if one of the function above is not called *)
exception Unregistred of string * string

(** This one is not mandatory.  The initialisation done in the dot
   file have priority over this one.  *)
val reg_init_vars : algo_id -> (neighbor list -> local_env) -> unit
erwan's avatar
erwan committed

(** Mandatory in custom mode only. *)
val reg_actions : algo_id -> action list -> unit

erwan's avatar
erwan committed
(** util(s) *)
val value_to_string : value -> string

(** Global infos *)

val card : unit -> int
(* val degree : unit -> int *)
(* val diameter : unit -> int *)
  
erwan's avatar
erwan committed

(**/**)
(** functions below are not part of the API *)
val vart_to_rif_decl: varT -> string -> (string * string) list
val vart_to_rif_string: varT -> string -> string
erwan's avatar
erwan committed
val verbose_level: int ref
val set_card : int -> unit
(* val set_degree :  int -> unit *)
(* val set_diameter : int -> unit *)
erwan's avatar
erwan committed

(** the following functions are used by sasa *)
val get_vars   : algo_id -> vars
val get_enable : algo_id -> enable_fun
val get_step   : algo_id -> step_fun 
val get_init_vars : algo_id -> (string * varT) list -> neighbor list -> local_env
val get_actions   : algo_id -> action list
erwan's avatar
erwan committed