summaryrefslogtreecommitdiff
path: root/src/election.ads
blob: 365ff3578bc31161fd75357b1ce8d699ebcdc4e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75


with Candidates.Containers;
with Bundles.Containers;
private with Ada.Containers.Vectors;


generic
    with package Given_Bundles is new Bundles (<>);
    with package Bundle_Containers is new Given_Bundles.Containers (<>);
package Election is


    procedure Setup
           (Candidate_Data           : in Candidates.Containers.Candidate_Map;
            Preference_File          : in String;
            Output_Dir, Main_Logfile : in String;
            Number_To_Elect          : in Natural;
            Is_Verbose               : in Boolean := False)
        with Post => Is_Properly_Setup;


    procedure Run
        with Pre => Is_Properly_Setup;


    function Is_Properly_Setup
        return Boolean;


private


    type Candidate_Status is (Elected, Running, Excluded);


    type Entry_Data is record
        ID            : Candidates.CandidateID;
        Vote_Change   : Integer;
        Total_Votes   : Natural;
        Paper_Change  : Integer;
        Total_Papers  : Natural;
        Status        : Candidate_Status;
        Changed       : Boolean;
        Order_Elected : Natural;
    end record;


    package Entry_Vectors is new Ada.Containers.Vectors
           (Index_Type   => Positive,
            Element_Type => Entry_Data);


    type Pending_Transfer is record
        From     : Candidates.CandidateID;
        Position : Positive;
    end record;


    package Transfer_Vectors is new Ada.Containers.Vectors
           (Index_Type   => Positive,
            Element_Type => Pending_Transfer);


    --  this is used to keep track of exhausted and
    --  fractional loss votes/papers
    type Extra_Data is record
        Paper_Change : Integer;
        Total_Papers : Natural;
    end record;


end Election;