Kea 1.5.0
server_selector.h
Go to the documentation of this file.
1// Copyright (C) 2018 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 <set>
11#include <string>
12
13namespace isc {
14namespace db {
15
46public:
47
49 enum class Type {
51 ALL,
52 SUBSET
53 };
54
57 static ServerSelector selector(Type::UNASSIGNED);
58 return (selector);
59 }
60
62 static ServerSelector& ALL() {
63 static ServerSelector selector(Type::ALL);
64 return (selector);
65 }
66
70 static ServerSelector& ONE(const std::string& server_tag) {
71 static ServerSelector selector(server_tag);
72 return (selector);
73 }
74
78 static ServerSelector& MULTIPLE(const std::set<std::string>& server_tags) {
79 static ServerSelector selector(server_tags);
80 return (selector);
81 }
82
84 Type getType() const {
85 return (type_);
86 }
87
92 std::set<std::string> getTags() const {
93 return (tags_);
94 }
95
99 bool amUnassigned() const {
100 return (getType() == Type::UNASSIGNED);
101 }
102
103private:
104
108 explicit ServerSelector(const Type& type)
109 : type_(type), tags_() {
110 }
111
115 explicit ServerSelector(const std::string& server_tag)
116 : type_(Type::SUBSET), tags_() {
117 tags_.insert(server_tag);
118 }
119
123 explicit ServerSelector(const std::set<std::string>& server_tags)
124 : type_(Type::SUBSET), tags_(server_tags) {
125 }
126
128 Type type_;
129
131 std::set<std::string> tags_;
132};
133
134
135} // end of namespace isc::db
136} // end of namespace isc
137
138#endif
Server selector for associating objects in a database with specific servers.
bool amUnassigned() const
Convenience method checking if the server selector is "unassigned".
static ServerSelector & MULTIPLE(const std::set< std::string > &server_tags)
Factory returning "multiple servers" selector.
Type
Type of the server selection.
static ServerSelector & ONE(const std::string &server_tag)
Factory returning selector of one server.
static ServerSelector & ALL()
Factory returning "all servers" selector.
std::set< std::string > getTags() const
Returns tags associated with the selector.
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-dhcp-ddns.