summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Selkirk <pselkirk@isc.org>2013-05-21 20:45:22 +0200
committerPaul Selkirk <pselkirk@isc.org>2013-05-21 20:45:22 +0200
commit7acdd8d445081e1a4c70ed58298367a96ccb55fd (patch)
treeb99c260fe948dbbe6b8e8474b1dc9bb176de778b /src
parent[2522] add SSHFP::operator= (diff)
downloadkea-7acdd8d445081e1a4c70ed58298367a96ccb55fd.tar.xz
kea-7acdd8d445081e1a4c70ed58298367a96ccb55fd.zip
[2522] remove OldRdataFactory, make AbstractRdataFactory pure virtual
Diffstat (limited to 'src')
-rw-r--r--src/lib/dns/rrparamregistry-placeholder.cc44
-rw-r--r--src/lib/dns/rrparamregistry.h17
-rw-r--r--src/lib/dns/tests/rrparamregistry_unittest.cc7
3 files changed, 14 insertions, 54 deletions
diff --git a/src/lib/dns/rrparamregistry-placeholder.cc b/src/lib/dns/rrparamregistry-placeholder.cc
index 5960759a4d..ae735bcf47 100644
--- a/src/lib/dns/rrparamregistry-placeholder.cc
+++ b/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)));
}
};
diff --git a/src/lib/dns/rrparamregistry.h b/src/lib/dns/rrparamregistry.h
index bf864368da..1d59e019db 100644
--- a/src/lib/dns/rrparamregistry.h
+++ b/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;
//@}
};
diff --git a/src/lib/dns/tests/rrparamregistry_unittest.cc b/src/lib/dns/tests/rrparamregistry_unittest.cc
index 08e0af10cb..b0d43a81d2 100644
--- a/src/lib/dns/tests/rrparamregistry_unittest.cc
+++ b/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) {