[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 531699b 115/156: Factor out common page_with_
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 531699b 115/156: Factor out common page_with_basic_tabular_report class |
Date: |
Tue, 30 Jan 2018 17:22:26 -0500 (EST) |
branch: master
commit 531699bde4d9e3fd22f5941e9866a6cf39bcf547
Author: Vadim Zeitlin <address@hidden>
Commit: Vadim Zeitlin <address@hidden>
Factor out common page_with_basic_tabular_report class
NASD and private group placement illustrations share almost the same
basic illustration page, so create a common base class for it which can
be reused for both.
This does create a bit of extra complexity with having to override
get_two_column_header() method, but the gain from not duplicating all
this code in the group private placement case more than compensates for
it.
No real changes so far, this is just a pure refactoring.
---
ledger_pdf_generator_wx.cpp | 62 ++++++++++++++++++++++++++++++++++-----------
1 file changed, 47 insertions(+), 15 deletions(-)
diff --git a/ledger_pdf_generator_wx.cpp b/ledger_pdf_generator_wx.cpp
index 7fd8880..efae8c8 100644
--- a/ledger_pdf_generator_wx.cpp
+++ b/ledger_pdf_generator_wx.cpp
@@ -37,7 +37,7 @@
#include "ledger_evaluator.hpp"
#include "ledger_invariant.hpp"
#include "ledger_variant.hpp"
-#include "miscellany.hpp" // lmi_tolower()
+#include "miscellany.hpp" // lmi_tolower(), split_into_lines()
#include "pdf_writer_wx.hpp"
#include "version.hpp"
#include "wx_table_generator.hpp"
@@ -1921,9 +1921,26 @@ class pdf_illustration_regular : public pdf_illustration
std::string get_lower_footer_template_name() const override { return
"footer"; }
};
-class nasd_basic : public page_with_tabular_report
+// Common base class for basic illustration pages using the same columns in
+// both NASD and private group placement illustrations.
+class page_with_basic_tabular_report : public page_with_tabular_report
{
private:
+ // This method must be overridden to return the text of the super-header
+ // used for all pairs of "cash surrogate value" and "death benefit"
+ // columns. The return value is subject to HTML interpolation and so may
+ // contain {{variables}} and also can be multiline but, if so, it must have
+ // the same number of lines for all input arguments.
+ //
+ // The suffix_xxx arguments can be used to construct the full name of the
+ // variable appropriate for the current column pair: the short one is
+ // either "Guaranteed" or "Current" while the full one also includes "Zero"
+ // for the column pairs using zero interest-rate assumption.
+ virtual std::string get_two_column_header
+ (std::string const& suffix_full
+ ,std::string const& suffix_short
+ ) const = 0;
+
enum
{column_policy_year
,column_end_of_year_age
@@ -1942,11 +1959,6 @@ class nasd_basic : public page_with_tabular_report
,column_max
};
- std::string get_fixed_page_contents() const override
- {
- return "{{>nasd_basic}}";
- }
-
illustration_table_columns const& get_table_columns() const override
{
static illustration_table_columns const columns =
@@ -2066,14 +2078,9 @@ class nasd_basic : public page_with_tabular_report
;
- std::array<std::string, 3> const header_lines =
- {
- {"{{InitAnnSepAcctGrossInt_" + suffix_full + "}} Assumed
Sep Acct"
- ,"Gross Rate* ({{InitAnnSepAcctNetInt_" + suffix_full +
"}} net)"
- ,"{{InitAnnGenAcctInt_" + suffix_short + "}} GPA rate"
- }
- };
-
+ auto const header_lines = split_into_lines
+ (get_two_column_header(suffix_full, suffix_short)
+ );
for(auto const& line : header_lines)
{
table.output_super_header
@@ -2122,6 +2129,31 @@ class nasd_basic : public page_with_tabular_report
}
};
+class nasd_basic : public page_with_basic_tabular_report
+{
+ private:
+ std::string get_fixed_page_contents() const override
+ {
+ return "{{>nasd_basic}}";
+ }
+
+ std::string get_two_column_header
+ (std::string const& suffix_full
+ ,std::string const& suffix_short
+ ) const override
+ {
+ std::ostringstream oss;
+ oss
+ << "{{InitAnnSepAcctGrossInt_" << suffix_full << "}} "
+ << "Assumed Sep Acct\n"
+ << "Gross Rate* "
+ << "({{InitAnnSepAcctNetInt_" << suffix_full << "}} net)\n"
+ << "{{InitAnnGenAcctInt_" << suffix_short << "}} GPA rate"
+ ;
+ return oss.str();
+ }
+};
+
class nasd_supplemental : public page_with_tabular_report
{
private:
- [lmi-commits] [lmi] master 36c84ce 123/156: Add another individual private placement illustration page, (continued)
- [lmi-commits] [lmi] master 36c84ce 123/156: Add another individual private placement illustration page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 0ecc8ec 036/156: Add support for partials to our ad hoc Mustache parser, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 6f09722 107/156: Add missing words to the narrative summary continuation page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 6510601 150/156: Rename a mute variable to avoid gcc -Wshadow warning, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 048ae05 093/156: Start NASD PDF illustration class implementation, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 5ea5c86 101/156: Simplify and correct current PDF DC font handling, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master ec490eb 153/156: Revise and extend some comments in PDF generation code, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 38cab5e 096/156: Make footer template depend on illustration kind, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master d1204c2 111/156: Factor out common parts of render_or_measure_fixed_page_part(), Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master e388f6e 037/156: Add beginning of numeric summary page using an external template, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 531699b 115/156: Factor out common page_with_basic_tabular_report class,
Greg Chicares <=
- [lmi-commits] [lmi] master a85943b 124/156: Add the rest of individual private placement illustration pages, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master f0b9cea 113/156: Add "Assumption Detail" page to NASD illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 031070b 132/156: Implement supplemental report page for the regular illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 9fe1d07 125/156: Implement page-specific footer for "Tabular Details" pages, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 4f3a02e 078/156: Add company logo to the cover page, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 2d93248 118/156: Add the rest of group private placement illustration pages, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 1272ce2 127/156: Don't include "Assumptions" page in composite NASD illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master e00ab7d 080/156: Hide "attained age" column for composite illustrations, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 29e63d6 117/156: Add basic illustration page of group placement illustration, Greg Chicares, 2018/01/30
- [lmi-commits] [lmi] master 1a9bfb3 137/156: Factor out standard_supplemental_report class, Greg Chicares, 2018/01/30