Kea 2.7.5
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
14namespace isc {
15namespace db {
16
47public:
48
50 enum class Type {
52 ALL,
53 SUBSET,
54 ANY
55 };
56
60 return (selector);
61 }
62
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
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
137private:
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
Represents a server tag.
Definition server_tag.h:25
Server selector for associating objects in a database with specific servers.
std::set< data::ServerTag > getTags() const
Returns tags associated with the selector.
bool hasNoTags() const
Convenience method checking if the server selector has no tags.
static ServerSelector MULTIPLE(const std::set< std::string > &server_tags)
Factory returning "multiple servers" selector.
bool amUnassigned() const
Convenience method checking if the server selector is "unassigned".
static ServerSelector ANY()
Factory returning "any server" selector.
static ServerSelector ALL()
Factory returning "all servers" selector.
bool hasMultipleTags() const
Convenience method checking if the server selector has multiple tags.
static ServerSelector ONE(const std::string &server_tag)
Factory returning selector of one server.
Type
Type of the server selection.
bool amAll() const
Convenience method checking if the server selector is "all".
bool amAny() const
Convenience method checking if the server selector is "any".
Type getType() const
Returns type of the selector.
static ServerSelector UNASSIGNED()
Factory returning "unassigned" server selector.
Defines the logger used by the top-level component of kea-lfc.