lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [4838] Refactor


From: Greg Chicares
Subject: [lmi-commits] [4838] Refactor
Date: Wed, 14 Apr 2010 18:35:16 +0000

Revision: 4838
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=4838
Author:   chicares
Date:     2010-04-14 18:35:16 +0000 (Wed, 14 Apr 2010)
Log Message:
-----------
Refactor

Modified Paths:
--------------
    lmi/trunk/antediluvian_stubs.cpp
    lmi/trunk/input.hpp
    lmi/trunk/input_xml_io.cpp
    lmi/trunk/mec_input.cpp
    lmi/trunk/mec_input.hpp
    lmi/trunk/mec_state.cpp
    lmi/trunk/mec_state.hpp
    lmi/trunk/product_data.cpp
    lmi/trunk/product_data.hpp
    lmi/trunk/xml_serializable.hpp
    lmi/trunk/xml_serializable.tpp

Modified: lmi/trunk/antediluvian_stubs.cpp
===================================================================
--- lmi/trunk/antediluvian_stubs.cpp    2010-04-14 14:55:15 UTC (rev 4837)
+++ lmi/trunk/antediluvian_stubs.cpp    2010-04-14 18:35:16 UTC (rev 4838)
@@ -84,13 +84,13 @@
     return false;
 }
 
-std::string mec_state::redintegrate_ex_ante
+bool mec_state::redintegrate_ex_ante
     (int
     ,std::string const&
-    ,std::string const&
+    ,std::string      &
     ) const
 {
-    return empty_string;
+    return false;
 }
 
 void mec_state::redintegrate_ex_post

Modified: lmi/trunk/input.hpp
===================================================================
--- lmi/trunk/input.hpp 2010-04-14 14:55:15 UTC (rev 4837)
+++ lmi/trunk/input.hpp 2010-04-14 18:35:16 UTC (rev 4838)
@@ -172,17 +172,17 @@
     virtual int         class_version() const;
     virtual std::string xml_root_name() const;
     virtual bool        is_detritus(std::string const&) const;
-    virtual std::string redintegrate_ex_ante
+    virtual bool redintegrate_ex_ante
         (int                file_version
         ,std::string const& name
-        ,std::string const& value
+        ,std::string      & value
         ) const;
-    virtual void        redintegrate_ex_post
+    virtual void redintegrate_ex_post
         (int                                file_version
         ,std::map<std::string, std::string> detritus_map
         ,std::list<std::string>             residuary_names
         );
-    virtual void        redintegrate_ad_terminum();
+    virtual void redintegrate_ad_terminum();
 
     // MvcModel required implementation.
     virtual void DoAdaptExternalities();

Modified: lmi/trunk/input_xml_io.cpp
===================================================================
--- lmi/trunk/input_xml_io.cpp  2010-04-14 14:55:15 UTC (rev 4837)
+++ lmi/trunk/input_xml_io.cpp  2010-04-14 18:35:16 UTC (rev 4838)
@@ -121,19 +121,17 @@
     return v.end() != std::find(v.begin(), v.end(), s);
 }
 
-std::string Input::redintegrate_ex_ante
+bool Input::redintegrate_ex_ante
     (int                file_version
     ,std::string const& name
-    ,std::string const& value
+    ,std::string      & value
     ) const
 {
     if(class_version() == file_version)
         {
-        return value;
+        return false;
         }
 
-    std::string new_value(value);
-
     // Prior to version 3, 'SolveType' distinguished:
     //   mce_solve_wd           --> !WithdrawToBasisThenLoan
     //   mce_solve_wd_then_loan -->  WithdrawToBasisThenLoan
@@ -163,11 +161,11 @@
                     << LMI_FLUSH
                     ;
                 }
