Kea 2.0.2
backend_selector.h
Go to the documentation of this file.
1// Copyright (C) 2018-2019 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 BACKEND_SELECTOR_H
8#define BACKEND_SELECTOR_H
9
10#include <cc/data.h>
11#include <cc/cfg_to_element.h>
12#include <cstdint>
13#include <string>
14
15namespace isc {
16namespace db {
17
56public:
57
62 enum class Type {
63 MYSQL,
64 PGSQL,
65 CQL,
66 UNSPEC
67 };
68
74 explicit BackendSelector();
75
79 explicit BackendSelector(const Type& backend_type);
80
88 explicit BackendSelector(const std::string& host, const uint16_t port = 0);
89
137 explicit BackendSelector(const data::ConstElementPtr& access_map);
138
140 static const BackendSelector& UNSPEC();
141
146 bool amUnspecified() const;
147
150 return (backend_type_);
151 }
152
157 std::string getBackendHost() const {
158 return (host_);
159 }
160
165 uint16_t getBackendPort() const {
166 return (port_);
167 }
168
173 std::string toText() const;
174
181 virtual data::ElementPtr toElement() const;
182
186 static Type stringToBackendType(const std::string& type);
187
191 static std::string backendTypeToString(const Type& type);
192
193private:
194
200 void validate() const;
201
203 Type backend_type_;
204
206 std::string host_;
207
209 uint16_t port_;
210};
211
212
213} // end of namespace isc::db
214} // end of namespace isc
215
216#endif
Config Backend selector.
static std::string backendTypeToString(const Type &type)
Converts backend type to string.
Type getBackendType() const
Returns backend type selected.
std::string toText() const
Returns selections as text.
static Type stringToBackendType(const std::string &type)
Converts string to backend type.
std::string getBackendHost() const
Returns host selected.
uint16_t getBackendPort() const
Returns port selected.
Type
Supported database types.
bool amUnspecified() const
Checks if selector is "unspecified".
virtual data::ElementPtr toElement() const
Unparse a backend selector object.
BackendSelector()
Default constructor.
static const BackendSelector & UNSPEC()
Returns instance of the "unspecified" backend selector.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:27
boost::shared_ptr< Element > ElementPtr
Definition: data.h:24
Defines the logger used by the top-level component of kea-lfc.
Abstract class for configuration Cfg_* classes.