[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi] [PATCH 3/5] Use caching for xml_actuarial_table.
From: |
Vaclav Slavik |
Subject: |
[lmi] [PATCH 3/5] Use caching for xml_actuarial_table. |
Date: |
Fri, 15 Jun 2012 18:19:27 +0200 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20120601 Thunderbird/13.0 |
Use caching for xml_actuarial_table.
Unfortunately, this treats xml_ and soa_ versions differently, but
solving that would mean more complicated code and I think that wouldn't
be worth it. The !LMI_USE_XML_TABLES of actuarial_table_rates() and
actuarial_table_rates_elaborated() will have to be updated to use the
cache when we remove soa_actuarial_table.
Vaclav
>From db4d85a171af2e97316109444758e4d1b35a3729 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Va=CC=81clav=20Slavi=CC=81k?= <address@hidden>
Date: Wed, 13 Jun 2012 18:33:31 +0200
Subject: [PATCH 3/5] Use caching for xml_actuarial_table.
---
actuarial_table.cpp | 14 ++++++++++----
actuarial_table.hpp | 2 ++
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/actuarial_table.cpp b/actuarial_table.cpp
index 616d1d1..779f91b 100644
--- a/actuarial_table.cpp
+++ b/actuarial_table.cpp
@@ -959,10 +959,13 @@ std::vector<double> actuarial_table_rates
)
{
#if defined LMI_USE_XML_TABLES
- xml_actuarial_table z(table_filename, table_number);
+ std::string const xmlfile
+ (xml_actuarial_table::compatibility_filename(table_filename,
table_number)
+ );
+ boost::shared_ptr<xml_actuarial_table const>
z(xml_actuarial_table::get_cached(xmlfile));
soa_actuarial_table z_soa(table_filename, table_number);
- std::vector<double> values (z.values(issue_age, length));
+ std::vector<double> values (z->values(issue_age, length));
std::vector<double> values_soa(z_soa.values(issue_age, length));
// SOA !! Temporarily verify correctness of XML implementation,
@@ -987,10 +990,13 @@ std::vector<double> actuarial_table_rates_elaborated
)
{
#if defined LMI_USE_XML_TABLES
- xml_actuarial_table z(table_filename, table_number);
+ std::string const xmlfile
+ (xml_actuarial_table::compatibility_filename(table_filename,
table_number)
+ );
+ boost::shared_ptr<xml_actuarial_table const>
z(xml_actuarial_table::get_cached(xmlfile));
soa_actuarial_table z_soa(table_filename, table_number);
- std::vector<double> values(z.values_elaborated
+ std::vector<double> values(z->values_elaborated
(issue_age
,length
,method
diff --git a/actuarial_table.hpp b/actuarial_table.hpp
index 349d5f1..044aa10 100644
--- a/actuarial_table.hpp
+++ b/actuarial_table.hpp
@@ -26,6 +26,7 @@
#include "config.hpp"
+#include "loaded_files_cache.hpp"
#include "obstruct_slicing.hpp"
#include "uncopyable_lmi.hpp"
#include "xml_lmi_fwd.hpp"
@@ -166,6 +167,7 @@ class actuarial_table_base
class xml_actuarial_table
: public actuarial_table_base
, private lmi::uncopyable <xml_actuarial_table>
+ , public loaded_from_cache<xml_actuarial_table>
,virtual private obstruct_slicing<xml_actuarial_table>
{
public:
--
1.7.10.4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi] [PATCH 3/5] Use caching for xml_actuarial_table.,
Vaclav Slavik <=