/// Similar to @c add() but with a different purpose.
///
/// @param host Pointer to the new @c Host object being inserted.
- /// @param[in,out] overwrite -1 if accepting conflicts, 0 if removing
- /// conflicting entries, set to the number of removed entries.
- /// @return true when succeeded.
- virtual bool insert(const ConstHostPtr& host, int& overwrite) = 0;
+ /// @param] overwrite false if doing nothing in case of conflicts
+ /// (and returning 1), true if removing conflicting entries
+ /// (and returning their number).
+ /// @return number of conflicts limited to one if overwrite is false.
+ virtual size_t insert(const ConstHostPtr& host, bool overwrite) = 0;
/// @brief Remove a host from the cache.
///
/// Does the same than @c del, @c del4 or @c del6 but with
/// a more uniform interface and a different purpose.
///
+ /// @note A pointer to a copy does not remove the object.
+ ///
/// @param host Pointer to the existing @c Host object being removed.
/// @return true when found and removed.
virtual bool remove(const HostPtr& host) = 0;
return;
}
// Replace any existing value.
- int overwrite = 0;
// Don't check the result as it does not matter?
- cache_ptr_->insert(host, overwrite);
+ cache_ptr_->insert(host, true);
}
}
IOAddress::IPV4_ZERO_ADDRESS()));
host->setNegative(true);
// Don't replace any existing value.
- int overwrite = -1;
// nor matter if it fails.
- cache_ptr_->insert(host, overwrite);
+ cache_ptr_->insert(host, false);
}
}
}
/// Insert
- bool insert(const ConstHostPtr& host, int& overwrite) {
- if (overwrite < 0) {
- ++adds_;
- } else {
+ size_t insert(const ConstHostPtr& host, bool overwrite) {
+ if (overwrite) {
++inserts_;
+ } else {
+ ++adds_;
}
HostPtr host_copy(new Host(*host));
store_.push_back(host_copy);
}
/// Insert throws
- bool insert(const ConstHostPtr& host, int& overwrite) {
+ size_t insert(const ConstHostPtr& host, bool overwrite) {
isc_throw(NotImplemented,
"insert is not implemented: " << host->toText()
<< " with overwrite: " << overwrite);