[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [4937] Strengthen typing
From: |
Greg Chicares |
Subject: |
[lmi-commits] [4937] Strengthen typing |
Date: |
Sun, 09 May 2010 14:05:20 +0000 |
Revision: 4937
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=4937
Author: chicares
Date: 2010-05-09 14:05:19 +0000 (Sun, 09 May 2010)
Log Message:
-----------
Strengthen typing
Modified Paths:
--------------
lmi/trunk/ChangeLog
lmi/trunk/basic_values.hpp
lmi/trunk/database.cpp
lmi/trunk/database.hpp
lmi/trunk/ihs_basicval.cpp
lmi/trunk/input_test.cpp
lmi/trunk/loads_test.cpp
Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2010-05-09 14:03:53 UTC (rev 4936)
+++ lmi/trunk/ChangeLog 2010-05-09 14:05:19 UTC (rev 4937)
@@ -25638,3 +25638,21 @@
database.cpp
Prefer map_lookup() for map lookups.
+20100509T1403Z <address@hidden> [706]
+
+ database_document.cpp
+ database_document.hpp
+ database_view.cpp
+ dbnames.hpp
+Rename an enum to improve concinnity.
+
+20100509T1405Z <address@hidden> [706]
+
+ basic_values.hpp
+ database.cpp
+ database.hpp
+ ihs_basicval.cpp
+ input_test.cpp
+ loads_test.cpp
+Strengthen typing.
+
Modified: lmi/trunk/basic_values.hpp
===================================================================
--- lmi/trunk/basic_values.hpp 2010-05-09 14:03:53 UTC (rev 4936)
+++ lmi/trunk/basic_values.hpp 2010-05-09 14:05:19 UTC (rev 4937)
@@ -26,6 +26,7 @@
#include "config.hpp"
+#include "dbnames.hpp" // e_database_key
#include "mc_enum_type_enums.hpp"
#include "oecumenic_enumerations.hpp"
#include "round_to.hpp"
@@ -282,7 +283,7 @@
) const;
std::vector<double> GetTable
(std::string const& TableFile
- ,long int const& TableID
+ ,e_database_key TableID
,bool IsTableValid = true
,EBlend const& CanBlendSmoking = CannotBlend
,EBlend const& CanBlendGender = CannotBlend
@@ -405,18 +406,18 @@
std::vector<double> GetActuarialTable
(std::string const& TableFile
- ,long int TableID
+ ,e_database_key TableID
,long int TableNumber
) const;
std::vector<double> GetUnblendedTable
(std::string const& TableFile
- ,long int TableID
+ ,e_database_key TableID
) const;
std::vector<double> GetUnblendedTable
(std::string const& TableFile
- ,long int TableID
+ ,e_database_key TableID
,mcenum_gender gender
,mcenum_smoking smoking
) const;
Modified: lmi/trunk/database.cpp
===================================================================
--- lmi/trunk/database.cpp 2010-05-09 14:03:53 UTC (rev 4936)
+++ lmi/trunk/database.cpp 2010-05-09 14:05:19 UTC (rev 4937)
@@ -32,7 +32,6 @@
#include "assert_lmi.hpp"
#include "data_directory.hpp"
#include "dbdict.hpp"
-#include "dbnames.hpp"
#include "dbvalue.hpp"
#include "lmi.hpp" // is_antediluvian_fork()
#include "map_lookup.hpp"
@@ -181,14 +180,14 @@
LMI_ASSERT(0 < length_ && length_ <= methuselah);
}
-double product_database::Query(int k) const
+double product_database::Query(e_database_key k) const
{
database_entity const& v = GetEntry(k);
LMI_ASSERT(1 == v.GetLength());
return *v[index_];
}
-void product_database::Query(std::vector<double>& dst, int k) const
+void product_database::Query(std::vector<double>& dst, e_database_key k) const
{
database_entity const& v = GetEntry(k);
double const*const z = v[index_];
@@ -204,12 +203,8 @@
}
}
-database_entity const& product_database::GetEntry(int k) const
+database_entity const& product_database::GetEntry(e_database_key k) const
{
- dict_map const& d = DBDictionary::instance().GetDictionary();
- LMI_ASSERT(d.size() == DB_LAST);
- LMI_ASSERT(0 == DB_FIRST);
- LMI_ASSERT(DB_FIRST <= k && k < DB_LAST);
- return map_lookup(d, k);
+ return map_lookup(DBDictionary::instance().GetDictionary(), k);
}
Modified: lmi/trunk/database.hpp
===================================================================
--- lmi/trunk/database.hpp 2010-05-09 14:03:53 UTC (rev 4936)
+++ lmi/trunk/database.hpp 2010-05-09 14:05:19 UTC (rev 4937)
@@ -27,6 +27,7 @@
#include "config.hpp"
#include "dbindex.hpp"
+#include "dbnames.hpp" // e_database_key
#include "mc_enum_type_enums.hpp"
#include "obstruct_slicing.hpp"
#include "so_attributes.hpp"
@@ -68,12 +69,12 @@
// Return scalar: use double because it's convertible to int, bool, etc.
// Someday, consider doing something like:
// template<typename T, typename DBValue>
- // void Query(T& dst, int k) const;
- double Query(int k) const;
+ // void Query(T& dst, e_database_key k) const;
+ double Query(e_database_key k) const;
- void Query(std::vector<double>& dst, int k) const;
+ void Query(std::vector<double>& dst, e_database_key k) const;
- database_entity const& GetEntry(int k) const;
+ database_entity const& GetEntry(e_database_key k) const;
private:
void initialize();
Modified: lmi/trunk/ihs_basicval.cpp
===================================================================
--- lmi/trunk/ihs_basicval.cpp 2010-05-09 14:03:53 UTC (rev 4936)
+++ lmi/trunk/ihs_basicval.cpp 2010-05-09 14:05:19 UTC (rev 4937)
@@ -36,7 +36,6 @@
#include "data_directory.hpp"
#include "database.hpp"
#include "dbdict.hpp"
-#include "dbnames.hpp"
#include "death_benefits.hpp"
#include "et_vector.hpp"
#include "fund_data.hpp"
@@ -1634,7 +1633,7 @@
std::vector<double> BasicValues::GetActuarialTable
(std::string const& TableFile
- ,long int TableID
+ ,e_database_key TableID
,long int TableNumber
) const
{
@@ -1669,7 +1668,7 @@
//============================================================================
std::vector<double> BasicValues::GetUnblendedTable
(std::string const& TableFile
- ,long int TableID
+ ,e_database_key TableID
) const
{
return GetActuarialTable
@@ -1682,7 +1681,7 @@
//============================================================================
std::vector<double> BasicValues::GetUnblendedTable
(std::string const& TableFile
- ,long int TableID
+ ,e_database_key TableID
,mcenum_gender gender
,mcenum_smoking smoking
) const
@@ -1722,7 +1721,7 @@
// The order of blending in the unisex unismoke case makes no difference.
std::vector<double> BasicValues::GetTable
(std::string const& TableFile
- ,long int const& TableID
+ ,e_database_key TableID
,bool IsTableValid
,EBlend const& CanBlendSmoking
,EBlend const& CanBlendGender
Modified: lmi/trunk/input_test.cpp
===================================================================
--- lmi/trunk/input_test.cpp 2010-05-09 14:03:53 UTC (rev 4936)
+++ lmi/trunk/input_test.cpp 2010-05-09 14:05:19 UTC (rev 4937)
@@ -152,12 +152,6 @@
<< '\n'
;
- BOOST_TEST_THROW
- (db.GetEntry(-1)
- ,std::runtime_error
- ,"Assertion 'DB_FIRST <= k && k < DB_LAST' failed."
- );
-
database_entity const maturity = db.GetEntry(DB_EndtAge);
// Maturity age must not vary by duration.
@@ -179,7 +173,7 @@
BOOST_TEST_THROW
(db.GetEntry(DB_EndtAge)
,std::runtime_error
- ,"Assertion 'i != d.end()' failed."
+ ,"map_lookup: key '258' not found."
);
}
Modified: lmi/trunk/loads_test.cpp
===================================================================
--- lmi/trunk/loads_test.cpp 2010-05-09 14:03:53 UTC (rev 4936)
+++ lmi/trunk/loads_test.cpp 2010-05-09 14:05:19 UTC (rev 4937)
@@ -57,8 +57,8 @@
product_database::product_database(int length) :length_(length) {}
product_database::~product_database() {}
int product_database::length() const {return length_;}
-void product_database::Query(std::vector<double>& v, int) const
{v.resize(length_);}
-double product_database::Query(int) const {return 0.0;}
+void product_database::Query(std::vector<double>& v, e_database_key) const
{v.resize(length_);}
+double product_database::Query(e_database_key) const {return 0.0;}
struct LoadsTest
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [4937] Strengthen typing,
Greg Chicares <=