diff options
author | Vladimir Byko-Ianko <v.bykoianko@corp.mail.ru> | 2016-03-16 17:53:36 +0300 |
---|---|---|
committer | Sergey Yershov <yershov@corp.mail.ru> | 2016-03-23 16:56:52 +0300 |
commit | 40d74317ea09c1064605ddbe41acef9ee8ac776b (patch) | |
tree | 6464e9f3c9bc4762acbcccb3d6b7a620ce693559 | |
parent | c77f454bddc9efb774444264c6f7a7d0a041b443 (diff) |
[new downloader] GetQueuedChildren() impementation.
-rw-r--r-- | storage/storage.cpp | 27 | ||||
-rw-r--r-- | storage/storage.hpp | 9 |
2 files changed, 30 insertions, 6 deletions
diff --git a/storage/storage.cpp b/storage/storage.cpp index ba581835a8..6cef88d8a5 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -1094,7 +1094,7 @@ TCountryId const Storage::GetRootId() const return m_countries.GetRoot().Value().Name(); } -void Storage::GetChildren(TCountryId const & parent, TCountriesVec & childrenId) const +void Storage::GetChildren(TCountryId const & parent, TCountriesVec & childIds) const { ASSERT_THREAD_CHECKER(m_threadChecker, ()); @@ -1106,10 +1106,10 @@ void Storage::GetChildren(TCountryId const & parent, TCountriesVec & childrenId) } size_t const childrenCount = parentNode->ChildrenCount(); - childrenId.clear(); - childrenId.reserve(childrenCount); + childIds.clear(); + childIds.reserve(childrenCount); for (size_t i = 0; i < childrenCount; ++i) - childrenId.emplace_back(parentNode->Child(i).Value().Name()); + childIds.emplace_back(parentNode->Child(i).Value().Name()); } void Storage::GetLocalRealMaps(TCountriesVec & localMaps) const @@ -1457,4 +1457,23 @@ void Storage::CorrectJustDownloadedAndQueue(TQueue::iterator justDownloadedItem) else m_justDownloaded.insert(justDownloadedItem->GetCountryId()); } + +void Storage::GetQueuedChildren(TCountryId const & parent, TCountriesVec & queuedChildren) const +{ + TCountryTreeNode const * const node = m_countries.FindFirst(parent); + if (!node) + { + ASSERT(false, ()); + return; + } + + queuedChildren.clear(); + node->ForEachChild([&queuedChildren, this](TCountryTreeNode const & child) + { + NodeStatus status = GetNodeStatus(child).status; + ASSERT_NOT_EQUAL(status, NodeStatus::Undefined, ()); + if (status == NodeStatus::Downloading || status == NodeStatus::InQueue) + queuedChildren.push_back(child.Value().Name()); + }); +} } // namespace storage diff --git a/storage/storage.hpp b/storage/storage.hpp index 8ca01fb0c9..cd682a0afc 100644 --- a/storage/storage.hpp +++ b/storage/storage.hpp @@ -283,9 +283,9 @@ public: /// \brief Returns root country id of the country tree. TCountryId const GetRootId() const; - /// \param childrenId is filled with children node ids by a parent. For example GetChildren(GetRootId()) + /// \param childIds is filled with children node ids by a parent. For example GetChildren(GetRootId()) /// returns in param all countries ids. It's content of map downloader list by default. - void GetChildren(TCountryId const & parent, TCountriesVec & childrenId) const; + void GetChildren(TCountryId const & parent, TCountriesVec & childIds) const; /// \brief Fills |downloadedChildren| and |availChildren| with children of parent. /// If a direct child of |parent| contains at least one downloaded mwm @@ -300,6 +300,11 @@ public: /// nor World.mwm and WorldCoasts.mwm. void GetChildrenInGroups(TCountryId const & parent, TCountriesVec & downloadedChildren, TCountriesVec & availChildren) const; + /// \brief Fills |queuedChildren| with children of |parent| if they (or thier childen) are in |m_queue|. + /// \note For group node children if one of child's ancestor has status + /// NodeStatus::Downloading or NodeStatus::InQueue the child is considered as a queued child + /// and will be added to |queuedChildren|. + void GetQueuedChildren(TCountryId const & parent, TCountriesVec & queuedChildren) const; /// \brief Returns current version for mwms which are available on the server. inline int64_t GetCurrentDataVersion() const { return m_currentVersion; } |