diff --git a/src/lib/datasrc/memory/domaintree.h b/src/lib/datasrc/memory/domaintree.h index 50f5d40cf6..5101c65635 100644 --- a/src/lib/datasrc/memory/domaintree.h +++ b/src/lib/datasrc/memory/domaintree.h @@ -684,7 +684,7 @@ DomainTreeNode::predecessor() const { /// DomainTree. /// This is the reason why manipulation methods such as \c push() and \c pop() /// are private (and not shown in the doxygen document). -template > +template class DomainTreeNodeChain { /// DomainTreeNodeChain is initialized by DomainTree, only DomainTree has /// knowledge to manipulate it. @@ -817,7 +817,7 @@ private: /// root node of DomainTree /// /// \exception None - NodeType* top() const { + const DomainTreeNode* top() const { assert(!isEmpty()); return (nodes_[level_count_ - 1]); } @@ -840,7 +840,7 @@ private: /// otherwise the node should be the root node of DomainTree. /// /// \exception None - void push(NodeType* node) { + void push(const DomainTreeNode* node) { assert(level_count_ < RBT_MAX_LEVEL); nodes_[level_count_++] = node; } @@ -852,7 +852,7 @@ private: const static int RBT_MAX_LEVEL = isc::dns::Name::MAX_LABELS; size_t level_count_; - NodeType* nodes_[RBT_MAX_LEVEL]; + const DomainTreeNode* nodes_[RBT_MAX_LEVEL]; const DomainTreeNode* last_compared_; isc::dns::NameComparisonResult last_comparison_; }; @@ -1080,39 +1080,25 @@ public: /// of it. In that case, node parameter is left intact. //@{ - /// \brief Simple find returning immutable node. + /// \brief Simple find /// - /// Acts as described in the \ref find section, but returns immutable node - /// pointer. + /// Acts as described in the \ref find section. Result find(const isc::dns::Name& name, const DomainTreeNode** node) const { DomainTreeNodeChain node_path; - const DomainTreeNode *target_node = NULL; const isc::dns::LabelSequence ls(name); - Result ret = (find >(ls, &target_node, - node_path, NULL, - NULL)); - if (ret != NOTFOUND) { - *node = target_node; - } + Result ret = (find(ls, node, node_path, NULL, NULL)); return (ret); } - /// \brief Simple find returning immutable node, with node_path tracking + /// \brief Simple find, with node_path tracking /// - /// Acts as described in the \ref find section, but returns immutable node - /// pointer. + /// Acts as described in the \ref find section. Result find(const isc::dns::Name& name, const DomainTreeNode** node, DomainTreeNodeChain& node_path) const { - const DomainTreeNode *target_node = NULL; const isc::dns::LabelSequence ls(name); - Result ret = (find >(ls, &target_node, - node_path, NULL, - NULL)); - if (ret != NOTFOUND) { - *node = target_node; - } + Result ret = (find(ls, node, node_path, NULL, NULL)); return (ret); } @@ -1190,34 +1176,12 @@ public: /// /// \return As in the description, but in case of callback returning /// \c true, it returns immediately with the current node. - template - Result find(const isc::dns::LabelSequence& target_labels_orig, - const NodeType** node, - DomainTreeNodeChain& node_path, - bool (*callback)(const DomainTreeNode&, CBARG), - CBARG callback_arg) const; - - /// \brief Simple find returning immutable node. - /// - /// Acts as described in the \ref find section, but returns immutable - /// node pointer. template - Result find(const isc::dns::LabelSequence& target_labels, + Result find(const isc::dns::LabelSequence& target_labels_orig, const DomainTreeNode** node, DomainTreeNodeChain& node_path, bool (*callback)(const DomainTreeNode&, CBARG), - CBARG callback_arg) const - { - const DomainTreeNode* target_node = NULL; - Result ret = find >(target_labels, - &target_node, - node_path, callback, - callback_arg); - if (ret != NOTFOUND) { - *node = target_node; - } - return (ret); - } + CBARG callback_arg) const; //@} /// \brief return the next bigger node in DNSSEC order from a given node @@ -1477,11 +1441,11 @@ DomainTree::deleteHelper(util::MemorySegment& mem_sgmt, } template -template +template typename DomainTree::Result DomainTree::find(const isc::dns::LabelSequence& target_labels_orig, - const NodeType** target, - DomainTreeNodeChain& node_path, + const DomainTreeNode** target, + DomainTreeNodeChain& node_path, bool (*callback)(const DomainTreeNode&, CBARG), CBARG callback_arg) const { @@ -1491,7 +1455,7 @@ DomainTree::find(const isc::dns::LabelSequence& target_labels_orig, " and label sequence"); } - NodeType* node; + const DomainTreeNode* node; if (!node_path.isEmpty()) { // Get the top node in the node chain