diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:15:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:15:43 +0000 |
commit | f5f56e1a1c4d9e9496fcb9d81131066a964ccd23 (patch) | |
tree | 49e44c6f87febed37efb953ab5485aa49f6481a7 /src/lib/dhcpsrv/cache_host_data_source.h | |
parent | Initial commit. (diff) | |
download | isc-kea-f5f56e1a1c4d9e9496fcb9d81131066a964ccd23.tar.xz isc-kea-f5f56e1a1c4d9e9496fcb9d81131066a964ccd23.zip |
Adding upstream version 2.4.1.upstream/2.4.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/lib/dhcpsrv/cache_host_data_source.h')
-rw-r--r-- | src/lib/dhcpsrv/cache_host_data_source.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/lib/dhcpsrv/cache_host_data_source.h b/src/lib/dhcpsrv/cache_host_data_source.h new file mode 100644 index 0000000..a0a32cc --- /dev/null +++ b/src/lib/dhcpsrv/cache_host_data_source.h @@ -0,0 +1,68 @@ +// Copyright (C) 2018-2020 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef CACHE_HOST_DATA_SOURCE_H +#define CACHE_HOST_DATA_SOURCE_H + +#include <dhcpsrv/base_host_data_source.h> + +namespace isc { +namespace dhcp { + +/// @brief Abstract interface extending base simple data source for host +/// reservations to host cache. +/// Only the insert() method is required to use the cache. +class CacheHostDataSource : public virtual BaseHostDataSource { +public: + + /// @brief Default destructor implementation. + virtual ~CacheHostDataSource() { } + + /// @brief Insert a host into the cache. + /// + /// Similar to @c add() but with a different purpose. + /// + /// @param host Pointer to the new @c Host object being inserted. + /// @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 as @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; + + /// @brief Flush entries. + /// + /// @param count number of entries to remove, 0 means all. + virtual void flush(size_t count) = 0; + + /// @brief Return the number of entries. + /// + /// @return the current number of active entries in the cache. + virtual size_t size() const = 0; + + /// @brief Return the maximum number of entries. + /// + /// @return the maximum number of entries, 0 means unbound. + virtual size_t capacity() const = 0; +}; + +/// @brief CacheHostDataSource pointer. +typedef boost::shared_ptr<CacheHostDataSource> CacheHostDataSourcePtr; + +} // end of namespace isc::dhcp +} // end of namespace isc + +#endif // CACHE_HOST_DATA_SOURCE_H |