BIND 10 trac2435, updated. 4d277fcbe264e299596a2ddc15243c87565f6127 [2435] Move datasrc::RRsetCollection implementation into database.cc

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Jan 10 09:47:13 UTC 2013


The branch, trac2435 has been updated
       via  4d277fcbe264e299596a2ddc15243c87565f6127 (commit)
      from  137cfc9037a103e5c5ec814a798dbc56db6ae835 (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 4d277fcbe264e299596a2ddc15243c87565f6127
Author: Mukund Sivaraman <muks at isc.org>
Date:   Thu Jan 10 14:47:29 2013 +0530

    [2435] Move datasrc::RRsetCollection implementation into database.cc
    
    This is so that it is not directly instantiated, but returned by
    getRRsetCollection() on the updater.

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

Summary of changes:
 src/lib/datasrc/Makefile.am                |    1 -
 src/lib/datasrc/database.cc                |   76 ++++++++++++++++++++++++++-
 src/lib/datasrc/rrset_collection.cc        |   66 -----------------------
 src/lib/datasrc/rrset_collection.h         |   78 ----------------------------
 src/lib/datasrc/tests/database_unittest.cc |    1 -
 5 files changed, 75 insertions(+), 147 deletions(-)
 delete mode 100644 src/lib/datasrc/rrset_collection.cc
 delete mode 100644 src/lib/datasrc/rrset_collection.h

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/Makefile.am b/src/lib/datasrc/Makefile.am
index ea70d92..a4edd4e 100644
--- a/src/lib/datasrc/Makefile.am
+++ b/src/lib/datasrc/Makefile.am
@@ -38,7 +38,6 @@ libb10_datasrc_la_SOURCES += client_list.h client_list.cc
 libb10_datasrc_la_SOURCES += memory_datasrc.h memory_datasrc.cc
 libb10_datasrc_la_SOURCES += master_loader_callbacks.h
 libb10_datasrc_la_SOURCES += master_loader_callbacks.cc
-libb10_datasrc_la_SOURCES += rrset_collection.h rrset_collection.cc
 libb10_datasrc_la_SOURCES += zone_loader.h zone_loader.cc
 nodist_libb10_datasrc_la_SOURCES = datasrc_messages.h datasrc_messages.cc
 libb10_datasrc_la_LDFLAGS = -no-undefined -version-info 1:0:1
diff --git a/src/lib/datasrc/database.cc b/src/lib/datasrc/database.cc
index 12c3f87..8257c21 100644
--- a/src/lib/datasrc/database.cc
+++ b/src/lib/datasrc/database.cc
@@ -31,7 +31,6 @@
 
 #include <datasrc/data_source.h>
 #include <datasrc/logger.h>
-#include <datasrc/rrset_collection.h>
 
 #include <boost/foreach.hpp>
 #include <boost/scoped_ptr.hpp>
@@ -1373,6 +1372,81 @@ DatabaseClient::getIterator(const isc::dns::Name& name,
     return (iterator);
 }
 
+/// \brief datasrc implementation of RRsetCollectionBase.
+class RRsetCollection : public isc::dns::RRsetCollectionBase {
+public:
+    /// \brief Constructor.
+    ///
+    /// No reference (count via \c shared_ptr) to the ZoneUpdater is
+    /// acquired. As long as the collection object is alive, the
+    /// corresponding \c ZoneUpdater should be kept alive.
+    ///
+    /// \param updater The ZoneUpdater to wrap around.
+    /// \param rrclass The RRClass of the records in the zone.
+    RRsetCollection(ZoneUpdater& updater, const isc::dns::RRClass& rrclass) :
+        updater_(updater),
+        rrclass_(rrclass)
+    {}
+
+    /// \brief Destructor
+    virtual ~RRsetCollection() {}
+
+    /// \brief Find a matching RRset in the collection.
+    ///
+    /// Returns the RRset in the collection that exactly matches the
+    /// given \c name, \c rrclass and \c rrtype.  If no matching RRset
+    /// is found, \c NULL is returned.
+    ///
+    /// \throw FindError if find() results in some underlying datasrc error.
+    /// \param name The name of the RRset to search for.
+    /// \param rrclass The class of the RRset to search for.
+    /// \param rrtype The type of the RRset to search for.
+    /// \returns The RRset if found, \c NULL otherwise.
+    virtual isc::dns::ConstRRsetPtr find(const isc::dns::Name& name,
+                                         const isc::dns::RRClass& rrclass,
+                                         const isc::dns::RRType& rrtype) const {
+        if (rrclass != rrclass_) {
+            // We could throw an exception here, but RRsetCollection is
+            // expected to support an arbitrary collection of RRsets,
+            // and it can be queried just as arbitrarily. So we just
+            // return nothing here.
+            return (ConstRRsetPtr());
+        }
+
+        ZoneFinder& finder = updater_.getFinder();
+        try {
+            ZoneFinderContextPtr result =
+                finder.find(name, rrtype,
+                            ZoneFinder::NO_WILDCARD | ZoneFinder::FIND_GLUE_OK);
+            return (result->rrset);
+        } catch (const OutOfZone&) {
+            // As RRsetCollection is an arbitrary set of RRsets, in case
+            // the searched name is out of zone, we return nothing
+            // instead of propagating the exception.
+            return (ConstRRsetPtr());
+        } catch (const DataSourceError& e) {
+            isc_throw(FindError, "ZoneFinder threw a DataSourceError: " <<
+                      e.getMessage().c_str());
+        }
+    }
+
+private:
+    ZoneUpdater& updater_;
+    isc::dns::RRClass rrclass_;
+
+protected:
+    // TODO: RRsetCollectionBase::Iter is not implemented and the
+    // following two methods just throw.
+
+    virtual RRsetCollectionBase::IterPtr getBeginning() {
+        isc_throw(NotImplemented, "This method is not implemented.");
+    }
+
+    virtual RRsetCollectionBase::IterPtr getEnd() {
+        isc_throw(NotImplemented, "This method is not implemented.");
+    }
+};
+
 //
 // Zone updater using some database system as the underlying data source.
 //
diff --git a/src/lib/datasrc/rrset_collection.cc b/src/lib/datasrc/rrset_collection.cc
deleted file mode 100644
index 0651dec..0000000
--- a/src/lib/datasrc/rrset_collection.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#include <datasrc/rrset_collection.h>
-#include <datasrc/zone_loader.h>
-#include <exceptions/exceptions.h>
-
-using namespace isc;
-using namespace isc::dns;
-
-namespace isc {
-namespace datasrc {
-
-ConstRRsetPtr
-RRsetCollection::find(const isc::dns::Name& name,
-                      const isc::dns::RRClass& rrclass,
-                      const isc::dns::RRType& rrtype) const
-{
-    if (rrclass != rrclass_) {
-        // We could throw an exception here, but RRsetCollection is
-        // expected to support an arbitrary collection of RRsets, and it
-        // can be queried just as arbitrarily. So we just return nothing
-        // here.
-        return (ConstRRsetPtr());
-    }
-
-    ZoneFinder& finder = updater_.getFinder();
-    try {
-        ZoneFinderContextPtr result =
-            finder.find(name, rrtype,
-                        ZoneFinder::NO_WILDCARD | ZoneFinder::FIND_GLUE_OK);
-        return (result->rrset);
-    } catch (const OutOfZone&) {
-        // As RRsetCollection is an arbitrary set of RRsets, in case the
-        // searched name is out of zone, we return nothing instead of
-        // propagating the exception.
-        return (ConstRRsetPtr());
-    } catch (const DataSourceError& e) {
-        isc_throw(FindError, "ZoneFinder threw a DataSourceError: " <<
-                  e.getMessage().c_str());
-    }
-}
-
-RRsetCollectionBase::IterPtr
-RRsetCollection::getBeginning() {
-    isc_throw(NotImplemented, "This method is not implemented.");
-}
-
-RRsetCollectionBase::IterPtr
-RRsetCollection::getEnd() {
-    isc_throw(NotImplemented, "This method is not implemented.");
-}
-
-} // end of namespace datasrc
-} // end of namespace isc
diff --git a/src/lib/datasrc/rrset_collection.h b/src/lib/datasrc/rrset_collection.h
deleted file mode 100644
index 0907323..0000000
--- a/src/lib/datasrc/rrset_collection.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
-//
-// Permission to use, copy, modify, and/or distribute this software for any
-// purpose with or without fee is hereby granted, provided that the above
-// copyright notice and this permission notice appear in all copies.
-//
-// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
-// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
-// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
-// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
-// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
-// PERFORMANCE OF THIS SOFTWARE.
-
-#ifndef RRSET_COLLECTION_DATASRC_H
-#define RRSET_COLLECTION_DATASRC_H 1
-
-#include <dns/rrset_collection_base.h>
-#include <dns/rrclass.h>
-#include <datasrc/zone.h>
-
-namespace isc {
-namespace datasrc {
-
-/// \brief datasrc implementation of RRsetCollectionBase.
-class RRsetCollection : public isc::dns::RRsetCollectionBase {
-public:
-    /// \brief Constructor.
-    ///
-    /// No reference (count via \c shared_ptr) to the ZoneUpdater is
-    /// acquired. As long as the collection object is alive, the
-    /// corresponding \c ZoneUpdater should be kept alive.
-    ///
-    /// \param updater The ZoneUpdater to wrap around.
-    /// \param rrclass The RRClass of the records in the zone.
-    RRsetCollection(ZoneUpdater& updater, const isc::dns::RRClass& rrclass) :
-        updater_(updater),
-        rrclass_(rrclass)
-    {}
-
-    /// \brief Destructor
-    virtual ~RRsetCollection() {}
-
-    /// \brief Find a matching RRset in the collection.
-    ///
-    /// Returns the RRset in the collection that exactly matches the
-    /// given \c name, \c rrclass and \c rrtype.  If no matching RRset
-    /// is found, \c NULL is returned.
-    ///
-    /// \throw FindError if find() results in some underlying datasrc error.
-    /// \param name The name of the RRset to search for.
-    /// \param rrclass The class of the RRset to search for.
-    /// \param rrtype The type of the RRset to search for.
-    /// \returns The RRset if found, \c NULL otherwise.
-    virtual isc::dns::ConstRRsetPtr find(const isc::dns::Name& name,
-                                         const isc::dns::RRClass& rrclass,
-                                         const isc::dns::RRType& rrtype) const;
-
-private:
-    ZoneUpdater& updater_;
-    isc::dns::RRClass rrclass_;
-
-protected:
-    // TODO: RRsetCollectionBase::Iter is not implemented and the
-    // following two methods just throw.
-
-    virtual RRsetCollectionBase::IterPtr getBeginning();
-    virtual RRsetCollectionBase::IterPtr getEnd();
-};
-
-} // end of namespace datasrc
-} // end of namespace isc
-
-#endif  // RRSET_COLLECTION_DATASRC_H
-
-// Local Variables:
-// mode: c++
-// End:
diff --git a/src/lib/datasrc/tests/database_unittest.cc b/src/lib/datasrc/tests/database_unittest.cc
index 0c85aea..297fd4c 100644
--- a/src/lib/datasrc/tests/database_unittest.cc
+++ b/src/lib/datasrc/tests/database_unittest.cc
@@ -28,7 +28,6 @@
 #include <datasrc/data_source.h>
 #include <datasrc/iterator.h>
 #include <datasrc/sqlite3_accessor.h>
-#include <datasrc/rrset_collection.h>
 
 #include <testutils/dnsmessage_test.h>
 



More information about the bind10-changes mailing list