lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [4943] Refactor


From: Greg Chicares
Subject: [lmi-commits] [4943] Refactor
Date: Mon, 10 May 2010 03:22:21 +0000

Revision: 4943
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=4943
Author:   chicares
Date:     2010-05-10 03:22:21 +0000 (Mon, 10 May 2010)
Log Message:
-----------
Refactor

Modified Paths:
--------------
    lmi/trunk/ChangeLog
    lmi/trunk/database.cpp
    lmi/trunk/database.hpp
    lmi/trunk/dbvalue.cpp
    lmi/trunk/dbvalue.hpp
    lmi/trunk/ihs_basicval.cpp

Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2010-05-10 02:43:36 UTC (rev 4942)
+++ lmi/trunk/ChangeLog 2010-05-10 03:22:21 UTC (rev 4943)
@@ -25656,3 +25656,57 @@
   loads_test.cpp
 Strengthen typing.
 
+20100510T0048Z <address@hidden> [706]
+
+  database.cpp
+  database.hpp
+  dbvalue.cpp
+  dbvalue.hpp
+Rearrange functions in logical order.
+
+20100510T0117Z <address@hidden> [706]
+
+  database_view_editor.cpp
+  database_view_editor.hpp
+  dbdict.cpp
+  dbvalue.cpp
+  dbvalue.hpp
+  input_test.cpp
+Augment and relocate enumerations.
+
+20100510T0135Z <address@hidden> [706]
+
+  database_view_editor.cpp
+  dbvalue.cpp
+  dbvalue.hpp
+Replace a static member with a free function.
+
+20100510T0201Z <address@hidden> [706]
+
+  database.cpp
+  database.hpp
+  database_view_editor.cpp
+  dbdict.cpp
+  dbvalue.cpp
+  dbvalue.hpp
+  ihs_basicval.cpp
+  input_test.cpp
+Rename certain member functions.
+
+20100510T0243Z <address@hidden> [706]
+
+  database.cpp
+  dbvalue.cpp
+  dbvalue.hpp
+  input_test.cpp
+Rework accessors in class database_entity.
+
+20100510T0322Z <address@hidden> [706]
+
+  database.cpp
+  database.hpp
+  dbvalue.cpp
+  dbvalue.hpp
+  ihs_basicval.cpp
+Refactor.
+

Modified: lmi/trunk/database.cpp
===================================================================
--- lmi/trunk/database.cpp      2010-05-10 02:43:36 UTC (rev 4942)
+++ lmi/trunk/database.cpp      2010-05-10 03:22:21 UTC (rev 4943)
@@ -122,7 +122,7 @@
     initialize();
 
     // State of jurisdiction must not depend on itself.
-    if(1 != entity_from_key(DB_PremTaxState).axis_lengths()[e_axis_state])
+    if(varies_by_state(DB_PremTaxState))
         {
         fatal_error()
             << "Database invalid: circular dependency."
@@ -196,6 +196,31 @@
         }
 }
 
+/// Ascertain whether two database entities are equivalent.
+///
+/// Equivalence here means that the dimensions and data are identical.
+/// For example, these distinct entities:
+///  - DB_PremTaxRate (what the state charges the insurer)
+///  - DB_PremTaxLoad (what the insurer charges the customer)
+/// may be equivalent when premium tax is passed through as a load.
+
+bool product_database::are_equivalent(e_database_key k0, e_database_key k1) 
const
+{
+    database_entity const& e0 = entity_from_key(k0);
+    database_entity const& e1 = entity_from_key(k1);
+    return
+           e0.axis_lengths() == e1.axis_lengths()
+        && e0.data_values () == e1.data_values ()
+        ;
+}
+
+/// Ascertain whether a database entity varies by state.
+
+bool product_database::varies_by_state(e_database_key k) const
+{
+    return 1 != entity_from_key(k).axis_lengths().at(e_axis_state);
+}
+
 void product_database::initialize()
 {
     index_ = database_index(Gender, Class, Smoker, IssueAge, UWBasis, State);

Modified: lmi/trunk/database.hpp
===================================================================
--- lmi/trunk/database.hpp      2010-05-10 02:43:36 UTC (rev 4942)
+++ lmi/trunk/database.hpp      2010-05-10 03:22:21 UTC (rev 4943)
@@ -73,12 +73,13 @@
     double Query(e_database_key) const;
     void Query(std::vector<double>&, e_database_key) const;
 
+    bool are_equivalent(e_database_key, e_database_key) const;
+    bool varies_by_state(e_database_key) const;
+
   private:
     void initialize();
 
-  public:  // for the nonce...
     database_entity const& entity_from_key(e_database_key) const;
-  private: // ...for the nonce
 
     database_index  index_;
     int             length_;

Modified: lmi/trunk/dbvalue.cpp
===================================================================
--- lmi/trunk/dbvalue.cpp       2010-05-10 02:43:36 UTC (rev 4942)
+++ lmi/trunk/dbvalue.cpp       2010-05-10 03:22:21 UTC (rev 4943)
@@ -49,26 +49,6 @@
 int const MaxPossibleElements = std::numeric_limits<int>::max();
 } // Unnamed namespace.
 
