blob: 18fbdbd0feb428a170657d2b0f53abb8cf827577 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
// Copyright (C) 2019-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/.
#include <config.h>
#include <database/server_selector.h>
#include <exceptions/exceptions.h>
using namespace isc::data;
namespace isc {
namespace db {
ServerSelector
ServerSelector::MULTIPLE(const std::set<std::string>& server_tags) {
if (server_tags.empty()) {
isc_throw(InvalidOperation, "ServerSelector: expecting at least one"
" server tag");
}
std::set<ServerTag> tags;
// Create a set of tags from strings.
for (auto tag : server_tags) {
tags.insert(ServerTag(tag));
}
ServerSelector selector(tags);
return (selector);
}
ServerSelector::ServerSelector(const Type& type)
: type_(type), tags_() {
if (type_ == Type::ALL) {
tags_.insert(ServerTag());
}
}
ServerSelector::ServerSelector(const ServerTag& server_tag)
: type_(server_tag.amAll() ? Type::ALL : Type::SUBSET), tags_({server_tag}) {
}
ServerSelector::ServerSelector(const std::set<ServerTag>& server_tags)
: type_(Type::SUBSET), tags_(server_tags) {
}
} // end of namespace isc::db
} // end of namespace isc
|