[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [4960] Refactor, using symbolic member names in class stra
From: |
Greg Chicares |
Subject: |
[lmi-commits] [4960] Refactor, using symbolic member names in class stratified_charges |
Date: |
Tue, 25 May 2010 14:44:21 +0000 |
Revision: 4960
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=4960
Author: chicares
Date: 2010-05-25 14:44:20 +0000 (Tue, 25 May 2010)
Log Message:
-----------
Refactor, using symbolic member names in class stratified_charges
Modified Paths:
--------------
lmi/trunk/ChangeLog
lmi/trunk/stratified_charges.cpp
lmi/trunk/stratified_charges.hpp
lmi/trunk/tier_document.cpp
Modified: lmi/trunk/ChangeLog
===================================================================
--- lmi/trunk/ChangeLog 2010-05-24 11:54:24 UTC (rev 4959)
+++ lmi/trunk/ChangeLog 2010-05-25 14:44:20 UTC (rev 4960)
@@ -25844,3 +25844,10 @@
stratified_charges.hpp
Improve documentation; remove old markup.
+20100525T1444Z <address@hidden> [704]
+
+ stratified_charges.cpp
+ stratified_charges.hpp
+ tier_document.cpp
+Refactor, using symbolic member names in class stratified_charges.
+
Modified: lmi/trunk/stratified_charges.cpp
===================================================================
--- lmi/trunk/stratified_charges.cpp 2010-05-24 11:54:24 UTC (rev 4959)
+++ lmi/trunk/stratified_charges.cpp 2010-05-25 14:44:20 UTC (rev 4960)
@@ -30,8 +30,8 @@
#include "alert.hpp"
#include "assert_lmi.hpp"
+#include "contains.hpp"
#include "data_directory.hpp"
-#include "map_lookup.hpp"
#include "miscellany.hpp" // minmax<T>()
#include "platform_dependent.hpp" // access()
#include "stratified_algorithms.hpp"
@@ -43,10 +43,31 @@
#include <algorithm>
#include <cfloat> // DBL_MAX
-#include <istream>
-#include <fstream>
-#include <ostream>
+/// Specialize value_cast<>() to throw an exception.
+///
+/// This is required by
+/// any_member::str()
+/// which is not useful here.
+
+template<> std::string value_cast<std::string>(stratified_entity const&)
+{
+ fatal_error() << "Invalid function call." << LMI_FLUSH;
+ throw "Unreachable--silences a compiler diagnostic.";
+}
+
+/// Specialize value_cast<>() to throw an exception.
+///
+/// This is required by
+/// any_member::operator=(std::string const&)
+/// which is not useful here.
+
+template<> stratified_entity value_cast<stratified_entity>(std::string const&)
+{
+ fatal_error() << "Invalid function call." << LMI_FLUSH;
+ throw "Unreachable--silences a compiler diagnostic.";
+}
+
// Class stratified_entity implementation.
stratified_entity::stratified_entity()
@@ -69,6 +90,15 @@
{
}
+bool stratified_entity::operator==(stratified_entity const& z)
+{
+ return
+ limits_ == z.limits_
+ && values_ == z.values_
+ && gloss_ == z.gloss_
+ ;
+}
+
/// Throw if invalid.
///
/// Assert the intersection of constraints on 'tiered' (incremental)
@@ -128,57 +158,104 @@
stratified_charges::stratified_charges()
{
- initialize_dictionary();
+ ascribe_members();
}
stratified_charges::stratified_charges(std::string const& filename)
{
- initialize_dictionary();
+ ascribe_members();
read(filename);
}
+stratified_charges::stratified_charges(stratified_charges const& z)
+ :obstruct_slicing <stratified_charges>()
+ ,MemberSymbolTable <stratified_charges>()
+{
+ ascribe_members();
+ typedef std::vector<std::string>::const_iterator svci;
+ for(svci i = member_names().begin(); i != member_names().end(); ++i)
+ {
+ datum(*i) = z.datum(*i);
+ }
+}
+
stratified_charges::~stratified_charges()
{
}
-stratified_entity& stratified_charges::raw_entity(e_stratified e)
+stratified_charges& stratified_charges::operator=(stratified_charges const& z)
{
- typedef std::map<e_stratified, stratified_entity>::iterator mi;
- mi i = dictionary.find(e);
- LMI_ASSERT(dictionary.end() != i);
- return i->second;
+ typedef std::vector<std::string>::const_iterator svci;
+ for(svci i = member_names().begin(); i != member_names().end(); ++i)
+ {
+ datum(*i) = z.datum(*i);
+ }
+ return *this;
}
-stratified_entity const& stratified_charges::raw_entity(e_stratified e) const
+stratified_entity const& stratified_charges::datum(std::string const& name)
const
{
- return map_lookup(dictionary, e);
+ return *member_cast<stratified_entity>(operator[](name));
}
-void stratified_charges::initialize_dictionary()
+stratified_entity& stratified_charges::datum(std::string const& name)
{
- // Dummy nodes: root and topic headers.
- dictionary[e_stratified_first ] = stratified_entity();
- dictionary[e_topic_premium_banded ] = stratified_entity();
- dictionary[e_topic_asset_banded ] = stratified_entity();
- dictionary[e_topic_asset_tiered ] = stratified_entity();
- dictionary[e_topic_tiered_premium_tax ] = stratified_entity();
+ return *member_cast<stratified_entity>(operator[](name));
+}
- // Information-bearing nodes.
+void stratified_charges::ascribe_members()
+{
+ ascribe("CurrSepAcctLoadBandedByPrem" ,
&stratified_charges::CurrSepAcctLoadBandedByPrem );
+ ascribe("GuarSepAcctLoadBandedByPrem" ,
&stratified_charges::GuarSepAcctLoadBandedByPrem );
+ ascribe("CurrSepAcctLoadBandedByAssets" ,
&stratified_charges::CurrSepAcctLoadBandedByAssets );
+ ascribe("GuarSepAcctLoadBandedByAssets" ,
&stratified_charges::GuarSepAcctLoadBandedByAssets );
+ ascribe("CurrMandETieredByAssets" ,
&stratified_charges::CurrMandETieredByAssets );
+ ascribe("GuarMandETieredByAssets" ,
&stratified_charges::GuarMandETieredByAssets );
+ ascribe("AssetCompTieredByAssets" ,
&stratified_charges::AssetCompTieredByAssets );
+ ascribe("InvestmentMgmtFeeTieredByAssets" ,
&stratified_charges::InvestmentMgmtFeeTieredByAssets);
+ ascribe("CurrSepAcctLoadTieredByAssets" ,
&stratified_charges::CurrSepAcctLoadTieredByAssets );
+ ascribe("GuarSepAcctLoadTieredByAssets" ,
&stratified_charges::GuarSepAcctLoadTieredByAssets );
+ ascribe("TieredAKPremTax" ,
&stratified_charges::TieredAKPremTax );
+ ascribe("TieredDEPremTax" ,
&stratified_charges::TieredDEPremTax );
+ ascribe("TieredSDPremTax" ,
&stratified_charges::TieredSDPremTax );
+}
- dictionary[e_curr_sepacct_load_banded_by_premium ] = stratified_entity();
- dictionary[e_guar_sepacct_load_banded_by_premium ] = stratified_entity();
- dictionary[e_curr_sepacct_load_banded_by_assets ] = stratified_entity();
- dictionary[e_guar_sepacct_load_banded_by_assets ] = stratified_entity();
- dictionary[e_curr_m_and_e_tiered_by_assets ] = stratified_entity();
- dictionary[e_guar_m_and_e_tiered_by_assets ] = stratified_entity();
- dictionary[e_asset_based_comp_tiered_by_assets ] = stratified_entity();
- dictionary[e_investment_mgmt_fee_tiered_by_assets ] = stratified_entity();
- dictionary[e_curr_sepacct_load_tiered_by_assets ] = stratified_entity();
- dictionary[e_guar_sepacct_load_tiered_by_assets ] = stratified_entity();
+namespace
+{
+ char const* s_stratified_nodes[] =
+ {"stratified_first"
- dictionary[e_tiered_ak_premium_tax ] = stratified_entity();
- dictionary[e_tiered_de_premium_tax ] = stratified_entity();
- dictionary[e_tiered_sd_premium_tax ] = stratified_entity();
+ ,"topic_premium_banded"
+ ,"CurrSepAcctLoadBandedByPrem"
+ ,"GuarSepAcctLoadBandedByPrem"
+
+ ,"topic_asset_banded"
+ ,"CurrSepAcctLoadBandedByAssets"
+ ,"GuarSepAcctLoadBandedByAssets"
+
+ ,"topic_asset_tiered"
+ ,"CurrMandETieredByAssets"
+ ,"GuarMandETieredByAssets"
+ ,"AssetCompTieredByAssets"
+ ,"InvestmentMgmtFeeTieredByAssets"
+ ,"CurrSepAcctLoadTieredByAssets"
+ ,"GuarSepAcctLoadTieredByAssets"
+
+ ,"topic_tiered_premium_tax"
+ ,"TieredAKPremTax"
+ ,"TieredDEPremTax"
+ ,"TieredSDPremTax"
+
+ ,"stratified_last"
+ };
+
+ BOOST_STATIC_ASSERT(sizeof s_stratified_nodes / sizeof(char const*) == 1 +
e_stratified_last);
+} // Unnamed namespace.
+
+stratified_entity& stratified_charges::raw_entity(e_stratified e)
+{
+ LMI_ASSERT(contains(member_names(), s_stratified_nodes[e]));
+ return datum(s_stratified_nodes[e]);
}
// 'special_limit' is 'DB_DynSepAcctLoadLimit'.
@@ -237,8 +314,8 @@
{
kx = std::min(assets, special_limit) / assets;
}
- stratified_entity const& x =
raw_entity(e_curr_sepacct_load_banded_by_premium);
- stratified_entity const& y =
raw_entity(e_curr_sepacct_load_banded_by_assets);
+ stratified_entity const& x = datum("CurrSepAcctLoadBandedByPrem");
+ stratified_entity const& y = datum("CurrSepAcctLoadBandedByAssets");
return
kx * banded_rate<double>() (premium, x.limits(), x.values())
+ ky * banded_rate<double>() (assets , y.limits(), y.values())
@@ -257,8 +334,8 @@
{
kx = std::min(assets, special_limit) / assets;
}
- stratified_entity const& x =
raw_entity(e_guar_sepacct_load_banded_by_premium);
- stratified_entity const& y =
raw_entity(e_guar_sepacct_load_banded_by_assets);
+ stratified_entity const& x = datum("GuarSepAcctLoadBandedByPrem");
+ stratified_entity const& y = datum("GuarSepAcctLoadBandedByAssets");
return
kx * banded_rate<double>() (premium, x.limits(), x.values())
+ ky * banded_rate<double>() (assets , y.limits(), y.values())
@@ -299,37 +376,37 @@
double stratified_charges::tiered_curr_m_and_e(double assets) const
{
- stratified_entity const& z = raw_entity(e_curr_m_and_e_tiered_by_assets);
+ stratified_entity const& z = datum("CurrMandETieredByAssets");
return tiered_rate<double>() (assets, z.limits(), z.values());
}
double stratified_charges::tiered_guar_m_and_e(double assets) const
{
- stratified_entity const& z = raw_entity(e_guar_m_and_e_tiered_by_assets);
+ stratified_entity const& z = datum("GuarMandETieredByAssets");
return tiered_rate<double>() (assets, z.limits(), z.values());
}
double stratified_charges::tiered_asset_based_compensation(double assets) const
{
- stratified_entity const& z =
raw_entity(e_asset_based_comp_tiered_by_assets);
+ stratified_entity const& z = datum("AssetCompTieredByAssets");
return tiered_rate<double>() (assets, z.limits(), z.values());
}
double stratified_charges::tiered_investment_management_fee(double assets)
const
{
- stratified_entity const& z =
raw_entity(e_investment_mgmt_fee_tiered_by_assets);
+ stratified_entity const& z = datum("InvestmentMgmtFeeTieredByAssets");
return tiered_rate<double>() (assets, z.limits(), z.values());
}
double stratified_charges::tiered_curr_sepacct_load(double assets, double /*
premium */) const
{
- stratified_entity const& z =
raw_entity(e_curr_sepacct_load_tiered_by_assets);
+ stratified_entity const& z = datum("CurrSepAcctLoadTieredByAssets");
return tiered_rate<double>() (assets, z.limits(), z.values());
}
double stratified_charges::tiered_guar_sepacct_load(double assets, double /*
premium */) const
{
- stratified_entity const& z =
raw_entity(e_guar_sepacct_load_tiered_by_assets);
+ stratified_entity const& z = datum("GuarSepAcctLoadTieredByAssets");
return tiered_rate<double>() (assets, z.limits(), z.values());
}
@@ -349,34 +426,34 @@
double stratified_charges::minimum_tiered_spread_for_7702() const
{
- stratified_entity const& z =
raw_entity(e_curr_sepacct_load_tiered_by_assets);
+ stratified_entity const& z = datum("CurrSepAcctLoadTieredByAssets");
LMI_ASSERT(!z.values().empty());
return *std::min_element(z.values().begin(), z.values().end());
}
namespace
{
-e_stratified premium_tax_table(mcenum_state state)
+std::string premium_tax_table(mcenum_state state)
{
if(mce_s_AK == state)
{
- return e_tiered_ak_premium_tax;
+ return "TieredAKPremTax";
}
else if(mce_s_DE == state)
{
// TRICKY !! We'll eventually implement DE like this:
- // return e_tiered_de_premium_tax;
+ // return "TieredDEPremTax";
// But we haven't implemented DE's tiered premium tax yet,
// so we treat it as any other state for now:
- return e_stratified_last;
+ return "";
}
else if(mce_s_SD == state)
{
- return e_tiered_sd_premium_tax;
+ return "TieredSDPremTax";
}
else
{
- return e_stratified_last;
+ return "";
}
}
} // Unnamed namespace.
@@ -400,14 +477,14 @@
,double aggregate_payment
) const
{
- e_stratified table = premium_tax_table(state);
- if(e_stratified_last == table)
+ std::string const table = premium_tax_table(state);
+ if(table.empty())
{
return 0.0;
}
else
{
- stratified_entity const& z = raw_entity(table);
+ stratified_entity const& z = datum(table);
return tiered_product<double>()
(payment
,aggregate_payment
@@ -419,56 +496,24 @@
bool stratified_charges::premium_tax_is_tiered(mcenum_state state) const
{
- return e_stratified_last != premium_tax_table(state);
+ return !premium_tax_table(state).empty();
}
double stratified_charges::minimum_tiered_premium_tax_rate(mcenum_state state)
const
{
- e_stratified table = premium_tax_table(state);
- if(e_stratified_last == table)
+ std::string const table = premium_tax_table(state);
+ if(table.empty())
{
return 0.0;
}
else
{
- stratified_entity const& z = raw_entity(table);
+ stratified_entity const& z = datum(table);
LMI_ASSERT(!z.values().empty());
return *std::min_element(z.values().begin(), z.values().end());
}
}
-namespace
-{
- char const* s_stratified_nodes[] =
- {"stratified_first"
-
- ,"topic_premium_banded"
- ,"CurrSepAcctLoadBandedByPrem"
- ,"GuarSepAcctLoadBandedByPrem"
-
- ,"topic_asset_banded"
- ,"CurrSepAcctLoadBandedByAssets"
- ,"GuarSepAcctLoadBandedByAssets"
-
- ,"topic_asset_tiered"
- ,"CurrMandETieredByAssets"
- ,"GuarMandETieredByAssets"
- ,"AssetCompTieredByAssets"
- ,"InvestmentMgmtFeeTieredByAssets"
- ,"CurrSepAcctLoadTieredByAssets"
- ,"GuarSepAcctLoadTieredByAssets"
-
- ,"topic_tiered_premium_tax"
- ,"TieredAKPremTax"
- ,"TieredDEPremTax"
- ,"TieredSDPremTax"
-
- ,"stratified_last"
- };
-
- BOOST_STATIC_ASSERT(sizeof s_stratified_nodes / sizeof(char const*) == 1 +
e_stratified_last);
-} // Unnamed namespace.
-
namespace xml_serialize
{
template<>
@@ -500,49 +545,23 @@
xml_lmi::dom_parser parser(filename);
xml::element const& root = parser.root_node("strata");
-
-#define READ(ELEMENT,ENTITY) xml_serialize::get_element(ELEMENT,
s_stratified_nodes[ENTITY], raw_entity(ENTITY))
-
- READ(root, e_curr_sepacct_load_banded_by_premium );
- READ(root, e_guar_sepacct_load_banded_by_premium );
- READ(root, e_curr_sepacct_load_banded_by_assets );
- READ(root, e_guar_sepacct_load_banded_by_assets );
- READ(root, e_curr_m_and_e_tiered_by_assets );
- READ(root, e_guar_m_and_e_tiered_by_assets );
- READ(root, e_asset_based_comp_tiered_by_assets );
- READ(root, e_investment_mgmt_fee_tiered_by_assets );
- READ(root, e_curr_sepacct_load_tiered_by_assets );
- READ(root, e_guar_sepacct_load_tiered_by_assets );
- READ(root, e_tiered_ak_premium_tax );
- READ(root, e_tiered_de_premium_tax );
- READ(root, e_tiered_sd_premium_tax );
-
-#undef READ
+ typedef std::vector<std::string>::const_iterator svci;
+ for(svci i = member_names().begin(); i != member_names().end(); ++i)
+ {
+ xml_serialize::get_element(root, *i, datum(*i));
+ }
}
void stratified_charges::write(std::string const& filename) const
{
xml_lmi::xml_document document("strata");
xml::element& root = document.root_node();
+ typedef std::vector<std::string>::const_iterator svci;
+ for(svci i = member_names().begin(); i != member_names().end(); ++i)
+ {
+ xml_serialize::set_element(root, *i, datum(*i));
+ }
-#define WRITE(ELEMENT,ENTITY) xml_serialize::set_element(ELEMENT,
s_stratified_nodes[ENTITY], raw_entity(ENTITY));
-
- WRITE(root, e_curr_sepacct_load_banded_by_premium );
- WRITE(root, e_guar_sepacct_load_banded_by_premium );
- WRITE(root, e_curr_sepacct_load_banded_by_assets );
- WRITE(root, e_guar_sepacct_load_banded_by_assets );
- WRITE(root, e_curr_m_and_e_tiered_by_assets );
- WRITE(root, e_guar_m_and_e_tiered_by_assets );
- WRITE(root, e_asset_based_comp_tiered_by_assets );
- WRITE(root, e_investment_mgmt_fee_tiered_by_assets );
- WRITE(root, e_curr_sepacct_load_tiered_by_assets );
- WRITE(root, e_guar_sepacct_load_tiered_by_assets );
- WRITE(root, e_tiered_ak_premium_tax );
- WRITE(root, e_tiered_de_premium_tax );
- WRITE(root, e_tiered_sd_premium_tax );
-
-#undef WRITE
-
// Instead of this:
// document.save_to_file(filename.c_str());
// for the nonce, explicitly change the extension, in order to
@@ -560,47 +579,47 @@
stratified_charges foo;
- foo.raw_entity(e_curr_sepacct_load_banded_by_premium
).values_.push_back(0.0);
- foo.raw_entity(e_curr_sepacct_load_banded_by_premium
).limits_.push_back(DBL_MAX);
- foo.raw_entity(e_guar_sepacct_load_banded_by_premium
).values_.push_back(0.0);
- foo.raw_entity(e_guar_sepacct_load_banded_by_premium
).limits_.push_back(DBL_MAX);
- foo.raw_entity(e_curr_sepacct_load_banded_by_assets
).values_.push_back(0.0);
- foo.raw_entity(e_curr_sepacct_load_banded_by_assets
).limits_.push_back(DBL_MAX);
- foo.raw_entity(e_guar_sepacct_load_banded_by_assets
).values_.push_back(0.0);
- foo.raw_entity(e_guar_sepacct_load_banded_by_assets
).limits_.push_back(DBL_MAX);
+ foo.datum("CurrSepAcctLoadBandedByPrem" ).values_.push_back(0.0);
+ foo.datum("CurrSepAcctLoadBandedByPrem" ).limits_.push_back(DBL_MAX);
+ foo.datum("GuarSepAcctLoadBandedByPrem" ).values_.push_back(0.0);
+ foo.datum("GuarSepAcctLoadBandedByPrem" ).limits_.push_back(DBL_MAX);
+ foo.datum("CurrSepAcctLoadBandedByAssets" ).values_.push_back(0.0);
+ foo.datum("CurrSepAcctLoadBandedByAssets" ).limits_.push_back(DBL_MAX);
+ foo.datum("GuarSepAcctLoadBandedByAssets" ).values_.push_back(0.0);
+ foo.datum("GuarSepAcctLoadBandedByAssets" ).limits_.push_back(DBL_MAX);
- foo.raw_entity(e_curr_m_and_e_tiered_by_assets
).values_.push_back(0.0);
- foo.raw_entity(e_curr_m_and_e_tiered_by_assets
).limits_.push_back(DBL_MAX);
- foo.raw_entity(e_guar_m_and_e_tiered_by_assets
).values_.push_back(0.0);
- foo.raw_entity(e_guar_m_and_e_tiered_by_assets
).limits_.push_back(DBL_MAX);
- foo.raw_entity(e_asset_based_comp_tiered_by_assets
).values_.push_back(0.0);
- foo.raw_entity(e_asset_based_comp_tiered_by_assets
).limits_.push_back(DBL_MAX);
- foo.raw_entity(e_investment_mgmt_fee_tiered_by_assets
).values_.push_back(0.0);
- foo.raw_entity(e_investment_mgmt_fee_tiered_by_assets
).limits_.push_back(DBL_MAX);
- foo.raw_entity(e_curr_sepacct_load_tiered_by_assets
).values_.push_back(0.0);
- foo.raw_entity(e_curr_sepacct_load_tiered_by_assets
).limits_.push_back(DBL_MAX);
- foo.raw_entity(e_guar_sepacct_load_tiered_by_assets
).values_.push_back(0.0);
- foo.raw_entity(e_guar_sepacct_load_tiered_by_assets
).limits_.push_back(DBL_MAX);
+ foo.datum("CurrMandETieredByAssets" ).values_.push_back(0.0);
+ foo.datum("CurrMandETieredByAssets" ).limits_.push_back(DBL_MAX);
+ foo.datum("GuarMandETieredByAssets" ).values_.push_back(0.0);
+ foo.datum("GuarMandETieredByAssets" ).limits_.push_back(DBL_MAX);
+ foo.datum("AssetCompTieredByAssets" ).values_.push_back(0.0);
+ foo.datum("AssetCompTieredByAssets" ).limits_.push_back(DBL_MAX);
+ foo.datum("InvestmentMgmtFeeTieredByAssets").values_.push_back(0.0);
+ foo.datum("InvestmentMgmtFeeTieredByAssets").limits_.push_back(DBL_MAX);
+ foo.datum("CurrSepAcctLoadTieredByAssets" ).values_.push_back(0.0);
+ foo.datum("CurrSepAcctLoadTieredByAssets" ).limits_.push_back(DBL_MAX);
+ foo.datum("GuarSepAcctLoadTieredByAssets" ).values_.push_back(0.0);
+ foo.datum("GuarSepAcctLoadTieredByAssets" ).limits_.push_back(DBL_MAX);
// For AK and SD, these are the actual rates as of 2003-09-09. Statutes:
// AK 21.09.210(m)
// SD 10-4-22(2) (see also 58-6-70)
- foo.raw_entity(e_tiered_ak_premium_tax ).values_.push_back
(0.02700);
- foo.raw_entity(e_tiered_ak_premium_tax ).values_.push_back
(0.00100);
- foo.raw_entity(e_tiered_ak_premium_tax
).limits_.push_back(100000.0);
- foo.raw_entity(e_tiered_ak_premium_tax
).limits_.push_back(DBL_MAX);
- foo.raw_entity(e_tiered_ak_premium_tax).gloss_ = "AK 21.09.210(m)";
+ foo.datum("TieredAKPremTax").values_.push_back (0.02700);
+ foo.datum("TieredAKPremTax").values_.push_back (0.00100);
+ foo.datum("TieredAKPremTax").limits_.push_back(100000.0);
+ foo.datum("TieredAKPremTax").limits_.push_back(DBL_MAX);
+ foo.datum("TieredAKPremTax").gloss_ = "AK 21.09.210(m)";
// DE: not yet implemented.
- foo.raw_entity(e_tiered_de_premium_tax ).values_.push_back
(0.0);
- foo.raw_entity(e_tiered_de_premium_tax
).limits_.push_back(DBL_MAX);
+ foo.datum("TieredDEPremTax").values_.push_back (0.0);
+ foo.datum("TieredDEPremTax").limits_.push_back(DBL_MAX);
- foo.raw_entity(e_tiered_sd_premium_tax ).values_.push_back
(0.02500);
- foo.raw_entity(e_tiered_sd_premium_tax ).values_.push_back
(0.00080);
- foo.raw_entity(e_tiered_sd_premium_tax
).limits_.push_back(100000.0);
- foo.raw_entity(e_tiered_sd_premium_tax
).limits_.push_back(DBL_MAX);
- foo.raw_entity(e_tiered_sd_premium_tax).gloss_ = "SD 10-4-22(2) (see also
58-6-70)";
+ foo.datum("TieredSDPremTax").values_.push_back (0.02500);
+ foo.datum("TieredSDPremTax").values_.push_back (0.00080);
+ foo.datum("TieredSDPremTax").limits_.push_back(100000.0);
+ foo.datum("TieredSDPremTax").limits_.push_back(DBL_MAX);
+ foo.datum("TieredSDPremTax").gloss_ = "SD 10-4-22(2) (see also 58-6-70)";
foo.write(AddDataDir("sample.strata"));
}
Modified: lmi/trunk/stratified_charges.hpp
===================================================================
--- lmi/trunk/stratified_charges.hpp 2010-05-24 11:54:24 UTC (rev 4959)
+++ lmi/trunk/stratified_charges.hpp 2010-05-25 14:44:20 UTC (rev 4960)
@@ -26,13 +26,12 @@
#include "config.hpp"
+#include "any_member.hpp"
#include "mc_enum_type_enums.hpp"
#include "obstruct_slicing.hpp"
#include "so_attributes.hpp"
#include "xml_lmi_fwd.hpp"
-#include <iosfwd>
-#include <map>
#include <string>
#include <vector>
@@ -80,6 +79,8 @@
);
~stratified_entity();
+ bool operator==(stratified_entity const&);
+
void read (xml::element const& node);
void write(xml::element&) const;
@@ -96,19 +97,22 @@
};
/// Rates that depend upon the amount they're multiplied by.
-///
-/// Implicitly-declared special member functions do the right thing.
class LMI_SO stratified_charges
- :virtual private obstruct_slicing<stratified_charges>
+ :virtual private obstruct_slicing <stratified_charges>
+ , public MemberSymbolTable <stratified_charges>
{
friend class TierDocument;
- friend class TierView;
public:
stratified_charges(std::string const& filename);
+ stratified_charges(stratified_charges const&);
~stratified_charges();
+ stratified_charges& operator=(stratified_charges const&);
+
+ stratified_entity const& datum(std::string const& name) const;
+
// TODO ?? These things are not implemented correctly:
//
// - tiered_asset_based_compensation, tiered_investment_management_fee:
@@ -148,11 +152,13 @@
private:
stratified_charges(); // Private, but implemented for friends' use.
- stratified_entity& raw_entity(e_stratified);
- stratified_entity const& raw_entity(e_stratified) const;
+ void ascribe_members();
- void initialize_dictionary();
+ stratified_entity& datum(std::string const& name);
+ // Deprecated: for backward compatibility only. Prefer datum().
+ stratified_entity& raw_entity(e_stratified);
+
void read (std::string const& filename);
void write(std::string const& filename) const;
@@ -174,7 +180,19 @@
double tiered_curr_m_and_e(double assets) const;
double tiered_guar_m_and_e(double assets) const;
- std::map<e_stratified, stratified_entity> dictionary;
+ stratified_entity CurrSepAcctLoadBandedByPrem;
+ stratified_entity GuarSepAcctLoadBandedByPrem;
+ stratified_entity CurrSepAcctLoadBandedByAssets;
+ stratified_entity GuarSepAcctLoadBandedByAssets;
+ stratified_entity CurrMandETieredByAssets;
+ stratified_entity GuarMandETieredByAssets;
+ stratified_entity AssetCompTieredByAssets;
+ stratified_entity InvestmentMgmtFeeTieredByAssets;
+ stratified_entity CurrSepAcctLoadTieredByAssets;
+ stratified_entity GuarSepAcctLoadTieredByAssets;
+ stratified_entity TieredAKPremTax;
+ stratified_entity TieredDEPremTax;
+ stratified_entity TieredSDPremTax;
};
bool LMI_SO is_highest_representable_double(double);
Modified: lmi/trunk/tier_document.cpp
===================================================================
--- lmi/trunk/tier_document.cpp 2010-05-24 11:54:24 UTC (rev 4959)
+++ lmi/trunk/tier_document.cpp 2010-05-25 14:44:20 UTC (rev 4960)
@@ -53,23 +53,15 @@
void TierDocument::initialize_charges()
{
- typedef std::map<e_stratified, stratified_entity> dictionary_t;
-
- charges_.initialize_dictionary();
-
- stratified_entity dummy_entity
+ static stratified_entity const dummy_entity
(std::vector<double>(1, DBL_MAX) // limits
,std::vector<double>(1, 0) // values
);
-
- for
- (dictionary_t::iterator it = charges_.dictionary.begin()
- , end = charges_.dictionary.end()
- ;it != end
- ;++it
- )
+ std::vector<std::string> const& v = charges_.member_names();
+ typedef std::vector<std::string>::const_iterator svci;
+ for(svci i = v.begin(); i != v.end(); ++i)
{
- it->second = dummy_entity;
+ charges_.datum(*i) = dummy_entity;
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [4960] Refactor, using symbolic member names in class stratified_charges,
Greg Chicares <=