Kea  2.3.3-git
stdout_control_socket.cc
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 #include <config.h>
11 
12 #include <cc/command_interpreter.h>
14 
15 #include <iostream>
16 
17 using namespace std;
18 using namespace isc::config;
19 using namespace isc::data;
20 
21 namespace isc {
22 namespace netconf {
23 
24 template <> ControlSocketBasePtr
25 createControlSocket<CfgControlSocket::Type::STDOUT>(CfgControlSocketPtr ctrl_sock) {
26  return (StdoutControlSocketPtr(new StdoutControlSocket(ctrl_sock)));
27 }
28 
29 StdoutControlSocket::StdoutControlSocket(CfgControlSocketPtr ctrl_sock)
30  : ControlSocketBase(ctrl_sock), output_(cout) {
31 }
32 
34  ostream& output)
35  : ControlSocketBase(ctrl_sock), output_(output) {
36 }
37 
39 StdoutControlSocket::configGet(const string& /*service*/) {
40  isc_throw(NotImplemented, "No config-get for stdout control socket");
41 }
42 
45  const string& /*service*/) {
46  return (createAnswer());
47 }
48 
51  const string& /*service*/) {
52  prettyPrint(config, output_);
53  output_ << endl;
54  return (createAnswer());
55 }
56 
57 } // namespace netconf
58 } // 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)
void prettyPrint(ConstElementPtr element, std::ostream &out, unsigned indent, unsigned step)
Pretty prints the data into stream.
Definition: data.cc:1487
Base class for control socket communication.
std::ostream & output_
The output stream (std::cout outside tests).
boost::shared_ptr< Element > ElementPtr
Definition: data.h:24
STL namespace.
data::ConstElementPtr configGet(const std::string &service) override final
Get configuration.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
Contains declarations for stdout control socket communication.
boost::shared_ptr< const Element > ConstElementPtr
Definition: data.h:27
data::ConstElementPtr configTest(data::ElementPtr config, const std::string &service) override final
Test configuration.
std::shared_ptr< StdoutControlSocket > StdoutControlSocketPtr
Type definition for the pointer to the StdoutControlSocket.
std::shared_ptr< CfgControlSocket > CfgControlSocketPtr
Defines a pointer for CfgControlSocket instances.
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 ...
Class for control socket communication over stdout.
std::shared_ptr< ControlSocketBase > ControlSocketBasePtr
Type definition for the pointer to the ControlSocketBase.
data::ConstElementPtr configSet(data::ElementPtr config, const std::string &service) override final
Set configuration.