lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master ee8667d 13/25: Turn a local variable into a m


From: Greg Chicares
Subject: [lmi-commits] [lmi] master ee8667d 13/25: Turn a local variable into a member
Date: Wed, 24 Feb 2021 19:00:53 -0500 (EST)

branch: master
commit ee8667d089a50a10c6c4e2c89db0def0b26f60d9
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Turn a local variable into a member
    
    The new member is a unique_ptr for concinnity with its congeners. The
    definition of pointed-to class i7702 therefore must appear wherever its
    dtor is needed, but is not required in the header of the class that owns
    the pointer.
    
    Incidentally made the new member a unique_ptr to const, and similarly
    constified congeners on which non-const member functions aren't called.
---
 basic_values.hpp | 19 +++++++++++--------
 basicvalues.cpp  |  1 +
 group_values.cpp |  1 +
 ihs_basicval.cpp | 15 ++++++---------
 4 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/basic_values.hpp b/basic_values.hpp
index f02909b..2f33900 100644
--- a/basic_values.hpp
+++ b/basic_values.hpp
@@ -60,6 +60,7 @@ class Irc7702A;
 class Loads;
 class MortalityRates;
 class death_benefits;
+class i7702;
 class lingo;
 class modal_outlay;
 class premium_tax;
@@ -126,14 +127,16 @@ class LMI_SO BasicValues
     std::shared_ptr<rounding_rules     const> const RoundingRules_;
     std::shared_ptr<stratified_charges const> const StratifiedCharges_;
 
-    std::unique_ptr<MortalityRates>     MortalityRates_;
-    std::unique_ptr<InterestRates>      InterestRates_;
-    std::unique_ptr<death_benefits>     DeathBfts_;
-    std::unique_ptr<modal_outlay>       Outlay_;
-    std::unique_ptr<premium_tax>        PremiumTax_;
-    std::unique_ptr<Loads>              Loads_;
-    std::unique_ptr<Irc7702>            Irc7702_;
-    std::unique_ptr<Irc7702A>           Irc7702A_;
+    std::unique_ptr<i7702          const> i7702_;
+
+    std::unique_ptr<MortalityRates const> MortalityRates_;
+    std::unique_ptr<InterestRates       > InterestRates_;
+    std::unique_ptr<death_benefits      > DeathBfts_;
+    std::unique_ptr<modal_outlay        > Outlay_;
+    std::unique_ptr<premium_tax         > PremiumTax_;
+    std::unique_ptr<Loads          const> Loads_;
+    std::unique_ptr<Irc7702             > Irc7702_;
+    std::unique_ptr<Irc7702A            > Irc7702A_;
 
     product_data     const& product () const {return *product_;}
     product_database const& database() const {return database_;}
diff --git a/basicvalues.cpp b/basicvalues.cpp
index 6a4726b..ec65687 100644
--- a/basicvalues.cpp
+++ b/basicvalues.cpp
@@ -30,6 +30,7 @@
 #include "ihs_irc7702a.hpp"             // dtor only, for (unused) unique_ptr
 #include "input.hpp"
 #include "interest_rates.hpp"
+#include "irc7702_interest.hpp"         // dtor only, for (unused) unique_ptr
 #include "loads.hpp"
 #include "mortality_rates.hpp"
 #include "outlay.hpp"
diff --git a/group_values.cpp b/group_values.cpp
index d2d8a69..96620f0 100644
--- a/group_values.cpp
+++ b/group_values.cpp
@@ -47,6 +47,7 @@
 #include "ihs_irc7702.hpp"
 #include "ihs_irc7702a.hpp"
 #include "interest_rates.hpp"
+#include "irc7702_interest.hpp"
 #include "loads.hpp"
 #include "mortality_rates.hpp"
 #include "outlay.hpp"
diff --git a/ihs_basicval.cpp b/ihs_basicval.cpp
index 1e25678..d96204b 100644
--- a/ihs_basicval.cpp
+++ b/ihs_basicval.cpp
@@ -76,6 +76,7 @@ BasicValues::BasicValues(Input const& input)
         (AddDataDir(product().datum("RoundingFilename"))))
     ,StratifiedCharges_  (stratified_charges::read_via_cache
         (AddDataDir(product().datum("TierFilename"))))
+    ,i7702_              {std::make_unique<i7702>(database(), 
*StratifiedCharges_)}
     ,DefnLifeIns_        {mce_cvat}
     ,DefnMaterialChange_ {mce_unnecessary_premium}
     ,Effective7702DboRop {mce_option1_for_7702}
@@ -124,6 +125,7 @@ BasicValues::BasicValues
         (AddDataDir(product().datum("RoundingFilename"))))
     ,StratifiedCharges_  (stratified_charges::read_via_cache
         (AddDataDir(product().datum("TierFilename"))))
+    ,i7702_              {std::make_unique<i7702>(database(), 
*StratifiedCharges_)}
     ,DefnLifeIns_        {mce_cvat}
     ,DefnMaterialChange_ {mce_unnecessary_premium}
     ,Effective7702DboRop {a_DBOptFor7702}
@@ -300,8 +302,6 @@ void BasicValues::Init()
     SetMaxSurvivalDur();
     set_partial_mortality();
 
-    // 7702 !! should become a member, to be shared with 7702A:
-//  i7702_ = i7702(database(), *StratifiedCharges_);
     Init7702();
     Init7702A();
 }
@@ -435,9 +435,6 @@ void BasicValues::Init7702()
         || mce_variable_loan_rate != yare_input_.LoanRateType
         );
 
-    // 7702 !! local with '_' suffix: should become a member
-    i7702 i7702_(database(), *StratifiedCharges_);
-
 #if 1 // 7702 !! moved to class i7702
     std::vector<double> const SpreadFor7702_
         (Length
@@ -509,10 +506,10 @@ void BasicValues::Init7702()
 
     database().query_into(DB_NaarDiscount, Mly7702ig);
 #endif // 1 // 7702 !! moved to class i7702
-    LMI_ASSERT(i7702_.gross  () == Mly7702ig);
-    LMI_ASSERT(i7702_.net_glp() == Mly7702iGlp);
-    LMI_ASSERT(i7702_.net_gsp() == Mly7702iGsp);
-    LMI_ASSERT(i7702_.spread () == SpreadFor7702_);
+    LMI_ASSERT(i7702_->gross  () == Mly7702ig);
+    LMI_ASSERT(i7702_->net_glp() == Mly7702iGlp);
+    LMI_ASSERT(i7702_->net_gsp() == Mly7702iGsp);
+    LMI_ASSERT(i7702_->spread () == SpreadFor7702_);
 
     // TODO ?? We should avoid reading the rate file again; but
     // the GPT server doesn't initialize a MortalityRates object



reply via email to

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