Kea  1.5.0
backend_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 BACKEND_SELECTOR_H
8 #define BACKEND_SELECTOR_H
9 
10 #include <cc/data.h>
11 #include <cstdint>
12 #include <string>
13 
14 namespace isc {
15 namespace db {
16 
55 public:
56 
61  enum class Type {
62  MYSQL,
63  PGSQL,
64  CQL,
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 
177  static Type stringToBackendType(const std::string& type);
178 
182  static std::string backendTypeToString(const Type& type);
183 
184 
185 private:
186 
192  void validate() const;
193 
195  Type backend_type_;
196 
198  std::string host_;
199 
201  uint16_t port_;
202 };
203 
204 
205 } // end of namespace isc::db
206 } // end of namespace isc
207 
208 #endif
static const BackendSelector & UNSPEC()
Returns instance of the "unspecified" backend selector.
uint16_t getBackendPort() const
Returns port selected.
std::string toText() const
Returns selections as text.
static Type stringToBackendType(const std::string &type)
Converts string to backend type.
static std::string backendTypeToString(const Type &type)
Converts backend type to string.
std::string getBackendHost() const
Returns host selected.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
BackendSelector()
Default constructor.
Defines the logger used by the top-level component of kea-dhcp-ddns.
Type
Supported database types.
Config Backend selector.
Type getBackendType() const
Returns backend type selected.
bool amUnspecified() const
Checks if selector is "unspecified".