summaryrefslogtreecommitdiff
path: root/src/candidates.ads
blob: 90b2425957457d0e78b8bc686edb0f95cf6c0d0b (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 Ada.Containers.Vectors;


package Candidates is


    type Candidate is private;
    type CandidateID is Natural;


    type Above_Line_Ballot is private;
    type Below_Line_Ballot is private;


    package Candidate_Vectors is new Ada.Containers.Vectors
           (Index_Type => CandidateID,
            Element_Type => Candidate);


    package CandidateID_Vectors is new Ada.Containers.Vectors
           (Index_Type => Natural,
            Element_Type => CandidateID);


    procedure Read_Candidates
           (Data_File, State : in     String;
            Above_Ballot     :    out Above_Line_Ballot;
            Below_Ballot     :    out Below_Line_Ballot;
            Candidate_List   :    out Candidate_Vectors.Vector);


    function Lookup
           (Above_Ballot : in Above_Line_Ballot;
            Index        : in Natural)
        return CandidateID_Vectors.Vector;


    function Lookup
           (Below_Ballot : in Below_Line_Ballot;
            Index        : in Natural)
        return CandidateID;


private


    type Candidate is record
        ID         : CandidateID;
        First_Name : String;
        Last_Name  : String;
        Group      : String;
        Group_Rank : Natural;
        Party      : String;
    end record;


    package Above_Line_Ballots is new Ada.Containers.Vectors
           (Index_Type => Natural,
            Element_Type => CandidateID_Vectors.Vector);


    package Below_Line_Ballots is new Ada.Containers.Vectors
           (Index_Type => Natural,
            Element_Type => CandidateID);


    type Above_Line_Ballot is Above_Line_Ballots.Vector;
    type Below_Line_Ballot is Below_Line_Ballots.Vector;


end Candidates;