lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [4840] Refactor


From: Greg Chicares
Subject: [lmi-commits] [4840] Refactor
Date: Fri, 16 Apr 2010 23:43:11 +0000

Revision: 4840
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=4840
Author:   chicares
Date:     2010-04-16 23:43:11 +0000 (Fri, 16 Apr 2010)
Log Message:
-----------
Refactor

Modified Paths:
--------------
    lmi/trunk/antediluvian_stubs.cpp
    lmi/trunk/input.hpp
    lmi/trunk/input_xml_io.cpp
    lmi/trunk/mec_input.cpp
    lmi/trunk/mec_input.hpp
    lmi/trunk/mec_state.cpp
    lmi/trunk/mec_state.hpp
    lmi/trunk/product_data.cpp
    lmi/trunk/product_data.hpp
    lmi/trunk/xml_serializable.hpp
    lmi/trunk/xml_serializable.tpp

Modified: lmi/trunk/antediluvian_stubs.cpp
===================================================================
--- lmi/trunk/antediluvian_stubs.cpp    2010-04-16 22:07:50 UTC (rev 4839)
+++ lmi/trunk/antediluvian_stubs.cpp    2010-04-16 23:43:11 UTC (rev 4840)
@@ -84,25 +84,6 @@
     return false;
 }
 
-bool mec_state::redintegrate_ex_ante
-    (int
-    ,std::string const&
-    ,std::string      &
-    ) const
-{
-    return false;
-}
-
-void mec_state::redintegrate_ex_post
-    (int
-    ,std::map<std::string, std::string>
-    ,std::list<std::string>
-    )
-{}
-
-void mec_state::redintegrate_ad_terminum()
-{}
-
 std::string const& product_data::datum(std::string const&) const
 {
     return empty_string;

Modified: lmi/trunk/input.hpp
===================================================================
--- lmi/trunk/input.hpp 2010-04-16 22:07:50 UTC (rev 4839)
+++ lmi/trunk/input.hpp 2010-04-16 23:43:11 UTC (rev 4840)
@@ -168,10 +168,12 @@
         (InputSequence const& s
         );
 
-    // Class 'xml_serializable' required implementation.
+    // xml_serializable required implementation.
     virtual int         class_version() const;
     virtual std::string xml_root_name() const;
-    virtual bool        is_detritus(std::string const&) const;
+
+    // xml_serializable overrides.
+    virtual bool is_detritus(std::string const&) const;
     virtual bool redintegrate_ex_ante
         (int                file_version
         ,std::string const& name

Modified: lmi/trunk/input_xml_io.cpp
===================================================================
--- lmi/trunk/input_xml_io.cpp  2010-04-16 22:07:50 UTC (rev 4839)
+++ lmi/trunk/input_xml_io.cpp  2010-04-16 23:43:11 UTC (rev 4840)
@@ -62,7 +62,7 @@
 }
 } // Unnamed namespace.
 
-/// Serial number of this class's xml version.
+/// Backward-compatibility serial number of this class's xml version.
 ///
 /// version 0: [prior to the lmi epoch]
 /// version 1: 20050114T1947Z
@@ -81,16 +81,11 @@
     return 5;
 }
 
-//============================================================================
 std::string Input::xml_root_name() const
 {
     return "cell";
 }
 
-/// Entities that were present in older versions and then removed
-/// are recognized and ignored. If they're resurrected in a later
-/// version, then they aren't ignored.
-
 bool Input::is_detritus(std::string const& s) const
 {
     static std::string const a[] =

Modified: lmi/trunk/mec_input.cpp
===================================================================
--- lmi/trunk/mec_input.cpp     2010-04-16 22:07:50 UTC (rev 4839)
+++ lmi/trunk/mec_input.cpp     2010-04-16 23:43:11 UTC (rev 4840)
@@ -603,7 +603,7 @@
         );
 }
 
-/// Serial number of this class's xml version.
+/// Backward-compatibility serial number of this class's xml version.
 ///
 /// version 0: 20090627T2249Z
 
@@ -617,10 +617,6 @@
     return "mec";
 }
 
-/// Entities that were present in older versions and then removed
-/// are recognized and ignored. If they're resurrected in a later
-/// version, then they aren't ignored.
-
 bool mec_input::is_detritus(std::string const& s) const
 {
     static std::string const a[] =
@@ -631,26 +627,6 @@
     return v.end() != std::find(v.begin(), v.end(), s);
 }
 
