[downloader] Implement retrieving countryId for topmost group node

This commit is contained in:
Sergey Yershov 2016-04-20 13:03:47 +03:00
parent 34791b0168
commit c3d68e8e3c
2 changed files with 28 additions and 0 deletions

View file

@ -1593,5 +1593,30 @@ void Storage::GetGroupNodePathToRoot(TCountryId const & groupNode, TCountriesVec
});
path.push_back(m_countries.GetRoot().Value().Name());
}
void Storage::GetTopmostNodesFor(TCountryId const & countryId, TCountriesVec & nodes) const
{
nodes.clear();
vector<TCountryTreeNode const *> treeNodes;
m_countries.Find(countryId, treeNodes);
if (treeNodes.empty())
{
LOG(LWARNING, ("TCountryId =", countryId, "not found in m_countries."));
return;
}
nodes.clear();
nodes.resize(treeNodes.size());
for (auto & node : nodes)
{
node = countryId;
ForEachAncestorExceptForTheRoot(treeNodes,
[&node](TCountryId const & id, TCountryTreeNode const &)
{
node = id;
});
}
}
} // namespace storage

View file

@ -342,6 +342,9 @@ public:
/// \param path is resulting array of TCountryId.
void GetGroupNodePathToRoot(TCountryId const & groupNode, TCountriesVec & path) const;
/// \brief TODO
void GetTopmostNodesFor(TCountryId const & countryId, TCountriesVec & nodes) const;
/// \brief Returns current version for mwms which are used by storage.
inline int64_t GetCurrentDataVersion() const { return m_currentVersion; }