Kea  2.3.4-git
control_socket.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 
9 
10 #ifndef CONTROL_SOCKET_H
11 #define CONTROL_SOCKET_H
12 
13 #include <exceptions/exceptions.h>
14 #include <netconf/netconf_config.h>
15 
16 namespace isc {
17 namespace netconf {
18 
21 public:
22  ControlSocketError(const char* file, size_t line, const char* what) :
23  isc::Exception(file, line, what) { }
24 }; // ControlSocketError
25 
33 public:
38  ControlSocketBase(CfgControlSocketPtr ctrl_sock) : socket_cfg_(ctrl_sock) {
39  if (!ctrl_sock) {
40  isc_throw(ControlSocketError, "ControlSocket constructor called "
41  "with a null configuration");
42  }
43  }
44 
46  virtual ~ControlSocketBase() = default;
47 
52  return (socket_cfg_->getType());
53  }
54 
58  const std::string getName() const {
59  return (socket_cfg_->getName());
60  }
61 
65  const isc::http::Url getUrl() const {
66  return (socket_cfg_->getUrl());
67  }
68 
76  virtual data::ConstElementPtr configGet(const std::string& service) = 0;
77 
86  virtual data::ConstElementPtr configTest(data::ElementPtr config,
87  const std::string& service) = 0;
88 
97  virtual data::ConstElementPtr configSet(data::ElementPtr config,
98  const std::string& service) = 0;
99 
102 }; // ControlSocketBase
103 
105 using ControlSocketBasePtr = std::shared_ptr<ControlSocketBase>;
106 
113 template <CfgControlSocket::Type TYPE> ControlSocketBasePtr
115  isc_throw(NotImplemented, "not specialized createControlSocket");
116 }
117 
125 
126 } // namespace netconf
127 } // namespace isc
128 
129 #endif // CONTROL_SOCKET_H
Exception thrown when the error during communication.
A generic exception that is thrown when a function is not implemented.
Base class for control socket communication.
ControlSocketBase(CfgControlSocketPtr ctrl_sock)
Constructor.
CfgControlSocket::Type getType() const
Getter which returns the socket type.
boost::shared_ptr< Element > ElementPtr
Definition: data.h:24
const std::string getName() const
Returns the Unix socket name.
virtual const char * what() const
Returns a C-style character string of the cause of the exception.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
ControlSocketBasePtr controlSocketFactory(CfgControlSocketPtr ctrl_sock)
Factory function for control sockets.
Represents an URL.
Definition: url.h:20
A collection of classes for housing and parsing the application configuration necessary for the Netco...
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:27
Type
Defines the list of possible control socket types.
ControlSocketBasePtr createControlSocket(CfgControlSocketPtr ctrl_sock)
Factory template for control sockets.
std::shared_ptr< CfgControlSocket > CfgControlSocketPtr
Defines a pointer for CfgControlSocket instances.
This is a base class for exceptions thrown from the DNS library module.
Defines the logger used by the top-level component of kea-lfc.
const isc::http::Url getUrl() const
Returns the HTTP server URL.
CfgControlSocketPtr socket_cfg_
The control socket configuration.
ControlSocketError(const char *file, size_t line, const char *what)
std::shared_ptr< ControlSocketBase > ControlSocketBasePtr
Type definition for the pointer to the ControlSocketBase.