[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi] access to mc_enum type information [patch 3/3]
From: |
Vaclav Slavik |
Subject: |
[lmi] access to mc_enum type information [patch 3/3] |
Date: |
Tue, 29 Mar 2011 20:42:12 +0200 |
User-agent: |
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 |
[PATCH 3/3] Specialize reconstitutor<> for mc_enum_base. Avoid duplicated code.
Provide reconstitutor<mc_enum_base,Input> specialization for using
try_member_cast<> to cast any_member<> to mc_enum_base.
Do this by calling more specialized reconstitutors (mc_enum_base and
datum_sequence> from reconstitutor<datum_base> in order to
avoid code duplication.
---
input.hpp | 59 ++++++++++++++++++++++++++++++++++++-----------------------
1 files changed, 36 insertions(+), 23 deletions(-)
diff --git a/input.hpp b/input.hpp
index 5de4fd1..68e5f69 100644
--- a/input.hpp
+++ b/input.hpp
@@ -488,21 +488,29 @@ class LMI_SO Input
};
/// Specialization of struct template reconstitutor for this Model
-/// and the base class that all its UDTs share.
+/// and the base class that all its input sequences share.
-template<> struct reconstitutor<datum_base, Input>
+template<> struct reconstitutor<datum_sequence, Input>
{
- typedef datum_base DesiredType;
+ typedef datum_sequence DesiredType;
static DesiredType* reconstitute(any_member<Input>& m)
{
DesiredType* z = 0;
- z = exact_cast<ce_product_name >(m); if(z) return z;
- z = exact_cast<datum_string >(m); if(z) return z;
- // Sequences.
- z = exact_cast<datum_sequence >(m); if(z) return z;
z = exact_cast<mode_sequence >(m); if(z) return z;
z = exact_cast<payment_sequence >(m); if(z) return z;
- // mc- types.
+ return z;
+ }
+};
+
+/// Specialization of struct template reconstitutor for this Model
+/// and the base class that all its mc- types share.
+
+template<> struct reconstitutor<mc_enum_base, Input>
+{
+ typedef mc_enum_base DesiredType;
+ static DesiredType* reconstitute(any_member<Input>& m)
+ {
+ DesiredType* z = 0;
z = exact_cast<mce_gen_basis >(m); if(z) return z;
z = exact_cast<mce_class >(m); if(z) return z;
z = exact_cast<mce_country >(m); if(z) return z;
@@ -534,6 +542,26 @@ template<> struct reconstitutor<datum_base, Input>
z = exact_cast<mce_to_point >(m); if(z) return z;
z = exact_cast<mce_uw_basis >(m); if(z) return z;
z = exact_cast<mce_yes_or_no >(m); if(z) return z;
+ return z;
+ }
+};
+
+/// Specialization of struct template reconstitutor for this Model
+/// and the base class that all its UDTs share.
+
+template<> struct reconstitutor<datum_base, Input>
+{
+ typedef datum_base DesiredType;
+ static DesiredType* reconstitute(any_member<Input>& m)
+ {
+ DesiredType* z = 0;
+ z = exact_cast<ce_product_name >(m); if(z) return z;
+ z = exact_cast<datum_string >(m); if(z) return z;
+ // Sequences.
+ z = exact_cast<datum_sequence >(m); if(z) return z;
+ z = reconstitutor<datum_sequence, Input>::reconstitute(m); if(z)
return z;
+ // mc- types.
+ z = reconstitutor<mc_enum_base, Input>::reconstitute(m); if(z)
return z;
// tnr- types.
z = exact_cast<tnr_age >(m); if(z) return z;
z = exact_cast<tnr_corridor_factor >(m); if(z) return z;
@@ -548,20 +576,5 @@ template<> struct reconstitutor<datum_base, Input>
}
};
-/// Specialization of struct template reconstitutor for this Model
-/// and the base class that all its input sequences share.
-
-template<> struct reconstitutor<datum_sequence, Input>
-{
- typedef datum_sequence DesiredType;
- static DesiredType* reconstitute(any_member<Input>& m)
- {
- DesiredType* z = 0;
- z = exact_cast<mode_sequence >(m); if(z) return z;
- z = exact_cast<payment_sequence >(m); if(z) return z;
- return z;
- }
-};
-
#endif // input_hpp