-/// Ascertain whether two database entities are equivalent.
-///
-/// Equivalence here means that the dimensions and data are identical.
-/// For example, these distinct entities:
-///  - DB_PremTaxRate (what the state charges the insurer)
-///  - DB_PremTaxLoad (what the insurer charges the customer)
-/// may be equivalent when premium tax is passed through as a load.
-
-bool database_entity::Equivalent(database_entity const& a, database_entity 
const& b)
-{
-    return(a.axis_lengths_ == b.axis_lengths_ && a.data_values_ == 
b.data_values_);
-}
-
-/// Ascertain whether this entity varies by state.
-
-bool database_entity::VariesByState(database_entity const& z)
-{
-    return 1 != z.axis_lengths_.at(5);
-}
-
 /// Default ctor.
 
 database_entity::database_entity()

Modified: lmi/trunk/dbvalue.hpp
===================================================================
--- lmi/trunk/dbvalue.hpp       2010-05-10 02:43:36 UTC (rev 4942)
+++ lmi/trunk/dbvalue.hpp       2010-05-10 03:22:21 UTC (rev 4943)
@@ -120,9 +120,6 @@
 
     std::ostream& write(std::ostream&) const;
 
-    static bool Equivalent(database_entity const&, database_entity const&);
-    static bool VariesByState(database_entity const&);
-
   private:
     void assert_invariants() const;
     int getndata() const;

Modified: lmi/trunk/ihs_basicval.cpp
===================================================================
--- lmi/trunk/ihs_basicval.cpp  2010-05-10 02:43:36 UTC (rev 4942)
+++ lmi/trunk/ihs_basicval.cpp  2010-05-10 03:22:21 UTC (rev 4943)
@@ -35,7 +35,6 @@
 #include "configurable_settings.hpp"
 #include "data_directory.hpp"
 #include "database.hpp"
-#include "dbdict.hpp"
 #include "death_benefits.hpp"
 #include "et_vector.hpp"
 #include "fund_data.hpp"
@@ -911,8 +910,7 @@
 
     z = db.Query(DB_PremTaxLoad);
 
-    database_entity const& premium_tax_loads = 
db.entity_from_key(DB_PremTaxLoad);
-    if(!database_entity::VariesByState(premium_tax_loads))
+    if(!db.varies_by_state(DB_PremTaxLoad))
         {
         return z;
         }
@@ -921,8 +919,7 @@
     // it equals premium-tax rate--i.e. that premium tax is passed
     // through exactly--and that therefore tiered tax rates determine
     // loads where applicable and implemented.
-    database_entity const& premium_tax_rates = 
db.entity_from_key(DB_PremTaxRate);
-    if(!database_entity::Equivalent(premium_tax_loads, premium_tax_rates))
+    if(!db.are_equivalent(DB_PremTaxLoad, DB_PremTaxRate))
         {
         fatal_error()
             << "Premium-tax load varies by state, but differs"
@@ -967,8 +964,7 @@
     // TODO ?? Don't override parameters--instead, only detect and
     // report inconsistencies.
     //
-    database_entity const& premium_tax_loads = 
Database_->entity_from_key(DB_PremTaxLoad);
-    if(!database_entity::VariesByState(premium_tax_loads))
+    if(!Database_->varies_by_state(DB_PremTaxLoad))
         {
         return;
         }





reply via email to

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