Browse Source

[2522] remove OldRdataFactory, make AbstractRdataFactory pure virtual

Paul Selkirk 12 years ago
parent
commit
7acdd8d445

+ 4 - 40
src/lib/dns/rrparamregistry-placeholder.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2010  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2010-2013  Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -41,35 +41,6 @@ using namespace isc::dns::rdata;
 namespace isc {
 namespace dns {
 
-namespace rdata {
-
-RdataPtr
-AbstractRdataFactory::create(MasterLexer& lexer, const Name*,
-                             MasterLoader::Options,
-                             MasterLoaderCallbacks&) const
-{
-    std::string s;
-
-    while (true) {
-        const MasterToken& token = lexer.getNextToken();
-        if ((token.getType() == MasterToken::END_OF_FILE) ||
-            (token.getType() == MasterToken::END_OF_LINE)) {
-            lexer.ungetToken(); // let the upper layer handle the end-of token
-            break;
-        }
-
-        if (!s.empty()) {
-            s += " ";
-        }
-
-        s += token.getString();
-    }
-
-    return (create(s));
-}
-
-} // end of namespace isc::dns::rdata
-
 namespace {
 ///
 /// The following function and class are a helper to define case-insensitive
@@ -190,10 +161,8 @@ typedef map<RRTypeClass, RdataFactoryPtr> RdataFactoryMap;
 typedef map<RRType, RdataFactoryPtr> GenericRdataFactoryMap;
 
 template <typename T>
-class OldRdataFactory : public AbstractRdataFactory {
+class RdataFactory : public AbstractRdataFactory {
 public:
-    using AbstractRdataFactory::create;
-
     virtual RdataPtr create(const string& rdata_str) const
     {
         return (RdataPtr(new T(rdata_str)));
@@ -208,16 +177,11 @@ public:
     {
         return (RdataPtr(new T(dynamic_cast<const T&>(source))));
     }
-};
-
-template <typename T>
-class RdataFactory : public OldRdataFactory<T> {
-public:
-    using OldRdataFactory<T>::create;
 
     virtual RdataPtr create(MasterLexer& lexer, const Name* origin,
                             MasterLoader::Options options,
-                            MasterLoaderCallbacks& callbacks) const {
+                            MasterLoaderCallbacks& callbacks) const
+    {
         return (RdataPtr(new T(lexer, origin, options, callbacks)));
     }
 };

+ 5 - 12
src/lib/dns/rrparamregistry.h

@@ -1,4 +1,4 @@
-// Copyright (C) 2010  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2010-2013  Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -55,11 +55,11 @@ namespace rdata {
 /// \brief The \c AbstractRdataFactory class is an abstract base class to
 /// encapsulate a set of Rdata factory methods in a polymorphic way.
 ///
-/// An external developers who want to introduce a new or experimental RR type
-/// are expected to define a corresponding derived class of \c
+/// An external developer who wants to introduce a new or experimental RR type
+/// is expected to define a corresponding derived class of \c
 /// AbstractRdataFactory and register it via \c RRParamRegistry.
 ///
-/// For other users of this API normally do not have to care about this class
+/// Other users of this API normally do not have to care about this class
 /// or its derived classes; this class is generally intended to be used
 /// as an internal utility of the API implementation.
 class AbstractRdataFactory {
@@ -125,16 +125,9 @@ public:
     /// of a specific RR type and class for \c RRParamRegistry::createRdata()
     /// that uses \c MasterLexer.  See its description for the expected
     /// behavior and meaning of the parameters.
-    ///
-    /// \note Right now this is not defined as a pure virtual method and
-    /// provides the default implementation.  This is an intermediate
-    /// workaround until we implement the underlying constructor for all
-    /// supported \c Rdata classes; once it's completed the workaround
-    /// default implementation should be removed and this method should become
-    /// pure virtual.
     virtual RdataPtr create(MasterLexer& lexer, const Name* origin,
                             MasterLoader::Options options,
-                            MasterLoaderCallbacks& callbacks) const;
+                            MasterLoaderCallbacks& callbacks) const = 0;
     //@}
 };
 

+ 5 - 2
src/lib/dns/tests/rrparamregistry_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2010  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2010-2013  Internet Systems Consortium, Inc. ("ISC")
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
@@ -108,13 +108,16 @@ TEST_F(RRParamRegistryTest, addError) {
 
 class TestRdataFactory : public AbstractRdataFactory {
 public:
-    using AbstractRdataFactory::create;
     virtual RdataPtr create(const string& rdata_str) const
     { return (RdataPtr(new in::A(rdata_str))); }
     virtual RdataPtr create(InputBuffer& buffer, size_t rdata_len) const
     { return (RdataPtr(new in::A(buffer, rdata_len))); }
     virtual RdataPtr create(const Rdata& source) const
     { return (RdataPtr(new in::A(dynamic_cast<const in::A&>(source)))); }
+    virtual RdataPtr create(MasterLexer& lexer, const Name* origin,
+                            MasterLoader::Options options,
+                            MasterLoaderCallbacks& callbacks) const
+    { return (RdataPtr(new in::A(lexer, origin, options, callbacks))); }
 };
 
 TEST_F(RRParamRegistryTest, addRemoveFactory) {