[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi] [PATCH 2/5] Add single-file xml_actuarial_table constructor.
From: |
Vaclav Slavik |
Subject: |
[lmi] [PATCH 2/5] Add single-file xml_actuarial_table constructor. |
Date: |
Fri, 15 Jun 2012 18:19:14 +0200 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20120601 Thunderbird/13.0 |
This patch is needed to make xml_actuarial_table fit into
loaded_files_cache<T> API. Plus, we'll need this constructor later anyway.
Vaclav
---
actuarial_table.cpp | 24 +++++++++++++++++++-----
actuarial_table.hpp | 7 +++++++
2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/actuarial_table.cpp b/actuarial_table.cpp
index 9d6be67..616d1d1 100644
--- a/actuarial_table.cpp
+++ b/actuarial_table.cpp
@@ -91,7 +91,7 @@ namespace
} // Unnamed namespace.
actuarial_table_base::actuarial_table_base()
- :table_type_ (-1)
+ :table_type_ (e_table_invalid)
,min_age_ (-1)
,max_age_ (-1)
,select_period_ (-1)
@@ -182,15 +182,17 @@ std::vector<double>
actuarial_table_base::values_elaborated
}
}
+xml_actuarial_table::xml_actuarial_table(std::string const& filename)
+{
+ load_xml_table(filename);
+}
+
xml_actuarial_table::xml_actuarial_table(std::string const& filename, int
table_number)
{
// SOA !! This is temporary code for API compatibility with
soa_actuarial_table.
// It should be changed so that the constructor takes only a single
// argument, filename of the XML table file.
- std::string xmlfile(filename, 0, filename.rfind('.'));
- xmlfile += "_";
- xmlfile += value_cast<std::string>(table_number);
- xmlfile += ".xtable";
+ std::string const xmlfile(compatibility_filename(filename, table_number));
load_xml_table(xmlfile);
}
@@ -198,6 +200,18 @@ xml_actuarial_table::~xml_actuarial_table()
{
}
+std::string xml_actuarial_table::compatibility_filename
+ (std::string const& filename
+ ,int table_number
+ )
+{
+ std::string xmlfile(filename, 0, filename.rfind('.'));
+ xmlfile += "_";
+ xmlfile += value_cast<std::string>(table_number);
+ xmlfile += ".xtable";
+ return xmlfile;
+}
+
void xml_actuarial_table::load_xml_table(std::string const& filename)
{
xml_lmi::dom_parser parser(filename);
diff --git a/actuarial_table.hpp b/actuarial_table.hpp
index f577205..349d5f1 100644
--- a/actuarial_table.hpp
+++ b/actuarial_table.hpp
@@ -169,9 +169,16 @@ class xml_actuarial_table
,virtual private obstruct_slicing<xml_actuarial_table>
{
public:
+ xml_actuarial_table(std::string const& filename);
xml_actuarial_table(std::string const& filename, int table_number);
virtual ~xml_actuarial_table();
+ // SOA !! This is temporary code for API compatibility with
soa_actuarial_table.
+ static std::string compatibility_filename
+ (std::string const& filename
+ ,int table_number
+ );
+
protected:
std::vector<double> specific_values(int issue_age, int length) const;
--
1.7.10.4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi] [PATCH 2/5] Add single-file xml_actuarial_table constructor.,
Vaclav Slavik <=