]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2107] clearly separated mutable and immutable versions of getNext().
authorJINMEI Tatuya <jinmei@isc.org>
Mon, 27 Aug 2012 21:46:13 +0000 (14:46 -0700)
committerJINMEI Tatuya <jinmei@isc.org>
Mon, 27 Aug 2012 21:46:13 +0000 (14:46 -0700)
and tested for both versions.

src/lib/datasrc/memory/rdataset.h
src/lib/datasrc/memory/tests/rdataset_unittest.cc

index e7c15f6c7358746801d17783a221a18ceb75ad9c..69fb17d0902b81bda439101331a45e68e67add61 100644 (file)
@@ -237,7 +237,11 @@ public:
     /// get the same result by directly calling get() on \c next, it would
     /// help encourage the use of more efficient usage if we provide an
     /// explicit accessor.
-    RdataSet* getNext() const { return (next.get()); }
+    //const RdataSet* getNext() const { return (next.get()); }
+    const RdataSet* getNext() const { return (next.get()); }
+
+    /// \brief Return the bare pointer to the next node, mutable version.
+    RdataSet* getNext() { return (next.get()); }
 
     /// \brief Return the number of RDATAs stored in the \c RdataSet.
     size_t getRdataCount() const { return (rdata_count_); }
index 02f812857670fe0e670b78debad8e67e70314807..07a240cb5554c51e1f349514cbb6200b7c4bfe2a 100644 (file)
@@ -121,13 +121,16 @@ TEST_F(RdataSetTest, getNext) {
                                           ConstRRsetPtr());
 
     // By default, the next pointer should be NULL (already tested in other
-    // test cases), which should be the case with getNext()
+    // test cases), which should be the case with getNext().  We test both
+    // mutable and immutable versions of getNext().
     EXPECT_EQ(static_cast<RdataSet*>(NULL), rdataset->getNext());
+    EXPECT_EQ(static_cast<const RdataSet*>(NULL),
+              static_cast<const RdataSet*>(rdataset)->getNext());
 
     // making a link (it would form an infinite loop, but it doesn't matter
     // in this test), and check the pointer returned by getNext().
     rdataset->next = rdataset;
-    EXPECT_EQ(rdataset, rdataset->getNext());
+    EXPECT_EQ(rdataset, static_cast<const RdataSet*>(rdataset)->getNext());
 
     RdataSet::destroy(mem_sgmt_, RRClass::IN(), rdataset);
 }