Commit b645455b authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

renamed AbstractZone to Zone, Zone to MemoryZone based on review comments.


git-svn-id: svn://bind10.isc.org/svn/bind10/branches/trac418@3745 e5f2f494-b856-4b98-b285-d166d9295462
parent 3524d934
......@@ -26,26 +26,28 @@ using namespace isc::datasrc;
namespace {
TEST(ZoneTest, init) {
Zone zone(RRClass::IN(), Name("example.com"));
MemoryZone zone(RRClass::IN(), Name("example.com"));
EXPECT_EQ(Name("example.com"), zone.getOrigin());
EXPECT_EQ(RRClass::IN(), zone.getClass());
Zone ch_zone(RRClass::CH(), Name("example"));
MemoryZone ch_zone(RRClass::CH(), Name("example"));
EXPECT_EQ(Name("example"), ch_zone.getOrigin());
EXPECT_EQ(RRClass::CH(), ch_zone.getClass());
}
TEST(ZoneTest, find) {
Zone zone(RRClass::IN(), Name("example.com"));
EXPECT_EQ(AbstractZone::NXDOMAIN,
MemoryZone zone(RRClass::IN(), Name("example.com"));
EXPECT_EQ(Zone::NXDOMAIN,
zone.find(Name("www.example.com"), RRType::A()).code);
}
class ZoneTableTest : public ::testing::Test {
protected:
ZoneTableTest() : zone1(new Zone(RRClass::IN(), Name("example.com"))),
zone2(new Zone(RRClass::IN(), Name("example.net"))),
zone3(new Zone(RRClass::IN(), Name("example")))
ZoneTableTest() : zone1(new MemoryZone(RRClass::IN(),
Name("example.com"))),
zone2(new MemoryZone(RRClass::IN(),
Name("example.net"))),
zone3(new MemoryZone(RRClass::IN(), Name("example")))
{}
ZoneTable zone_table;
ZonePtr zone1, zone2, zone3;
......@@ -56,7 +58,7 @@ TEST_F(ZoneTableTest, add) {
EXPECT_EQ(ZoneTable::EXIST, zone_table.add(zone1));
// names are compared in a case insensitive manner.
EXPECT_EQ(ZoneTable::EXIST, zone_table.add(
ZonePtr(new Zone(RRClass::IN(), Name("EXAMPLE.COM")))));
ZonePtr(new MemoryZone(RRClass::IN(), Name("EXAMPLE.COM")))));
EXPECT_EQ(ZoneTable::SUCCESS, zone_table.add(zone2));
EXPECT_EQ(ZoneTable::SUCCESS, zone_table.add(zone3));
......@@ -64,7 +66,8 @@ TEST_F(ZoneTableTest, add) {
// Zone table is indexed only by name. Duplicate origin name with
// different zone class isn't allowed.
EXPECT_EQ(ZoneTable::EXIST, zone_table.add(
ZonePtr(new Zone(RRClass::CH(), Name("example.com")))));
ZonePtr(new MemoryZone(RRClass::CH(),
Name("example.com")))));
/// Bogus zone (NULL)
EXPECT_THROW(zone_table.add(ZonePtr()), isc::InvalidParameter);
......@@ -102,7 +105,7 @@ TEST_F(ZoneTableTest, find) {
// make sure the partial match is indeed the longest match by adding
// a zone with a shorter origin and query again.
ZonePtr zone_com(new Zone(RRClass::IN(), Name("com")));
ZonePtr zone_com(new MemoryZone(RRClass::IN(), Name("com")));
EXPECT_EQ(ZoneTable::SUCCESS, zone_table.add(zone_com));
EXPECT_EQ(Name("example.com"),
zone_table.find(Name("www.example.com")).zone->getOrigin());
......
......@@ -28,34 +28,35 @@ using namespace isc::dns;
namespace isc {
namespace datasrc {
struct Zone::ZoneImpl {
ZoneImpl(const RRClass& zone_class, const Name& origin) :
struct MemoryZone::MemoryZoneImpl {
MemoryZoneImpl(const RRClass& zone_class, const Name& origin) :
zone_class_(zone_class), origin_(origin)
{}
RRClass zone_class_;
Name origin_;
};
Zone::Zone(const RRClass& zone_class, const Name& origin) : impl_(NULL) {
impl_ = new ZoneImpl(zone_class, origin);
MemoryZone::MemoryZone(const RRClass& zone_class, const Name& origin) :
impl_(new MemoryZoneImpl(zone_class, origin))
{
}
Zone::~Zone() {
MemoryZone::~MemoryZone() {
delete impl_;
}
const Name&
Zone::getOrigin() const {
MemoryZone::getOrigin() const {
return (impl_->origin_);
}
const RRClass&
Zone::getClass() const {
MemoryZone::getClass() const {
return (impl_->zone_class_);
}
AbstractZone::FindResult
Zone::find(const Name&, const RRType&) const {
Zone::FindResult
MemoryZone::find(const Name&, const RRType&) const {
// This is a tentative implementation that always returns NXDOMAIN.
return (FindResult(NXDOMAIN, RRsetPtr()));
}
......
......@@ -29,7 +29,7 @@ namespace datasrc {
/// \brief The base class for a single authoritative zone
///
/// The \c AbstractZone class is an abstract base class for representing
/// The \c Zone class is an abstract base class for representing
/// a DNS zone as part of data source.
///
/// At the moment this is provided mainly for making the \c ZoneTable class
......@@ -44,7 +44,12 @@ namespace datasrc {
/// will have more specific features. For example, they will maintain
/// information about the location of a zone file, whether it's loaded in
/// memory, etc.
class AbstractZone {
///
/// <b>Note:</b> Unlike some other abstract base classes we don't name the
/// class beginning with "Abstract". This is because we want to have
/// commonly used definitions such as \c Result and \c ZonePtr, and we want
/// to make them look more intuitive.
class Zone {
public:
/// Result codes of the \c find() method.
///
......@@ -98,10 +103,10 @@ protected:
///
/// This is intentionally defined as \c protected as this base class should
/// never be instantiated (except as part of a derived class).
AbstractZone() {}
Zone() {}
public:
/// The destructor.
virtual ~AbstractZone() {}
virtual ~Zone() {}
//@}
///
......@@ -157,18 +162,18 @@ public:
//@}
};
/// \brief A pointer-like type pointing to a \c AbstractZone object.
typedef boost::shared_ptr<AbstractZone> ZonePtr;
/// \brief A pointer-like type pointing to a \c Zone object.
typedef boost::shared_ptr<Zone> ZonePtr;
/// \brief A pointer-like type pointing to a \c AbstractZone object.
typedef boost::shared_ptr<const AbstractZone> ConstZonePtr;
/// \brief A pointer-like type pointing to a \c Zone object.
typedef boost::shared_ptr<const Zone> ConstZonePtr;
/// A derived zone class intended to be used with the memory data source.
///
/// Currently this is almost empty and is only used for testing the
/// \c ZoneTable class. It will be substantially expanded, and will probably
/// moved to a separate header file.
class Zone : public AbstractZone {
class MemoryZone : public Zone {
///
/// \name Constructors and Destructor.
///
......@@ -177,8 +182,8 @@ class Zone : public AbstractZone {
/// defined as private, making this class non copyable.
//@{
private:
Zone(const Zone& source);
Zone& operator=(const Zone& source);
MemoryZone(const MemoryZone& source);
MemoryZone& operator=(const MemoryZone& source);
public:
/// \brief Constructor from zone parameters.
///
......@@ -188,10 +193,10 @@ public:
///
/// \param rrclass The RR class of the zone.
/// \param origin The origin name of the zone.
Zone(const isc::dns::RRClass& rrclass, const isc::dns::Name& origin);
MemoryZone(const isc::dns::RRClass& rrclass, const isc::dns::Name& origin);
/// The destructor.
virtual ~Zone();
virtual ~MemoryZone();
//@}
virtual const isc::dns::Name& getOrigin() const;
......@@ -200,8 +205,8 @@ public:
const isc::dns::RRType& type) const;
private:
struct ZoneImpl;
ZoneImpl* impl_;
struct MemoryZoneImpl;
MemoryZoneImpl* impl_;
};
/// \brief A set of authoritative zones.
......@@ -274,11 +279,11 @@ public:
/// See the description of \c find() for the semantics of the member
/// variables.
struct FindResult {
FindResult(Result param_code, const AbstractZone* param_zone) :
FindResult(Result param_code, const Zone* param_zone) :
code(param_code), zone(param_zone)
{}
const Result code;
const AbstractZone* const zone;
const Zone* const zone;
};
///
......
Supports Markdown
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