From: Michal 'vorner' Vaner Date: Sun, 7 Oct 2012 14:38:23 +0000 (+0200) Subject: [2292] Remove mutable find methods X-Git-Tag: trac2351_base~1^2~9^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e1b4bf1cb50160c436f2e5440fd774680b91b7a2;p=thirdparty%2Fkea.git [2292] Remove mutable find methods They are currently used in test code only (so we'll need to update the tests to compile). The real code seams clean now. --- diff --git a/src/lib/datasrc/memory/domaintree.h b/src/lib/datasrc/memory/domaintree.h index e54d8eaaed..50f5d40cf6 100644 --- a/src/lib/datasrc/memory/domaintree.h +++ b/src/lib/datasrc/memory/domaintree.h @@ -1080,17 +1080,6 @@ public: /// of it. In that case, node parameter is left intact. //@{ - /// \brief Simple find. - /// - /// Acts as described in the \ref find section. - Result find(const isc::dns::Name& name, - DomainTreeNode** node) const { - DomainTreeNodeChain > node_path; - const isc::dns::LabelSequence ls(name); - return (find >(ls, node, node_path, NULL, - NULL)); - } - /// \brief Simple find returning immutable node. /// /// Acts as described in the \ref find section, but returns immutable node @@ -1109,17 +1098,6 @@ public: return (ret); } - /// \brief Simple find, with node_path tracking - /// - /// Acts as described in the \ref find section. - Result find(const isc::dns::Name& name, DomainTreeNode** node, - DomainTreeNodeChain& node_path) const - { - const isc::dns::LabelSequence ls(name); - return (find >(ls, node, node_path, - NULL, NULL)); - } - /// \brief Simple find returning immutable node, with node_path tracking /// /// Acts as described in the \ref find section, but returns immutable node @@ -1138,27 +1116,6 @@ public: return (ret); } - /// \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::Name& name, - const DomainTreeNode** node, - DomainTreeNodeChain& node_path, - bool (*callback)(const DomainTreeNode&, CBARG), - CBARG callback_arg) const - { - const DomainTreeNode* target_node = NULL; - const isc::dns::LabelSequence ls(name); - Result ret = find(ls, &target_node, node_path, callback, - callback_arg); - if (ret != NOTFOUND) { - *node = target_node; - } - return (ret); - } - /// \brief Find with callback and node chain /// \anchor callback /// @@ -1235,7 +1192,7 @@ public: /// \c true, it returns immediately with the current node. template Result find(const isc::dns::LabelSequence& target_labels_orig, - NodeType** node, + const NodeType** node, DomainTreeNodeChain& node_path, bool (*callback)(const DomainTreeNode&, CBARG), CBARG callback_arg) const; @@ -1523,7 +1480,7 @@ template template typename DomainTree::Result DomainTree::find(const isc::dns::LabelSequence& target_labels_orig, - NodeType** target, + const NodeType** target, DomainTreeNodeChain& node_path, bool (*callback)(const DomainTreeNode&, CBARG), CBARG callback_arg) const diff --git a/src/lib/datasrc/memory/memory_client.cc b/src/lib/datasrc/memory/memory_client.cc index 5eaf58b547..de953ca107 100644 --- a/src/lib/datasrc/memory/memory_client.cc +++ b/src/lib/datasrc/memory/memory_client.cc @@ -725,7 +725,7 @@ InMemoryClient::load(const isc::dns::Name& zone_name, const std::string InMemoryClient::getFileName(const isc::dns::Name& zone_name) const { - FileNameNode* node(NULL); + const FileNameNode* node(NULL); FileNameTree::Result result = impl_->file_name_tree_->find(zone_name, &node); if (result == FileNameTree::EXACTMATCH) { @@ -735,24 +735,6 @@ InMemoryClient::getFileName(const isc::dns::Name& zone_name) const { } } -result::Result -InMemoryClient::add(const isc::dns::Name& zone_name, - const ConstRRsetPtr& rrset) -{ - const ZoneTable::FindResult result = - impl_->zone_table_->findZone(zone_name); - if (result.code != result::SUCCESS) { - isc_throw(DataSourceError, "No such zone: " + zone_name.toText()); - } - - const ConstRRsetPtr sig_rrset = - rrset ? rrset->getRRsig() : ConstRRsetPtr(); - impl_->add(rrset, sig_rrset, zone_name, *result.zone_data); - - // add() doesn't allow duplicate add, so we always return SUCCESS. - return (result::SUCCESS); -} - namespace { class MemoryIterator : public ZoneIterator { diff --git a/src/lib/datasrc/memory/memory_client.h b/src/lib/datasrc/memory/memory_client.h index 330d62e15f..c37ad53c0b 100644 --- a/src/lib/datasrc/memory/memory_client.h +++ b/src/lib/datasrc/memory/memory_client.h @@ -139,35 +139,6 @@ public: /// zone from a file before. const std::string getFileName(const isc::dns::Name& zone_name) const; - /// \brief Inserts an rrset into the zone. - /// - /// It puts another RRset into the zone. - /// - /// In the current implementation, this method doesn't allow an existing - /// RRset to be updated or overridden. So the caller must make sure that - /// all RRs of the same type and name must be given in the form of a - /// single RRset. The current implementation will also require that - /// when an RRSIG is added, the RRset to be covered has already been - /// added. These restrictions are probably too strict when this data - /// source accepts various forms of input, so they should be revisited - /// later. - /// - /// Except for NullRRset and OutOfZone, this method does not guarantee - /// strong exception safety (it is currently not needed, if it is needed - /// in future, it should be implemented). - /// - /// \throw NullRRset \c rrset is a NULL pointer. - /// \throw OutOfZone The owner name of \c rrset is outside of the - /// origin of the zone. - /// \throw AddError Other general errors. - /// \throw Others This method might throw standard allocation exceptions. - /// - /// \param rrset The set to add. - /// \return SUCCESS or EXIST (if an rrset for given name and type already - /// exists). - result::Result add(const isc::dns::Name& zone_name, - const isc::dns::ConstRRsetPtr& rrset); - /// \brief RRset is NULL exception. /// /// This is thrown if the provided RRset parameter is NULL. diff --git a/src/lib/datasrc/memory/zone_table.cc b/src/lib/datasrc/memory/zone_table.cc index 68c73ad712..0e6ed3c4ed 100644 --- a/src/lib/datasrc/memory/zone_table.cc +++ b/src/lib/datasrc/memory/zone_table.cc @@ -98,7 +98,7 @@ ZoneTable::addZone(util::MemorySegment& mem_sgmt, RRClass zone_class, ZoneTable::FindResult ZoneTable::findZone(const Name& name) const { - ZoneTableNode* node(NULL); + const ZoneTableNode* node(NULL); result::Result my_result; // Translate the return codes diff --git a/src/lib/datasrc/memory/zone_table.h b/src/lib/datasrc/memory/zone_table.h index aebd4d0d0f..4f309b7c2e 100644 --- a/src/lib/datasrc/memory/zone_table.h +++ b/src/lib/datasrc/memory/zone_table.h @@ -82,11 +82,11 @@ public: /// \brief Result data of findZone() method. struct FindResult { FindResult(result::Result param_code, - ZoneData* param_zone_data) : + const ZoneData* param_zone_data) : code(param_code), zone_data(param_zone_data) {} const result::Result code; - ZoneData* const zone_data; + const ZoneData* const zone_data; }; private: