2016-01-15 02:47:19 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-01-21 04:24:28 +00:00
|
|
|
#include <unordered_map>
|
2018-12-10 15:25:45 +00:00
|
|
|
#include <Poco/Exception.h>
|
|
|
|
#include "GeodataProviders/IHierarchiesProvider.h"
|
|
|
|
#include "RegionsHierarchy.h"
|
2016-01-15 02:47:19 +00:00
|
|
|
|
|
|
|
|
2017-11-28 22:15:06 +00:00
|
|
|
/** Contains several hierarchies of regions.
|
2017-04-17 11:56:55 +00:00
|
|
|
* Used to support several different perspectives on the ownership of regions by countries.
|
|
|
|
* First of all, for the Crimea (Russian and Ukrainian points of view).
|
2016-01-15 02:47:19 +00:00
|
|
|
*/
|
|
|
|
class RegionsHierarchies
|
|
|
|
{
|
|
|
|
private:
|
2017-04-01 07:20:54 +00:00
|
|
|
using Container = std::unordered_map<std::string, RegionsHierarchy>;
|
|
|
|
Container data;
|
2016-01-15 02:47:19 +00:00
|
|
|
|
|
|
|
public:
|
2017-11-28 22:15:06 +00:00
|
|
|
RegionsHierarchies(IRegionsHierarchiesDataProviderPtr data_provider);
|
2017-04-01 07:20:54 +00:00
|
|
|
|
2017-04-17 11:56:55 +00:00
|
|
|
/** Reloads, if necessary, all hierarchies of regions.
|
2017-04-01 07:20:54 +00:00
|
|
|
*/
|
|
|
|
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;
|
|
|
|
}
|
2016-01-15 02:47:19 +00:00
|
|
|
};
|