diff options
author | Jed Barber <jjbarber@y7mail.com> | 2017-02-12 23:07:52 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2017-02-12 23:07:52 +1100 |
commit | 348dc88775fac78f5c1afa30c4f00d6d14dff592 (patch) | |
tree | b96db643d0642edf54242da5c672f3096bb98e22 /src/election.ads | |
parent | 60b2207a469a5a1e7a7e5619a8eb1b01c67f314a (diff) |
Election counting now works, logging improved from Haskell version, still need to fix exhausted paper collection
Diffstat (limited to 'src/election.ads')
-rw-r--r-- | src/election.ads | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/src/election.ads b/src/election.ads new file mode 100644 index 0000000..365ff35 --- /dev/null +++ b/src/election.ads @@ -0,0 +1,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; + + |