alaCarte Maps
Renderer for OpenStreetMap tiles
configuration.hpp
Go to the documentation of this file.
1 
21 #pragma once
22 #ifndef CONFIGURATION_HPP
23 #define CONFIGURATION_HPP
24 
25 
26 #include "settings.hpp"
27 
28 #include <boost/program_options/variables_map.hpp>
29 #include <boost/program_options/options_description.hpp>
30 #include <boost/program_options/positional_options.hpp>
31 #include <boost/filesystem.hpp>
32 
33 namespace opt {
34  // general
36  static const char* help = "help";
37 
39  static const char* config = "config";
40 
42  static const char* logfile = "logfile";
43 
44  // importer
45  namespace importer {
47  static const char* path_to_osmdata = "importer.osm-data";
48 
50  static const char* path_to_geodata = "importer.geo-data";
51 
53  static const char* check_xml_entities = "importer.check-xml-entities";
54 
56  static const char* min_lat = "importer.min-lat";
57 
59  static const char* min_lon = "importer.min-lon";
60 
62  static const char* max_lat = "importer.max-lat";
63 
65  static const char* max_lon = "importer.max-lon";
66 
67  }
68 
69  namespace server {
70  // server
72  static const char* path_to_geodata = "server.geo-data";
73 
75  static const char* access_log = "server.access-log";
76 
78  static const char* num_threads = "server.num-threads";
79 
81  static const char* style_source = "server.style-src";
82 
84  static const char* server_address = "server.address";
85 
87  static const char* server_port = "server.port";
88 
90  static const char* max_queue_size = "server.max-queue";
91 
93  static const char* path_to_default_style = "server.default-style";
94 
96  static const char* path_to_default_tile = "server.default-tile";
97 
99  static const char* cache_size = "server.cache-size";
100 
102  static const char* cache_keep_tile = "server.cache-keep-tile";
103 
105  static const char* cache_path = "server.cache-path";
106 
108  static const char* parse_timeout = "server.parse-timeout";
109 
111  //static const char* request_timeout = "server.request-timeout";
112 
114  static const char* prerender_level = "server.prerender-level";
115 
117  static const char* log_mute_component = "server.log-mute-component";
118 
120  static const char* performance_log = "server.performance-log";
121  }
122 }
123 
128 class Configuration : public boost::enable_shared_from_this<Configuration>
129 {
130 public:
131  Configuration() = default;
132  Configuration( boost::program_options::options_description& cmd_desc,
133  boost::program_options::options_description& config_desc,
134  boost::program_options::positional_options_description& pos_desc,
135  int argc, char** argv);
136 
137  bool has(const string& key);
138 
145  template<typename T>
146  T get(const string& key)
147  {
148  return boost::any_cast<const T&>(getValueByKey(key));
149  }
150 
158  template<typename T>
159  T get(const string& key, const T& defaultValue)
160  {
161  return has(key)? get<T>(key) : defaultValue;
162  }
163 
164  void printConfigToLog();
165 
171  bool usedConfigFile() const;
178  const std::vector<string>& getSearchDirectories() const;
179 protected:
180  TESTABLE const boost::any& getValueByKey(const string& key) const;
181 
183  boost::program_options::variables_map options;
184 
186  std::vector<string> searchDirectories;
187 };
188 
189 
190 
191 
192 #endif
static const char * server_address
Address of the server (type: string)
static const char * path_to_geodata
Option to get the filename to save geodata (type: string)
static const char * check_xml_entities
Check all xml entities.
static const char * path_to_default_style
Path to the default stylesheet (type: string)
static const char * max_lat
maximum node latitude to include into imported data
static const char * cache_size
Option to get the cache size (type: int)
static const char * min_lat
minimum node latitude to include into imported data
static const char * path_to_osmdata
Option to get the path to osm xml file (type: string)
static const char * cache_keep_tile
Option to get the zoomlevel until tiles are kept on harddrive (type: int)
static const char * performance_log
Filepath to the performance log (type: string)
static const char * style_source
Path to be observed for stylesheets (type: string)
static const char * access_log
Filepath to the access log (type: string)
boost::program_options::variables_map options
Internal map holding the options.
static const char * max_queue_size
Maximum size for the queue (type: int)
static const char * min_lon
minimum node longitude to include into imported data
static const char * path_to_default_tile
Path to the default tile (type: string)
static const char * config
Option to get the configuration filename (type: string)
static const char * max_lon
maximum node longitude to include into imported data
Represents a set of options accessible via strings.
static const char * parse_timeout
Option to get the timeout for stylesheet-parsing (type: int)
static const char * log_mute_component
Option to get the muted Components.
#define TESTABLE
Definition: settings.hpp:85
static const char * cache_path
Option to get the cache path (type: string)
static const char * num_threads
Option to get number of worker threads (type: int)
static const char * help
Use Configuration::has to check weather the user wanted help.
static const char * prerender_level
Option to get the timeout for request-processing (type: int)
std::vector< string > searchDirectories
static const char * server_port
Port the server should listen at (type: int)
static const char * logfile
Option to get the filename of the log (type: string)