Kea  2.5.2
backend_selector.h
Go to the documentation of this file.
1 // Copyright (C) 2018-2022 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 
15 namespace isc {
16 namespace db {
17 
56 public:
57 
62  enum class Type {
63  MYSQL,
64  POSTGRESQL,
65  UNSPEC
66  };
67 
73  explicit BackendSelector();
74 
78  explicit BackendSelector(const Type& backend_type);
79 
87  explicit BackendSelector(const std::string& host, const uint16_t port = 0);
88 
136  explicit BackendSelector(const data::ConstElementPtr& access_map);
137 
139  static const BackendSelector& UNSPEC();
140 
145  bool amUnspecified() const;
146 
149  return (backend_type_);
150  }
151 
156  std::string getBackendHost() const {
157  return (host_);
158  }
159 
164  uint16_t getBackendPort() const {
165  return (port_);
166  }
167 
172  std::string toText() const;
173 
180  virtual data::ElementPtr toElement() const;
181 
185  static Type stringToBackendType(const std::string& type);
186 
190  static std::string backendTypeToString(const Type& type);
191 
192 private:
193 
199  void validate() const;
200 
202  Type backend_type_;
203 
205  std::string host_;
206 
208  uint16_t port_;
209 };
210 
211 
212 } // end of namespace isc::db
213 } // end of namespace isc
214 
215 #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:29
boost::shared_ptr< Element > ElementPtr
Definition: data.h:26
Defines the logger used by the top-level component of kea-lfc.
Abstract class for configuration Cfg_* classes.