Skip to content
Snippets Groups Projects
Commit e9f869c6 authored by David Bühler's avatar David Bühler Committed by Michele Alberti
Browse files

[server] Data: standardizes the Identified functor with Index and Static.

parent 84ca6787
No related branches found
No related tags found
No related merge requests found
...@@ -632,10 +632,9 @@ module type IdentifiedType = ...@@ -632,10 +632,9 @@ module type IdentifiedType =
sig sig
type t type t
val id : t -> int val id : t -> int
include Info
end end
module Identified(A : IdentifiedType) : Index with type t = A.t = module Identified(A : IdentifiedType)(I : Info) : Index with type t = A.t =
struct struct
type index = (int,A.t) Hashtbl.t type index = (int,A.t) Hashtbl.t
...@@ -646,13 +645,13 @@ struct ...@@ -646,13 +645,13 @@ struct
type t = index type t = index
include Datatype.Undefined include Datatype.Undefined
let reprs = [Hashtbl.create 0] let reprs = [Hashtbl.create 0]
let name = "Server.Data.Identified.Type." ^ A.name let name = "Server.Data.Identified.Type." ^ I.name
let mem_project = Datatype.never_any_project let mem_project = Datatype.never_any_project
end) end)
module STATE = State_builder.Ref(TYPE) module STATE = State_builder.Ref(TYPE)
(struct (struct
let name = "Server.Data.Identified.State." ^ A.name let name = "Server.Data.Identified.State." ^ I.name
let dependencies = [] let dependencies = []
let default () = Hashtbl.create 0 let default () = Hashtbl.create 0
end) end)
...@@ -666,12 +665,12 @@ struct ...@@ -666,12 +665,12 @@ struct
include Collection include Collection
(struct (struct
type t = A.t type t = A.t
let syntax = publish_id (module A) let syntax = publish_id (module I)
let to_json a = `Int (get a) let to_json a = `Int (get a)
let of_json js = let of_json js =
let k = Ju.to_int js in let k = Ju.to_int js in
try find k try find k
with Not_found -> failure "[%s] No registered id #%d" A.name k with Not_found -> failure "[%s] No registered id #%d" I.name k
end) end)
end end
......
...@@ -321,11 +321,10 @@ module type IdentifiedType = ...@@ -321,11 +321,10 @@ module type IdentifiedType =
sig sig
type t type t
val id : t -> int val id : t -> int
include Info
end end
(** Builds a {i projectified} index on types with {i unique} identifiers. *) (** Builds a {i projectified} index on types with {i unique} identifiers. *)
module Identified(A : IdentifiedType) : Index with type t = A.t module Identified(A : IdentifiedType)(I:Info) : Index with type t = A.t
(* -------------------------------------------------------------------------- *) (* -------------------------------------------------------------------------- *)
(** {2 Error handling} (** {2 Error handling}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment