bitz-server  1.0.2
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 
26 
27 #ifndef BITZ_SERVER_CONFIG_FILE
28 #define BITZ_SERVER_CONFIG_FILE "/etc/bitz/bitz-server.conf"
29 #endif
30 
31 namespace bitz {
32 
34  std::string name;
35  std::string module;
36  };
37 
39  std::string name;
40  std::string class_name;
41  unsigned int modules_count;
42 
43  modules_config_t * modules;
44  };
45 
46  struct config_t {
47  int port;
48  int max_workers;
49  int max_worker_requests;
50  int comm_timeout;
51  std::string pid_file;
52  std::string log_file;
53  std::string log_category;
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 
84  Config();
85  ~Config();
86  Config( Config const &copy );
87  Config &operator=( const Config &copy );
88 
89  void read_req_handler_configs() throw();
90 
91  };
92 
93 } /* end of namespace bitz */
94 
95 #endif /* !BITZ_CONFIG_H */
96 
Definition: src/bitz/config.h:46
Definition: echo.cpp:23
Definition: src/bitz/config.h:38
Definition: src/bitz/config.h:59
Definition: src/bitz/config.h:33