mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
namespace storage_tests
|
||||
{
|
||||
struct UnitClass_StorageTest_DeleteCountry;
|
||||
} // storage_tests
|
||||
} // namespace storage_tests
|
||||
|
||||
namespace storage
|
||||
{
|
||||
@@ -47,9 +47,17 @@ struct CountryIdAndName
|
||||
/// It's applicable for expandable and not expandable node id.
|
||||
struct NodeAttrs
|
||||
{
|
||||
NodeAttrs() : m_mwmCounter(0), m_localMwmCounter(0), m_downloadingMwmCounter(0),
|
||||
m_mwmSize(0), m_localMwmSize(0), m_downloadingMwmSize(0),
|
||||
m_status(NodeStatus::Undefined), m_error(NodeErrorCode::NoError), m_present(false) {}
|
||||
NodeAttrs()
|
||||
: m_mwmCounter(0)
|
||||
, m_localMwmCounter(0)
|
||||
, m_downloadingMwmCounter(0)
|
||||
, m_mwmSize(0)
|
||||
, m_localMwmSize(0)
|
||||
, m_downloadingMwmSize(0)
|
||||
, m_status(NodeStatus::Undefined)
|
||||
, m_error(NodeErrorCode::NoError)
|
||||
, m_present(false)
|
||||
{}
|
||||
|
||||
/// If the node is expandable (a big country) |m_mwmCounter| is number of mwm files (leaves)
|
||||
/// belonging to the node. If the node isn't expandable |m_mwmCounter| == 1.
|
||||
@@ -259,32 +267,28 @@ private:
|
||||
void LoadCountriesFile(std::string const & pathToCountriesFile);
|
||||
|
||||
void ReportProgress(CountryId const & countryId, downloader::Progress const & p);
|
||||
void ReportProgressForHierarchy(CountryId const & countryId,
|
||||
downloader::Progress const & leafProgress);
|
||||
void ReportProgressForHierarchy(CountryId const & countryId, downloader::Progress const & leafProgress);
|
||||
|
||||
// QueuedCountry::Subscriber overrides:
|
||||
void OnCountryInQueue(QueuedCountry const & queuedCountry) override;
|
||||
void OnStartDownloading(QueuedCountry const & queuedCountry) override;
|
||||
/// Called on the main thread by MapFilesDownloader when
|
||||
/// downloading of a map file succeeds/fails.
|
||||
void OnDownloadFinished(QueuedCountry const & queuedCountry,
|
||||
downloader::DownloadStatus status) override;
|
||||
void OnDownloadFinished(QueuedCountry const & queuedCountry, downloader::DownloadStatus status) override;
|
||||
|
||||
/// Periodically called on the main thread by MapFilesDownloader
|
||||
/// during the downloading process.
|
||||
void OnDownloadProgress(QueuedCountry const & queuedCountry,
|
||||
downloader::Progress const & progress) override;
|
||||
void OnDownloadProgress(QueuedCountry const & queuedCountry, downloader::Progress const & progress) override;
|
||||
|
||||
void RegisterDownloadedFiles(CountryId const & countryId, MapFileType type);
|
||||
|
||||
void OnMapDownloadFinished(CountryId const & countryId, downloader::DownloadStatus status,
|
||||
MapFileType type);
|
||||
void OnMapDownloadFinished(CountryId const & countryId, downloader::DownloadStatus status, MapFileType type);
|
||||
|
||||
/// Dummy ctor for private use only.
|
||||
explicit Storage(int);
|
||||
|
||||
public:
|
||||
ThreadChecker const & GetThreadChecker() const {return m_threadChecker;}
|
||||
ThreadChecker const & GetThreadChecker() const { return m_threadChecker; }
|
||||
|
||||
/// \brief Storage will create its directories in Writable Directory
|
||||
/// (gotten with platform::WritableDir) by default.
|
||||
@@ -296,8 +300,7 @@ public:
|
||||
/// * create a instance of Storage with a special countries.txt and |dataDir|
|
||||
/// * download some maps to WritableDir/|dataDir|
|
||||
/// * destroy the instance of Storage and move the downloaded maps to proper place
|
||||
Storage(std::string const & pathToCountriesFile = COUNTRIES_FILE,
|
||||
std::string const & dataDir = std::string());
|
||||
Storage(std::string const & pathToCountriesFile = COUNTRIES_FILE, std::string const & dataDir = std::string());
|
||||
|
||||
/// \brief This constructor should be used for testing only.
|
||||
Storage(std::string const & referenceCountriesTxtJsonForTesting,
|
||||
@@ -337,8 +340,8 @@ public:
|
||||
/// which have been written in coutries.txt or cournties_migrate.txt.
|
||||
/// It means the method does not put to its params neither custom maps generated by user
|
||||
/// nor World.mwm and WorldCoasts.mwm.
|
||||
void GetChildrenInGroups(CountryId const & parent, CountriesVec & downloadedChildren,
|
||||
CountriesVec & availChildren, bool keepAvailableChildren = false) const;
|
||||
void GetChildrenInGroups(CountryId const & parent, CountriesVec & downloadedChildren, CountriesVec & availChildren,
|
||||
bool keepAvailableChildren = false) 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
|
||||
@@ -354,8 +357,7 @@ public:
|
||||
/// \param level is distance from top level except root.
|
||||
/// For disputed territories all possible owners will be added.
|
||||
/// Puts |countryId| to |nodes| when |level| is greater than the level of |countryId|.
|
||||
void GetTopmostNodesFor(CountryId const & countryId, CountriesVec & nodes,
|
||||
size_t level = 0) const;
|
||||
void GetTopmostNodesFor(CountryId const & countryId, CountriesVec & nodes, size_t level = 0) const;
|
||||
|
||||
/// \brief Returns topmost country id prior root id or |countryId| itself, if it's already
|
||||
/// a topmost node or disputed territory id if |countryId| is a disputed territory or belongs to
|
||||
@@ -392,10 +394,7 @@ public:
|
||||
/// \note This method works quicklier than GetNodeAttrs().
|
||||
void GetNodeStatuses(CountryId const & countryId, NodeStatuses & nodeStatuses) const;
|
||||
|
||||
std::string GetNodeLocalName(CountryId const & countryId) const
|
||||
{
|
||||
return m_countryNameGetter(countryId);
|
||||
}
|
||||
std::string GetNodeLocalName(CountryId const & countryId) const { return m_countryNameGetter(countryId); }
|
||||
|
||||
/// \brief Downloads/update one node (expandable or not) by countryId.
|
||||
/// If node is expandable downloads/update all children (grandchildren) by the node
|
||||
@@ -471,7 +470,7 @@ public:
|
||||
|
||||
/// \returns real (not fake) local maps contained in countries.txt.
|
||||
/// So this method does not return custom user local maps and World and WorldCoasts country id.
|
||||
//void GetLocalRealMaps(CountriesVec & localMaps) const;
|
||||
// void GetLocalRealMaps(CountriesVec & localMaps) const;
|
||||
|
||||
/// Do we have downloaded countries
|
||||
bool HaveDownloadedCountries() const;
|
||||
@@ -485,7 +484,8 @@ public:
|
||||
/// Used in Android to get absent Worlds files to download.
|
||||
/// @param[out] res Out vector, empty if all files are present some or error occured.
|
||||
/// @return WorldStatus:
|
||||
enum class WorldStatus {
|
||||
enum class WorldStatus
|
||||
{
|
||||
READY = 0, ///< Ready to download or all files are present if \a res is empty
|
||||
WAS_MOVED, ///< All World files are present and one or more files was moved, \a res is empty.
|
||||
ERROR_CREATE_FOLDER, ///< Error when creating folder
|
||||
@@ -523,10 +523,7 @@ public:
|
||||
{
|
||||
return localFile.GetCountryName();
|
||||
}
|
||||
CountryId const & FindCountryIdByFile(std::string const & name) const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
CountryId const & FindCountryIdByFile(std::string const & name) const { return name; }
|
||||
/// @}
|
||||
|
||||
// Returns true iff |countryId| exists as a node in the tree.
|
||||
@@ -563,7 +560,7 @@ public:
|
||||
bool IsDownloadInProgress() const;
|
||||
|
||||
/// @param[out] res Populated with oudated countries.
|
||||
//void GetOutdatedCountries(std::vector<Country const *> & countries) const;
|
||||
// void GetOutdatedCountries(std::vector<Country const *> & countries) const;
|
||||
|
||||
/// Sets and gets locale, which is used to get localized counries names
|
||||
void SetLocale(std::string const & locale) { m_countryNameGetter.SetLocale(locale); }
|
||||
@@ -577,7 +574,7 @@ public:
|
||||
void SetLocaleForTesting(std::string const & jsonBuffer, std::string const & locale);
|
||||
|
||||
/// Returns true if the diff scheme is available and all local outdated maps can be updated via diffs.
|
||||
//bool IsPossibleToAutoupdate() const;
|
||||
// bool IsPossibleToAutoupdate() const;
|
||||
|
||||
void SetStartDownloadingCallback(StartDownloadingCallback const & cb);
|
||||
|
||||
@@ -630,10 +627,9 @@ private:
|
||||
|
||||
/// Returns status for a node (group node or not).
|
||||
/// Fills |disputedTeritories| with all disputed teritories in subtree with the root == |node|.
|
||||
StatusAndError GetNodeStatusInfo(
|
||||
CountryTree::Node const & node,
|
||||
std::vector<std::pair<CountryId, NodeStatus>> & disputedTeritories,
|
||||
bool isDisputedTerritoriesCounted) const;
|
||||
StatusAndError GetNodeStatusInfo(CountryTree::Node const & node,
|
||||
std::vector<std::pair<CountryId, NodeStatus>> & disputedTeritories,
|
||||
bool isDisputedTerritoriesCounted) const;
|
||||
|
||||
void NotifyStatusChanged(CountryId const & countryId);
|
||||
void NotifyStatusChangedForHierarchy(CountryId const & countryId);
|
||||
@@ -654,7 +650,7 @@ private:
|
||||
|
||||
void OnMapDownloadFailed(CountryId const & countryId);
|
||||
|
||||
//void LoadDiffScheme();
|
||||
// void LoadDiffScheme();
|
||||
void ApplyDiff(CountryId const & countryId, std::function<void(bool isSuccess)> const & fn);
|
||||
|
||||
using IsDiffAbsentForCountry = std::function<bool(CountryId const & id)>;
|
||||
@@ -677,7 +673,8 @@ void Storage::ForEachInSubtree(CountryId const & root, ToDo && toDo) const
|
||||
ASSERT(false, ("CountryId =", root, "not found in m_countries."));
|
||||
return;
|
||||
}
|
||||
rootNode->ForEachInSubtree([&toDo](CountryTree::Node const & node) {
|
||||
rootNode->ForEachInSubtree([&toDo](CountryTree::Node const & node)
|
||||
{
|
||||
Country const & value = node.Value();
|
||||
toDo(value.Name(), value.GetSubtreeMwmCounter() != 1 /* groupNode. */);
|
||||
});
|
||||
@@ -712,7 +709,8 @@ void Storage::ForEachAncestorExceptForTheRoot(CountryTree::NodesBufferT const &
|
||||
// may be more than one. It means |childId| is present in the country tree more than once.
|
||||
for (auto const & node : nodes)
|
||||
{
|
||||
node->ForEachAncestorExceptForTheRoot([&](CountryTree::Node const & node) {
|
||||
node->ForEachAncestorExceptForTheRoot([&](CountryTree::Node const & node)
|
||||
{
|
||||
CountryId const ancestorId = node.Value().Name();
|
||||
if (visitedAncestors.find(&node) != visitedAncestors.end())
|
||||
return; // The node was visited before because countryId is present in the tree more
|
||||
|
||||
Reference in New Issue
Block a user