-bool mec_input::redintegrate_ex_ante
-    (int                file_version
-    ,std::string const& name
-    ,std::string      & value
-    ) const
-{
-    typedef xml_serializable<mec_input> base;
-    return base::redintegrate_ex_ante(file_version, name, value);
-}
-
-void mec_input::redintegrate_ex_post
-    (int                                file_version
-    ,std::map<std::string, std::string> detritus_map
-    ,std::list<std::string>             residuary_names
-    )
-{
-    typedef xml_serializable<mec_input> base;
-    base::redintegrate_ex_post(file_version, detritus_map, residuary_names);
-}
-
 void mec_input::redintegrate_ad_terminum()
 {
     Reconcile();

Modified: lmi/trunk/mec_input.hpp
===================================================================
--- lmi/trunk/mec_input.hpp     2010-04-16 22:07:50 UTC (rev 4839)
+++ lmi/trunk/mec_input.hpp     2010-04-16 23:43:11 UTC (rev 4840)
@@ -101,20 +101,12 @@
   private:
     void AscribeMembers();
 
-    // Class 'xml_serializable' required implementation.
+    // xml_serializable required implementation.
     virtual int         class_version() const;
     virtual std::string xml_root_name() const;
-    virtual bool        is_detritus(std::string const&) const;
-    virtual bool redintegrate_ex_ante
-        (int                file_version
-        ,std::string const& name
-        ,std::string      & value
-        ) const;
-    virtual void redintegrate_ex_post
-        (int                                file_version
-        ,std::map<std::string, std::string> detritus_map
-        ,std::list<std::string>             residuary_names
-        );
+
+    // xml_serializable overrides.
+    virtual bool is_detritus(std::string const&) const;
     virtual void redintegrate_ad_terminum();
 
     // MvcModel required implementation.

Modified: lmi/trunk/mec_state.cpp
===================================================================
--- lmi/trunk/mec_state.cpp     2010-04-16 22:07:50 UTC (rev 4839)
+++ lmi/trunk/mec_state.cpp     2010-04-16 23:43:11 UTC (rev 4840)
@@ -383,7 +383,7 @@
     ascribe("Q6_max_non_mec_prem"      , &mec_state::Q6_max_non_mec_prem      
);
 }
 
-/// Serial number of this class's xml version.
+/// Backward-compatibility serial number of this class's xml version.
 ///
 /// version 0: 20090728T1324Z
 
@@ -397,10 +397,6 @@
     return "mec_state";
 }
 
-/// Entities that were present in older versions and then removed
-/// are recognized and ignored. If they're resurrected in a later
-/// version, then they aren't ignored.
-
 bool mec_state::is_detritus(std::string const& s) const
 {
     static std::string const a[] =
@@ -410,27 +406,3 @@
     return v.end() != std::find(v.begin(), v.end(), s);
 }
 
-bool mec_state::redintegrate_ex_ante
-    (int                file_version
-    ,std::string const& name
-    ,std::string      & value
-    ) const
-{
-    typedef xml_serializable<mec_state> base;
-    return base::redintegrate_ex_ante(file_version, name, value);
-}
-
-void mec_state::redintegrate_ex_post
-    (int                                file_version
-    ,std::map<std::string, std::string> detritus_map
-    ,std::list<std::string>             residuary_names
-    )
-{
-    typedef xml_serializable<mec_state> base;
-    base::redintegrate_ex_post(file_version, detritus_map, residuary_names);
-}
-
-void mec_state::redintegrate_ad_terminum()
-{
-}
-

Modified: lmi/trunk/mec_state.hpp
===================================================================
--- lmi/trunk/mec_state.hpp     2010-04-16 22:07:50 UTC (rev 4839)
+++ lmi/trunk/mec_state.hpp     2010-04-16 23:43:11 UTC (rev 4840)
@@ -67,22 +67,13 @@
   private:
     void AscribeMembers();
 
-    // Class 'xml_serializable' required implementation.
+    // xml_serializable required implementation.
     virtual int         class_version() const;
     virtual std::string xml_root_name() const;
-    virtual bool        is_detritus(std::string const&) const;
-    virtual bool redintegrate_ex_ante
-        (int                file_version
-        ,std::string const& name
-        ,std::string      & value
-        ) const;
-    virtual void redintegrate_ex_post
-        (int                                file_version
-        ,std::map<std::string, std::string> detritus_map
-        ,std::list<std::string>             residuary_names
-        );
-    virtual void redintegrate_ad_terminum();
 
+    // xml_serializable overrides.
+    virtual bool is_detritus(std::string const&) const;
+
     int    B0_deduced_policy_year;
     int    B1_deduced_contract_year;
     double B2_deduced_px7_rate;

Modified: lmi/trunk/product_data.cpp
===================================================================
--- lmi/trunk/product_data.cpp  2010-04-16 22:07:50 UTC (rev 4839)
+++ lmi/trunk/product_data.cpp  2010-04-16 23:43:11 UTC (rev 4840)
@@ -184,7 +184,7 @@
     ascribe("MonthlyChargesPaymentFootnote" , 
&product_data::MonthlyChargesPaymentFootnote );
 }
 
-/// Serial number of this class's xml version.
+/// Backward-compatibility serial number of this class's xml version.
 ///
 /// version 0: 20100402T1123Z
 
@@ -207,30 +207,6 @@
     return v.end() != std::find(v.begin(), v.end(), s);
 }
 