-            new_value = "Allow MEC";
+            value = "Allow MEC";
             }
         if("DeprecatedSolveTgtAtWhich" == name)
             {
-            new_value =
+            value =
                   ("TgtAtRetirement" == value) ? "Retirement"
                 : ("TgtAtYear"       == value) ? "Year"
                 : ("TgtAtAge"        == value) ? "Age"
@@ -177,7 +175,7 @@
             }
         if("DeprecatedSolveFromWhich" == name)
             {
-            new_value =
+            value =
                   ("FromIssue"      == value) ? "Issue"
                 : ("FromYear"       == value) ? "Year"
                 : ("FromAge"        == value) ? "Age"
@@ -187,7 +185,7 @@
             }
         if("DeprecatedSolveToWhich" == name)
             {
-            new_value =
+            value =
                   ("ToRetirement"    == value) ? "Retirement"
                 : ("ToYear"          == value) ? "Year"
                 : ("ToAge"           == value) ? "Age"
@@ -197,7 +195,7 @@
             }
         if("SolveBasis" == name)
             {
-            new_value =
+            value =
                   ("Current basis"    == value) ? "Current"
                 : ("Current_basis"    == value) ? "Current"
                 : ("Guaranteed basis" == value) ? "Guaranteed"
@@ -210,7 +208,7 @@
 
         if("SolveSeparateAccountBasis" == name)
             {
-            new_value =
+            value =
                   ("Input %"         == value) ? "Hypothetical"
                 : ("Input_%"         == value) ? "Hypothetical"
                 : ("Zero %"          == value) ? "Zero"
@@ -223,7 +221,7 @@
 
         if("SolveType" == name)
             {
-            new_value =
+            value =
                   ("SolveNone"       == value) ? "No solve"
                 : ("SolveSpecAmt"    == value) ? "Specified amount"
                 : ("SolveEePrem"     == value) ? "Employee premium"
@@ -237,7 +235,7 @@
 
         if("SolveTarget" == name)
             {
-            new_value =
+            value =
                   ("SolveForEndt"     == value) ? "Endowment"
                 : ("SolveForTarget"   == value) ? "Target CSV"
                 : ("SolveForTaxBasis" == value) ? "CSV = tax basis"
@@ -248,7 +246,7 @@
 
         if("GeneralAccountRateType" == name)
             {
-            new_value =
+            value =
                   ("CredRate"  == value) ? "Credited rate"
                 : ("NetRate"   == value) ? "Credited rate"
                 : ("GrossRate" == value) ? "Earned rate"
@@ -258,7 +256,7 @@
 
         if("SeparateAccountRateType" == name)
             {
-            new_value =
+            value =
                   ("CredRate"  == value) ? "Net rate"
                 : ("NetRate"   == value) ? "Net rate"
                 : ("GrossRate" == value) ? "Gross rate"
@@ -268,7 +266,7 @@
 
         if("LoanRateType" == name)
             {
-            new_value =
+            value =
                   ("Fixed" == value) ? "Fixed loan rate"
                 : ("VLR"   == value) ? "Variable loan rate"
                 : throw std::runtime_error(value + ": unexpected loan-rate 
type.")
@@ -276,7 +274,7 @@
             }
         }
 
-    return new_value;
+    return true;
 }
 
 void Input::redintegrate_ex_post

Modified: lmi/trunk/mec_input.cpp
===================================================================
--- lmi/trunk/mec_input.cpp     2010-04-14 14:55:15 UTC (rev 4837)
+++ lmi/trunk/mec_input.cpp     2010-04-14 18:35:16 UTC (rev 4838)
@@ -631,10 +631,10 @@
     return v.end() != std::find(v.begin(), v.end(), s);
 }
 
-std::string mec_input::redintegrate_ex_ante
+bool mec_input::redintegrate_ex_ante
     (int                file_version
     ,std::string const& name
-    ,std::string const& value
+    ,std::string      & value
     ) const
 {
     typedef xml_serializable<mec_input> base;

Modified: lmi/trunk/mec_input.hpp
===================================================================
--- lmi/trunk/mec_input.hpp     2010-04-14 14:55:15 UTC (rev 4837)
+++ lmi/trunk/mec_input.hpp     2010-04-14 18:35:16 UTC (rev 4838)
@@ -105,17 +105,17 @@
     virtual int         class_version() const;
     virtual std::string xml_root_name() const;
     virtual bool        is_detritus(std::string const&) const;
-    virtual std::string redintegrate_ex_ante
+    virtual bool redintegrate_ex_ante
         (int                file_version
         ,std::string const& name
-        ,std::string const& value
+        ,std::string      & value
         ) const;
-    virtual void        redintegrate_ex_post
+    virtual void redintegrate_ex_post
         (int                                file_version
         ,std::map<std::string, std::string> detritus_map
         ,std::list<std::string>             residuary_names
         );
-    virtual void        redintegrate_ad_terminum();
+    virtual void redintegrate_ad_terminum();
 
     // MvcModel required implementation.
     virtual void DoAdaptExternalities();

Modified: lmi/trunk/mec_state.cpp
===================================================================
--- lmi/trunk/mec_state.cpp     2010-04-14 14:55:15 UTC (rev 4837)
+++ lmi/trunk/mec_state.cpp     2010-04-14 18:35:16 UTC (rev 4838)
@@ -410,10 +410,10 @@
     return v.end() != std::find(v.begin(), v.end(), s);
 }
 
-std::string mec_state::redintegrate_ex_ante
+bool mec_state::redintegrate_ex_ante
     (int                file_version
     ,std::string const& name
-    ,std::string const& value
+    ,std::string      & value
     ) const
 {
     typedef xml_serializable<mec_state> base;

Modified: lmi/trunk/mec_state.hpp
===================================================================
--- lmi/trunk/mec_state.hpp     2010-04-14 14:55:15 UTC (rev 4837)
+++ lmi/trunk/mec_state.hpp     2010-04-14 18:35:16 UTC (rev 4838)
@@ -71,17 +71,17 @@
     virtual int         class_version() const;
     virtual std::string xml_root_name() const;
     virtual bool        is_detritus(std::string const&) const;
-    virtual std::string redintegrate_ex_ante
+    virtual bool redintegrate_ex_ante
         (int                file_version
         ,std::string const& name
-        ,std::string const& value
+        ,std::string      & value
         ) const;
-    virtual void        redintegrate_ex_post
+    virtual void redintegrate_ex_post
         (int                                file_version
         ,std::map<std::string, std::string> detritus_map
         ,std::list<std::string>             residuary_names
         );
-    virtual void        redintegrate_ad_terminum();
+    virtual void redintegrate_ad_terminum();
 
     int    B0_deduced_policy_year;
     int    B1_deduced_contract_year;

Modified: lmi/trunk/product_data.cpp
===================================================================
--- lmi/trunk/product_data.cpp  2010-04-14 14:55:15 UTC (rev 4837)
+++ lmi/trunk/product_data.cpp  2010-04-14 18:35:16 UTC (rev 4838)
@@ -207,10 +207,10 @@
     return v.end() != std::find(v.begin(), v.end(), s);
 }
 
-std::string product_data::redintegrate_ex_ante
+bool product_data::redintegrate_ex_ante
     (int                file_version
     ,std::string const& name
-    ,std::string const& value
+    ,std::string      & value
     ) const
 {
     typedef xml_serializable<product_data> base;

Modified: lmi/trunk/product_data.hpp
===================================================================
--- lmi/trunk/product_data.hpp  2010-04-14 14:55:15 UTC (rev 4837)
+++ lmi/trunk/product_data.hpp  2010-04-14 18:35:16 UTC (rev 4838)
@@ -69,17 +69,17 @@
     virtual int         class_version() const;
     virtual std::string xml_root_name() const;
     virtual bool        is_detritus(std::string const&) const;
-    virtual std::string redintegrate_ex_ante
+    virtual bool redintegrate_ex_ante
         (int                file_version
         ,std::string const& name
-        ,std::string const& value
+        ,std::string      & value
         ) const;
-    virtual void        redintegrate_ex_post
+    virtual void redintegrate_ex_post
         (int                                file_version
         ,std::map<std::string, std::string> detritus_map
         ,std::list<std::string>             residuary_names
         );
-    virtual void        redintegrate_ad_terminum();
+    virtual void redintegrate_ad_terminum();
 
     // Names of files that contain other product data.
     std::string DatabaseFilename;

Modified: lmi/trunk/xml_serializable.hpp
===================================================================
--- lmi/trunk/xml_serializable.hpp      2010-04-14 14:55:15 UTC (rev 4837)
+++ lmi/trunk/xml_serializable.hpp      2010-04-14 18:35:16 UTC (rev 4838)
@@ -55,17 +55,17 @@
     virtual int         class_version() const = 0;
     virtual std::string xml_root_name() const = 0;
     virtual bool        is_detritus(std::string const&) const = 0;
-    virtual std::string redintegrate_ex_ante
+    virtual bool redintegrate_ex_ante
         (int                file_version
         ,std::string const& name
-        ,std::string const& value
+        ,std::string      & value
         ) const = 0;
-    virtual void        redintegrate_ex_post
+    virtual void redintegrate_ex_post
         (int                                file_version
         ,std::map<std::string, std::string> detritus_map
         ,std::list<std::string>             residuary_names
         ) = 0;
-    virtual void        redintegrate_ad_terminum() = 0;
+    virtual void redintegrate_ad_terminum() = 0;
 
   private:
     void immit_members_into(xml::element&) const;

Modified: lmi/trunk/xml_serializable.tpp
===================================================================
--- lmi/trunk/xml_serializable.tpp      2010-04-14 14:55:15 UTC (rev 4837)
+++ lmi/trunk/xml_serializable.tpp      2010-04-14 18:35:16 UTC (rev 4838)
@@ -140,11 +140,10 @@
             );
         if(residuary_names.end() != current_member)
             {
-            t[node_tag] = redintegrate_ex_ante
-                (file_version
-                ,node_tag
-                ,xml_lmi::get_content(*child)
-                );
+            std::string s = xml_lmi::get_content(*child);
+            // Return value unused for the moment:
+            redintegrate_ex_ante(file_version, node_tag, s);
+            t[node_tag] = s;
             residuary_names.erase(current_member);
             }
         else if(is_detritus(node_tag))
@@ -208,18 +207,19 @@
 /// enumeration, which would elicit a runtime error.
 ///
 /// The element's text contents are given as a string argument; the
-/// transformed contents are returned as a string.
+/// return value is 'true' if the string was modified, and 'false'
+/// otherwise.
 
 template<typename T>
-std::string xml_serializable<T>::redintegrate_ex_ante
+bool xml_serializable<T>::redintegrate_ex_ante
     (int                file_version
     ,std::string const& // name
-    ,std::string const& value
+    ,std::string      & // value
     ) const
 {
     if(class_version() == file_version)
         {
-        return value;
+        return false;
         }
     else
         {
@@ -228,7 +228,7 @@
             << " An explicit override is necessary."
             << LMI_FLUSH
             ;
-        return value; // Stifle compiler warning.
+        return true; // Stifle compiler warning.
         }
 }
 





reply via email to

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