[svn] commit: r3745 - in /branches/trac418/src/lib/datasrc: tests/zonetable_unittest.cc zonetable.cc zonetable.h

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Dec 7 11:25:52 UTC 2010


Author: jinmei
Date: Tue Dec  7 11:25:52 2010
New Revision: 3745

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

Modified:
    branches/trac418/src/lib/datasrc/tests/zonetable_unittest.cc
    branches/trac418/src/lib/datasrc/zonetable.cc
    branches/trac418/src/lib/datasrc/zonetable.h

Modified: branches/trac418/src/lib/datasrc/tests/zonetable_unittest.cc
==============================================================================
--- branches/trac418/src/lib/datasrc/tests/zonetable_unittest.cc (original)
+++ branches/trac418/src/lib/datasrc/tests/zonetable_unittest.cc Tue Dec  7 11:25:52 2010
@@ -26,26 +26,28 @@
 
 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 @@
     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 @@
     // 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 @@
 
     // 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());

Modified: branches/trac418/src/lib/datasrc/zonetable.cc
==============================================================================
--- branches/trac418/src/lib/datasrc/zonetable.cc (original)
+++ branches/trac418/src/lib/datasrc/zonetable.cc Tue Dec  7 11:25:52 2010
@@ -28,34 +28,35 @@
 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()));
 }

Modified: branches/trac418/src/lib/datasrc/zonetable.h
==============================================================================
--- branches/trac418/src/lib/datasrc/zonetable.h (original)
+++ branches/trac418/src/lib/datasrc/zonetable.h Tue Dec  7 11:25:52 2010
@@ -29,7 +29,7 @@
 
 /// \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 @@
 /// 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 @@
     ///
     /// 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 @@
     //@}
 };
 
-/// \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 AbstractZone object.
-typedef boost::shared_ptr<const AbstractZone> ConstZonePtr;
+/// \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 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 @@
     /// 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 @@
     ///
     /// \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 @@
                             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 @@
     /// 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;
     };
 
     ///




More information about the bind10-changes mailing list