lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [4942] Rework accessors in class database_entity


From: Greg Chicares
Subject: [lmi-commits] [4942] Rework accessors in class database_entity
Date: Mon, 10 May 2010 02:43:36 +0000

Revision: 4942
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=4942
Author:   chicares
Date:     2010-05-10 02:43:36 +0000 (Mon, 10 May 2010)
Log Message:
-----------
Rework accessors in class database_entity

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

Modified: lmi/trunk/database.cpp
===================================================================
--- lmi/trunk/database.cpp      2010-05-10 02:01:17 UTC (rev 4941)
+++ lmi/trunk/database.cpp      2010-05-10 02:43:36 UTC (rev 4942)
@@ -122,8 +122,7 @@
     initialize();
 
     // State of jurisdiction must not depend on itself.
-    database_entity const& StateEntry = entity_from_key(DB_PremTaxState);
-    if(1 != StateEntry.GetLength(5))
+    if(1 != entity_from_key(DB_PremTaxState).axis_lengths()[e_axis_state])
         {
         fatal_error()
             << "Database invalid: circular dependency."
@@ -131,6 +130,7 @@
             << LMI_FLUSH
             ;
         }
+
     switch(static_cast<int>(Query(DB_PremTaxState)))
         {
         case oe_ee_state:
@@ -176,7 +176,7 @@
 double product_database::Query(e_database_key k) const
 {
     database_entity const& v = entity_from_key(k);
-    LMI_ASSERT(1 == v.GetLength());
+    LMI_ASSERT(1 == v.extent());
     return *v[index_];
 }
 
@@ -184,14 +184,14 @@
 {
     database_entity const& v = entity_from_key(k);
     double const*const z = v[index_];
-    if(1 == v.GetLength())
+    if(1 == v.extent())
         {
         dst.assign(length_, *z);
         }
     else
         {
         dst.reserve(length_);
-        dst.assign(z, z + std::min(length_, v.GetLength()));
+        dst.assign(z, z + std::min(length_, v.extent()));
         dst.resize(length_, dst.back());
         }
 }

Modified: lmi/trunk/dbvalue.cpp
===================================================================
--- lmi/trunk/dbvalue.cpp       2010-05-10 02:01:17 UTC (rev 4941)
+++ lmi/trunk/dbvalue.cpp       2010-05-10 02:43:36 UTC (rev 4942)
@@ -43,8 +43,11 @@
 #include <numeric>
 #include <ostream>
 
-static int const ScalarDims[e_number_of_axes] = {1, 1, 1, 1, 1, 1, 1};
-static int const MaxPossibleElements = std::numeric_limits<int>::max();
+namespace
+{
+int const ScalarDims[e_number_of_axes] = {1, 1, 1, 1, 1, 1, 1};
+int const MaxPossibleElements = std::numeric_limits<int>::max();
+} // Unnamed namespace.
 
 /// Ascertain whether two database entities are equivalent.
 ///
@@ -307,22 +310,24 @@
     return key_;
 }
 
-int database_entity::GetLength() const
-{
-    return axis_lengths_.at(6);
-}
+/// Dimension along the duration axis.
 
-int database_entity::GetLength(int axis) const
+int database_entity::extent() const
 {
-    LMI_ASSERT(0 <= axis && axis < e_number_of_axes);
-    return axis_lengths_.at(axis);
+    return axis_lengths_.at(e_axis_duration);
 }
 
 std::vector<int> const& database_entity::axis_lengths() const
 {
+    LMI_ASSERT(e_number_of_axes == axis_lengths_.size());
     return axis_lengths_;
 }
 
+std::vector<double> const& database_entity::data_values() const
+{
+    return data_values_;
+}
+
 std::ostream& database_entity::write(std::ostream& os) const
 {
     os

Modified: lmi/trunk/dbvalue.hpp
===================================================================
--- lmi/trunk/dbvalue.hpp       2010-05-10 02:01:17 UTC (rev 4941)
+++ lmi/trunk/dbvalue.hpp       2010-05-10 02:43:36 UTC (rev 4942)
@@ -114,9 +114,9 @@
     double&       operator[](std::vector<int> const& idx);
 
     int key() const;
-    int GetLength()         const;
-    int GetLength(int axis) const;
-    std::vector<int> const& axis_lengths() const;
+    int extent() const;
+    std::vector<int>    const& axis_lengths() const;
+    std::vector<double> const& data_values () const;
 
     std::ostream& write(std::ostream&) const;
 

Modified: lmi/trunk/input_test.cpp
===================================================================
--- lmi/trunk/input_test.cpp    2010-05-10 02:01:17 UTC (rev 4941)
+++ lmi/trunk/input_test.cpp    2010-05-10 02:43:36 UTC (rev 4942)
@@ -140,7 +140,7 @@
     BOOST_TEST_THROW
         (db.Query(DB_StatVxQ)
         ,std::runtime_error
-        ,"Assertion '1 == v.GetLength()' failed."
+        ,"Assertion '1 == v.extent()' failed."
         );
 
     std::cout
@@ -164,7 +164,7 @@
     BOOST_TEST_THROW
         (db.initialize();
         ,std::runtime_error
-        ,"Assertion '1 == v.GetLength()' failed."
+        ,"Assertion '1 == v.extent()' failed."
         );
     DBDictionary::instance().dictionary_[DB_EndtAge] = maturity;
 





reply via email to

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