BIND 10 trac2206, updated. 538a160ef48f7dbe927f75cafc335e470a82db33 [2206] Add const variant of getHeader()

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Oct 3 05:28:45 UTC 2012


The branch, trac2206 has been updated
       via  538a160ef48f7dbe927f75cafc335e470a82db33 (commit)
       via  e45115237b2c8c12f0c2fd3c62ae0aff01248cc9 (commit)
       via  a072ee8db55261a67dc7041c7c17d0536f8def0b (commit)
       via  473e340929d0869bf71d972e1a1843dc81b0fbfa (commit)
       via  94656c03d42d0339c79d10be8ccedaea6da55028 (commit)
      from  a6748eee324ebb4cf4ba99aa225df51d71458c81 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 538a160ef48f7dbe927f75cafc335e470a82db33
Author: Mukund Sivaraman <muks at isc.org>
Date:   Wed Oct 3 10:58:30 2012 +0530

    [2206] Add const variant of getHeader()

commit e45115237b2c8c12f0c2fd3c62ae0aff01248cc9
Author: Mukund Sivaraman <muks at isc.org>
Date:   Wed Oct 3 10:57:59 2012 +0530

    [2206] Fix const variant of getTable()

commit a072ee8db55261a67dc7041c7c17d0536f8def0b
Author: Mukund Sivaraman <muks at isc.org>
Date:   Wed Oct 3 10:57:42 2012 +0530

    [2206] Add const method tests

commit 473e340929d0869bf71d972e1a1843dc81b0fbfa
Author: Mukund Sivaraman <muks at isc.org>
Date:   Wed Oct 3 10:49:54 2012 +0530

    [2206] Update comments

commit 94656c03d42d0339c79d10be8ccedaea6da55028
Author: Mukund Sivaraman <muks at isc.org>
Date:   Wed Oct 3 10:49:01 2012 +0530

    [2206] Make constructors protected

-----------------------------------------------------------------------

Summary of changes:
 src/lib/datasrc/memory/zone_table_segment.h        |   19 +++++++++++++++++--
 src/lib/datasrc/memory/zone_table_segment_local.cc |    5 +++++
 src/lib/datasrc/memory/zone_table_segment_local.h  |   20 ++++++++++++++++++++
 .../tests/memory/zone_table_segment_unittest.cc    |   11 +++++++++++
 4 files changed, 53 insertions(+), 2 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory/zone_table_segment.h b/src/lib/datasrc/memory/zone_table_segment.h
index 8505019..10457f7 100644
--- a/src/lib/datasrc/memory/zone_table_segment.h
+++ b/src/lib/datasrc/memory/zone_table_segment.h
@@ -40,9 +40,9 @@ public:
         return (table.get());
     }
 
-    /// \brief const version of getTable().
+    /// \brief const version of \c getTable().
     const ZoneTable* getTable() const {
-        return (getTable());
+        return (table.get());
     }
 
 private:
