BIND 10 trac2432, updated. 201672389bfa78c8eb59e122f6f117d1eb0644ed [2432] Add rrset_collection{, _base}.h to libdns++ installed headers

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Jan 1 10:29:35 UTC 2013


The branch, trac2432 has been updated
       via  201672389bfa78c8eb59e122f6f117d1eb0644ed (commit)
       via  fc882313210b117eeec371b33796a54a4094c1d3 (commit)
       via  82d0b7f2ab2fcca6daafdcd5aae06cc0efcd2ffd (commit)
       via  2205f81d523ba1175614c6a7ee54904b74ea1a43 (commit)
       via  a9c8b8f3cd7ae57265efd4e01c51cbb4526c038f (commit)
      from  12b24545cb9aeb86229694cda68c71577587f125 (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 201672389bfa78c8eb59e122f6f117d1eb0644ed
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Jan 1 15:57:40 2013 +0530

    [2432] Add rrset_collection{,_base}.h to libdns++ installed headers

commit fc882313210b117eeec371b33796a54a4094c1d3
Author: JINMEI Tatuya <jinmei at isc.org>
Date:   Mon Dec 31 19:18:56 2012 -0800

    [2432] use EXPECT_TRUE and ==/!= instead of EXPECT_EQ/NE iterators
    
    the latter doesn't always work.

commit 82d0b7f2ab2fcca6daafdcd5aae06cc0efcd2ffd
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Jan 1 15:52:49 2013 +0530

    [2432] Explain ownership of rrset passed to addRRset()

commit 2205f81d523ba1175614c6a7ee54904b74ea1a43
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Jan 1 15:48:46 2013 +0530

    [2432] Add virtual destructor

commit a9c8b8f3cd7ae57265efd4e01c51cbb4526c038f
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Jan 1 15:48:33 2013 +0530

    [2432] Untabify

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

Summary of changes:
 src/lib/dns/Makefile.am                        |    2 ++
 src/lib/dns/rrset_collection.h                 |   15 ++++++++++-----
 src/lib/dns/rrset_collection_base.h            |    5 ++++-
 src/lib/dns/tests/rrset_collection_unittest.cc |   12 ++++++------
 4 files changed, 22 insertions(+), 12 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/dns/Makefile.am b/src/lib/dns/Makefile.am
index 5a44edd..6d8d162 100644
--- a/src/lib/dns/Makefile.am
+++ b/src/lib/dns/Makefile.am
@@ -172,6 +172,8 @@ libdns___include_HEADERS = \
 	rdata.h \
 	rrparamregistry.h \
 	rrset.h \
+	rrset_collection_base.h \
+	rrset_collection.h \
 	rrttl.h \
 	tsigkey.h
 # Purposely not installing these headers:
diff --git a/src/lib/dns/rrset_collection.h b/src/lib/dns/rrset_collection.h
index 9cbf98c..540ef55 100644
--- a/src/lib/dns/rrset_collection.h
+++ b/src/lib/dns/rrset_collection.h
@@ -31,8 +31,7 @@ namespace dns {
 class RRsetCollection : public RRsetCollectionBase {
 public:
     /// \brief Constructor.
-    RRsetCollection()
-    {}
+    RRsetCollection() {}
 
     /// \brief Constructor.
     ///
@@ -47,12 +46,18 @@ public:
     RRsetCollection(const char* filename, const isc::dns::Name& origin,
                     const isc::dns::RRClass& rrclass);
 
+    /// \brief Destructor
+    virtual ~RRsetCollection() {}
+
     /// \brief Add an RRset to the collection.
     ///
     /// Does not do any validation whether \c rrset belongs to a
-    /// particular zone or not. It throws an \c isc::InvalidParameter
-    /// exception if an rrset with the same class, type and name already
-    /// exists.
+    /// particular zone or not. A reference to \c rrset is taken in an
+    /// internally managed \c shared_ptr, so even if the caller's
+    /// \c RRsetPtr is destroyed, the RRset it wrapped is still alive
+    /// and managed by the \c RRsetCollection. It throws an
+    /// \c isc::InvalidParameter exception if an rrset with the same
+    /// class, type and name already exists.
     void addRRset(isc::dns::RRsetPtr rrset);
 
     /// \brief Remove an RRset from the collection.
diff --git a/src/lib/dns/rrset_collection_base.h b/src/lib/dns/rrset_collection_base.h
index 5c4314c..2db50e7 100644
--- a/src/lib/dns/rrset_collection_base.h
+++ b/src/lib/dns/rrset_collection_base.h
@@ -50,9 +50,12 @@ public:
     /// \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 isc::dns::RRClass& rrclass)
         const = 0;
 
+    /// \brief Destructor
+    virtual ~RRsetCollectionBase() {}
+
 protected:
     class Iter; // forward declaration
     typedef boost::shared_ptr<Iter> IterPtr;
diff --git a/src/lib/dns/tests/rrset_collection_unittest.cc b/src/lib/dns/tests/rrset_collection_unittest.cc
index c7b6636..5452189 100644
--- a/src/lib/dns/tests/rrset_collection_unittest.cc
+++ b/src/lib/dns/tests/rrset_collection_unittest.cc
@@ -129,7 +129,7 @@ doAddAndRemove(RRsetCollection& collection, const RRClass& rrclass) {
     EXPECT_EQ(Name("foo.example.org"), rrset_found->getName());
 
     // The collection must not be empty.
-    EXPECT_NE(collection.end(), collection.begin());
+    EXPECT_TRUE(collection.end() != collection.begin());
 
     // Adding a duplicate RRset must throw.
     EXPECT_THROW({
@@ -153,18 +153,18 @@ TEST_F(RRsetCollectionTest, empty) {
     RRsetCollection cln;
 
     // Here, cln is empty.
-    EXPECT_EQ(cln.end(), cln.begin());
+    EXPECT_TRUE(cln.end() == cln.begin());
 
     doAddAndRemove(cln, rrclass);
 
     // cln should be empty again here, after the add and remove
     // operations.
-    EXPECT_EQ(cln.end(), cln.begin());
+    EXPECT_TRUE(cln.end() == cln.begin());
 }
 
 TEST_F(RRsetCollectionTest, iteratorTest) {
     // The collection must not be empty.
-    EXPECT_NE(collection.end(), collection.begin());
+    EXPECT_TRUE(collection.end() != collection.begin());
 
     // Here, we just count the records and do some basic tests on them.
     size_t count = 0;
@@ -249,8 +249,8 @@ TEST_F(RRsetCollectionTest, iteratorCompareDifferent) {
 
     // Comparing two iterators from different RRsetCollectionBase
     // implementations must not throw.
-    EXPECT_NE(cln2.begin(), cln1.begin());
-    EXPECT_NE(cln1.end(), cln2.end());
+    EXPECT_TRUE(cln2.begin() != cln1.begin());
+    EXPECT_TRUE(cln1.end() != cln2.end());
 }
 
 } // namespace



More information about the bind10-changes mailing list