lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [5260] Make class datum_sequence abstract


From: Greg Chicares
Subject: [lmi-commits] [5260] Make class datum_sequence abstract
Date: Fri, 19 Aug 2011 00:29:17 +0000

Revision: 5260
          http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=5260
Author:   chicares
Date:     2011-08-19 00:29:16 +0000 (Fri, 19 Aug 2011)
Log Message:
-----------
Make class datum_sequence abstract

Modified Paths:
--------------
    lmi/trunk/datum_sequence.hpp
    lmi/trunk/input.hpp

Modified: lmi/trunk/datum_sequence.hpp
===================================================================
--- lmi/trunk/datum_sequence.hpp        2011-08-17 20:57:39 UTC (rev 5259)
+++ lmi/trunk/datum_sequence.hpp        2011-08-19 00:29:16 UTC (rev 5260)
@@ -59,6 +59,12 @@
 /// Still others permit both numbers and keywords. Specified amount,
 /// e.g., must accommodate numeric entry.
 ///
+/// The dtor is pure because this class should not be instantiated.
+/// Most of the other virtuals would normally be overridden in any
+/// derived class, but aren't pure because that requirement is obvious
+/// and it's convenient to invoke them in assert_sanity() to validate
+/// ctor postconditions.
+///
 /// Implicitly-declared special member functions do the right thing.
 
 class datum_sequence
@@ -68,16 +74,12 @@
   public:
     datum_sequence();
     explicit datum_sequence(std::string const&);
-    virtual ~datum_sequence();
+    virtual ~datum_sequence() = 0;
 
     datum_sequence& operator=(std::string const&);
 
     void block_keyword_values(bool);
 
-    // For the nonce, this class is used concretely. These three
-    // functions will become pure virtual once a full complement of
-    // derived classes has been written.
-    //
     virtual bool numeric_values_are_allowable() const;
     virtual bool keyword_values_are_allowable() const;
     virtual std::string const default_keyword() const;
@@ -96,18 +98,20 @@
 
 bool operator==(datum_sequence const&, datum_sequence const&);
 
-template<> inline datum_sequence value_cast<datum_sequence,std::string>
-    (std::string const& from)
-{
-    return datum_sequence(from);
-}
+// Specialize value_cast<> for each derived class, e.g., as follows:
+//
+// template<> inline datum_sequence value_cast<datum_sequence,std::string>
+//     (std::string const& from)
+// {
+//     return datum_sequence(from);
+// }
+//
+// template<> inline std::string value_cast<std::string,datum_sequence>
+//     (datum_sequence const& from)
+// {
+//     return from.value();
+// }
 
-template<> inline std::string value_cast<std::string,datum_sequence>
-    (datum_sequence const& from)
-{
-    return from.value();
-}
-
 /// Numeric MVC input sequence.
 
 class numeric_sequence

Modified: lmi/trunk/input.hpp
===================================================================
--- lmi/trunk/input.hpp 2011-08-17 20:57:39 UTC (rev 5259)
+++ lmi/trunk/input.hpp 2011-08-19 00:29:16 UTC (rev 5260)
@@ -581,10 +581,6 @@
         DesiredType* z = 0;
         z = exact_cast<ce_product_name         >(m); if(z) return z;
         z = exact_cast<datum_string            >(m); if(z) return z;
-        // As long as type datum_sequence is used directly (and not
-        // only as a base class), the following line is necessary,
-        // even though datum_sequence's reconstitutor is called.
-        z = exact_cast<datum_sequence          >(m); if(z) return z;
         z = reconstitutor<datum_sequence,Input>::reconstitute(m); if(z) return 
z;
         z = reconstitutor<mc_enum_base  ,Input>::reconstitute(m); if(z) return 
z;
         z = reconstitutor<tn_range_base ,Input>::reconstitute(m); if(z) return 
z;




reply via email to

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