bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
DaemonCommandHandler.h
1// BESServerHandler.h
2
3// This file is part of bes, A C++ back-end server implementation framework
4// for the OPeNDAP Data Access Protocol.
5
6// Copyright (c) 2011 OPeNDAP
7// Author: James Gallagher <jgallagher@opendap.org> Based on code by Partick
8// West and Jose Garcia.
9//
10// This library is free software; you can redistribute it and/or
11// modify it under the terms of the GNU Lesser General Public
12// License as published by the Free Software Foundation; either
13// version 2.1 of the License, or (at your option) any later version.
14//
15// This library is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18// Lesser General Public License for more details.
19//
20// You should have received a copy of the GNU Lesser General Public
21// License along with this library; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23//
24// You can contact University Corporation for Atmospheric Research at
25// 3080 Center Green Drive, Boulder, CO 80301
26
27// (c) COPYRIGHT OPeNDAP
28// Please read the full copyright statement in the file COPYING.
29
30#ifndef DaemonCommandHandler_h
31#define DaemonCommandHandler_h 1
32
33#include <string>
34#include <vector>
35
36#include "ServerHandler.h"
37
38class Connection;
39class BESXMLWriter;
40
41class DaemonCommandHandler: public ServerHandler {
42private:
43 typedef enum {
44 HAI_UNKNOWN,
45 HAI_STOP_NOW,
46 HAI_START,
47 HAI_EXIT,
48 HAI_GET_CONFIG,
49 HAI_SET_CONFIG,
50 HAI_TAIL_LOG,
51 HAI_GET_LOG_CONTEXTS,
52 HAI_SET_LOG_CONTEXT
53 } hai_command;
54
55 std::string d_bes_conf;
56#if 0
57 std::string d_config_dir;
58 std::string d_include_dir;
59#endif
60
61 // Build a map of all the various config files. This map relates the name
62 // of the config file (eg 'bes.conf') to the full pathname for that file.
63 // Only the name of config file is shown in responses; we use the map to
64 // actually find/read/write the file.
65 std::map<std::string,std::string> d_pathnames;
66
67 std::string d_log_file_name;
68
69 void load_include_files(std::vector<std::string> &files, const std::string &keys_file_name);
70 void load_include_file(const std::string &files, const std::string &keys_file_name);
71
72 hai_command lookup_command(const std::string &command);
73 void execute_command(const std::string &command, BESXMLWriter &writer);
74
75public:
76 explicit DaemonCommandHandler(const std::string &config);
77 ~DaemonCommandHandler() override = default;
78
79 std::string get_config_file() const { return d_bes_conf; }
80 void set_config_file(const std::string &config) { d_bes_conf = config; }
81
82 void handle(Connection *c) override;
83
84 void dump(std::ostream &strm) const override;
85};
86
87#endif // DaemonCommandHandler_h
88
void dump(std::ostream &strm) const override
dumps information about this object
void handle(Connection *c) override