BIND 10 trac2750, updated. 3674f8287a482a77b9bc2f8a0f161ce2dc4e3f9f [2750] Fix indent level

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Aug 26 02:40:55 UTC 2013


The branch, trac2750 has been updated
       via  3674f8287a482a77b9bc2f8a0f161ce2dc4e3f9f (commit)
       via  79c66d327a479ff5d6dca45c17e438a404bc9dec (commit)
      from  9b06e690a16a338fc943fd039d6cee03e5c9ca45 (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 3674f8287a482a77b9bc2f8a0f161ce2dc4e3f9f
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Aug 26 08:10:24 2013 +0530

    [2750] Fix indent level

commit 79c66d327a479ff5d6dca45c17e438a404bc9dec
Author: Mukund Sivaraman <muks at isc.org>
Date:   Mon Aug 26 08:10:16 2013 +0530

    [2750] Add non-const variant of find()

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

Summary of changes:
 src/lib/datasrc/memory/domaintree.h |   99 ++++++++++++++++++++++++++++-------
 1 file changed, 79 insertions(+), 20 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/memory/domaintree.h b/src/lib/datasrc/memory/domaintree.h
index ffba88c..275e227 100644
--- a/src/lib/datasrc/memory/domaintree.h
+++ b/src/lib/datasrc/memory/domaintree.h
@@ -1279,6 +1279,19 @@ public:
         return (ret);
     }
 
+private:
+    /// \brief Static helper function used by const and non-const
+    /// variants of find() below
+    template <typename TT, typename TTN, typename CBARG>
+    static Result findImpl(TT* tree,
+                           const isc::dns::LabelSequence& target_labels_orig,
+                           TTN** target,
+                           TTN* node,
+                           DomainTreeNodeChain<T>& node_path,
+                           bool (*callback)(const DomainTreeNode<T>&, CBARG),
+                           CBARG callback_arg);
+
+public:
     /// \brief Find with callback and node chain
     /// \anchor callback
     ///
