Commit a270e042 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner Committed by JINMEI Tatuya
Browse files

[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.
parent 0a23277c
......@@ -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
......
......@@ -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 {
......
......@@ -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.
......
......@@ -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
......
......@@ -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:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment