Kea 2.7.5
server_selector.cc
Go to the documentation of this file.
1// Copyright (C) 2019-2024 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
11
12using namespace isc::data;
13
14namespace isc {
15namespace db {
16
17ServerSelector
18ServerSelector::MULTIPLE(const std::set<std::string>& server_tags) {
19 if (server_tags.empty()) {
20 isc_throw(InvalidOperation, "ServerSelector: expecting at least one"
21 " server tag");
22 }
23
24 std::set<ServerTag> tags;
25
26 // Create a set of tags from strings.
27 for (auto const& tag : server_tags) {
28 tags.insert(ServerTag(tag));
29 }
30
31 ServerSelector selector(tags);
32 return (selector);
33}
34
35ServerSelector::ServerSelector(const Type& type)
36 : type_(type), tags_() {
37 if (type_ == Type::ALL) {
38 tags_.insert(ServerTag());
39 }
40}
41
42ServerSelector::ServerSelector(const ServerTag& server_tag)
43 : type_(server_tag.amAll() ? Type::ALL : Type::SUBSET), tags_({server_tag}) {
44}
45
46ServerSelector::ServerSelector(const std::set<ServerTag>& server_tags)
47 : type_(Type::SUBSET), tags_(server_tags) {
48}
49
50} // end of namespace isc::db
51} // end of namespace isc
A generic exception that is thrown if a function is called in a prohibited way.
Represents a server tag.
Definition server_tag.h:25
Server selector for associating objects in a database with specific servers.
static ServerSelector MULTIPLE(const std::set< std::string > &server_tags)
Factory returning "multiple servers" selector.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Defines the logger used by the top-level component of kea-lfc.