MCPcopy Create free account
hub / github.com/comaps/comaps / GetGroupNodePathToRoot

Method GetGroupNodePathToRoot

libs/storage/storage.cpp:2205–2232  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2203}
2204
2205void Storage::GetGroupNodePathToRoot(CountryId const & groupNode, CountriesVec & path) const
2206{
2207 path.clear();
2208
2209 CountryTree::NodesBufferT nodes;
2210 m_countries.Find(groupNode, nodes);
2211 if (nodes.empty())
2212 {
2213 LOG(LWARNING, ("CountryId =", groupNode, "not found in m_countries."));
2214 return;
2215 }
2216
2217 if (nodes.size() != 1)
2218 {
2219 LOG(LWARNING, (groupNode, "Group node can't have more than one parent."));
2220 return;
2221 }
2222
2223 if (nodes[0]->ChildrenCount() == 0)
2224 {
2225 LOG(LWARNING, (nodes[0]->Value().Name(), "is a leaf node."));
2226 return;
2227 }
2228
2229 ForEachAncestorExceptForTheRoot(nodes,
2230 [&path](CountryId const & id, CountryTree::Node const &) { path.push_back(id); });
2231 path.push_back(m_countries.GetRoot().Value().Name());
2232}
2233
2234void Storage::GetTopmostNodesFor(CountryId const & countryId, CountriesVec & nodes, size_t level) const
2235{

Calls 9

ChildrenCountMethod · 0.80
GetRootMethod · 0.80
clearMethod · 0.45
FindMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
NameMethod · 0.45
ValueMethod · 0.45
push_backMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.64