From: Michal Malý Date: Fri, 5 Dec 2014 18:18:37 +0000 (+0100) Subject: Create Titration_Curve_Suite package skeleton X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=86037984304678c00a1f6d69c80e83f1eac324ad;p=Nine-Q.git Create Titration_Curve_Suite package skeleton --- diff --git a/src/problem_generators/problem_generator-titration_curve_suite.adb b/src/problem_generators/problem_generator-titration_curve_suite.adb new file mode 100644 index 0000000..c54fec3 --- /dev/null +++ b/src/problem_generators/problem_generator-titration_curve_suite.adb @@ -0,0 +1,37 @@ +separate(Problem_Generator) + +package body Titration_Curve_Suite is + + -- BEGIN: Inherited functions + function Create return access Titration_Curve_Problem is + begin + return new Titration_Curve_Problem; + end Create; + + function Check_Answer(Problem: in out Titration_Curve_Problem; Answer: in Answer_Info.Map; + Message: out UB_Text) return Answer_RetCode is + begin + return No_Answer; + end Check_Answer; + + function Get_Assignment(Problem: in out Titration_Curve_Problem; Assignment: in out Assignment_Info.Map) return RetCode is + begin + return E_INVAL; + end Get_Assignment; + + function Get_Parameters(Problem: in out Titration_Curve_Problem; Parameters: out Parameters_Info.Map) return RetCode is + begin + return E_INVAL; + end Get_Parameters; + + procedure New_Problem(Problem: in out Titration_Curve_Problem) is + begin + null; + end New_problem; + + function Set_Parameters(Problem: in out Titration_Curve_Problem; Parameters: in Parameters_Info.Map) return RetCode is + begin + return E_INVAL; + end Set_Parameters; + +end Titration_Curve_Suite; diff --git a/src/problem_generators/problem_generator.adb b/src/problem_generators/problem_generator.adb index 672f87f..140f737 100644 --- a/src/problem_generators/problem_generator.adb +++ b/src/problem_generators/problem_generator.adb @@ -24,7 +24,7 @@ package body Problem_Generator is end if; end Finalize; end Auto_Lock; - + function Get_Problem(P_Type: in Problem_Type) return access Chem_Problem'Class is begin case P_Type is @@ -32,10 +32,13 @@ package body Problem_Generator is return Acidobazic_Suite.Create; when Solubility => return Solubility_Suite.Create; + when Titration_Curve => + return Titration_Curve_Suite.Create; end case; end Get_Problem; package body Acidobazic_Suite is separate; package body Solubility_Suite is separate; + package body Titration_Curve_Suite is separate; end Problem_Generator; diff --git a/src/problem_generators/problem_generator.ads b/src/problem_generators/problem_generator.ads index c9b0b5b..ab646d2 100644 --- a/src/problem_generators/problem_generator.ads +++ b/src/problem_generators/problem_generator.ads @@ -156,7 +156,7 @@ private Ks_MW: SS_Float; -- Molar mass of the sample Ks_V: SS_Float; -- Sample volume in dm3 when C_FROM_KS_DIFFERENT_IONS | C_FROM_KS_SHARED_ION => - C_EC: SS_Float; -- Concentration of the other electrolyte in the solution + C_EC: SS_Float; -- Concentration of the other electrolyte in the solution C_Ks: SS_Float; -- Ks constant end case; end record; @@ -183,4 +183,25 @@ private end Solubility_Suite; + package Titration_Curve_Suite is + use Problem_Generator_Syswides.Titration_Curve_Suite; + + type Titration_Curve_Problem is new Problem_Generator.Chem_Problem with private; + -- Constructor + function Create return access Titration_Curve_Problem; + -- Inherited + function Check_Answer(Problem: in out Titration_Curve_Problem; Answer: in Answer_Info.Map; Message: out UB_Text) return Answer_RetCode; + function Get_Assignment(Problem: in out Titration_Curve_Problem; Assignment: in out Assignment_Info.Map) return RetCode; + function Get_Parameters(Problem: in out Titration_Curve_Problem; Parameters: out Parameters_Info.Map) return RetCode; + procedure New_Problem(Problem: in out Titration_Curve_Problem); + function Set_Parameters(Problem: in out Titration_Curve_Problem; Parameters: in Parameters_Info.Map) return RetCode; + + private + type T_Float is digits 15; + + type Titration_Curve_Problem is new Problem_Generator.Chem_Problem with null record; + + end Titration_Curve_Suite; + + end Problem_Generator; diff --git a/src/problem_generators/problem_generator_syswides.ads b/src/problem_generators/problem_generator_syswides.ads index 3694316..b6b238e 100644 --- a/src/problem_generators/problem_generator_syswides.ads +++ b/src/problem_generators/problem_generator_syswides.ads @@ -3,7 +3,7 @@ with Ada.Containers.Indefinite_Ordered_Maps; package Problem_Generator_Syswides is type Answer_RetCode is (Invalid_Answer, No_Answer, Correct_Answer, Wrong_Answer, Malformed_Answer); - type Problem_Type is (Acidobazic, Solubility); + type Problem_Type is (Acidobazic, Solubility, Titration_Curve); package Answer_Info is new Ada.Containers.Indefinite_Ordered_Maps(String, String); package Assignment_Info is new Ada.Containers.Indefinite_Ordered_Maps(String, String); package Parameters_Info is new Ada.Containers.Indefinite_Ordered_Maps(String, String); @@ -80,4 +80,8 @@ package Problem_Generator_Syswides is end Solubility_Suite; + package Titration_Curve_Suite is + PROBLEM_NAME_READABLE: constant String := "Titrační křivka"; + end Titration_Curve_Suite; + end Problem_Generator_Syswides; diff --git a/src/problem_manager.adb b/src/problem_manager.adb index 7457b7a..487825f 100644 --- a/src/problem_manager.adb +++ b/src/problem_manager.adb @@ -105,6 +105,8 @@ package body Problem_Manager is P_Cat := Problem_Manager.Acidobazic; elsif Raw_P_Cat = Problem_Manager.Problem_Category'Image(Problem_Manager.Solubility) then P_Cat := Problem_Manager.Solubility; + elsif Raw_P_Cat = Problem_Manager.Problem_Category'Image(Problem_Manager.Titration_Curve) then + P_Cat := Problem_Manager.Titration_Curve; else return E_INVAL; end if; @@ -114,6 +116,8 @@ package body Problem_Manager is Problem := Problem_Generator.Get_Problem(Problem_Generator_Syswides.Acidobazic); when Solubility => Problem := Problem_Generator.Get_Problem(Problem_Generator_Syswides.Solubility); + when Titration_Curve => + Problem := Problem_Generator.Get_Problem(Problem_Generator_Syswides.Titration_Curve); when others => return E_INVAL; end case; @@ -282,12 +286,12 @@ package body Problem_Manager is procedure Free_Session_Data_Internal is new Ada.Unchecked_Deallocation(Object => User_Session_Data, Name => User_Session_All_Access); begin Free_Session_Data_Internal(Data); - end Free_Session_Data; - + end Free_Session_Data; + function Get_Problem(UID: in Unique_ID; Pr_ID: in Problem_ID) return Stored_Problem_All_Access is use Problem_Storage; use Session_Keeping; - + USD: User_Session_All_Access; S: Stored_Problem_All_Access; begin diff --git a/src/problem_manager.ads b/src/problem_manager.ads index ab460e9..a0046be 100644 --- a/src/problem_manager.ads +++ b/src/problem_manager.ads @@ -7,7 +7,7 @@ with AWS.Session; use Global_Types; package Problem_Manager is - type Problem_Category is (Invalid, Acidobazic, Solubility); + type Problem_Category is (Invalid, Acidobazic, Solubility, Titration_Curve); function Display_Checked_Answer(UID: in Unique_ID; Answer: in Problem_Generator_Syswides.Answer_Info.Map; HTML: out HTML_Code; Pr_ID: in Problem_ID) return RetCode; @@ -46,7 +46,7 @@ private ERRMSG_GET_ASSIGNMENT: constant String := "Unable to get assignment"; ERRMSG_GET_PARAMETERS: constant String := "Unable to get problem parameters"; ERRMSG_UNHANDLED_EXCEPTION: constant String := "Unhandled exception occured"; - + package Session_Keeping is new Ada.Containers.Ordered_Maps(Key_Type => Unique_ID, Element_Type => User_Session_All_Access); protected Active_Sessions is