Kea  1.9.9-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 
47 public:
48 
50  enum class Type {
51  UNASSIGNED,
52  ALL,
53  SUBSET,
54  ANY
55  };
56 
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
Type
Type of the server selection.
static ServerSelector ONE(const std::string &server_tag)
Factory returning selector of one server.
bool amAny() const
Convenience method checking if the server selector is "any".
Type getType() const
Returns type of the selector.
bool amUnassigned() const
Convenience method checking if the server selector is "unassigned".
Represents a server tag.
Definition: server_tag.h:25
bool amAll() const
Convenience method checking if the server selector is "all".
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.
static ServerSelector ANY()
Factory returning "any server" selector.
Defines the logger used by the top-level component of kea-dhcp-ddns.
bool hasNoTags() const
Convenience method checking if the server selector has no tags.
static ServerSelector UNASSIGNED()
Factory returning "unassigned" server selector.
static ServerSelector ALL()
Factory returning "all servers" selector.
bool hasMultipleTags() const
Convenience method checking if the server selector has multiple tags.
std::set< data::ServerTag > getTags() const
Returns tags associated with the selector.