]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2292] Remove mutable find methods
authorMichal 'vorner' Vaner <michal.vaner@nic.cz>
Sun, 7 Oct 2012 14:38:23 +0000 (16:38 +0200)
committerMichal 'vorner' Vaner <michal.vaner@nic.cz>
Sun, 7 Oct 2012 14:38:23 +0000 (16:38 +0200)
They are currently used in test code only (so we'll need to update the
tests to compile). The real code seams clean now.

src/lib/datasrc/memory/domaintree.h
src/lib/datasrc/memory/memory_client.cc
src/lib/datasrc/memory/memory_client.h
src/lib/datasrc/memory/zone_table.cc
src/lib/datasrc/memory/zone_table.h

index e54d8eaaed3f8959c820677e2267035a7baa9905..50f5d40cf6a0ecd8cf80e834383573b4a0116d2d 100644 (file)
@@ -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<T>** node) const {
-        DomainTreeNodeChain<T, DomainTreeNode<T> > node_path;
-        const isc::dns::LabelSequence ls(name);
-        return (find<void*, DomainTreeNode<T> >(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<T>** node,
-                DomainTreeNodeChain<T>& node_path) const
-    {
-        const isc::dns::LabelSequence ls(name);
-        return (find<void*, const DomainTreeNode<T> >(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 <typename CBARG>
-    Result find(const isc::dns::Name& name,
-                const DomainTreeNode<T>** node,
-                DomainTreeNodeChain<T>& node_path,
-                bool (*callback)(const DomainTreeNode<T>&, CBARG),
-                CBARG callback_arg) const
-    {
-        const DomainTreeNode<T>* 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 <typename CBARG, typename NodeType>
     Result find(const isc::dns::LabelSequence& target_labels_orig,
-                NodeType** node,
+                const NodeType** node,
                 DomainTreeNodeChain<T, NodeType>& node_path,
                 bool (*callback)(const DomainTreeNode<T>&, CBARG),
                 CBARG callback_arg) const;
@@ -1523,7 +1480,7 @@ template <typename T>
 template <typename CBARG, typename NodeType>
 typename DomainTree<T>::Result
 DomainTree<T>::find(const isc::dns::LabelSequence& target_labels_orig,
-                    NodeType** target,
+                    const NodeType** target,
                     DomainTreeNodeChain<T, NodeType>& node_path,
                     bool (*callback)(const DomainTreeNode<T>&, CBARG),
                     CBARG callback_arg) const
index 5eaf58b547e83b3414f20732e94795a5b1911ef0..de953ca10738114230e5c13cc4e5ed5efd1560d6 100644 (file)
@@ -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 {
index 330d62e15f2539f9a3b8b5ec71dc6828f6660451..c37ad53c0b28dcf04b186ee8f7eec0bd1bc511b7 100644 (file)
@@ -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.
index 68c73ad712bac3dd2ac359a23cd73351e3abef07..0e6ed3c4ed4a4209e0d3d894c48fe9e5c5d69f84 100644 (file)
@@ -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
index aebd4d0d0fb1dffc9e02f969829bc65dc284c061..4f309b7c2ea04b15ff390e1a6894d103dca66211 100644 (file)
@@ -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: