bes  Updated for version 3.20.6
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 #include "BESXMLWriter.h"
38 
39 class Connection ;
40 
42 private:
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  string d_bes_conf;
56  string d_config_dir;
57  string d_include_dir;
58 
59  // Build a map of all the various config files. This map relates the name
60  // of the config file (eg 'bes.conf') to the full pathname for that file.
61  // Only the name of config file is shown in responses; we use the map to
62  // actually find/read/write the file.
63  std::map<string,string> d_pathnames;
64 
65  string d_log_file_name;
66 
67  void load_include_files(std::vector<string> &files, const string &keys_file_name);
68  void load_include_file(const string &files, const string &keys_file_name);
69 
70  hai_command lookup_command(const string &command);
71  void execute_command(const string &command, BESXMLWriter &writer);
72 
73 public:
74  DaemonCommandHandler(const string &config);
75  virtual ~DaemonCommandHandler() { }
76 
77  string get_config_file() { return d_bes_conf; }
78  void set_config_file(const string &config) { d_bes_conf = config; }
79 
80  virtual void handle(Connection *c);
81 
82  virtual void dump(std::ostream &strm) const;
83 };
84 
85 #endif // DaemonCommandHandler_h
86 
DaemonCommandHandler::dump
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: DaemonCommandHandler.cc:831
BESXMLWriter
Definition: BESXMLWriter.h:35
Connection
Definition: Connection.h:43
ServerHandler
Definition: ServerHandler.h:40
DaemonCommandHandler::handle
virtual void handle(Connection *c)
Definition: DaemonCommandHandler.cc:739
DaemonCommandHandler
Definition: DaemonCommandHandler.h:41