[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [5466] Refactor to facilitate an impending change (VS)
From: |
Greg Chicares |
Subject: |
[lmi-commits] [5466] Refactor to facilitate an impending change (VS) |
Date: |
Sat, 26 May 2012 12:29:38 +0000 |
Revision: 5466
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5466
Author: chicares
Date: 2012-05-26 12:29:33 +0000 (Sat, 26 May 2012)
Log Message:
-----------
Refactor to facilitate an impending change (VS)
Modified Paths:
--------------
lmi/trunk/ChangeLog
lmi/trunk/actuarial_table.cpp
lmi/trunk/actuarial_table.hpp
Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2012-05-26 11:33:16 UTC (rev 5465)
+++ lmi/trunk/ChangeLog 2012-05-26 12:29:33 UTC (rev 5466)
@@ -30071,3 +30071,38 @@
version.hpp
Designate release candidate.
+20120526T1023Z <address@hidden> [578]
+
+ cell.rnc
+ cell.xsd
+ test_schemata.sh
+ types.rnc [new file]
+ types.xsd [new file]
+Refactor, splitting types into a separate file to allow reuse. See:
+ http://lists.nongnu.org/archive/html/lmi/2012-05/msg00006.html
+
+20120526T1035Z <address@hidden> [578]
+
+ actuarial_table.rnc [new file]
+Add RNG schema for xml tables (VS). See:
+ http://lists.nongnu.org/archive/html/lmi/2012-05/msg00006.html
+
+20120526T1117Z <address@hidden> [578]
+
+ actuarial_table.hpp
+Remove an unused member function (VS). See:
+ http://lists.nongnu.org/archive/html/lmi/2012-05/msg00007.html
+
+20120526T1133Z <address@hidden> [578]
+
+ test_coding_rules.cpp
+Allow a new marker for SOA-to-xml table-migration issues.
+
+20120526T1229Z <address@hidden> [578]
+
+ actuarial_table.cpp
+ actuarial_table.hpp
+Refactor to facilitate an impending change (VS), crucially adding a
+virtual dtor to the base class. See:
+ http://lists.nongnu.org/archive/html/lmi/2012-05/msg00008.html
+
Modified: lmi/trunk/actuarial_table.cpp
===================================================================
--- lmi/trunk/actuarial_table.cpp 2012-05-26 11:33:16 UTC (rev 5465)
+++ lmi/trunk/actuarial_table.cpp 2012-05-26 12:29:33 UTC (rev 5466)
@@ -83,39 +83,22 @@
}
} // Unnamed namespace.
-actuarial_table::actuarial_table(std::string const& filename, int table_number)
- :filename_ (filename)
- ,table_number_ (table_number)
- ,table_type_ (-1)
+actuarial_table_base::actuarial_table_base()
+ :table_type_ (-1)
,min_age_ (-1)
,max_age_ (-1)
,select_period_ (-1)
,max_select_age_ (-1)
- ,table_offset_ (-1)
{
- if(table_number_ <= 0)
- {
- fatal_error()
- << "There is no table number "
- << table_number_
- << " in file '"
- << filename_
- << "'."
- << LMI_FLUSH
- ;
- }
-
- find_table();
- parse_table();
}
-actuarial_table::~actuarial_table()
+actuarial_table_base::~actuarial_table_base()
{
}
/// Read a given number of values for a given issue age.
-std::vector<double> actuarial_table::values(int issue_age, int length) const
+std::vector<double> actuarial_table_base::values(int issue_age, int length)
const
{
return specific_values(issue_age, length);
}
@@ -127,7 +110,7 @@
/// method: method-specific adjustments are not permitted to render
/// sane what was insane ab ovo.
-std::vector<double> actuarial_table::values_elaborated
+std::vector<double> actuarial_table_base::values_elaborated
(int issue_age
,int length
,e_actuarial_table_method method
@@ -192,6 +175,31 @@
}
}
+soa_actuarial_table::soa_actuarial_table(std::string const& filename, int
table_number)
+ :filename_ (filename)
+ ,table_number_ (table_number)
+ ,table_offset_ (-1)
+{
+ if(table_number_ <= 0)
+ {
+ fatal_error()
+ << "There is no table number "
+ << table_number_
+ << " in file '"
+ << filename_
+ << "'."
+ << LMI_FLUSH
+ ;
+ }
+
+ find_table();
+ parse_table();
+}
+
+soa_actuarial_table::~soa_actuarial_table()
+{
+}
+
/// Find the table specified by table_number_.
///
/// SOA documentation does not specify the domain of table numbers,
@@ -207,7 +215,7 @@
/// Asserting that the table number is nonzero makes it safe to use
/// zero as a sentry.
-void actuarial_table::find_table()
+void soa_actuarial_table::find_table()
{
LMI_ASSERT(0 != table_number_);
@@ -302,7 +310,7 @@
/// 15 2-byte integer: Maximum select age (if zero, then it's max age)
/// 17 8-byte doubles: Table values
-void actuarial_table::parse_table()
+void soa_actuarial_table::parse_table()
{
LMI_ASSERT(-1 == table_type_ );
LMI_ASSERT(-1 == min_age_ );
@@ -447,7 +455,7 @@
/// taken as unlimited, so its value should be max_age_; this
/// implementation makes it so after the fact.
-void actuarial_table::read_values(std::istream& is, int nominal_length)
+void soa_actuarial_table::read_values(std::istream& is, int nominal_length)
{
if('S' != table_type_)
{
@@ -504,7 +512,7 @@
/// considered preferable to throw an exception, in case permitting
/// issue age to exceed max_select_age_ is an inadvertent mistake.
-std::vector<double> actuarial_table::specific_values
+std::vector<double> soa_actuarial_table::specific_values
(int issue_age
,int length
) const
@@ -583,7 +591,7 @@
,int length
)
{
- actuarial_table z(table_filename, table_number);
+ soa_actuarial_table z(table_filename, table_number);
return z.values(issue_age, length);
}
@@ -597,7 +605,7 @@
,int reset_duration
)
{
- actuarial_table z(table_filename, table_number);
+ soa_actuarial_table z(table_filename, table_number);
return z.values_elaborated
(issue_age
,length
Modified: lmi/trunk/actuarial_table.hpp
===================================================================
--- lmi/trunk/actuarial_table.hpp 2012-05-26 11:33:16 UTC (rev 5465)
+++ lmi/trunk/actuarial_table.hpp 2012-05-26 12:29:33 UTC (rev 5466)
@@ -115,9 +115,49 @@
,e_reenter_upon_rate_reset = 2
};
+/// Base class for actuarial tables, both XML and binary.
+/// SOA !! This is only temporary, merge with xml_actuarial_table into
+/// single class once we remove binary SOA format support
+
+class actuarial_table_base
+{
+ public:
+ actuarial_table_base();
+ virtual ~actuarial_table_base();
+
+ std::vector<double> values(int issue_age, int length) const;
+ std::vector<double> values_elaborated
+ (int issue_age
+ ,int length
+ ,e_actuarial_table_method method
+ ,int inforce_duration
+ ,int reset_duration
+ ) const;
+
+ char table_type () const {return table_type_ ;}
+ int min_age () const {return min_age_ ;}
+ int max_age () const {return max_age_ ;}
+ int select_period () const {return select_period_ ;}
+ int max_select_age () const {return max_select_age_ ;}
+
+ protected:
+ virtual std::vector<double> specific_values(int issue_age, int length)
const = 0;
+
+ // Table parameters, in order read from table header.
+ char table_type_ ;
+ int min_age_ ;
+ int max_age_ ;
+ int select_period_ ;
+ int max_select_age_ ;
+};
+
/// Read a table from a database in the binary format designed by the
/// Society of Actuaries (SOA) and used for the tables SOA publishes.
///
+/// This is deprecated, old format, this class' code is left in only
+/// temporarily for the purpose of validating the new XML-based format
+/// loader's correctness.
+///
/// Do not check CRCs of these tables as the SOA software does. Tests
/// show that CRC checking makes the illustration system considerably
/// slower. Data should generally be validated against published
@@ -130,29 +170,16 @@
/// has apparently chosen to leave them that way for backward
/// compatibility.
-class actuarial_table
- : private lmi::uncopyable <actuarial_table>
- ,virtual private obstruct_slicing<actuarial_table>
+class soa_actuarial_table
+ : public actuarial_table_base
+ , private lmi::uncopyable <soa_actuarial_table>
+ ,virtual private obstruct_slicing<soa_actuarial_table>
{
public:
- actuarial_table(std::string const& filename, int table_number);
- ~actuarial_table();
+ soa_actuarial_table(std::string const& filename, int table_number);
+ ~soa_actuarial_table();
- std::vector<double> values(int issue_age, int length) const;
- std::vector<double> values_elaborated
- (int issue_age
- ,int length
- ,e_actuarial_table_method method
- ,int inforce_duration
- ,int reset_duration
- ) const;
-
std::string const& filename () const {return filename_ ;}
- char table_type () const {return table_type_ ;}
- int min_age () const {return min_age_ ;}
- int max_age () const {return max_age_ ;}
- int select_period () const {return select_period_ ;}
- int max_select_age () const {return max_select_age_ ;}
private:
void find_table();
@@ -164,18 +191,14 @@
std::string filename_ ;
int table_number_ ;
- // Table parameters, in order read from table header.
- char table_type_ ;
- int min_age_ ;
- int max_age_ ;
- int select_period_ ;
- int max_select_age_ ;
-
+ // Table data.
std::vector<double> data_;
std::streampos table_offset_;
};
+typedef soa_actuarial_table actuarial_table;
+
/// Convenience function: read particular values from a table stored
/// in the SOA table-manager format.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [5466] Refactor to facilitate an impending change (VS),
Greg Chicares <=