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

Method GetNodeAttrs

libs/storage/storage.cpp:1916–2006  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1914}
1915
1916void Storage::GetNodeAttrs(CountryId const & countryId, NodeAttrs & nodeAttrs) const
1917{
1918 CHECK_THREAD_CHECKER(m_threadChecker, ());
1919
1920 CountryTree::NodesBufferT nodes;
1921 m_countries.Find(countryId, nodes);
1922 CHECK(!nodes.empty(), (countryId));
1923 // If nodes.size() > 1 countryId corresponds to a disputed territories.
1924 // In that case it's guaranteed that most of attributes are equal for
1925 // each element of nodes. See Country class description for further details.
1926 CountryTree::Node const * const node = nodes[0];
1927
1928 Country const & nodeValue = node->Value();
1929 nodeAttrs.m_mwmCounter = nodeValue.GetSubtreeMwmCounter();
1930 nodeAttrs.m_mwmSize = nodeValue.GetSubtreeMwmSizeBytes();
1931 StatusAndError statusAndErr = GetNodeStatus(*node);
1932 nodeAttrs.m_status = statusAndErr.status;
1933 nodeAttrs.m_error = statusAndErr.error;
1934 nodeAttrs.m_nodeLocalName = m_countryNameGetter(countryId);
1935 nodeAttrs.m_nodeLocalDescription = m_countryNameGetter.Get(countryId + LOCALIZATION_DESCRIPTION_SUFFIX);
1936
1937 // Progress.
1938 if (nodeAttrs.m_status == NodeStatus::OnDisk)
1939 {
1940 // Group or leaf node is on disk and up to date.
1941 MwmSize const subTreeSizeBytes = node->Value().GetSubtreeMwmSizeBytes();
1942 nodeAttrs.m_downloadingProgress.m_bytesDownloaded = subTreeSizeBytes;
1943 nodeAttrs.m_downloadingProgress.m_bytesTotal = subTreeSizeBytes;
1944 }
1945 else
1946 {
1947 CountriesVec subtree;
1948 node->ForEachInSubtree([&subtree](CountryTree::Node const & d) { subtree.push_back(d.Value().Name()); });
1949
1950 nodeAttrs.m_downloadingProgress = CalculateProgress(subtree);
1951 }
1952
1953 // Local mwm information and information about downloading mwms.
1954 nodeAttrs.m_localMwmCounter = 0;
1955 nodeAttrs.m_localMwmSize = 0;
1956 nodeAttrs.m_downloadingMwmCounter = 0;
1957 nodeAttrs.m_downloadingMwmSize = 0;
1958 CountriesSet visitedLocalNodes;
1959 node->ForEachInSubtree([this, &nodeAttrs, &visitedLocalNodes](CountryTree::Node const & d)
1960 {
1961 CountryId const & countryId = d.Value().Name();
1962 if (!visitedLocalNodes.insert(countryId).second)
1963 return;
1964
1965 // Downloading mwm information.
1966 StatusAndError const statusAndErr = GetNodeStatus(d);
1967 ASSERT_NOT_EQUAL(statusAndErr.status, NodeStatus::Undefined, ());
1968 if (statusAndErr.status != NodeStatus::NotDownloaded && statusAndErr.status != NodeStatus::Partly &&
1969 d.ChildrenCount() == 0)
1970 {
1971 nodeAttrs.m_downloadingMwmCounter += 1;
1972 nodeAttrs.m_downloadingMwmSize += d.Value().GetSubtreeMwmSizeBytes();
1973 }

Callers 12

PutItemsToListFunction · 0.80
OnItemClickMethod · 0.80
GetNodeNameMethod · 0.80
IsEnoughSpaceForDownloadFunction · 0.80
UNIT_CLASS_TESTFunction · 0.80
UNIT_CLASS_TESTFunction · 0.80
DownloadGroupFunction · 0.80
DeleteGroupFunction · 0.80
UNIT_TESTFunction · 0.80
UNIT_TESTFunction · 0.80

Calls 15

GetRootIdFunction · 0.85
GetSubtreeMwmCounterMethod · 0.80
ChildrenCountMethod · 0.80
FindMethod · 0.45
emptyMethod · 0.45
ValueMethod · 0.45
GetMethod · 0.45
ForEachInSubtreeMethod · 0.45
push_backMethod · 0.45
NameMethod · 0.45
insertMethod · 0.45

Tested by 6

UNIT_CLASS_TESTFunction · 0.64
UNIT_CLASS_TESTFunction · 0.64
DownloadGroupFunction · 0.64
DeleteGroupFunction · 0.64
UNIT_TESTFunction · 0.64
UNIT_TESTFunction · 0.64