lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [5299] Resolve runtime errors in guideline-premium server


From: Greg Chicares
Subject: [lmi-commits] [5299] Resolve runtime errors in guideline-premium server
Date: Tue, 18 Oct 2011 16:38:28 +0000

Revision: 5299
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5299
Author:   chicares
Date:     2011-10-18 16:38:27 +0000 (Tue, 18 Oct 2011)
Log Message:
-----------
Resolve runtime errors in guideline-premium server

Modified Paths:
--------------
    lmi/trunk/ChangeLog
    lmi/trunk/ihs_basicval.cpp
    lmi/trunk/ihs_server7702.cpp
    lmi/trunk/ihs_server7702io.cpp
    lmi/trunk/ihs_server7702test.cpp

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2011-10-09 15:01:38 UTC (rev 5298)
+++ lmi/trunk/ChangeLog 2011-10-18 16:38:27 UTC (rev 5299)
@@ -28582,3 +28582,11 @@
 Allow direct drill-down editing in census manager (VS). See:
   http://savannah.nongnu.org/support/?105977
 
+20111018T1638Z <address@hidden> [607]
+
+  ihs_basicval.cpp
+  ihs_server7702.cpp
+  ihs_server7702io.cpp
+  ihs_server7702test.cpp
+Resolve runtime errors in guideline-premium server.
+

Modified: lmi/trunk/ihs_basicval.cpp
===================================================================
--- lmi/trunk/ihs_basicval.cpp  2011-10-09 15:01:38 UTC (rev 5298)
+++ lmi/trunk/ihs_basicval.cpp  2011-10-18 16:38:27 UTC (rev 5299)
@@ -84,6 +84,16 @@
     Init();
 }
 
+// Temporary kludge for ancient GPT server.
+template<typename T>
+std::string mc_str(T t)
+{
+    return mc_enum<T>(t).str();
+}
+
+template std::string mc_str(mcenum_class   );
+template std::string mc_str(mcenum_uw_basis);
+
 //============================================================================
 // TODO ?? Not for general use--use for GPT server only. This is bad design.
 BasicValues::BasicValues