@@ -58,6 +58,14 @@ private:
 /// management implementation. Derived classes would implement the
 /// interface for specific memory-implementation behavior.
 class ZoneTableSegment {
+protected:
+    /// \brief Protected constructor
+    ///
+    /// An instance implementing this interface is expected to be
+    /// created by the factory method (\c create()), so this constructor
+    /// is protected.
+    ZoneTableSegment()
+    {}
 public:
     /// \brief Destructor
     virtual ~ZoneTableSegment() {}
@@ -69,6 +77,13 @@ public:
     /// \return Returns the ZoneTableHeader for this zone table segment.
     virtual ZoneTableHeader* getHeader() = 0;
 
+    /// \brief const version of \c getHeader().
+    ///
+    /// NOTE: This method should never return \c NULL.
+    ///
+    /// \return Returns the ZoneTableHeader for this zone table segment.
+    virtual const ZoneTableHeader* getHeader() const = 0;
+
     /// \brief Return the MemorySegment for the zone table segment.
     ///
     /// \return Returns the ZoneTableHeader for this zone table segment.
diff --git a/src/lib/datasrc/memory/zone_table_segment_local.cc b/src/lib/datasrc/memory/zone_table_segment_local.cc
index 0b24319..80f2606 100644
--- a/src/lib/datasrc/memory/zone_table_segment_local.cc
+++ b/src/lib/datasrc/memory/zone_table_segment_local.cc
@@ -25,6 +25,11 @@ ZoneTableSegmentLocal::getHeader() {
      return (&header_);
 }
 
+const ZoneTableHeader*
+ZoneTableSegmentLocal::getHeader() const {
+     return (&header_);
+}
+
 MemorySegment&
 ZoneTableSegmentLocal::getMemorySegment() {
      return (mem_sgmt_);
diff --git a/src/lib/datasrc/memory/zone_table_segment_local.h b/src/lib/datasrc/memory/zone_table_segment_local.h
index 6d823a7..f0e147e 100644
--- a/src/lib/datasrc/memory/zone_table_segment_local.h
+++ b/src/lib/datasrc/memory/zone_table_segment_local.h
@@ -28,6 +28,17 @@ namespace memory {
 /// MemorySegmentLocal based ZoneTableSegment. Please see the
 /// ZoneTableSegment class documentation for usage.
 class ZoneTableSegmentLocal : public ZoneTableSegment {
+    // This is so that ZoneTableSegmentLocal can be instantiated from
+    // ZoneTableSegment::create().
+    friend class ZoneTableSegment;
+protected:
+    /// \brief Protected constructor
+    ///
+    /// Instances are expected to be created by the factory method
+    /// (\c ZoneTableSegment::create()), so this constructor is
+    /// protected.
+    ZoneTableSegmentLocal()
+    {}
 public:
     /// \brief Destructor
     virtual ~ZoneTableSegmentLocal() {}
@@ -35,9 +46,18 @@ public:
     /// \brief Return the ZoneTableHeader for the local zone table
     /// segment implementation.
     ///
+    /// NOTE: This method will never return \c NULL.
+    ///
     /// \return Returns the ZoneTableHeader for this zone table segment.
     virtual ZoneTableHeader* getHeader();
 
+    /// \brief const version of \c getHeader().
+    ///
+    /// NOTE: This method will never return \c NULL.
+    ///
+    /// \return Returns the ZoneTableHeader for this zone table segment.
+    virtual const ZoneTableHeader* getHeader() const;
+
     /// \brief Return the MemorySegment for the local zone table segment
     /// implementation.
     ///
diff --git a/src/lib/datasrc/tests/memory/zone_table_segment_unittest.cc b/src/lib/datasrc/tests/memory/zone_table_segment_unittest.cc
index f023b6b..3dead7a 100644
--- a/src/lib/datasrc/tests/memory/zone_table_segment_unittest.cc
+++ b/src/lib/datasrc/tests/memory/zone_table_segment_unittest.cc
@@ -64,6 +64,17 @@ TEST_F(ZoneTableSegmentTest, getHeader) {
     EXPECT_EQ(static_cast<void*>(NULL), table);
 }
 
+TEST_F(ZoneTableSegmentTest, getHeaderConst) {
+    // getHeader() should never return NULL.
+    const ZoneTableHeader* header =
+         static_cast<const ZoneTableSegment*>(segment_)->getHeader();
+    EXPECT_NE(static_cast<void*>(NULL), header);
+
+    // The zone table is unset.
+    const ZoneTable* table = header->getTable();
+    EXPECT_EQ(static_cast<void*>(NULL), table);
+}
+
 TEST_F(ZoneTableSegmentTest, getMemorySegment) {
     // This doesn't do anything fun except test the API.
     MemorySegment& mem_sgmt = segment_->getMemorySegment();



More information about the bind10-changes mailing list