Libosmium
2.16.0
Fast and flexible C++ library for working with OpenStreetMap data
|
Go to the documentation of this file. 1 #ifndef OSMIUM_INDEX_MAP_HPP
2 #define OSMIUM_INDEX_MAP_HPP
45 #include <type_traits>
53 std::runtime_error(message) {
57 std::runtime_error(message) {
95 template <
typename TId,
typename TValue>
98 "TId template parameter for class Map must be unsigned integral type");
102 Map(
Map&&) noexcept = default;
103 Map& operator=(
Map&&) noexcept = default;
113 Map() noexcept = default;
116 Map& operator=(const
Map&) = delete;
118 virtual ~
Map() noexcept = default;
125 virtual void set(
const TId
id,
const TValue value) = 0;
134 virtual TValue
get(
const TId
id)
const = 0;
145 virtual TValue
get_noexcept(
const TId
id)
const noexcept = 0;
153 virtual std::size_t
size()
const = 0;
168 virtual void clear() = 0;
182 throw std::runtime_error{
"can't dump as list"};
189 throw std::runtime_error{
"can't dump as array"};
196 template <
typename TId,
typename TValue>
228 return m_callbacks.emplace(map_type_name, func).second;
236 std::vector<std::string> result;
239 result.push_back(cb.first);
242 std::sort(result.begin(), result.end());
247 std::unique_ptr<map_type>
create_map(
const std::string& config_string)
const {
250 if (config.empty()) {
256 return std::unique_ptr<map_type>((it->second)(config));
259 throw map_factory_error{std::string{
"Support for map type '"} + config[0] +
"' not compiled into this binary"};
266 template <
typename TId,
typename TValue,
template <
typename,
typename>
class TMap>
268 TMap<TId, TValue>*
operator()(
const std::vector<std::string>& ) {
269 return new TMap<TId, TValue>();
275 template <
typename TId,
typename TValue,
template <
typename,
typename>
class TMap>
282 #define OSMIUM_CONCATENATE_DETAIL_(x, y) x##y
283 #define OSMIUM_CONCATENATE_(x, y) OSMIUM_CONCATENATE_DETAIL_(x, y)
285 #define REGISTER_MAP(id, value, klass, name) \
286 namespace osmium { namespace index { namespace detail { \
287 namespace OSMIUM_CONCATENATE_(register_map_, __COUNTER__) { \
288 const bool registered = osmium::index::register_map<id, value, klass>(#name); \
289 inline bool get_registered() noexcept { \
298 #endif // OSMIUM_INDEX_MAP_HPP
std::vector< std::string > map_types() const
Definition: map.hpp:235
map_factory_error(const std::string &message)
Definition: map.hpp:56
virtual void set(const TId id, const TValue value)=0
Set the field with id to value.
bool register_map(const std::string &map_type_name, create_map_func func)
Definition: map.hpp:227
TValue value_type
Definition: map.hpp:202
TId key_type
The "key" type, usually osmium::unsigned_object_id_type.
Definition: map.hpp:108
TMap< TId, TValue > * operator()(const std::vector< std::string > &)
Definition: map.hpp:268
TValue value_type
The "value" type, usually a Location or size_t.
Definition: map.hpp:111
bool has_map_type(const std::string &map_type_name) const
Definition: map.hpp:231
virtual void dump_as_array(const int)
Definition: map.hpp:188
Namespace for everything in the Osmium library.
Definition: assembler.hpp:53
std::map< const std::string, create_map_func > m_callbacks
Definition: map.hpp:208
virtual void sort()
Definition: map.hpp:174
map_factory_error(const char *message)
Definition: map.hpp:52
virtual std::size_t size() const =0
virtual void dump_as_list(const int)
Definition: map.hpp:181
MapFactory & operator=(const MapFactory &)=delete
std::unique_ptr< map_type > create_map(const std::string &config_string) const
Definition: map.hpp:247
TId id_type
Definition: map.hpp:201
virtual std::size_t used_memory() const =0
bool register_map(const std::string &name)
Definition: map.hpp:276
virtual TValue get_noexcept(const TId id) const noexcept=0
Definition: location.hpp:551
virtual void reserve(const std::size_t)
Definition: map.hpp:120
static MapFactory< id_type, value_type > & instance()
Definition: map.hpp:222
virtual TValue get(const TId id) const =0
std::function< map_type *(const std::vector< std::string > &)> create_map_func
Definition: map.hpp:204
std::vector< std::string > split_string(const std::string &str, const char sep, bool compact=false)
Definition: string.hpp:50