summaryrefslogtreecommitdiff
path: root/src/candidates-containers.ads
blob: b83093a67d7ffad48fd0d714e00912c4ce8c22c6 (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
76
77
78
79
80
81
82


with

    Ada.Containers.Vectors,
    Ada.Containers.Ordered_Maps,
    Ada.Containers.Ordered_Sets;


package Candidates.Containers is


    --  By making this a Vector, later generics will be able to
    --  determine the range of valid CandidateIDs.
    package Candidate_Vectors is new Ada.Containers.Vectors
           (Index_Type   => CandidateID,
            Element_Type => Candidate);


    subtype Candidate_Vector is Candidate_Vectors.Vector;


    procedure Read_Candidates
           (Filename       : in     String;
            State          : in     State_Name;
            Candidate_Data :    out Candidate_Vector);




    --  This must be a Map so that the Index/Key doesn't have to start
    --  from 1, which is important for the Above_Line_Ballot type.
    package CandidateID_Maps is new Ada.Containers.Ordered_Maps
           (Key_Type     => Positive,
            Element_Type => CandidateID);


    --  Technically doesn't have to be a Map, but nonetheless is,
    --  simply for consistency with CandidateID_Maps.
    package CandidateID_Map_Maps is new Ada.Containers.Ordered_Maps
           (Key_Type     => Positive,
            Element_Type => CandidateID_Maps.Map,
            "="          => CandidateID_Maps."=");


    --  Possibly put some aspects here to ensure the types are as expected?
    subtype Above_Line_Ballot is CandidateID_Map_Maps.Map;
    subtype Below_Line_Ballot is CandidateID_Maps.Map;


    procedure Generate_Ballots
           (Candidate_Data : in     Candidate_Vector;
            Above_Ballot   :    out Above_Line_Ballot;
            Below_Ballot   :    out Below_Line_Ballot);


    --  Debugging function
    function To_String
           (Above_Ballot : in Above_Line_Ballot)
        return String;


    --  Debugging function
    function To_String
           (Below_Ballot : in Below_Line_Ballot)
        return String;




    --  Used for passing the CandidateIDs that have been elected, excluded, etc,
    --  around to various functions when calculating the election.
    package CandidateID_Sets is new Ada.Containers.Ordered_Sets
           (Element_Type => CandidateID);


    subtype CandidateID_Set is CandidateID_Sets.Set;


end Candidates.Containers;