bes  Updated for version 3.17.0
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 using std::string ;
37 
38 #include "ServerHandler.h"
39 #include "BESXMLWriter.h"
40 
41 class Connection ;
42 
44 private:
45  typedef enum {
46  HAI_UNKNOWN,
47  HAI_STOP_NOW,
48  HAI_START,
49  HAI_EXIT,
50  HAI_GET_CONFIG,
51  HAI_SET_CONFIG,
52  HAI_TAIL_LOG,
53  HAI_GET_LOG_CONTEXTS,
54  HAI_SET_LOG_CONTEXT
55  } hai_command;
56 
57  string d_bes_conf;
58  string d_config_dir;
59  string d_include_dir;
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  map<string,string> d_pathnames;
66 
67  string d_log_file_name;
68 
69  void load_include_files(vector<string> &files, const string &keys_file_name);
70  void load_include_file(const string &files, const string &keys_file_name);
71 
72  hai_command lookup_command(const string &command);
73  void execute_command(const string &command, BESXMLWriter &writer);
74 
75 public:
76  DaemonCommandHandler(const string &config);
77  virtual ~DaemonCommandHandler() { }
78 
79  string get_config_file() { return d_bes_conf; }
80  void set_config_file(const string &config) { d_bes_conf = config; }
81 
82  virtual void handle(Connection *c);
83 
84  virtual void dump(ostream &strm) const;
85 };
86 
87 #endif // DaemonCommandHandler_h
88 
virtual void dump(ostream &strm) const
dumps information about this object
virtual void handle(Connection *c)