Download The demexp Book - Linux
Transcript
A response to a question contains the response itself r desc, its author r author and an
optional external link arguing this response.
233a
hposbase.ml 232ai+≡
type response = { r_desc: string;
r_author: authenticated_participant;
mutable external_link: string option;
}
/ 232d 233b .
The author of a vote is either a Delegate or a simple participant whose name has been
Individual.
233b
hposbase.ml 232ai+≡
type vote_author =
Delegate of authenticated_participant
| Individual of string
/ 233a 233c .
A position in the Position base is made of a question, its attached responses, the expressed votes and the optional elected responses (that is set if the votes have been computed).
233c
hposbase.ml 232ai+≡
type position = { question: question;
mutable responses: response array;
votes: (vote_author, int list) Hashtbl.t;
mutable elected_responses: int list;
}
/ 233b 233d .
The different questions (and their responses and vote) are stored in a hash table positions
indexed by the question identifiers. Those identifiers are managed using Id.Question module
in ids table.
We also use Id.Question module to store timestamps associated to each question. Those
timestamps are updated whenever a questions is created or is added a new response.
233d
hposbase.ml 232ai+≡
type position_base = {
ids : Id.Question.t;
positions : (int, position) Hashtbl.t;
(* question id |-> position *)
}
let new_position_base () = {
ids = Id.Question.create ();
positions = Hashtbl.create 3;
}
let the_position_base = ref (new_position_base ())
233
/ 233c 234a .