| Kea 3.0.2-git

server_selector.h
Go to the documentation of this file.
1// Copyright (C) 2018-2019,2021 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#ifndef SERVER_SELECTOR_H
8#define SERVER_SELECTOR_H
9
10#include <cc/server_tag.h>
11#include <set>
12#include <string>
13
14 namespace isc {
15 namespace db {
16
46 class ServerSelector {
47 public:
48
50 enum class Type {
51 UNASSIGNED,
52 ALL,
53 SUBSET,
54 ANY
55 };
56
58 static ServerSelector UNASSIGNED() {
59 ServerSelector selector(Type::UNASSIGNED);
60 return (selector);
61 }
62
64 static ServerSelector ALL() {
65 ServerSelector selector(Type::ALL);
66 return (selector);
67 }
68
72 static ServerSelector ONE(const std::string& server_tag) {
73 ServerSelector selector((data::ServerTag(server_tag)));
74 return (selector);
75 }
76
81 static ServerSelector MULTIPLE(const std::set<std::string>& server_tags);
82
84 static ServerSelector ANY() {
85 ServerSelector selector(Type::ANY);
86 return (selector);
87 }
88
90 Type getType() const {
91 return (type_);
92 }
93
98 std::set<data::ServerTag> getTags() const {
99 return (tags_);
100 }
101
105 bool hasNoTags() const {
106 return (tags_.empty());
107 }
108
112 bool amUnassigned() const {
113 return (getType() == Type::UNASSIGNED);
114 }
115
119 bool amAll() const {
120 return (getType() == Type::ALL);
121 }
122
126 bool amAny() const {
127 return (getType() == Type::ANY);
128 }
129
133 bool hasMultipleTags() const {
134 return (tags_.size() > 1);
135 }
136
137 private:
138
142 explicit ServerSelector(const Type& type);
143
147 explicit ServerSelector(const data::ServerTag& server_tag);
148
152 explicit ServerSelector(const std::set<data::ServerTag>& server_tags);
153
155 Type type_;
156
158 std::set<data::ServerTag> tags_;
159};
160
161
162} // end of namespace isc::db
163} // end of namespace isc
164
165#endif
isc::data::ServerTag
Represents a server tag.
Definition server_tag.h:25
isc::db::ServerSelector
Server selector for associating objects in a database with specific servers.
Definition server_selector.h:46
isc::db::ServerSelector::getTags
std::set< data::ServerTag > getTags() const
Returns tags associated with the selector.
Definition server_selector.h:98
isc::db::ServerSelector::hasNoTags
bool hasNoTags() const
Convenience method checking if the server selector has no tags.
Definition server_selector.h:105
isc::db::ServerSelector::MULTIPLE
static ServerSelector MULTIPLE(const std::set< std::string > &server_tags)
Factory returning "multiple servers" selector.
Definition server_selector.cc:18
isc::db::ServerSelector::amUnassigned
bool amUnassigned() const
Convenience method checking if the server selector is "unassigned".
Definition server_selector.h:112
isc::db::ServerSelector::ANY
static ServerSelector ANY()
Factory returning "any server" selector.
Definition server_selector.h:84
isc::db::ServerSelector::ALL
static ServerSelector ALL()
Factory returning "all servers" selector.
Definition server_selector.h:64
isc::db::ServerSelector::hasMultipleTags
bool hasMultipleTags() const
Convenience method checking if the server selector has multiple tags.
Definition server_selector.h:133
isc::db::ServerSelector::ONE
static ServerSelector ONE(const std::string &server_tag)
Factory returning selector of one server.
Definition server_selector.h:72
isc::db::ServerSelector::Type
Type
Type of the server selection.
Definition server_selector.h:50
isc::db::ServerSelector::Type::UNASSIGNED
@ UNASSIGNED
Definition server_selector.h:51
isc::db::ServerSelector::Type::ALL
@ ALL
Definition server_selector.h:52
isc::db::ServerSelector::Type::ANY
@ ANY
Definition server_selector.h:54
isc::db::ServerSelector::Type::SUBSET
@ SUBSET
Definition server_selector.h:53
isc::db::ServerSelector::amAll
bool amAll() const
Convenience method checking if the server selector is "all".
Definition server_selector.h:119
isc::db::ServerSelector::amAny
bool amAny() const
Convenience method checking if the server selector is "any".
Definition server_selector.h:126
isc::db::ServerSelector::getType
Type getType() const
Returns type of the selector.
Definition server_selector.h:90
isc::db::ServerSelector::UNASSIGNED
static ServerSelector UNASSIGNED()
Factory returning "unassigned" server selector.
Definition server_selector.h:58
isc::db
Definition audit_entry.cc:14
isc
Defines the logger used by the top-level component of kea-lfc.
Definition agent_parser.cc:148
server_tag.h