Commit dd444334 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2432] Remove RRsetCollection::find() that returns an AbstractRRset

Instead, make the one that returns ConstRRsetPtr virtual.
parent 5d3af5f8
......@@ -74,17 +74,6 @@ RRsetCollection::RRsetCollection(std::istream& input_stream, const Name& origin,
constructHelper<std::istream&>(input_stream, origin, rrclass);
}
const AbstractRRset*
RRsetCollection::find(const Name& name, const RRType& rrtype,
const RRClass& rrclass) const {
const CollectionKey key(rrclass, rrtype, name);
CollectionMap::const_iterator it = rrsets_.find(key);
if (it != rrsets_.end()) {
return (&(*it->second));
}
return (NULL);
}
RRsetPtr
RRsetCollection::find(const Name& name, const RRClass& rrclass,
const RRType& rrtype) {
......
......@@ -97,32 +97,25 @@ public:
/// \brief Find a matching RRset in the collection.
///
/// Returns the RRset in the collection that exactly matches the
/// given \c name and \c rrtype. If no matching RRset is found,
/// \c NULL is returned.
/// given \c name, \c rrclass and \c rrtype. If no matching RRset
/// is found, \c NULL is returned.
///
/// \param name The name of the RRset to search for.
/// \param rrtype The type of the RRset to search for.
/// \param rrclass The class of the RRset to search for.
/// \returns A pointer to the RRset if found, \c NULL otherwise.
virtual const isc::dns::AbstractRRset* find
(const isc::dns::Name& name, const isc::dns::RRType& rrtype,
const isc::dns::RRClass& rrclass)
const;
/// \param rrtype The type of the RRset to search for.
/// \returns The RRset if found, \c NULL otherwise.
virtual isc::dns::ConstRRsetPtr find(const isc::dns::Name& name,
const isc::dns::RRClass& rrclass,
const isc::dns::RRType& rrtype) const;
/// \brief Find a matching RRset in the collection.
/// \brief Find a matching RRset in the collection (non-const
/// variant).
///
/// See above for a description of the method and arguments.
isc::dns::RRsetPtr find(const isc::dns::Name& name,
const isc::dns::RRClass& rrclass,
const isc::dns::RRType& rrtype);
/// \brief Find a matching RRset in the collection (const variant).
///
/// See above for a description of the method and arguments.
isc::dns::ConstRRsetPtr find(const isc::dns::Name& name,
const isc::dns::RRClass& rrclass,
const isc::dns::RRType& rrtype) const;
private:
template<typename T>
void constructHelper(T source, const isc::dns::Name& origin,
......
......@@ -41,16 +41,16 @@ public:
/// \brief Find a matching RRset in the collection.
///
/// Returns the RRset in the collection that exactly matches the
/// given \c name and \c rrtype. If no matching RRset is found,
/// \c NULL is returned.
/// given \c name, \c rrclass and \c rrtype. If no matching RRset
/// is found, \c NULL is returned.
///
/// \param name The name of the RRset to search for.
/// \param rrtype The type of the RRset to search for.
/// \param rrclass The class of the RRset to search for.
/// \returns A pointer to the RRset if found, \c NULL otherwise.
virtual const isc::dns::AbstractRRset* find
(const isc::dns::Name& name, const isc::dns::RRType& rrtype,
const isc::dns::RRClass& rrclass)
/// \returns The RRset if found, \c NULL otherwise.
virtual isc::dns::ConstRRsetPtr find
(const isc::dns::Name& name, const isc::dns::RRClass& rrclass,
const isc::dns::RRType& rrtype)
const = 0;
/// \brief Destructor
......
......@@ -55,34 +55,6 @@ TEST_F(RRsetCollectionTest, istreamConstructor) {
EXPECT_TRUE(iter2 == collection2.end());
}
TEST_F(RRsetCollectionTest, findBase) {
// Test the find() that returns isc::dns::AbstractRRset*
const AbstractRRset* rrset = collection.find(Name("www.example.org"),
RRType::A(), rrclass);
EXPECT_NE(static_cast<AbstractRRset*>(NULL), rrset);
EXPECT_EQ(RRType::A(), rrset->getType());
EXPECT_EQ(RRTTL(3600), rrset->getTTL());
EXPECT_EQ(RRClass("IN"), rrset->getClass());
EXPECT_EQ(Name("www.example.org"), rrset->getName());
// foo.example.org doesn't exist
rrset = collection.find(Name("foo.example.org"), RRType::A(), rrclass);
EXPECT_EQ(static_cast<AbstractRRset*>(NULL), rrset);
// www.example.org exists, but not with MX
rrset = collection.find(Name("www.example.org"), RRType::MX(), rrclass);
EXPECT_EQ(static_cast<AbstractRRset*>(NULL), rrset);
// www.example.org exists, with AAAA
rrset = collection.find(Name("www.example.org"), RRType::AAAA(), rrclass);
EXPECT_NE(static_cast<AbstractRRset*>(NULL), rrset);
// www.example.org with AAAA does not exist in RRClass::CH()
rrset = collection.find(Name("www.example.org"), RRType::AAAA(),
RRClass::CH());
EXPECT_EQ(static_cast<AbstractRRset*>(NULL), rrset);
}
template <typename T, typename TP>
void doFind(T& collection, const RRClass& rrclass) {
// Test the find() that returns ConstRRsetPtr
......@@ -211,12 +183,10 @@ public:
MyRRsetCollection()
{}
virtual const isc::dns::AbstractRRset* find
(const isc::dns::Name&, const isc::dns::RRType&,
const isc::dns::RRClass&)
const
{
return (NULL);
virtual isc::dns::ConstRRsetPtr find(const isc::dns::Name&,
const isc::dns::RRClass&,
const isc::dns::RRType&) const {
return (ConstRRsetPtr());
}
typedef std::list<isc::dns::RRset> MyCollection;
......
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