bitz-server  2.0.0
src/bitz/config.h
1 /*
2  * bitz-server, An ICAP server implementation in C++
3  * Copyright (C) 2012 Uditha Atukorala
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #ifndef BITZ_CONFIG_H
21 #define BITZ_CONFIG_H
22 
23 #include <string>
24 #include <libconfig.h++>
25 #include <spdlog/spdlog.h>
26 
27 
28 #ifndef BITZ_SERVER_CONFIG_FILE
29 #define BITZ_SERVER_CONFIG_FILE "/etc/bitz/bitz-server.conf"
30 #endif
31 
32 namespace bitz {
33 
35  std::string name;
36  std::string module;
37  };
38 
40  std::string name;
41  std::string class_name;
42  unsigned int modules_count;
43 
44  modules_config_t * modules;
45  };
46 
47  struct config_t {
48  int port;
49  int max_workers;
50  int max_worker_requests;
51  int comm_timeout;
52  std::string pid_file;
53  std::string log_file;
54  unsigned int req_handlers_count;
55 
56  req_handlers_config_t * req_handlers;
57  };
58 
59  class Config {
60  public:
61  static Config &instance() {
62  static Config config;
63  return config;
64  }
65 
66  const config_t &initialise( const std::string &config_file = BITZ_SERVER_CONFIG_FILE );
67  const config_t &configs();
68 
78  const std::string module_config( const std::string &module, const std::string &config ) throw();
79 
80  private:
81  config_t _config;
82  libconfig::Config * _lconfig;
83  std::shared_ptr<spdlog::logger> _logger;
84 
85  Config();
86  ~Config();
87  Config( Config const &copy );
88  Config &operator=( const Config &copy );
89 
90  void read_req_handler_configs() throw();
91 
92  };
93 
94 } /* end of namespace bitz */
95 
96 #endif /* !BITZ_CONFIG_H */
97 
Definition: src/bitz/config.h:47
Definition: echo.cpp:23
Definition: src/bitz/config.h:39
Definition: src/bitz/config.h:59
Definition: src/bitz/config.h:34