blob: 925b7b490ff5360b06e98e76cb7bb9b83511f29f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#pragma once
#include <unordered_map>
#include <Poco/Exception.h>
#include "GeodataProviders/IHierarchiesProvider.h"
#include "RegionsHierarchy.h"
/** Contains several hierarchies of regions.
* Used to support several different perspectives on the ownership of regions by countries.
* First of all, for the Falklands/Malvinas (UK and Argentina points of view).
*/
class RegionsHierarchies
{
private:
using Container = std::unordered_map<std::string, RegionsHierarchy>;
Container data;
public:
explicit RegionsHierarchies(IRegionsHierarchiesDataProviderPtr data_provider);
/** Reloads, if necessary, all hierarchies of regions.
*/
void reload()
{
for (auto & elem : data)
elem.second.reload();
}
const RegionsHierarchy & get(const std::string & key) const
{
auto it = data.find(key);
if (data.end() == it)
throw Poco::Exception("There is no regions hierarchy for key " + key);
return it->second;
}
};
|