Kea  1.9.9-git
stdout_control_socket.cc
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 
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 }
38 
40 StdoutControlSocket::configGet(const string& /*service*/) {
41  isc_throw(NotImplemented, "No config-get for stdout control socket");
42 }
43 
46  const string& /*service*/) {
47  return (createAnswer());
48 }
49 
52  const string& /*service*/) {
53  prettyPrint(config, output_);
54  output_ << endl;
55  return (createAnswer());
56 }
57 
58 } // namespace netconf
59 } // namespace isc
virtual ~StdoutControlSocket()
Destructor (does nothing).
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:1224
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:23
Defines the logger used by the top-level component of kea-dhcp-ddns.
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.