From 040eee1aa49b49df4698d83a05af57c220127fd1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 13:36:04 +0200 Subject: Adding upstream version 2.2.0. Signed-off-by: Daniel Baumann --- src/lib/cc/user_context.h | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 src/lib/cc/user_context.h (limited to 'src/lib/cc/user_context.h') diff --git a/src/lib/cc/user_context.h b/src/lib/cc/user_context.h new file mode 100644 index 0000000..2804c7e --- /dev/null +++ b/src/lib/cc/user_context.h @@ -0,0 +1,59 @@ +// Copyright (C) 2017-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 USER_CONTEXT_H +#define USER_CONTEXT_H + +#include +#include + +namespace isc { +namespace data { + +/// @brief Base class for user context +/// +/// Many configuration structures allow attaching and storing arbitrary +/// user data that we call user context. Each of those configuration +/// structures need to derive from this class or include this class +/// to handle user context. +struct UserContext { + /// @brief Returns const pointer to the user context. + data::ConstElementPtr getContext() const { + return (user_context_); + } + + /// @brief Sets user context. + /// @param ctx user context to be stored. + void setContext(const data::ConstElementPtr& ctx) { + user_context_ = ctx; + } + + /// @brief Merge unparse a user_context object. + /// + /// Add user-context to map, but only if defined. Omit if it was not. + /// + /// @param map A pointer to map where the user context will be unparsed. + void contextToElement(data::ElementPtr map) const; + + /// @brief Copy an Element map + /// + /// A previous version of this extracted comments. + /// + /// @param map A pointer to map. + /// @return a copy of map + static data::ElementPtr toElement(data::ConstElementPtr map); + +protected: + + /// @brief Pointer to the user context (may be NULL) + data::ConstElementPtr user_context_; +}; + +} // end of isc::dhcp namespace +} // end of isc namespace + + +#endif // USER_CONTEXT_H -- cgit v1.2.3