Kea  2.1.7-git
stdout_control_socket.cc
Go to the documentation of this file.
1 // Copyright (C) 2018-2021 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 #include <config.h>
11 
13 #include <cc/command_interpreter.h>
14 
15 using namespace std;
16 using namespace isc::config;
17 using namespace isc::data;
18 
19 namespace isc {
20 namespace netconf {
21 
22 template <> ControlSocketBasePtr
23 createControlSocket<CfgControlSocket::Type::STDOUT>(CfgControlSocketPtr ctrl_sock) {
24  return (StdoutControlSocketPtr(new StdoutControlSocket(ctrl_sock)));
25 }
26 
27 StdoutControlSocket::StdoutControlSocket(CfgControlSocketPtr ctrl_sock)
28  : ControlSocketBase(ctrl_sock), output_(cout) {
29 }
30 
32  ostream& output)
33  : ControlSocketBase(ctrl_sock), output_(output) {
34 }
35 
37 StdoutControlSocket::configGet(const string& /*service*/) {
38  isc_throw(NotImplemented, "No config-get for stdout control socket");
39 }
40 
43  const string& /*service*/) {
44  return (createAnswer());
45 }
46 
49  const string& /*service*/) {
50  prettyPrint(config, output_);
51  output_ << endl;
52  return (createAnswer());
53 }
54 
55 } // namespace netconf
56 } // namespace isc
StdoutControlSocket(CfgControlSocketPtr ctrl_sock)
Constructor.
A generic exception that is thrown when a function is not implemented.
ConstElementPtr createAnswer(const int status_code, const std::string &text, const ConstElementPtr &arg)
boost::shared_ptr< ControlSocketBase > ControlSocketBasePtr
Type definition for the pointer to the ControlSocketBase.
void prettyPrint(ConstElementPtr element, std::ostream &out, unsigned indent, unsigned step)
Pretty prints the data into stream.
Definition: data.cc:1279
Base class for control socket communication.
std::ostream & output_
The output stream (std::cout outside tests).
STL namespace.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
virtual data::ConstElementPtr configGet(const std::string &service)
Get configuration.
Contains declarations for stdout control socket communication.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:27
Defines the logger used by the top-level component of kea-lfc.
string & output_
Definition: dns/message.cc:877
This file contains several functions and constants that are used for handling commands and responses ...
boost::shared_ptr< StdoutControlSocket > StdoutControlSocketPtr
Type definition for the pointer to the StdoutControlSocket.
virtual data::ConstElementPtr configTest(data::ConstElementPtr config, const std::string &service)
Test configuration.
Class for control socket communication over stdout.
boost::shared_ptr< CfgControlSocket > CfgControlSocketPtr
Defines a pointer for CfgControlSocket instances.
virtual data::ConstElementPtr configSet(data::ConstElementPtr config, const std::string &service)
Set configuration.