-bool product_data::redintegrate_ex_ante
-    (int                file_version
-    ,std::string const& name
-    ,std::string      & value
-    ) const
-{
-    typedef xml_serializable<product_data> base;
-    return base::redintegrate_ex_ante(file_version, name, value);
-}
-
-void product_data::redintegrate_ex_post
-    (int                                file_version
-    ,std::map<std::string, std::string> detritus_map
-    ,std::list<std::string>             residuary_names
-    )
-{
-    typedef xml_serializable<product_data> base;
-    base::redintegrate_ex_post(file_version, detritus_map, residuary_names);
-}
-
-void product_data::redintegrate_ad_terminum()
-{
-}
-
 /// Create a product file for the 'sample' product.
 ///
 /// Only the most crucial members are explicitly initialized. For the

Modified: lmi/trunk/product_data.hpp
===================================================================
--- lmi/trunk/product_data.hpp  2010-04-16 22:07:50 UTC (rev 4839)
+++ lmi/trunk/product_data.hpp  2010-04-16 23:43:11 UTC (rev 4840)
@@ -44,9 +44,9 @@
 
 class LMI_SO product_data
     :        private boost::noncopyable
-    ,virtual public  obstruct_slicing  <product_data>
-    ,        public  MemberSymbolTable <product_data>
+    ,virtual private obstruct_slicing  <product_data>
     ,        public  xml_serializable  <product_data>
+    ,        public  MemberSymbolTable <product_data>
 {
     friend class PolicyDocument;
 
@@ -68,19 +68,10 @@
     // xml_serializable required implementation.
     virtual int         class_version() const;
     virtual std::string xml_root_name() const;
-    virtual bool        is_detritus(std::string const&) const;
-    virtual bool redintegrate_ex_ante
-        (int                file_version
-        ,std::string const& name
-        ,std::string      & value
-        ) const;
-    virtual void redintegrate_ex_post
-        (int                                file_version
-        ,std::map<std::string, std::string> detritus_map
-        ,std::list<std::string>             residuary_names
-        );
-    virtual void redintegrate_ad_terminum();
 
+    // xml_serializable overrides.
+    virtual bool is_detritus(std::string const&) const;
+
     // Names of files that contain other product data.
     std::string DatabaseFilename;
     std::string FundFilename;

Modified: lmi/trunk/xml_serializable.hpp
===================================================================
--- lmi/trunk/xml_serializable.hpp      2010-04-16 22:07:50 UTC (rev 4839)
+++ lmi/trunk/xml_serializable.hpp      2010-04-16 23:43:11 UTC (rev 4840)
@@ -51,24 +51,27 @@
     void read (xml::element const&);
     void write(xml::element&) const;
 
-  protected: // Possibly-implemented pure virtuals.
+  private:
+    // Private non-virtuals.
+    void immit_members_into(xml::element&) const;
+
+    // Class (T) identification.
     virtual int         class_version() const = 0;
     virtual std::string xml_root_name() const = 0;
-    virtual bool        is_detritus(std::string const&) const = 0;
+
+    // Backward compatibility.
+    virtual bool is_detritus(std::string const&) const;
     virtual bool redintegrate_ex_ante
         (int                file_version
         ,std::string const& name
         ,std::string      & value
-        ) const = 0;
+        ) const;
     virtual void redintegrate_ex_post
         (int                                file_version
         ,std::map<std::string, std::string> detritus_map
         ,std::list<std::string>             residuary_names
-        ) = 0;
-    virtual void redintegrate_ad_terminum() = 0;
-
-  private:
-    void immit_members_into(xml::element&) const;
+        );
+    virtual void redintegrate_ad_terminum();
 };
 
 template<typename T>

Modified: lmi/trunk/xml_serializable.tpp
===================================================================
--- lmi/trunk/xml_serializable.tpp      2010-04-16 22:07:50 UTC (rev 4839)
+++ lmi/trunk/xml_serializable.tpp      2010-04-16 23:43:11 UTC (rev 4840)
@@ -193,6 +193,43 @@
         }
 }
 
+/// Backward-compatibility serial number of class T's xml version.
+
+template<typename T>
+int xml_serializable<T>::class_version() const
+{
+    throw "Unreachable--silences a compiler diagnostic.";
+}
+
+/// Root tag (when T is saved as the root of a document).
+
+template<typename T>
+std::string xml_serializable<T>::xml_root_name() const
+{
+    throw "Unreachable--silences a compiler diagnostic.";
+}
+
+/// Ascertain whether an element-tag is obsolete.
+///
+/// Tags that were present in older versions and later removed are
+/// recognized and redintegrated with other tags (elsewhere). If
+/// they're subsequently resurrected, then they may resume their
+/// original or an enhanced function.
+
+template<typename T>
+bool xml_serializable<T>::is_detritus(std::string const&) const
+{
+    return false;
+    // Pastable specimen implementation for derived classes:
+#if 0
+    static std::string const a[] =
+        {"Remove this string when adding the first removed entity."
+        };
+    static std::vector<std::string> const v(a, a + lmi_array_size(a));
+    return v.end() != std::find(v.begin(), v.end(), s);
+#endif // 0
+}
+
 /// Provide for backward compatibility before assigning values.
 ///
 /// Motivation: transform an old enumerative string to a contemporary





reply via email to

[Prev in Thread] Current Thread [Next in Thread]