alaCarte Maps
Renderer for OpenStreetMap tiles
settings.hpp
Go to the documentation of this file.
1 
21 #pragma once
22 #ifndef SETTINGS_HPP
23 #define SETTINGS_HPP
24 
25 /*
26  * =====================================================================================
27  *
28  * Filename: settings.hpp
29  *
30  * Description: Contains important includes and definitions for alacarte
31  *
32  * =====================================================================================
33  */
34 
35 // std includes
36 #include <cassert>
37 #include <string>
38 #include <map>
39 #include <vector>
40 #include <list>
41 #include <queue>
42 #include <stack>
43 #include <cstdint>
44 #include <iostream>
45 #include <stdexcept>
46 
47 // boost includes
48 #include <boost/shared_ptr.hpp>
49 #include <boost/scoped_ptr.hpp>
50 #include <boost/enable_shared_from_this.hpp>
51 #include <boost/make_shared.hpp>
52 #include <boost/asio/ip/tcp.hpp>
53 #include <boost/asio/basic_socket.hpp>
54 #include <boost/exception/all.hpp>
55 
56 // boost log
57 #include <boost/log/trivial.hpp>
58 #include <boost/log/sources/severity_channel_logger.hpp>
59 #include <boost/log/sources/global_logger_storage.hpp>
60 namespace logging = boost::log;
61 namespace keywords = boost::log::keywords;
62 typedef logging::sources::severity_channel_logger_mt<
63  logging::trivial::severity_level, // those are: trace, debug, info, warning, error, fatal
66 
67 BOOST_LOG_INLINE_GLOBAL_LOGGER_CTOR_ARGS(app_log, logger_mt, (keywords::channel = "Application"))
68 BOOST_LOG_INLINE_GLOBAL_LOGGER_CTOR_ARGS(importer_log, logger_mt, (keywords::channel = "Importer"))
69 BOOST_LOG_INLINE_GLOBAL_LOGGER_CTOR_ARGS(geo_log, logger_mt, (keywords::channel = "Geodata"))
70 BOOST_LOG_INLINE_GLOBAL_LOGGER_CTOR_ARGS(stat_log, logger_mt, (keywords::channel = "Statistics"))
71 BOOST_LOG_INLINE_GLOBAL_LOGGER_CTOR_ARGS(server_log, logger_mt, (keywords::channel = "Server"))
72 BOOST_LOG_INLINE_GLOBAL_LOGGER_CTOR_ARGS(access_log, logger_mt, (keywords::channel = "Access"))
73 BOOST_LOG_INLINE_GLOBAL_LOGGER_CTOR_ARGS(style_log, logger_mt, (keywords::channel = "Stylesheets"))
74 BOOST_LOG_INLINE_GLOBAL_LOGGER_CTOR_ARGS(cache_log, logger_mt, (keywords::channel = "Cache"))
75 BOOST_LOG_INLINE_GLOBAL_LOGGER_CTOR_ARGS(request_log, logger_mt, (keywords::channel = "Request"))
76 BOOST_LOG_INLINE_GLOBAL_LOGGER_CTOR_ARGS(render_log, logger_mt, (keywords::channel = "Renderer"))
77 
78 #define LOG_SEV(log, lvl)\
79  BOOST_LOG_SEV(log::get(), (logging::trivial::lvl))
80 
81 
82 #ifdef ALACARTE_TEST
83  #define TESTABLE virtual
84 #else
85  #define TESTABLE
86 #endif
87 
88 // Dont ask! this is c++ makro-blabla
90 #define ALAC_JOIN(_a, _b) ALAC_DO_JOIN1(_a, _b)
91 #define ALAC_DO_JOIN1(_a, _b) ALAC_DO_JOIN2(_a, _b)
92 #define ALAC_DO_JOIN2(_a, _b) _a##_b
93 
94 
95 #define NOT_IMPLEMENTED() {BOOST_THROW_EXCEPTION(excp::NotImplementedException() << excp::InfoFileName(__FILE__));}
96 #define IMPLEMENTATION_TODO(_text) { \
97  static bool ALAC_JOIN(_found_, __LINE__) = false; \
98  if(! ALAC_JOIN(_found_, __LINE__)) \
99  { \
100  std::clog << "Not Implemented: "<< _text << std::endl; \
101  ALAC_JOIN(_found_, __LINE__) = true; \
102  } \
103  }
104 
105 using boost::shared_ptr;
106 using boost::scoped_ptr;
107 using boost::weak_ptr;
108 
109 // we want to use the std::string as stringtype
111 typedef std::int8_t int8;
112 typedef std::uint8_t uint8;
113 typedef std::int16_t int16;
114 typedef std::uint16_t uint16;
115 typedef std::int32_t int32;
116 typedef std::uint32_t uint32;
117 typedef std::int32_t coord_t;
118 
119 // include utils
120 #include "utils/point.hpp"
121 #include "utils/exceptions.hpp"
122 #include "utils/color.hpp"
123 #include "utils/rect.hpp"
124 #include "utils/typedId.hpp"
125 #include "utils/cached_string.hpp"
126 
127 #define DEFAULT_CONFIG_NAME "alacarte-maps.conf"
128 
129 #define DEFAULT_FONT "DejaVu Sans"
130 #define TILE_OVERLAP (1.0/META_TILE_SIZE * 0.25)
131 #define META_TILE_SIZE 4
132 #define ALAC_ZOOM_BOTTOM 0
133 #define ALAC_ZOOM_TOP 18
134 
138 
139 #include <boost/unordered_map.hpp>
140 template<typename Key, typename Value>
141 class DataMap
142  : public boost::unordered_map<Key, Value>
143 {
144  friend class boost::serialization::access;
145 
146 // typedef std::vector< std::pair<Key, Value> > container;
147 // typedef typename container::const_iterator iterator;
148 
149 
150  template<typename Archive>
151  void save(Archive & ar, const unsigned int version) const
152  {
153  int s = this->size();
154  ar << s;
155  for(auto& e : *this)
156  ar << e;
157  }
158  template<class Archive>
159  void load(Archive & ar, const unsigned int version)
160  {
161  typename boost::unordered_map<Key, Value>::value_type value;
162 
163  int s;
164  ar >> s;
165 
166  while(s--)
167  {
168  ar >> value;
169  this->insert(value);
170  }
171  }
172 
173  BOOST_SERIALIZATION_SPLIT_MEMBER()
174 public:
175  /*iterator find(const Key& key) const
176  {
177  for(auto it = begin(); it != end(); ++it)
178  {
179  if(it->first == key)
180  {
181  return it;
182  }
183  }
184  return end();
185  }
186 
187  Value& operator[](const Key& key)
188  {
189  push_back(std::make_pair(key, Value()));
190  return back().second;
191  }
192 
193  const Value& operator[](const Key& key) const
194  {
195  push_back(std::make_pair(key, Value()));
196  return back().second;
197  }
198 
199  Value& at(const Key& key)
200  {
201  return find(key)->second;
202  }
203 
204  const Value& at(const Key& key) const
205  {
206  return find(key)->second;
207  }*/
208 };
209 
210 #endif
std::uint8_t uint8
Definition: settings.hpp:112
logging::sources::severity_channel_logger_mt< logging::trivial::severity_level, std::string > logger_mt
Definition: settings.hpp:65
std::int8_t int8
Definition: settings.hpp:111
std::uint32_t uint32
Definition: settings.hpp:116
void save(Archive &ar, const unsigned int version) const
Definition: settings.hpp:151
std::int32_t coord_t
Definition: settings.hpp:117
TypedId< 0 > NodeId
Definition: settings.hpp:135
TypedId< 1 > WayId
Definition: settings.hpp:136
std::int32_t int32
Definition: settings.hpp:115
std::string string
Definition: settings.hpp:110
static const char * access_log
Filepath to the access log (type: string)
std::uint16_t uint16
Definition: settings.hpp:114
void load(Archive &ar, const unsigned int version)
Definition: settings.hpp:159
std::int16_t int16
Definition: settings.hpp:113
Definition: cache.hpp:38
TypedId< 2 > RelId
Definition: settings.hpp:137