@@ -1355,6 +1368,14 @@ public:
     ///     \c true, it returns immediately with the current node.
     template <typename CBARG>
     Result find(const isc::dns::LabelSequence& target_labels_orig,
+                DomainTreeNode<T>** node,
+                DomainTreeNodeChain<T>& node_path,
+                bool (*callback)(const DomainTreeNode<T>&, CBARG),
+                CBARG callback_arg);
+
+    /// \brief Find with callback and node chain (const variant)
+    template <typename CBARG>
+    Result find(const isc::dns::LabelSequence& target_labels_orig,
                 const DomainTreeNode<T>** node,
                 DomainTreeNodeChain<T>& node_path,
                 bool (*callback)(const DomainTreeNode<T>&, CBARG),
@@ -1639,13 +1660,15 @@ DomainTree<T>::deleteHelper(util::MemorySegment& mem_sgmt,
 }
 
 template <typename T>
-template <typename CBARG>
+template <typename TT, typename TTN, typename CBARG>
 typename DomainTree<T>::Result
-DomainTree<T>::find(const isc::dns::LabelSequence& target_labels_orig,
-                    const DomainTreeNode<T>** target,
-                    DomainTreeNodeChain<T>& node_path,
-                    bool (*callback)(const DomainTreeNode<T>&, CBARG),
-                    CBARG callback_arg) const
+DomainTree<T>::findImpl(TT* tree,
+                        const isc::dns::LabelSequence& target_labels_orig,
+                        TTN** target,
+                        TTN* node,
+                        DomainTreeNodeChain<T>& node_path,
+                        bool (*callback)(const DomainTreeNode<T>&, CBARG),
+                        CBARG callback_arg)
 {
     if (node_path.isEmpty() ^ target_labels_orig.isAbsolute()) {
         isc_throw(isc::BadValue,
@@ -1653,17 +1676,6 @@ DomainTree<T>::find(const isc::dns::LabelSequence& target_labels_orig,
                   " and label sequence");
     }
 
-    const DomainTreeNode<T>* node;
-
-    if (!node_path.isEmpty()) {
-        // Get the top node in the node chain
-        node = node_path.top();
-        // Start searching from its down pointer
-        node = node->getDown();
-    } else {
-        node = root_.get();
-    }
-
     Result ret = NOTFOUND;
     dns::LabelSequence target_labels(target_labels_orig);
 
@@ -1674,7 +1686,7 @@ DomainTree<T>::find(const isc::dns::LabelSequence& target_labels_orig,
             node_path.last_comparison_.getRelation();
 
         if (relation == isc::dns::NameComparisonResult::EQUAL) {
-            if (needsReturnEmptyNode_ || !node->isEmpty()) {
+            if (tree->needsReturnEmptyNode_ || !node->isEmpty()) {
                 node_path.push(node);
                 *target = node;
                 ret = EXACTMATCH;
@@ -1687,7 +1699,7 @@ DomainTree<T>::find(const isc::dns::LabelSequence& target_labels_orig,
                 node->getLeft() : node->getRight();
         } else {
             if (relation == isc::dns::NameComparisonResult::SUBDOMAIN) {
-                if (needsReturnEmptyNode_ || !node->isEmpty()) {
+                if (tree->needsReturnEmptyNode_ || !node->isEmpty()) {
                     ret = PARTIALMATCH;
                     *target = node;
                     if (callback != NULL &&
@@ -1711,6 +1723,53 @@ DomainTree<T>::find(const isc::dns::LabelSequence& target_labels_orig,
 }
 
 template <typename T>
+template <typename CBARG>
+typename DomainTree<T>::Result
+DomainTree<T>::find(const isc::dns::LabelSequence& target_labels_orig,
+                    DomainTreeNode<T>** target,
+                    DomainTreeNodeChain<T>& node_path,
+                    bool (*callback)(const DomainTreeNode<T>&, CBARG),
+                    CBARG callback_arg)
+{
+    if (!node_path.isEmpty()) {
+        isc_throw(isc::BadValue,
+                  "DomainTree::find() non-const method is given "
+                  "non-empty node chain");
+    }
+
+    DomainTreeNode<T>* node = root_.get();
+
+    return (findImpl<DomainTree<T>, DomainTreeNode<T>, CBARG >
+            (this, target_labels_orig, target, node, node_path,
+             callback, callback_arg));
+}
+
+template <typename T>
+template <typename CBARG>
+typename DomainTree<T>::Result
+DomainTree<T>::find(const isc::dns::LabelSequence& target_labels_orig,
+                    const DomainTreeNode<T>** target,
+                    DomainTreeNodeChain<T>& node_path,
+                    bool (*callback)(const DomainTreeNode<T>&, CBARG),
+                    CBARG callback_arg) const
+{
+    const DomainTreeNode<T>* node;
+
+    if (!node_path.isEmpty()) {
+        // Get the top node in the node chain
+        node = node_path.top();
+        // Start searching from its down pointer
+        node = node->getDown();
+    } else {
+        node = root_.get();
+    }
+
+    return (findImpl<const DomainTree<T>, const DomainTreeNode<T>, CBARG >
+            (this, target_labels_orig, target, node, node_path,
+             callback, callback_arg));
+}
+
+template <typename T>
 const DomainTreeNode<T>*
 DomainTree<T>::nextNode(DomainTreeNodeChain<T>& node_path) const {
     if (node_path.isEmpty()) {
@@ -1914,7 +1973,7 @@ DomainTree<T>::largestNodeImpl(TT* tree) {
 template <typename T>
 DomainTreeNode<T>*
 DomainTree<T>::largestNode() {
-  return (largestNodeImpl<DomainTree<T>, DomainTreeNode<T> >(this));
+    return (largestNodeImpl<DomainTree<T>, DomainTreeNode<T> >(this));
 }
 
 template <typename T>



More information about the bind10-changes mailing list