@@ -114,20 +124,20 @@
 {
     Input* kludge_input = new Input;
 
-    (*kludge_input)["IssueAge"         ] = value_cast<std::string>(a_IssueAge) 
        ;
-    (*kludge_input)["RetirementAge"    ] = value_cast<std::string>(a_IssueAge) 
        ;
-    (*kludge_input)["Gender"           ] = value_cast<std::string>(a_Gender)   
        ;
-    (*kludge_input)["Smoking"          ] = value_cast<std::string>(a_Smoker)   
        ;
-    (*kludge_input)["UnderwritingClass"] = 
value_cast<std::string>(a_UnderwritingClass);
+    (*kludge_input)["IssueAge"         ] = value_cast<std::string>(a_IssueAge);
+    (*kludge_input)["RetirementAge"    ] = value_cast<std::string>(a_IssueAge);
+    (*kludge_input)["Gender"           ] = mc_str(a_Gender)                   ;
+    (*kludge_input)["Smoking"          ] = mc_str(a_Smoker)                   ;
+    (*kludge_input)["UnderwritingClass"] = mc_str(a_UnderwritingClass)        ;
     if(a_AdbInForce)
         {
-        (*kludge_input)["Status[0].HasADD"] = "Yes";
+        (*kludge_input)["AccidentalDeathBenefit"] = "Yes";
         }
     else
         {
-        (*kludge_input)["Status[0].HasADD"] = "No";
+        (*kludge_input)["AccidentalDeathBenefit"] = "No";
         }
-    (*kludge_input)["GroupUnderwritingType"     ] = 
value_cast<std::string>(a_UnderwritingBasis);
+    (*kludge_input)["GroupUnderwritingType"     ] = 
mc_str(a_UnderwritingBasis);
     (*kludge_input)["ProductName"               ] = a_ProductName;
     (*kludge_input)["PremiumTaxState"           ] = 
mc_str(a_StateOfJurisdiction);
     (*kludge_input)["DefinitionOfLifeInsurance" ] = "GPT";
@@ -267,6 +277,14 @@
     EndtAge = static_cast<int>(Database_->Query(DB_MaturityAge));
     Length = EndtAge - IssueAge;
 
+    yare_input_.ExtraMonthlyCustodialFee  .resize(Length);
+    yare_input_.ExtraCompensationOnAssets .resize(Length);
+    yare_input_.ExtraCompensationOnPremium.resize(Length);
+    yare_input_.CurrentCoiMultiplier      .resize(Length);
+    yare_input_.SpecifiedAmount           .resize(Length);
+    yare_input_.DeathBenefitOption        .resize(Length);
+    yare_input_.FlatExtra                 .resize(Length);
+
     LedgerType_ =
         static_cast<mcenum_ledger_type>
             (static_cast<int>
@@ -299,9 +317,13 @@
     StratifiedCharges_.reset
         (new 
stratified_charges(AddDataDir(ProductData_->datum("TierFilename")))
         );
+    SpreadFor7702_.assign
+        (Length
+        ,StratifiedCharges_->minimum_tiered_spread_for_7702()
+        );
 
     // Requires database.
-//  MortalityRates_.reset(new MortalityRates (*this));
+    MortalityRates_.reset(new MortalityRates (*this)); // Used by certain 
target-premium calculations.
 //  InterestRates_ .reset(new InterestRates  (*this));
     // Will require mortality rates eventually.
 //  SurrChgRates_  .reset(new SurrChgRates   (Database_));

Modified: lmi/trunk/ihs_server7702.cpp
===================================================================
--- lmi/trunk/ihs_server7702.cpp        2011-10-09 15:01:38 UTC (rev 5298)
+++ lmi/trunk/ihs_server7702.cpp        2011-10-18 16:38:27 UTC (rev 5299)
@@ -34,9 +34,11 @@
 #include "assert_lmi.hpp"
 #include "basic_values.hpp"
 #include "fenv_lmi.hpp"
+#include "handle_exceptions.hpp"
 #include "ihs_irc7702.hpp"
 #include "ihs_server7702io.hpp"
 #include "ihs_x_type.hpp"
+#include "path_utility.hpp" // initialize_filesystem()
 
 #if defined LMI_MSW
 #   include <windows.h> // HINSTANCE etc.
@@ -51,10 +53,20 @@
 //============================================================================
 int main()
 {
-    InitializeServer7702();
-    // Read from std input, process, and write to std output
-    return RunServer7702();
+    std::set_terminate(lmi_terminate_handler);
+    try
+        {
+        // Absolute paths require "native" name-checking policy for msw.
+        initialize_filesystem();
+        InitializeServer7702();
+        // Read from std input, process, and write to std output
+        return RunServer7702();
 // TODO ?? NEED DECISION What should this return?
+        }
+    catch(...)
+        {
+        report_exception();
+        }
 }
 
 //============================================================================

Modified: lmi/trunk/ihs_server7702io.cpp
===================================================================
--- lmi/trunk/ihs_server7702io.cpp      2011-10-09 15:01:38 UTC (rev 5298)
+++ lmi/trunk/ihs_server7702io.cpp      2011-10-18 16:38:27 UTC (rev 5299)
@@ -32,6 +32,7 @@
 #include <ios>
 #include <istream>
 #include <ostream>
+#include <sstream>
 #include <string>
 
 // TODO ?? NEED DECISION on i/o representation.
@@ -51,6 +52,11 @@
 //============================================================================
 std::istream& operator>> (std::istream& is, Server7702Input& z)
 {
+    // Use of std::stringstream here is a kludge. That doesn't matter
+    // because this obsolescent code will soon be removed.
+    std::string s;
+    std::stringstream ss;
+
     is >> z.UniqueIdentifier;
     is >> z.IsIssuedToday;
     is >> z.Duration;
@@ -58,25 +64,25 @@
     is >> z.Premium;
     is >> z.DecreaseRequiredByContract;
     is >> z.ProductName;
-    is >> z.UnderwritingBasis;
+    s.clear(); ss.clear(); ss.str(""); is >> std::ws; is >> s; ss << s; ss >> 
z.UnderwritingBasis;
     is >> z.PremTaxLoadRate;
     is >> z.TieredAssetChargeRate;
     is >> z.LeastBenefitAmountEver;
-    is >> z.TargetPremium;
+//    is >> z.TargetPremium; // Apparently this came at the end long ago.
     is >> z.OldGuidelineLevelPremium;
     is >> z.OldGuidelineSinglePremium;
     is >> z.NewIssueAge;
     is >> z.OldIssueAge;
-    is >> z.NewGender;
-    is >> z.OldGender;
-    is >> z.NewSmoker;
-    is >> z.OldSmoker;
-    is >> z.NewUnderwritingClass;
-    is >> z.OldUnderwritingClass;
-    is >> z.NewStateOfJurisdiction;
-    is >> z.OldStateOfJurisdiction;
-    is >> z.NewDeathBenefitOption;
-    is >> z.OldDeathBenefitOption;
+    s.clear(); ss.clear(); ss.str(""); is >> std::ws; is >> s; ss << s; ss >> 
z.NewGender;
+    s.clear(); ss.clear(); ss.str(""); is >> std::ws; is >> s; ss << s; ss >> 
z.OldGender;
+    s.clear(); ss.clear(); ss.str(""); is >> std::ws; is >> s; ss << s; ss >> 
z.NewSmoker;
+    s.clear(); ss.clear(); ss.str(""); is >> std::ws; is >> s; ss << s; ss >> 
z.OldSmoker;
+    s.clear(); ss.clear(); ss.str(""); is >> std::ws; is >> s; ss << s; ss >> 
z.NewUnderwritingClass;
+    s.clear(); ss.clear(); ss.str(""); is >> std::ws; is >> s; ss << s; ss >> 
z.OldUnderwritingClass;
+    s.clear(); ss.clear(); ss.str(""); is >> std::ws; is >> s; ss << s; ss >> 
z.NewStateOfJurisdiction;
+    s.clear(); ss.clear(); ss.str(""); is >> std::ws; is >> s; ss << s; ss >> 
z.OldStateOfJurisdiction;
+    s.clear(); ss.clear(); ss.str(""); is >> std::ws; is >> s; ss << s; ss >> 
z.NewDeathBenefitOption;
+    s.clear(); ss.clear(); ss.str(""); is >> std::ws; is >> s; ss << s; ss >> 
z.OldDeathBenefitOption;
     is >> z.NewBenefitAmount;
     is >> z.OldBenefitAmount;
     is >> z.NewSpecifiedAmount;
@@ -87,14 +93,14 @@
     is >> z.OldWaiverOfPremiumInForce;
     is >> z.NewPremiumsWaived;
     is >> z.OldPremiumsWaived;
-    is >> z.NewWaiverOfPremiumRating;
-    is >> z.OldWaiverOfPremiumRating;
+    s.clear(); ss.clear(); ss.str(""); is >> std::ws; is >> s; ss << s; ss >> 
z.NewWaiverOfPremiumRating;
+    s.clear(); ss.clear(); ss.str(""); is >> std::ws; is >> s; ss << s; ss >> 
z.OldWaiverOfPremiumRating;
     is >> z.NewAccidentalDeathInForce;
     is >> z.OldAccidentalDeathInForce;
-    is >> z.NewAccidentalDeathRating;
-    is >> z.OldAccidentalDeathRating;
-    is >> z.NewTableRating;
-    is >> z.OldTableRating;
+    s.clear(); ss.clear(); ss.str(""); is >> std::ws; is >> s; ss << s; ss >> 
z.NewAccidentalDeathRating;
+    s.clear(); ss.clear(); ss.str(""); is >> std::ws; is >> s; ss << s; ss >> 
z.OldAccidentalDeathRating;
+    s.clear(); ss.clear(); ss.str(""); is >> std::ws; is >> s; ss << s; ss >> 
z.NewTableRating;
+    s.clear(); ss.clear(); ss.str(""); is >> std::ws; is >> s; ss << s; ss >> 
z.OldTableRating;
 
     // I give the names with a suffix "0" here,
     // but they need to be repeated with "1", "2",
@@ -118,6 +124,7 @@
     is >> z.OldTemporaryFlatDuration1;
     is >> z.NewTemporaryFlatDuration2;
     is >> z.OldTemporaryFlatDuration2;
+    is >> z.TargetPremium; // Apparently this came at the end long ago.
 
     return is;
 }

Modified: lmi/trunk/ihs_server7702test.cpp
===================================================================
--- lmi/trunk/ihs_server7702test.cpp    2011-10-09 15:01:38 UTC (rev 5298)
+++ lmi/trunk/ihs_server7702test.cpp    2011-10-18 16:38:27 UTC (rev 5299)
@@ -28,6 +28,8 @@
 
 #include "ihs_server7702.hpp"
 
+#include "handle_exceptions.hpp"
+#include "path_utility.hpp" // initialize_filesystem()
 #include "so_attributes.hpp"
 
 #if defined LMI_POSIX
@@ -188,7 +190,7 @@
         );
 */
     char c[] =
-        "1 1 0 0 10000 0 " "sample" "\nMedical\n .02 0 1000000 0 0 0"
+        "1 1 0 0 10000 0 " "sample" "\nMedical\n .02 0 1000000 0 0"
         " 45 
45\nMale\nMale\nNonsmoker\nNonsmoker\nPreferred\nPreferred\nCT\nCT\nA\nA\n"
         " 1000000 1000000 1000000 1000000 0 0 0 0 0 0"
         "\nA=+25%\nA=+25%\n0 0\nNone\nNone\nP=+400%\nP=+400%\n"
@@ -199,6 +201,12 @@
 1 0 0 19643.11999999999898136593 213777.04000000000814907253 
19643.1199999999989
 8136593 213777.04000000000814907253 0.00000000000000000000 
0.0000000000000000000
 0 0.00000000000000000000 0.00000000000000000000 1000000.00000000000000000000
+
+but now it is:
+1 0 0 22110.68343118850680184551 239162.50350465354858897626 
22110.6834311885068
+0184551 239162.50350465354858897626 0.00000000000000000000 
0.0000000000000000000
+0 0.00000000000000000000 0.00000000000000000000
+
 */
 
     char o[16384];
@@ -208,20 +216,30 @@
     int j; for(j = 0; j < 1000; j++)
 */
 
+    std::set_terminate(lmi_terminate_handler);
+    try
+        {
+        // Absolute paths require "native" name-checking policy for msw.
+        initialize_filesystem();
 #if defined LMI_POSIX
-    dlopen("gpt_server.so", RTLD_LAZY | RTLD_GLOBAL);
+        dlopen("gpt_server.so", RTLD_LAZY | RTLD_GLOBAL);
 #elif defined LMI_MSW
-    LoadLibrary("gpt_server.dll");
+        LoadLibrary("gpt_server.dll");
 #else // Unknown platform.
 #   error "Unknown platform. Consider contributing support."
 #endif // Unknown platform.
 
-    InitializeServer7702();
-    RunServer7702FromString(c, o);
-    std::fprintf
-        (stdout
-        ,"%s\n"
-        ,o
-        );
+        InitializeServer7702();
+        RunServer7702FromString(c, o);
+        std::fprintf
+            (stdout
+            ,"%s\n"
+            ,o
+            );
+        }
+    catch(...)
+        {
+        report_exception();
+        }
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]