Commit 9a9260c2 authored by Mukund Sivaraman's avatar Mukund Sivaraman

[2266] Remove all traces of RRsetList

It is no longer used anywhere.
parent daedcaea
......@@ -34,7 +34,6 @@
#include <dns/nsec3hash.h>
#include <dns/rdataclass.h>
#include <dns/rrclass.h>
#include <dns/rrsetlist.h>
#include <dns/masterload.h>
#include <boost/function.hpp>
......
......@@ -20,7 +20,6 @@
#include <dns/nsec3hash.h>
#include <dns/rdataclass.h>
#include <dns/rrclass.h>
#include <dns/rrsetlist.h>
#include <dns/masterload.h>
#include <datasrc/memory_datasrc.h>
......
......@@ -22,7 +22,6 @@
#include <dns/nsec3hash.h>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
#include <dns/rrsetlist.h>
#include <dns/rrttl.h>
#include <dns/masterload.h>
......
......@@ -22,7 +22,6 @@
#include <dns/rdata.h>
#include <dns/rdataclass.h>
#include <dns/rrclass.h>
#include <dns/rrsetlist.h>
#include <dns/rrttl.h>
#include <dns/masterload.h>
......
......@@ -107,7 +107,6 @@ libb10_dns___la_SOURCES += rdatafields.h rdatafields.cc
libb10_dns___la_SOURCES += rrclass.cc
libb10_dns___la_SOURCES += rrparamregistry.h
libb10_dns___la_SOURCES += rrset.h rrset.cc
libb10_dns___la_SOURCES += rrsetlist.h rrsetlist.cc
libb10_dns___la_SOURCES += rrttl.h rrttl.cc
libb10_dns___la_SOURCES += rrtype.cc
libb10_dns___la_SOURCES += question.h question.cc
......@@ -153,7 +152,6 @@ libdns___include_HEADERS = \
rdata.h \
rrparamregistry.h \
rrset.h \
rrsetlist.h \
rrttl.h \
tsigkey.h
# Purposely not installing these headers:
......
// Copyright (C) 2010 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
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include <vector>
#include <boost/foreach.hpp>
#include <exceptions/exceptions.h>
#include <dns/rrclass.h>
#include <dns/rrtype.h>
#include <dns/rrset.h>
#include <dns/rrsetlist.h>
namespace isc {
namespace dns {
void
RRsetList::addRRset(RRsetPtr rrsetptr) {
ConstRRsetPtr rrset_found = findRRset(rrsetptr->getType(),
rrsetptr->getClass());
if (rrset_found != NULL) {
isc_throw(DuplicateRRset, "RRset is being doubly added to RRsetList: "
"type=" << rrsetptr->getType() << ", class=" <<
rrsetptr->getClass());
}
rrsets_.push_back(rrsetptr);
}
void
RRsetList::append(RRsetList& source) {
BOOST_FOREACH(RRsetPtr rrset, source) {
addRRset(rrset);
}
}
RRsetPtr
RRsetList::findRRset(const RRType& rrtype, const RRClass& rrclass) {
BOOST_FOREACH(RRsetPtr rrsetptr, rrsets_) {
if ((rrsetptr->getClass() == rrclass) &&
(rrsetptr->getType() == rrtype)) {
return (rrsetptr);
}
}
return (RRsetPtr());
}
}
}
// Copyright (C) 2010 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
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#ifndef __RRSETLIST_H
#define __RRSETLIST_H 1
#include <iostream>
#include <iterator>
#include <vector>
#include <boost/shared_ptr.hpp>
#include <dns/rrset.h>
#include <dns/rrclass.h>
#include <dns/rrtype.h>
namespace isc {
namespace dns {
class DuplicateRRset : public Exception {
public:
DuplicateRRset(const char* file, size_t line, const char* what) :
isc::Exception(file, line, what) {}
};
template <typename T, typename P, typename R>
class RRsetListIterator :
public std::iterator<std::input_iterator_tag, RRsetPtr> {
public:
RRsetListIterator() {}
explicit RRsetListIterator(const T& it) :
it_(it) {}
RRsetListIterator& operator++()
{
++it_;
return (*this);
}
RRsetListIterator operator++(int)
{
RRsetListIterator tmp(*this);
++it_;
return (tmp);
}
R operator*() const
{
return (*it_);
}
P operator->() const
{
return (&(operator*()));
}
bool operator==(const RRsetListIterator& other)
{
return (it_ == other.it_);
}
bool operator!=(const RRsetListIterator& other)
{
return (it_ != other.it_);
}
private:
T it_;
};
/// A set of RRsets.
///
/// \note Do not use this class unless you really understand what
/// you're doing and you're 100% sure that this class is the best choice
/// for your purpose.
///
/// Counter intuitively, this class is not a "list" of RRsets but a
/// "set" of them; it doesn't allow multiple RRsets of the same RR
/// type and RR class to be added at the same time. And, for that
/// reason, adding an RRset is more expensive than you'd expect. The
/// class name is confusing, but was named so as a result of
/// compromise: "RRsetset" would look awkward; RRsets would be
/// confusing (with RRset).
///
/// In any case, if you want a list like container of RRsets, your best choice
/// would be \c std::vector<RRset> or \c std::list<RRset>, not this class.
/// In fact, in many cases \c RRsetList will be a suboptimal choice.
/// This class is defined publicly as part of libdns++ for a historical
/// reason and is actually quite specific to a particular need for libdatasrc.
/// If you are tempted to use it, think twice to assess if this class
/// is really what you want. Again, in many cases the answer will be no.
class RRsetList {
private:
RRsetList(const RRsetList& source);
RRsetList& operator=(const RRsetList& source);
public:
RRsetList() {}
void addRRset(RRsetPtr new_rrsetptr);
void append(RRsetList& source);
RRsetPtr findRRset(const RRType& rrtype, const RRClass& rrclass);
typedef RRsetListIterator<std::vector<RRsetPtr>::iterator,
RRsetPtr*,
RRsetPtr&> iterator;
typedef RRsetListIterator<std::vector<RRsetPtr>::const_iterator,
const RRsetPtr*,
const RRsetPtr&> const_iterator;
const_iterator begin() const { return (const_iterator(rrsets_.begin())); }
const_iterator end() const { return (const_iterator(rrsets_.end())); }
iterator begin() { return (iterator(rrsets_.begin())); }
iterator end() { return (iterator(rrsets_.end())); }
size_t size() const { return (rrsets_.size()); }
private:
std::vector<RRsetPtr> rrsets_;
};
} // end of namespace dns
} // end of namespace isc
#endif // __RRSETLIST_H
// Local Variables:
// mode: c++
// End:
......@@ -56,7 +56,7 @@ run_unittests_SOURCES += rdata_minfo_unittest.cc
run_unittests_SOURCES += rdata_tsig_unittest.cc
run_unittests_SOURCES += rdata_naptr_unittest.cc
run_unittests_SOURCES += rdata_hinfo_unittest.cc
run_unittests_SOURCES += rrset_unittest.cc rrsetlist_unittest.cc
run_unittests_SOURCES += rrset_unittest.cc
run_unittests_SOURCES += question_unittest.cc
run_unittests_SOURCES += rrparamregistry_unittest.cc
run_unittests_SOURCES += masterload_unittest.cc
......
// Copyright (C) 2010 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
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include <vector>
#include <boost/foreach.hpp>
#include <dns/rdata.h>
#include <dns/rdataclass.h>
#include <dns/rrclass.h>
#include <dns/rrtype.h>
#include <dns/rrsetlist.h>
#include <dns/rrset.h>
#include <dns/rrttl.h>
#include <gtest/gtest.h>
using namespace std;
using namespace isc::dns;
using namespace isc::dns::rdata;
namespace {
class RRsetListTest : public ::testing::Test {
protected:
RRsetListTest() : example_name(Name("example.com")),
example_ttl(RRTTL(3600))
{}
void setupList(RRsetList& list);
Name example_name;
RRTTL example_ttl;
};
const in::A rdata_in_a("192.0.2.1");
const in::AAAA rdata_in_aaaa("2001:db8::1234");
const generic::NS rdata_ns("ns.example.com");
const generic::SOA rdata_soa(Name("ns.example.com"), Name("root.example.com"),
2010012601, 3600, 300, 3600000, 1200);
const generic::CNAME rdata_cname("target.example.com");
const generic::DNAME rdata_dname("dtarget.example.com");
void
RRsetListTest::setupList(RRsetList& list) {
RRsetPtr a(new RRset(Name("example.com"), RRClass::IN(),
RRType::A(), example_ttl));
RRsetPtr aaaa(new RRset(Name("example.com"), RRClass::IN(),
RRType::AAAA(), example_ttl));
RRsetPtr ns(new RRset(Name("example.com"), RRClass::IN(),
RRType::NS(), example_ttl));
RRsetPtr soa(new RRset(Name("example.com"), RRClass::IN(),
RRType::SOA(), example_ttl));
RRsetPtr cname(new RRset(Name("example.com"), RRClass::IN(),
RRType::CNAME(), example_ttl));
a->addRdata(rdata_in_a);
aaaa->addRdata(rdata_in_aaaa);
ns->addRdata(rdata_ns);
soa->addRdata(rdata_soa);
cname->addRdata(rdata_cname);
list.addRRset(a);
list.addRRset(aaaa);
list.addRRset(ns);
list.addRRset(soa);
list.addRRset(cname);
}
TEST_F(RRsetListTest, emptyOnInitialCreate) {
RRsetList list;
EXPECT_EQ(list.size(), 0);
}
TEST_F(RRsetListTest, addRRsets) {
RRsetList list;
setupList(list);
EXPECT_EQ(list.size(), 5);
}
TEST_F(RRsetListTest, append) {
RRsetList list1;
setupList(list1);
RRsetList list2;
RRsetPtr dname(new RRset(Name("example.com"), RRClass::IN(),
RRType::DNAME(), example_ttl));
dname->addRdata(rdata_dname);
list2.addRRset(dname);
list1.append(list2);
EXPECT_EQ(list2.size(), 1);
EXPECT_EQ(list1.size(), 6);
RRsetPtr rrset = list1.findRRset(RRType::DNAME(), RRClass::IN());
EXPECT_EQ(RRType::DNAME(), rrset->getType());
EXPECT_THROW(list1.append(list2), DuplicateRRset);
}
TEST_F(RRsetListTest, extraRRset) {
RRsetList list;
setupList(list);
RRsetPtr cname(new RRset(Name("another.example.com"), RRClass::IN(),
RRType::CNAME(), example_ttl));
EXPECT_THROW(list.addRRset(cname), DuplicateRRset);
}
void
checkFindResult(RRsetList& list, const Name& name,
const RRType& rrtype, const RRClass& rrclass,
const RRTTL& rrttl)
{
RRsetPtr rrset = list.findRRset(rrtype, rrclass);;
EXPECT_EQ(name, rrset->getName());
EXPECT_EQ(rrtype, rrset->getType());
EXPECT_EQ(rrclass, rrset->getClass());
EXPECT_EQ(rrttl, rrset->getTTL());
}
TEST_F(RRsetListTest, findRRset) {
RRsetList list;
setupList(list);
checkFindResult(list, example_name, RRType::A(), RRClass::IN(),
example_ttl);
checkFindResult(list, example_name, RRType::CNAME(), RRClass::IN(),
example_ttl);
checkFindResult(list, example_name, RRType::AAAA(), RRClass::IN(),
example_ttl);
checkFindResult(list, example_name, RRType::NS(), RRClass::IN(),
example_ttl);
checkFindResult(list, example_name, RRType::SOA(), RRClass::IN(),
example_ttl);
}
TEST_F(RRsetListTest, checkData) {
RRsetList list;
RRsetPtr a(new RRset(Name("example.com"), RRClass::IN(),
RRType::A(), example_ttl));
a->addRdata(rdata_in_a);
list.addRRset(a);
RdataIteratorPtr it =
list.findRRset(RRType::A(), RRClass::IN())->getRdataIterator();
EXPECT_FALSE(it->isLast());
EXPECT_EQ("192.0.2.1", it->getCurrent().toText());
}
TEST_F(RRsetListTest, iterate) {
RRsetList list;
setupList(list);
bool has_a = false, has_aaaa = false, has_ns = false, has_soa = false,
has_cname = false;
int i = 0;
BOOST_FOREACH(RRsetPtr rrset, list) {
if (rrset->getType() == RRType::A()) {
has_a = true;
}
if (rrset->getType() == RRType::AAAA()) {
has_aaaa = true;
}
if (rrset->getType() == RRType::NS()) {
has_ns = true;
}
if (rrset->getType() == RRType::SOA()) {
has_soa = true;
}
if (rrset->getType() == RRType::CNAME()) {
has_cname = true;
}
++i;
}
EXPECT_TRUE(has_a);
EXPECT_TRUE(has_aaaa);
EXPECT_TRUE(has_ns);
EXPECT_TRUE(has_soa);
EXPECT_TRUE(has_cname);
EXPECT_TRUE(i == 5);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment