Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuri Gorshenin <y@maps.me>2015-07-01 16:55:50 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:53:33 +0300
commit54e5990c7e4c65b0749c21ce4fe3866909a29668 (patch)
treeec9f80550c7402b7d5f577773353c0d7eb6fb0a7 /indexer/mwm_set.hpp
parent025f73ad85d489c4ea143b9d95dde4d308daf89b (diff)
Revert "Merge pull request #1068 from maps/revert-929-abstract-country-file"
This reverts commit 66aac38c3004d261ee06a16f7e9db372f67614df, reversing changes made to ad8708944070f6b32a17fbb944d3c493b3fb2a24.
Diffstat (limited to 'indexer/mwm_set.hpp')
-rw-r--r--indexer/mwm_set.hpp86
1 files changed, 44 insertions, 42 deletions
diff --git a/indexer/mwm_set.hpp b/indexer/mwm_set.hpp
index 25682c16b0..dfc225f4c4 100644
--- a/indexer/mwm_set.hpp
+++ b/indexer/mwm_set.hpp
@@ -2,6 +2,9 @@
#include "indexer/mwm_version.hpp"
+#include "platform/country_file.hpp"
+#include "platform/local_country_file.hpp"
+
#include "geometry/rect2d.hpp"
#include "base/macros.hpp"
@@ -31,10 +34,9 @@ public:
enum Status
{
- STATUS_UP_TO_DATE, ///< Mwm is registered and up-to-date
- STATUS_MARKED_TO_DEREGISTER, ///< Mwm is marked to be deregistered as soon as possible
- STATUS_DEREGISTERED, ///< Mwm is deregistered
- STATUS_PENDING_UPDATE ///< Mwm is registered but there're a pending update to it
+ STATUS_REGISTERED, ///< Mwm is registered and up to date.
+ STATUS_MARKED_TO_DEREGISTER, ///< Mwm is marked to be deregistered as soon as possible.
+ STATUS_DEREGISTERED, ///< Mwm is deregistered.
};
MwmInfo();
@@ -46,31 +48,32 @@ public:
inline Status GetStatus() const { return m_status; }
+ inline bool IsUpToDate() const { return IsRegistered(); }
+
inline bool IsRegistered() const
{
- return m_status == STATUS_UP_TO_DATE || m_status == STATUS_PENDING_UPDATE;
+ return m_status == STATUS_REGISTERED;
}
- inline bool IsUpToDate() const { return m_status == STATUS_UP_TO_DATE; }
+ inline platform::LocalCountryFile const & GetLocalFile() const { return m_file; }
+
+ inline string GetCountryName() const { return m_file.GetCountryFile().GetNameWithoutExt(); }
- inline string const & GetFileName() const { return m_fileName; }
+ inline int64_t GetVersion() const { return m_file.GetVersion(); }
MwmTypeT GetType() const;
private:
inline void SetStatus(Status status) { m_status = status; }
- string m_fileName; ///< Path to the mwm file.
- Status m_status; ///< Current country status.
- uint8_t m_lockCount; ///< Number of locks.
+ platform::LocalCountryFile m_file; ///< Path to the mwm file.
+ Status m_status; ///< Current country status.
+ uint8_t m_lockCount; ///< Number of locks.
};
class MwmSet
{
public:
- using TMwmFileName = string;
- using TMwmInfoTable = map<TMwmFileName, shared_ptr<MwmInfo>>;
-
struct MwmId
{
public:
@@ -94,9 +97,9 @@ public:
friend ostream & operator<<(ostream & os, MwmId const & id)
{
if (id.m_info.get())
- os << "MwmId[" << id.m_info->GetFileName() << "]";
+ os << "MwmId [" << id.m_info->GetCountryName() << "]";
else
- os << "MwmId[invalid]";
+ os << "MwmId [invalid]";
return os;
}
@@ -152,41 +155,43 @@ public:
/// Registers a new map.
///
- /// \return A pair of an MwmLock and a flag. MwmLock is locked iff the
- /// map with fileName was created or already exists. Flag
- /// is set when the map was registered for a first
- /// time. Thus, there are three main cases:
+ /// \return A pair of an MwmLock and a flag. There are three cases:
+ /// * the map is newer than the newest registered - returns
+ /// active lock and set flag.
+ /// * the map is older than the newest registered - returns inactive lock and
+ /// unset flag.
+ /// * the version of the map equals to the version of the newest registered -
+ /// returns active lock and unset flag.
///
- /// * the map already exists - returns active lock and unset flag
- /// * the map was already registered - returns active lock and set flag
- /// * the map can't be registered - returns inactive lock and unset flag
- //@{
+ /// *NOTE* When a new version for the same country is registered,
+ /// all previous versions will be automatically deregistered.
protected:
- WARN_UNUSED_RESULT pair<MwmLock, bool> RegisterImpl(TMwmFileName const & fileName);
+ WARN_UNUSED_RESULT pair<MwmLock, bool> RegisterImpl(platform::LocalCountryFile const & localFile);
public:
- WARN_UNUSED_RESULT pair<MwmLock, bool> Register(TMwmFileName const & fileName);
+ WARN_UNUSED_RESULT pair<MwmLock, bool> Register(platform::LocalCountryFile const & localFile);
//@}
/// @name Remove mwm.
//@{
protected:
- /// Deregisters a map from the set when it's possible. Note that an
- /// underlying file is not deleted.
+ /// Deregisters a map from internal records.
///
- /// @return true when the map was deregistered.
+ /// \param countryFile A countryFile denoting a map to be deregistered.
+ /// \return True if the map was successfully deregistered. If map is locked
+ /// now, returns false.
//@{
bool DeregisterImpl(MwmId const & id);
- bool DeregisterImpl(TMwmFileName const & ofileName);
+ bool DeregisterImpl(platform::CountryFile const & countryFile);
//@}
public:
- bool Deregister(TMwmFileName const & fileName);
+ bool Deregister(platform::CountryFile const & countryFile);
void DeregisterAll();
//@}
- /// @param[in] file File name without extension.
- bool IsLoaded(TMwmFileName const & fileName) const;
+ /// Returns true when country is registered and can be used.
+ bool IsLoaded(platform::CountryFile const & countryFile) const;
/// Get ids of all mwms. Some of them may be with not active status.
/// In that case, LockValue returns NULL.
@@ -194,14 +199,14 @@ public:
void ClearCache();
- MwmId GetMwmIdByFileName(TMwmFileName const & fileName) const;
+ MwmId GetMwmIdByCountryFile(platform::CountryFile const & countryFile) const;
- MwmLock GetMwmLockByFileName(TMwmFileName const & fileName);
+ MwmLock GetMwmLockByCountryFile(platform::CountryFile const & countryFile);
protected:
/// @return True when file format version was successfully read to MwmInfo.
- virtual bool GetVersion(TMwmFileName const & fileName, MwmInfo & info) const = 0;
- virtual TMwmValueBasePtr CreateValue(string const & name) const = 0;
+ virtual bool GetVersion(platform::LocalCountryFile const & localFile, MwmInfo & info) const = 0;
+ virtual TMwmValueBasePtr CreateValue(platform::LocalCountryFile const & localFile) const = 0;
void Cleanup();
@@ -226,7 +231,7 @@ protected:
/// Find mwm with a given name.
/// @precondition This function is always called under mutex m_lock.
- MwmId GetMwmIdByFileNameImpl(TMwmFileName const & fileName) const;
+ MwmId GetMwmIdByCountryFileImpl(platform::CountryFile const & countryFile) const;
/// @precondition This function is always called under mutex m_lock.
WARN_UNUSED_RESULT inline MwmLock GetLock(MwmId const & id)
@@ -236,12 +241,9 @@ protected:
// This method is called under m_lock when mwm is removed from a
// registry.
- virtual void OnMwmDeleted(shared_ptr<MwmInfo> const & info) {}
-
- // This method is called under m_lock when mwm is ready for update.
- virtual void OnMwmReadyForUpdate(shared_ptr<MwmInfo> const & info) {}
+ virtual void OnMwmDeregistered(platform::LocalCountryFile const & localFile) {}
- TMwmInfoTable m_info;
+ map<string, vector<shared_ptr<MwmInfo>>> m_info;
mutable mutex m_lock;
};