Kea  1.9.9-git
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 
15 namespace isc {
16 namespace db {
17 
56 public:
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 
193 private:
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
static const BackendSelector & UNSPEC()
Returns instance of the "unspecified" backend selector.
static Type stringToBackendType(const std::string &type)
Converts string to backend type.
static std::string backendTypeToString(const Type &type)
Converts backend type to string.
bool amUnspecified() const
Checks if selector is "unspecified".
boost::shared_ptr< Element > ElementPtr
Definition: data.h:20
std::string toText() const
Returns selections as text.
Abstract class for configuration Cfg_* classes.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:23
uint16_t getBackendPort() const
Returns port selected.
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.
virtual data::ElementPtr toElement() const
Unparse a backend selector object.
std::string getBackendHost() const
Returns host selected.